1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

[187711] [api] link with editor for system view

This commit is contained in:
David McKnight 2008-01-02 19:28:31 +00:00
parent 97b069a9ec
commit e2a2214137
11 changed files with 300 additions and 97 deletions

View file

@ -16,6 +16,7 @@
* Martin Oberhuber (Wind River) - [187218] Fix error reporting for connect()
* David McKnight (IBM) - [207095] Implicit connect needs to run in the same job as caller
* David McKnight (IBM) - [186363] get rid of obsolete calls to ISubSystem.connect()
* David McKnight (IBM) - [187711] new doesFilterEncompass apis
********************************************************************************/
package org.eclipse.rse.core.subsystems;
@ -271,6 +272,23 @@ public interface ISubSystem extends ISystemFilterPoolReferenceManagerProvider, I
*/
public boolean doesFilterStringMatch(String filterString, String remoteObjectAbsoluteName, boolean caseSensitive);
/**
* Return true if the remote remote object would be a descendent of the result of this filter
* @param filter
* @param remoteObjectAbsoluteName
* @return
*/
public boolean doesFilterEncompass(ISystemFilter filter, String remoteObjectAbsoluteName);
/**
* Return true if the remote remote object would be a descendent of the result of this filter
* @param filterString
* @param remoteObjectAbsoluteName
* @param caseSensitive
* @return
*/
public boolean doesFilterStringEncompass(String filterString, String remoteObjectAbsoluteName, boolean caseSensitive);
// -------------------------
// Filter Pool References...
// -------------------------

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

View file

@ -13,6 +13,7 @@
#
# Contributors:
# Willian Mitsuda - [184824] added a Remote action set item
# David McKnight (IBM) - [187711] Link with Editor action for System View
###############################################################################
# NLS_MESSAGEFORMAT_NONE
@ -50,3 +51,5 @@ searchMenu.label = Se&arch
Remote.ActionSet = Remote...
Remote.Search = &Remote...
Remote.Search.tooltip = Opens Remote Search dialog page for text and file searching on remote systems
LinkWithSystemView.label = Link with Editor

View file

@ -15,6 +15,7 @@ Contributors:
Martin Oberhuber (Wind River) - [180519] declaratively register adapter factories
Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter from UI/rse.core.subsystems.util
David McKnight (IBM) - [187711] Link with Editor action for System View
-->
<?eclipse version="3.0"?>
<plugin>
@ -434,5 +435,21 @@ Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter fro
</action>
</objectContribution>
</extension>
<extension
point="org.eclipse.ui.viewActions">
<viewContribution
targetID="org.eclipse.rse.ui.view.systemView"
id="org.eclipse.rse.ui.view.systemView.toolbar">
<action
id="org.eclipse.rse.ui.view.systemView.toolbar.linkWithSystemView"
toolbarPath="navigationGroup"
class="org.eclipse.rse.internal.files.ui.actions.LinkWithSystemViewAction"
icon="$nl$/icons/full/elcl16/synced.gif"
helpContextId="link_editor_with_system_view_action_context"
label="%LinkWithSystemView.label">
</action>
</viewContribution>
</extension>
</plugin>

View file

@ -0,0 +1,121 @@
/********************************************************************************
* Copyright (c) 2007 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) - [187711] Link with Editor action for System View
********************************************************************************/
package org.eclipse.rse.internal.files.ui.actions;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.internal.ui.view.SystemView;
import org.eclipse.rse.internal.ui.view.SystemViewPart;
import org.eclipse.rse.subsystems.files.core.SystemIFileProperties;
import org.eclipse.rse.ui.IViewLinker;
import org.eclipse.rse.ui.view.ISystemEditableRemoteObject;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
public class LinkWithSystemViewAction implements IViewActionDelegate {
public class ViewLinker implements IViewLinker
{
public void link(IEditorPart editor, SystemView systemView)
{
IEditorInput input = editor.getEditorInput();
if (input instanceof IFileEditorInput)
{
IFileEditorInput fileInput = (IFileEditorInput) input;
fileInput.getFile();
IFile file = fileInput.getFile();
SystemIFileProperties properties = new SystemIFileProperties(file);
Object rmtEditable = properties.getRemoteFileObject();
Object remoteObj = null;
ISubSystem subSystem = null;
if (rmtEditable != null && rmtEditable instanceof ISystemEditableRemoteObject)
{
ISystemEditableRemoteObject editable = (ISystemEditableRemoteObject) rmtEditable;
remoteObj = editable.getRemoteObject();
}
else
{
String subsystemId = properties.getRemoteFileSubSystem();
String path = properties.getRemoteFilePath();
if (subsystemId != null && path != null)
{
subSystem = RSECorePlugin.getTheSystemRegistry().getSubSystem(subsystemId);
if (subSystem != null)
{
if (subSystem.isConnected())
{
try
{
remoteObj = subSystem.getObjectWithAbsoluteName(path, new NullProgressMonitor());
}
catch (Exception e)
{
return;
}
}
}
}
}
if (remoteObj != null)
{
TreeItem item = (TreeItem)systemView.findFirstRemoteItemReference(remoteObj, null);
if (item != null){
systemView.getTree().setSelection(item);
}
else {
// item does not exist in tree
systemView.expandTo(subSystem, remoteObj);
}
}
}
}
}
private SystemViewPart _systemViewPart;
private IAction _action;
private IViewLinker _linker;
public void init(IViewPart view) {
_systemViewPart = (SystemViewPart)view;
_linker = new ViewLinker();
}
public void run(IAction action) {
if (_systemViewPart != null){
_systemViewPart.setLinkingEnabled(action.isChecked(), _linker);
}
}
public void selectionChanged(IAction action, ISelection selection) {
if (_action == null) {
action.setChecked(_systemViewPart.isLinkingEnabled());
_action= action;
}
}
}

View file

@ -23,6 +23,7 @@
* David McKnight (IBM) - [207178] changing list APIs for file service and subsystems
* David McKnight (IBM) - [210109] store constants in IFileService rather than IFileServiceConstants
* David McKnight (IBM) - [211472] [api][breaking] IRemoteObjectResolver.getObjectWithAbsoluteName() needs a progress monitor
* David McKnight (IBM) - [187711] doestFilterEncompass api
*******************************************************************************/
package org.eclipse.rse.subsystems.files.core.subsystems;
@ -404,6 +405,52 @@ public abstract class RemoteFileSubSystem extends SubSystem implements IRemoteFi
// "Univ Filter String Testing '" + container + "' versus '" + remoteObjectAbsoluteName + "' => " + affected);
return affected;
}
/**
* Return true if the remote remote object would be a descendent of the result of this filter
* @param filterString
* @param remoteObjectAbsoluteName
* @param caseSensitive
* @return
*/
public boolean doesFilterStringEncompass(String filterString, String remoteObjectAbsoluteName, boolean caseSensitive)
{
RemoteFileFilterString rffs = new RemoteFileFilterString(getParentRemoteFileSubSystemConfiguration(), filterString);
// ok, this is a tweak: if the absolute name has " -folder" at the end, that means it is a folder...
if (remoteObjectAbsoluteName.endsWith(" -folder")) //$NON-NLS-1$
{
if (!rffs.getShowSubDirs())
return false;
remoteObjectAbsoluteName = remoteObjectAbsoluteName.substring(0, remoteObjectAbsoluteName.indexOf(" -folder")); //$NON-NLS-1$
}
// problem 1: we don't know if the given remote object name represents a file or folder. We have to assume a file,
// since we don't support filtering by folder names.
if (!rffs.getShowFiles())
return false;
// step 1: verify the path of the remote object matches the path of the filter string
String container = rffs.getPath();
if (container == null)
return false;
if (container.equals(".")) //$NON-NLS-1$
{
try
{
container = getRemoteFileObject(container, new NullProgressMonitor()).getAbsolutePath();
}
catch (Exception e)
{
}
}
if (container.indexOf(remoteObjectAbsoluteName) > -1){
return true;
}
return false;
}
// -------------------------------
// SubSystem METHODS ...

View file

@ -46,6 +46,7 @@
* David McKnight (IBM) - [205819] Need to use input stream copy when EFS files are the src
* Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread
* David McKnight (IBM) - [199424] api to create tree items after query complete
* David McKnight (IBM) - [187711] expandTo to handle filters specially
********************************************************************************/
package org.eclipse.rse.internal.ui.view;
@ -5709,8 +5710,22 @@ public class SystemView extends SafeTreeViewer
provider.setEnableDeferredQueries(true);
return;
}
else
else if (data instanceof ISystemFilterReference)
{
ISystemFilterReference ref = (ISystemFilterReference)data;
if (ss.doesFilterMatch(ref.getReferencedFilter(), remoteObjectName)){
expandTo(data, remoteObject);
}
else if (ss.doesFilterListContentsOf(ref.getReferencedFilter(),remoteObjectName)){
expandTo(data, remoteObject);
}
else if (ss.doesFilterEncompass(ref.getReferencedFilter(), remoteObjectName))
{
expandTo(data, remoteObject);
}
}
else
{
ISystemViewElementAdapter dataAdapter = (ISystemViewElementAdapter)((IAdaptable)data).getAdapter(ISystemViewElementAdapter.class);
String path = dataAdapter.getAbsoluteName(data);
if (remoteObjectName.startsWith(path))

View file

@ -26,6 +26,7 @@
* Martin Oberhuber (Wind River) - [197025] Wait for model complete before restoring initial state
* Martin Oberhuber (Wind River) - [197025][197167] Improved wait for model complete
* David McKnight (IBM) - [199424] restoring memento state asynchronously
* David McKnight (IBM) - [187711] Link with Editor handled by extension
********************************************************************************/
package org.eclipse.rse.internal.ui.view;
@ -44,7 +45,6 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
@ -86,8 +86,8 @@ import org.eclipse.rse.internal.ui.actions.SystemPreferenceShowFilterPoolsAction
import org.eclipse.rse.internal.ui.actions.SystemWorkWithProfilesAction;
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
import org.eclipse.rse.ui.ISystemContextMenuConstants;
import org.eclipse.rse.ui.ISystemIconConstants;
import org.eclipse.rse.ui.ISystemPreferencesConstants;
import org.eclipse.rse.ui.IViewLinker;
import org.eclipse.rse.ui.RSESystemTypeAdapter;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemBasePlugin;
@ -115,7 +115,6 @@ import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IElementFactory;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IPartListener;
import org.eclipse.ui.IPersistableElement;
@ -142,20 +141,7 @@ public class SystemViewPart
implements ISetSelectionTarget, IShellProvider, ISystemMessageLine, IElementFactory, IPersistableElement, IAdapterFactory, ISystemPreferenceChangeListener, ISelectionChangedListener, IRSEViewPart
{
public class ToggleLinkingAction extends Action
{
public ToggleLinkingAction(SystemViewPart viewPart, String label)
{
super(label);
setChecked(isLinkingEnabled);
}
public void run()
{
toggleLinkingEnabled();
setChecked(isLinkingEnabled);
}
}
protected SystemView systemView;
protected ISystemViewInputProvider input = null;
@ -163,11 +149,16 @@ public class SystemViewPart
protected SystemMessage sysErrorMessage;
protected IStatusLineManager statusLine = null;
protected boolean inputIsRoot = true;
protected boolean isLinkingEnabled = false;
protected FrameList frameList;
protected SystemViewPartGotoActionGroup gotoActionGroup;
protected ToggleLinkingAction toggleLinkingAction;
// link with editor stuff
protected boolean _isLinkingEnabled = false;
// view linker is used when a link with editor is required
protected IViewLinker _viewLinker;
// remember-state variables...
@ -251,11 +242,17 @@ public class SystemViewPart
return ((ILabelProvider) getSystemView().getLabelProvider()).getText(element);
}
public void toggleLinkingEnabled()
public boolean isLinkingEnabled()
{
isLinkingEnabled = !isLinkingEnabled;
if (isLinkingEnabled)
return _isLinkingEnabled;
}
public void setLinkingEnabled(boolean flag, IViewLinker viewLinker)
{
_isLinkingEnabled = flag;
if (_isLinkingEnabled)
{
_viewLinker = viewLinker;
IWorkbenchWindow activeWindow = SystemBasePlugin.getActiveWorkbenchWindow();
IWorkbenchPage activePage = activeWindow.getActivePage();
IEditorPart editor = activePage.getActiveEditor();
@ -274,59 +271,11 @@ public class SystemViewPart
*/
protected void editorActivated(IEditorPart editor)
{
if (!isLinkingEnabled)
if (!_isLinkingEnabled)
return;
IEditorInput input = editor.getEditorInput();
if (input instanceof IFileEditorInput)
{
IFileEditorInput fileInput = (IFileEditorInput) input;
fileInput.getFile();
/* FIXME - can't couple this view to files ui
IFile file = fileInput.getFile();
SystemIFileProperties properties = new SystemIFileProperties(file);
Object rmtEditable = properties.getRemoteFileObject();
Object remoteObj = null;
if (rmtEditable != null && rmtEditable instanceof ISystemEditableRemoteObject)
{
ISystemEditableRemoteObject editable = (ISystemEditableRemoteObject) rmtEditable;
remoteObj = editable.getRemoteObject();
}
else
{
String subsystemId = properties.getRemoteFileSubSystem();
String path = properties.getRemoteFilePath();
if (subsystemId != null && path != null)
{
ISubSystem subSystem = RSECorePlugin.getTheSystemRegistry().getSubSystem(subsystemId);
if (subSystem != null)
{
if (subSystem.isConnected())
{
try
{
remoteObj = subSystem.getObjectWithAbsoluteName(path);
}
catch (Exception e)
{
return;
}
}
}
}
}
if (remoteObj != null)
{
// DKM - causes editor to loose focus
//systemView.refreshRemoteObject(path, remoteObj, true);
SystemResourceChangeEvent event = new SystemResourceChangeEvent(remoteObj, ISystemResourceChangeEvents.EVENT_SELECT_REMOTE, null);
systemView.systemResourceChanged(event);
}
*/
if (_viewLinker != null){
_viewLinker.link(editor, systemView);
}
}
/**
@ -614,7 +563,7 @@ public class SystemViewPart
_copyAction.setEnabled(_copyAction.updateSelection(sel));
_pasteAction.setEnabled(_pasteAction.updateSelection(sel));
//systemView.getPropertyDialogAction();
if (isLinkingEnabled)
if (_isLinkingEnabled)
{
linkToEditor(sel);
}
@ -715,13 +664,6 @@ public class SystemViewPart
collapseAllAction.setSelectionProvider(systemView);
toolBarMgr.add(collapseAllAction);
toolBarMgr.add(new GroupMarker(ISystemContextMenuConstants.GROUP_VIEWER_SETUP));
toggleLinkingAction = new ToggleLinkingAction(this, SystemViewResources.RESID_PROPERTY_LINKINGACTION_TEXT);
toggleLinkingAction.setToolTipText(SystemViewResources.RESID_PROPERTY_LINKINGACTION_TOOLTIP);
toggleLinkingAction.setImageDescriptor(getNavigatorImageDescriptor(ISystemIconConstants.ICON_IDE_LINKTOEDITOR_ID));
toggleLinkingAction.setHoverImageDescriptor(getNavigatorImageDescriptor(ISystemIconConstants.ICON_IDE_LINKTOEDITOR_ID));
toolBarMgr.add(toggleLinkingAction);
IMenuManager menuMgr = actionBars.getMenuManager();
populateSystemViewPulldownMenu(menuMgr, getShell(), showConnectionActions, this, systemView);
@ -1038,7 +980,7 @@ public class SystemViewPart
return;
}
if (isLinkingEnabled)
if (_isLinkingEnabled)
{
memento.putString(TAG_LINKWITHEDITOR, "t"); //$NON-NLS-1$
}
@ -1797,21 +1739,7 @@ public class SystemViewPart
// restore the show filter pools and show filter strings settings as they were when this was saved
boolean showFilterPools = false;
boolean showFilterStrings = false;
String linkWithEditor = memento.getString(TAG_LINKWITHEDITOR);
if (linkWithEditor != null)
{
if (linkWithEditor.equals("t")) //$NON-NLS-1$
{
isLinkingEnabled = true;
toggleLinkingAction.setChecked(true);
}
else
isLinkingEnabled = false;
}
else
{
isLinkingEnabled = false;
}
String savedValue = memento.getString(TAG_SHOWFILTERPOOLS);
if (savedValue != null)

View file

@ -0,0 +1,27 @@
/********************************************************************************
* Copyright (c) 2007 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) - [187711] IViewLinker to be API that system view part calls when link with editor
********************************************************************************/
package org.eclipse.rse.ui;
import org.eclipse.rse.internal.ui.view.SystemView;
import org.eclipse.ui.IEditorPart;
public interface IViewLinker {
/**
* System View part calls link when using Link With Editor. Provider of action supplies this implementation.
* @param editor the active editor
* @param systemView the view to link
*/
public void link(IEditorPart editor, SystemView systemView);
}

View file

@ -83,6 +83,8 @@ public class SystemPreferencesManager {
}
private static void initDefaultsUI() {
String showProp = System.getProperty("rse.showNewConnectionPrompt");
RSEUIPlugin ui = RSEUIPlugin.getDefault();
Preferences store = ui.getPluginPreferences();
showNewConnectionPrompt= getBooleanProperty("rse.showNewConnectionPrompt", ISystemPreferencesConstants.DEFAULT_SHOWNEWCONNECTIONPROMPT); //$NON-NLS-1$

View file

@ -28,6 +28,7 @@
* David McKnight (IBM) - [186363] get rid of obsolete calls to SubSystem.connect()
* David McKnight (IBM) - [211472] [api][breaking] IRemoteObjectResolver.getObjectWithAbsoluteName() needs a progress monitor
* David McKnight (IBM) - [212403] [apidoc][breaking] Fixing docs of SubSystem#getConnectorService() and making internalConnect() private
* David McKnight (IBM) - [187711] default implementation of doesFilterEncompass()
********************************************************************************/
package org.eclipse.rse.core.subsystems;
@ -743,6 +744,30 @@ public abstract class SubSystem extends RSEModelObject
{
return true;
}
public boolean doesFilterStringEncompass(String filter, String remoteObjectAbsoluteName, boolean caseSensitive)
{
return true;
}
public boolean doesFilterEncompass(ISystemFilter filter, String remoteObjectAbsoluteName)
{
boolean would = false;
String[] strings = filter.getFilterStrings();
if (strings != null){
for (int idx=0; !would && (idx<strings.length); idx++)
{
if (strings[idx].equals("*")) //$NON-NLS-1$
would = true;
else if (strings[idx].equals("./*")) //$NON-NLS-1$
would = true;
else
would = doesFilterStringEncompass(strings[idx], remoteObjectAbsoluteName, filter.areStringsCaseSensitive());
}
}
return would;
}
// -------------------------------------
// GUI methods