mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-15 21:15:23 +02:00
[218227][usability] Contribute a "Show in RSE" action to Resource Navigator and Project Explorer
This commit is contained in:
parent
995c8f06e7
commit
a921481a0b
4 changed files with 124 additions and 8 deletions
|
@ -15,6 +15,7 @@
|
|||
# Willian Mitsuda - [184824] added a Remote action set item
|
||||
# David McKnight (IBM) - [187711] Link with Editor action for System View
|
||||
# David McKnight (IBM) - [209593] [api] add support for "file permissions" and "owner" properties for unix files
|
||||
# David McKnight (IBM) - [218227][usability] Contribute a "Show in RSE" action to Resource Navigator and Project Explorer
|
||||
###############################################################################
|
||||
|
||||
# NLS_MESSAGEFORMAT_NONE
|
||||
|
@ -55,3 +56,9 @@ Remote.Search = &Remote...
|
|||
Remote.Search.tooltip = Opens Remote Search dialog page for text and file searching on remote systems
|
||||
|
||||
LinkWithSystemView.label = Link with Editor
|
||||
|
||||
# Show in RSE View
|
||||
ShowInRSEView.label = Show in Remote Systems view
|
||||
ShowInRSEView.tooltip = Display the selected resource in the Remote Systems view
|
||||
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
|||
|
||||
Contributors:
|
||||
David McKnight (IBM) - [261019] New File/Folder actions available in Work Offline mode
|
||||
David McKnight (IBM) - [218227][usability] Contribute a "Show in RSE" action to Resource Navigator and Project Explorer
|
||||
-->
|
||||
<?eclipse version="3.0"?>
|
||||
<plugin>
|
||||
|
@ -474,5 +475,21 @@ David McKnight (IBM) - [261019] New File/Folder actions available in Wo
|
|||
</action>
|
||||
</viewContribution>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
point="org.eclipse.ui.popupMenus">
|
||||
<objectContribution
|
||||
objectClass="org.eclipse.core.resources.IResource"
|
||||
id="org.eclipse.rse.ui.ShowResourceInSystemsView">
|
||||
<action id="org.eclipse.rse.ui.ShowResourceInSystemsViewAction"
|
||||
label="%ShowInRSEView.label"
|
||||
tooltip="%ShowInRSEView.tooltip"
|
||||
class="org.eclipse.rse.internal.files.ui.actions.ShowResourceInSystemsViewDelegate">
|
||||
menubarPath="group.goto"
|
||||
enablesFor="1"
|
||||
id="showResourceInSystemsView">
|
||||
</action>
|
||||
</objectContribution>
|
||||
</extension>
|
||||
</plugin>
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2009 IBM Corporation. All rights reserved.
|
||||
* This program and the accompanying materials are made available under the terms
|
||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight.
|
||||
*
|
||||
* Contributors:
|
||||
* David McKnight (IBM) - [218227][usability] Contribute a "Show in RSE" action to Resource Navigator and Project Explorer
|
||||
********************************************************************************/
|
||||
package org.eclipse.rse.internal.files.ui.actions;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.rse.core.RSECorePlugin;
|
||||
import org.eclipse.rse.core.model.IHost;
|
||||
import org.eclipse.rse.core.model.ISystemProfile;
|
||||
import org.eclipse.rse.core.model.ISystemRegistry;
|
||||
import org.eclipse.rse.internal.ui.actions.ShowInSystemsViewDelegate;
|
||||
import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility;
|
||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
||||
|
||||
public class ShowResourceInSystemsViewDelegate extends
|
||||
ShowInSystemsViewDelegate {
|
||||
|
||||
public void run(IAction action) {
|
||||
|
||||
if (_selectedObject instanceof IResource){
|
||||
Object remoteObject = null;
|
||||
IResource resource = (IResource)_selectedObject;
|
||||
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
|
||||
// need to find the remote equivalent of this
|
||||
IPath location = resource.getLocation();
|
||||
|
||||
if (location != null){
|
||||
String fullPath = location.toOSString();
|
||||
|
||||
IHost localHost = sr.getLocalHost();
|
||||
if (localHost != null){
|
||||
IRemoteFileSubSystem ss = RemoteFileUtility.getFileSubSystem(localHost);
|
||||
try {
|
||||
remoteObject = ss.getRemoteFileObject(fullPath, new NullProgressMonitor());
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
URI uri = resource.getLocationURI();
|
||||
|
||||
String hostName = uri.getHost();
|
||||
String fullPath = uri.getPath();
|
||||
|
||||
IHost host = null;
|
||||
|
||||
// find the host
|
||||
ISystemProfile[] profiles = sr.getSystemProfileManager().getActiveSystemProfiles();
|
||||
for (int i = 0; i < profiles.length && host == null; i++){
|
||||
ISystemProfile profile = profiles[i];
|
||||
host = sr.getHost(profile, hostName);
|
||||
}
|
||||
|
||||
if (host != null){
|
||||
IRemoteFileSubSystem ss = RemoteFileUtility.getFileSubSystem(host);
|
||||
try {
|
||||
remoteObject = ss.getRemoteFileObject(fullPath, new NullProgressMonitor());
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (remoteObject != null){
|
||||
_selectedObject = remoteObject;
|
||||
}
|
||||
else {
|
||||
//unable to find remote object equivalent so returning
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.run(action);
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* David McKnight (IBM) - [160105] [usability] Universal action needed to locate a resource in the Remote Systems View
|
||||
* David McKnight (IBM) - [218227][usability] Contribute a "Show in RSE" action to Resource Navigator and Project Explorer
|
||||
********************************************************************************/
|
||||
package org.eclipse.rse.internal.ui.actions;
|
||||
|
||||
|
@ -318,7 +319,7 @@ public class ShowInSystemsViewDelegate implements IViewActionDelegate {
|
|||
|
||||
}
|
||||
private IAction _action;
|
||||
private Object _remoteObject;
|
||||
protected Object _selectedObject;
|
||||
private SystemViewPart _systemViewPart;
|
||||
|
||||
public void init(IViewPart view) {
|
||||
|
@ -330,19 +331,19 @@ public class ShowInSystemsViewDelegate implements IViewActionDelegate {
|
|||
SystemView systemTree = viewPart.getSystemView();
|
||||
|
||||
// now we've got to show the object in this view part
|
||||
TreeItem item = (TreeItem)systemTree.findFirstRemoteItemReference(_remoteObject, null);
|
||||
TreeItem item = (TreeItem)systemTree.findFirstRemoteItemReference(_selectedObject, null);
|
||||
if (item != null){
|
||||
systemTree.getTree().setSelection(item);
|
||||
}
|
||||
else if (_remoteObject instanceof IAdaptable)
|
||||
else if (_selectedObject instanceof IAdaptable)
|
||||
{
|
||||
ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)((IAdaptable)_remoteObject).getAdapter(ISystemViewElementAdapter.class);
|
||||
ISystemViewElementAdapter adapter = getAdapter((IAdaptable)_selectedObject);
|
||||
if (adapter != null){
|
||||
ISubSystem subSystem = adapter.getSubSystem(_remoteObject);
|
||||
ISubSystem subSystem = adapter.getSubSystem(_selectedObject);
|
||||
if (subSystem.getSubSystemConfiguration().supportsFilters()){
|
||||
// no match, so we will expand from filter
|
||||
// query matching filter in a job (to avoid main thread)
|
||||
LinkFromFilterJob job = new LinkFromFilterJob((IAdaptable)_remoteObject, systemTree);
|
||||
LinkFromFilterJob job = new LinkFromFilterJob((IAdaptable)_selectedObject, systemTree);
|
||||
job.schedule();
|
||||
}
|
||||
else {
|
||||
|
@ -351,7 +352,7 @@ public class ShowInSystemsViewDelegate implements IViewActionDelegate {
|
|||
|
||||
// put these items in the tree and look for remote object
|
||||
// if we can't find the remote object under this, the ShowChildrenInTree will recurse
|
||||
Display.getDefault().asyncExec(new ShowChildrenInTree(subSystem, children, null, systemTree, (IAdaptable)_remoteObject));
|
||||
Display.getDefault().asyncExec(new ShowChildrenInTree(subSystem, children, null, systemTree, (IAdaptable)_selectedObject));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -381,7 +382,7 @@ public class ShowInSystemsViewDelegate implements IViewActionDelegate {
|
|||
IStructuredSelection sel = (IStructuredSelection)selection;
|
||||
if (sel.size() == 1){
|
||||
_action.setEnabled(true);
|
||||
_remoteObject = sel.getFirstElement();
|
||||
_selectedObject = sel.getFirstElement();
|
||||
}
|
||||
else {
|
||||
_action.setEnabled(false);
|
||||
|
|
Loading…
Add table
Reference in a new issue