From 1071df698c0aa84fb4f55b250f31312551258018 Mon Sep 17 00:00:00 2001 From: Uwe Stieber Date: Thu, 15 Mar 2007 15:06:36 +0000 Subject: [PATCH] [177537] [api] Dynamic system type provider need a hook to add dynamic system type specific menu groups --- .../rse/internal/ui/view/SystemView.java | 27 ++++++++++++++----- .../ui/view/SystemViewConnectionAdapter.java | 7 +---- .../eclipse/rse/ui/RSESystemTypeAdapter.java | 27 +++++++++++-------- 3 files changed, 38 insertions(+), 23 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java index c3b90bf3054..5bcc4dfc545 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemView.java @@ -15,6 +15,8 @@ * Tobias Schwarz (Wind River) - Fix 166343 getChildCount() counts invalid items * Martin Oberhuber (Wind River) - Improve fix for 166343 getChildCount() * Uwe Stieber (Wind River) - [172492] Use SafeTreeViewer + * - [177537] [api] Dynamic system type provider need a hook to add dynamic system type specific menu groups + * - Several bugfixes. * David Dykstal (IBM) - moved SystemPreferencesManager to a new package ********************************************************************************/ @@ -60,6 +62,8 @@ import org.eclipse.jface.viewers.TreeExpansionEvent; import org.eclipse.jface.viewers.TreePath; import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.jface.window.SameShellProvider; +import org.eclipse.rse.core.IRSESystemType; +import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.SystemAdapterHelpers; import org.eclipse.rse.core.SystemBasePlugin; import org.eclipse.rse.core.filters.ISystemFilter; @@ -94,6 +98,7 @@ import org.eclipse.rse.ui.ISystemContextMenuConstants; import org.eclipse.rse.ui.ISystemDeleteTarget; import org.eclipse.rse.ui.ISystemMessages; import org.eclipse.rse.ui.ISystemRenameTarget; +import org.eclipse.rse.ui.RSESystemTypeAdapter; import org.eclipse.rse.ui.RSEUIPlugin; import org.eclipse.rse.ui.SystemMenuManager; import org.eclipse.rse.ui.SystemPreferencesManager; @@ -896,16 +901,16 @@ ISelectionChangedListener, ITreeViewerListener, ISystemResourceChangeEvents, ISy // GO INTO ACTION... // OPEN IN NEW WINDOW ACTION... - if (fromSystemViewPart && showOpenViewActions()) { - - + if (fromSystemViewPart) { GoIntoAction goIntoAction = getGoIntoAction(); goIntoAction.setEnabled(selection.size() == 1); menu.appendToGroup(ISystemContextMenuConstants.GROUP_GOTO, goIntoAction); - SystemOpenExplorerPerspectiveAction openToPerspectiveAction = getOpenToPerspectiveAction(); - openToPerspectiveAction.setSelection(selection); - menu.appendToGroup(openToPerspectiveAction.getContextMenuGroup(), openToPerspectiveAction); + if (showOpenViewActions()) { + SystemOpenExplorerPerspectiveAction openToPerspectiveAction = getOpenToPerspectiveAction(); + openToPerspectiveAction.setSelection(selection); + menu.appendToGroup(openToPerspectiveAction.getContextMenuGroup(), openToPerspectiveAction); + } if (showGenericShowInTableAction()) { @@ -993,6 +998,16 @@ ISelectionChangedListener, ITreeViewerListener, ISystemResourceChangeEvents, ISy menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_REPLACEWITH)); menu.add(new Separator(ISystemContextMenuConstants.GROUP_PROPERTIES)); // Properties + // [177537] [api] Dynamic system type provider need a hook to add dynamic system type specific menu groups. + IRSESystemType[] systemTypes = RSECorePlugin.getDefault().getRegistry().getSystemTypes(); + for (int i = 0; i < systemTypes.length; i++) { + IRSESystemType systemType = systemTypes[i]; + Object adapter = systemType.getAdapter(IRSESystemType.class); + if (adapter instanceof RSESystemTypeAdapter) { + ((RSESystemTypeAdapter)adapter).addCustomMenuGroups(menu); + } + } + return menu; } diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java index 3821f3d1bf3..2273a7a3e71 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewConnectionAdapter.java @@ -259,12 +259,7 @@ public class SystemViewConnectionAdapter Object adapter = sysType != null ? sysType.getAdapter(IRSESystemType.class) : null; RSESystemTypeAdapter sysTypeAdapter = adapter instanceof RSESystemTypeAdapter ? (RSESystemTypeAdapter)adapter : null; if (sysTypeAdapter != null) { - boolean accepted = false; - Class[] affectedClasses = new Class[] { GoIntoAction.class, SystemOpenExplorerPerspectiveAction.class }; - for (int i = 0; i < affectedClasses.length && accepted == false; i++) { - accepted |= sysTypeAdapter.acceptContextMenuActionContribution((IHost)element, affectedClasses[i]); - } - return accepted; + return sysTypeAdapter.acceptContextMenuActionContribution((IHost)element, SystemOpenExplorerPerspectiveAction.class); } } return super.showOpenViewActions(element); diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSESystemTypeAdapter.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSESystemTypeAdapter.java index 18cd5139635..fcf3c0185f0 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSESystemTypeAdapter.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSESystemTypeAdapter.java @@ -23,6 +23,7 @@ import java.net.URL; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; +import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.IRSESystemTypeConstants; @@ -31,6 +32,7 @@ import org.eclipse.rse.core.RSEPreferencesManager; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.core.subsystems.IConnectorService; +import org.eclipse.rse.internal.ui.view.SystemView; import org.eclipse.rse.ui.actions.SystemClearAllPasswordsAction; import org.eclipse.rse.ui.actions.SystemWorkOfflineAction; import org.eclipse.rse.ui.wizards.registries.IRSEWizardDescriptor; @@ -39,7 +41,7 @@ import org.osgi.framework.Bundle; /** * Adapter for RSE system types. */ -public class RSESystemTypeAdapter extends RSEAdapter implements IRSESystemTypeConstants { +public class RSESystemTypeAdapter extends RSEAdapter { public RSESystemTypeAdapter() { super(); @@ -51,7 +53,7 @@ public class RSESystemTypeAdapter extends RSEAdapter implements IRSESystemTypeCo * @see org.eclipse.ui.model.WorkbenchAdapter#getImageDescriptor(java.lang.Object) */ public ImageDescriptor getImageDescriptor(Object object) { - ImageDescriptor img = getImage(object, ICON); + ImageDescriptor img = getImage(object, IRSESystemTypeConstants.ICON); if (img==null) img = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_CONNECTION_ID); return img; } @@ -68,8 +70,8 @@ public class RSESystemTypeAdapter extends RSEAdapter implements IRSESystemTypeCo * @return ImageDescriptor */ public ImageDescriptor getLiveImageDescriptor(Object object) { - ImageDescriptor img = getImage(object, ICON_LIVE); - if (img==null) img = getImage(object, ICON); + ImageDescriptor img = getImage(object, IRSESystemTypeConstants.ICON_LIVE); + if (img==null) img = getImage(object, IRSESystemTypeConstants.ICON); if (img==null) img = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_CONNECTIONLIVE_ID); return img; } @@ -166,7 +168,7 @@ public class RSESystemTypeAdapter extends RSEAdapter implements IRSESystemTypeCo public boolean isEnableOffline(Object object) { if ((object != null) && (object instanceof IRSESystemType)) { - String property = ((IRSESystemType)object).getProperty(ENABLE_OFFLINE); + String property = ((IRSESystemType)object).getProperty(IRSESystemTypeConstants.ENABLE_OFFLINE); if (property != null) { return Boolean.valueOf(property).booleanValue(); } @@ -246,6 +248,15 @@ public class RSESystemTypeAdapter extends RSEAdapter implements IRSESystemTypeCo return result; } + /** + * Called from {@link SystemView#createStandardGroups(IMenuManager)} to allow dynamic system + * type providers to customize the RSE standard menu structure regarding their needs. + * + * @param menu The menu manager. Must be not null. + */ + public void addCustomMenuGroups(IMenuManager menu) { + // The static standard RSE system types have no custom menu groups. + } /** * Called to approve the contribution of the specified action class to the context menu of the @@ -254,12 +265,6 @@ public class RSESystemTypeAdapter extends RSEAdapter implements IRSESystemTypeCo * Note: System type providers should implement this method in a way that specific * actions might be denied, but all other action contributions, including unknown * action contributions, should be accepted. - *

- * This method is called from:
- *

* * @param host The host object. Must be not null. * @param actionClass The contributed action. Must be not null.