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 936c76f8103..2b29623061c 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 @@ -102,43 +102,68 @@ public class SystemViewConnectionAdapter * @param shell Shell of viewer * @param menuGroup recommended menu group to add actions to. If added to another group, you must be sure to create that group first. */ - public void addActions(SystemMenuManager menu, IStructuredSelection selection, Shell shell, String menuGroup) - { - if (!actionsCreated) - createActions(); - //updateAction.setValue(null); // reset - menu.add(menuGroup, anotherConnectionAction); - menu.add(menuGroup, copyAction); - menu.add(menuGroup, moveAction); - menu.add(menuGroup, upAction); - menu.add(menuGroup, downAction); - - // MJB: RE defect 40854 - addConnectOrDisconnectAction(menu, menuGroup, selection); - - menu.add(menuGroup, clearPasswordAction); - - IRSESystemType sysType = RSECorePlugin.getDefault().getRegistry().getSystemType((((IHost)selection.getFirstElement()).getSystemType())); - RSESystemTypeAdapter sysTypeAdapter = (RSESystemTypeAdapter)(sysType.getAdapter(IRSESystemType.class)); - - // yantzi: artemis 6.0, offline support, only add work offline action for system types that support offline mode - if (sysTypeAdapter.isEnableOffline(sysType)) - { - menu.add(menuGroup, offlineAction); - } + public void addActions(SystemMenuManager menu, IStructuredSelection selection, Shell shell, String menuGroup) { + if (!actionsCreated) createActions(); + + // bugzilla#161195: _ALL_ actions needs to be passed to the system type for approval. + // _Never_ add any action without the system type provider having said ok to this. + IHost host = (IHost)selection.getFirstElement(); + IRSESystemType sysType = RSECorePlugin.getDefault().getRegistry().getSystemType((host.getSystemType())); + Object adapter = sysType.getAdapter(IRSESystemType.class); + RSESystemTypeAdapter sysTypeAdapter = adapter instanceof RSESystemTypeAdapter ? (RSESystemTypeAdapter)adapter : null; + + //updateAction.setValue(null); // reset + if (sysTypeAdapter == null + || sysTypeAdapter.acceptContextMenuActionContribution(host, sysType, menu.getMenuManager(), anotherConnectionAction)) + menu.add(menuGroup, anotherConnectionAction); + + if (sysTypeAdapter == null + || sysTypeAdapter.acceptContextMenuActionContribution(host, sysType, menu.getMenuManager(), copyAction)) + menu.add(menuGroup, copyAction); + + if (sysTypeAdapter == null + || sysTypeAdapter.acceptContextMenuActionContribution(host, sysType, menu.getMenuManager(), moveAction)) + menu.add(menuGroup, moveAction); + if (sysTypeAdapter == null + || sysTypeAdapter.acceptContextMenuActionContribution(host, sysType, menu.getMenuManager(), upAction)) + menu.add(menuGroup, upAction); + if (sysTypeAdapter == null + || sysTypeAdapter.acceptContextMenuActionContribution(host, sysType, menu.getMenuManager(), downAction)) + menu.add(menuGroup, downAction); + + // MJB: RE defect 40854 + addConnectOrDisconnectAction(menu, menuGroup, selection); + + if (sysTypeAdapter == null + || sysTypeAdapter.acceptContextMenuActionContribution(host, sysType, menu.getMenuManager(), clearPasswordAction)) + menu.add(menuGroup, clearPasswordAction); + + // yantzi: artemis 6.0, offline support, only add work offline action for system types that support offline mode + if (sysTypeAdapter == null + || sysTypeAdapter.acceptContextMenuActionContribution(host, sysType, menu.getMenuManager(), offlineAction)) + menu.add(menuGroup, offlineAction); } - private void addConnectOrDisconnectAction(SystemMenuManager menu, String menuGroup, IStructuredSelection selection) - { - IHost sysCon = (IHost) selection.getFirstElement(); - ISystemRegistry sysReg = RSEUIPlugin.getTheSystemRegistry(); - boolean anySupportsConnect = sysReg.isAnySubSystemSupportsConnect(sysCon); + private void addConnectOrDisconnectAction(SystemMenuManager menu, String menuGroup, IStructuredSelection selection) { + IHost host = (IHost)selection.getFirstElement(); + IRSESystemType sysType = RSECorePlugin.getDefault().getRegistry().getSystemType((host.getSystemType())); + Object adapter = sysType.getAdapter(IRSESystemType.class); + RSESystemTypeAdapter sysTypeAdapter = adapter instanceof RSESystemTypeAdapter ? (RSESystemTypeAdapter)adapter : null; + ISystemRegistry sysReg = RSEUIPlugin.getTheSystemRegistry(); + boolean anySupportsConnect = sysReg.isAnySubSystemSupportsConnect(host); + if (anySupportsConnect) { - boolean anyConnected = sysReg.isAnySubSystemConnected(sysCon); - boolean allConnected = sysReg.areAllSubSystemsConnected(sysCon); - if (!allConnected) menu.add(menuGroup, connectAction); - if (anyConnected) menu.add(menuGroup, disconnectAction); + boolean anyConnected = sysReg.isAnySubSystemConnected(host); + boolean allConnected = sysReg.areAllSubSystemsConnected(host); + + if (!allConnected && (sysTypeAdapter == null + || sysTypeAdapter.acceptContextMenuActionContribution(host, sysType, menu.getMenuManager(), connectAction))) + menu.add(menuGroup, connectAction); + + if (anyConnected && (sysTypeAdapter == null + || sysTypeAdapter.acceptContextMenuActionContribution(host, sysType, menu.getMenuManager(), disconnectAction))) + menu.add(menuGroup, disconnectAction); } } 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 734040c63b3..d1c951d90aa 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,10 +23,17 @@ 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.IAction; +import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.IRSESystemTypeConstants; 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.ui.actions.SystemClearAllPasswordsAction; +import org.eclipse.rse.ui.actions.SystemWorkOfflineAction; import org.eclipse.rse.ui.wizards.registries.IRSEWizardDescriptor; import org.osgi.framework.Bundle; @@ -235,6 +242,47 @@ public class RSESystemTypeAdapter extends RSEAdapter implements IRSESystemTypeCo return result; } + + /** + * Called to approve the contribution of the specified action to the context menu of the + * specified host of the specified system type. 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:
+ *
True
if the contributed action is accepted for the specified context, false
otherwise.
+ */
+ public boolean acceptContextMenuActionContribution(IHost host, IRSESystemType systemType, IMenuManager menuManager, IAction action) {
+ // The SystemWorkOfflineAction is accepted if isEnabledOffline is returning true
+ if (action instanceof SystemWorkOfflineAction) {
+ return isEnableOffline(systemType);
+ }
+
+ // SystemClearAllPasswordsAction is accepted only if passwords are supported
+ // by any of the sub systems.
+ if (action instanceof SystemClearAllPasswordsAction) {
+ ISystemRegistry registry = RSEUIPlugin.getDefault().getSystemRegistry();
+ IConnectorService[] connectorServices = registry.getConnectorServices(host);
+ boolean passwordsSupported = false;
+ for (int i = 0; i < connectorServices.length && passwordsSupported == false; i++) {
+ passwordsSupported |= !connectorServices[i].isSuppressSignonPrompt();
+ }
+ return passwordsSupported;
+ }
+
+ // Accept all the rest not special handled here.
+ return true;
+ }
+
/**
* Checks if the given wizard descriptor is accepted for the system types the
* adapter is covering.