1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-03 15:15:25 +02:00

[199032] [api] Remove method acceptContextMenuActionContribution(...) from RSESystemTypeAdapter

This commit is contained in:
Uwe Stieber 2007-11-08 13:51:15 +00:00
parent a9cbb90104
commit e15128480f
2 changed files with 21 additions and 195 deletions

View file

@ -27,6 +27,7 @@
* Kevin Doyle (IBM) - [189005] Fixed getParent() to return SystemRegistryUI instead of SystemRegistry
* Martin Oberhuber (Wind River) - [190271] Move ISystemViewInputProvider to Core
* David McKnight (IBM) - [191288] Up To Action doesn't go all the way back to the connections
* Uwe Stieber (Wind River) - [199032] [api] Remove method acceptContextMenuActionContribution(...) from RSESystemTypeAdapter
********************************************************************************/
package org.eclipse.rse.internal.ui.view;
@ -45,20 +46,16 @@ 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.model.ISystemViewInputProvider;
import org.eclipse.rse.core.subsystems.IConnectorService;
import org.eclipse.rse.core.subsystems.ISubSystem;
import org.eclipse.rse.internal.ui.SystemResources;
import org.eclipse.rse.internal.ui.actions.SystemClearAllPasswordsAction;
import org.eclipse.rse.internal.ui.actions.SystemCommonDeleteAction;
import org.eclipse.rse.internal.ui.actions.SystemCommonRenameAction;
import org.eclipse.rse.internal.ui.actions.SystemConnectAllSubSystemsAction;
import org.eclipse.rse.internal.ui.actions.SystemCopyConnectionAction;
import org.eclipse.rse.internal.ui.actions.SystemDisconnectAllSubSystemsAction;
import org.eclipse.rse.internal.ui.actions.SystemMoveConnectionAction;
import org.eclipse.rse.internal.ui.actions.SystemMoveDownConnectionAction;
import org.eclipse.rse.internal.ui.actions.SystemMoveUpConnectionAction;
import org.eclipse.rse.internal.ui.actions.SystemOpenExplorerPerspectiveAction;
import org.eclipse.rse.internal.ui.actions.SystemShowInMonitorAction;
import org.eclipse.rse.internal.ui.actions.SystemShowInTableAction;
import org.eclipse.rse.internal.ui.actions.SystemWorkOfflineAction;
import org.eclipse.rse.ui.ISystemContextMenuConstants;
import org.eclipse.rse.ui.ISystemMessages;
@ -66,13 +63,11 @@ import org.eclipse.rse.ui.RSESystemTypeAdapter;
import org.eclipse.rse.ui.RSEUIPlugin;
import org.eclipse.rse.ui.SystemMenuManager;
import org.eclipse.rse.ui.actions.SystemNewConnectionAction;
import org.eclipse.rse.ui.actions.SystemRefreshAction;
import org.eclipse.rse.ui.validators.ISystemValidator;
import org.eclipse.rse.ui.validators.ValidatorSpecialChar;
import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
import org.eclipse.rse.ui.view.ISystemPropertyConstants;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.dialogs.PropertyDialogAction;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.PropertyDescriptor;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
@ -143,43 +138,35 @@ public class SystemViewConnectionAdapter
RSESystemTypeAdapter sysTypeAdapter = adapter instanceof RSESystemTypeAdapter ? (RSESystemTypeAdapter)adapter : null;
//updateAction.setValue(null); // reset
if (sysTypeAdapter == null || sysTypeAdapter.acceptContextMenuActionContribution(host, anotherConnectionAction.getClass())) {
menu.add(menuGroup, anotherConnectionAction);
}
menu.add(menuGroup, anotherConnectionAction);
menu.appendToGroup(ISystemContextMenuConstants.GROUP_NEW, new GroupMarker(ISystemContextMenuConstants.GROUP_NEW_NONCASCADING));// user or BP/ISV additions
if (sysTypeAdapter == null
|| sysTypeAdapter.acceptContextMenuActionContribution(host, copyAction.getClass()))
menu.add(menuGroup, copyAction);
if (sysTypeAdapter == null
|| sysTypeAdapter.acceptContextMenuActionContribution(host, moveAction.getClass()))
menu.add(menuGroup, moveAction);
if (sysTypeAdapter == null
|| sysTypeAdapter.acceptContextMenuActionContribution(host, upAction.getClass()))
menu.add(menuGroup, upAction);
if (sysTypeAdapter == null
|| sysTypeAdapter.acceptContextMenuActionContribution(host, downAction.getClass()))
menu.add(menuGroup, downAction);
menu.add(menuGroup, copyAction);
menu.add(menuGroup, moveAction);
menu.add(menuGroup, upAction);
menu.add(menuGroup, downAction);
// MJB: RE defect 40854
addConnectOrDisconnectAction(menu, menuGroup, selection);
if (sysTypeAdapter == null
|| sysTypeAdapter.acceptContextMenuActionContribution(host, clearPasswordAction.getClass()))
menu.add(menuGroup, clearPasswordAction);
// SystemClearAllPasswordsAction is added only if passwords are supported
// by any of the sub systems.
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
IConnectorService[] connectorServices = registry.getConnectorServices(host);
boolean passwordsSupported = false;
for (int i = 0; i < connectorServices.length && passwordsSupported == false; i++) {
passwordsSupported |= connectorServices[i].supportsPassword();
}
if (passwordsSupported) 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, offlineAction.getClass()))
if (sysTypeAdapter != null && sysTypeAdapter.isEnableOffline(host.getSystemType())) {
menu.add(menuGroup, offlineAction);
}
}
private void addConnectOrDisconnectAction(SystemMenuManager menu, String menuGroup, IStructuredSelection selection) {
IHost host = (IHost)selection.getFirstElement();
IRSESystemType sysType = getSystemTypeForHost(host);
Object adapter = sysType != null ? sysType.getAdapter(RSESystemTypeAdapter.class) : null;
RSESystemTypeAdapter sysTypeAdapter = adapter instanceof RSESystemTypeAdapter ? (RSESystemTypeAdapter)adapter : null;
ISystemRegistry sysReg = RSECorePlugin.getTheSystemRegistry();
boolean anySupportsConnect = sysReg.isAnySubSystemSupportsConnect(host);
@ -188,13 +175,8 @@ public class SystemViewConnectionAdapter
boolean anyConnected = sysReg.isAnySubSystemConnected(host);
boolean allConnected = sysReg.areAllSubSystemsConnected(host);
if (!allConnected && (sysTypeAdapter == null
|| sysTypeAdapter.acceptContextMenuActionContribution(host, connectAction.getClass())))
menu.add(menuGroup, connectAction);
if (anyConnected && (sysTypeAdapter == null
|| sysTypeAdapter.acceptContextMenuActionContribution(host, disconnectAction.getClass())))
menu.add(menuGroup, disconnectAction);
if (!allConnected) menu.add(menuGroup, connectAction);
if (anyConnected) menu.add(menuGroup, disconnectAction);
}
}
@ -221,113 +203,6 @@ public class SystemViewConnectionAdapter
actionsCreated = true;
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#showDelete(java.lang.Object)
*/
public boolean showDelete(Object element) {
// 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.
if (element instanceof IHost) {
IRSESystemType sysType = getSystemTypeForHost((IHost)element);
Object adapter = sysType != null ? sysType.getAdapter(RSESystemTypeAdapter.class) : null;
RSESystemTypeAdapter sysTypeAdapter = adapter instanceof RSESystemTypeAdapter ? (RSESystemTypeAdapter)adapter : null;
if (sysTypeAdapter != null) {
return sysTypeAdapter.acceptContextMenuActionContribution((IHost)element, SystemCommonDeleteAction.class);
}
}
return super.showDelete(element);
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#showGenericShowInTableAction(java.lang.Object)
*/
public boolean showGenericShowInTableAction(Object element) {
// 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.
if (element instanceof IHost) {
IRSESystemType sysType = getSystemTypeForHost((IHost)element);
Object adapter = sysType != null ? sysType.getAdapter(RSESystemTypeAdapter.class) : null;
RSESystemTypeAdapter sysTypeAdapter = adapter instanceof RSESystemTypeAdapter ? (RSESystemTypeAdapter)adapter : null;
if (sysTypeAdapter != null) {
boolean accepted = false;
Class[] affectedClasses = new Class[] { SystemShowInTableAction.class, SystemShowInMonitorAction.class };
for (int i = 0; i < affectedClasses.length && accepted == false; i++) {
accepted |= sysTypeAdapter.acceptContextMenuActionContribution((IHost)element, affectedClasses[i]);
}
return accepted;
}
}
return super.showGenericShowInTableAction(element);
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#showOpenViewActions(java.lang.Object)
*/
public boolean showOpenViewActions(Object element) {
// 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.
if (element instanceof IHost) {
IRSESystemType sysType = getSystemTypeForHost((IHost)element);
Object adapter = sysType != null ? sysType.getAdapter(RSESystemTypeAdapter.class) : null;
RSESystemTypeAdapter sysTypeAdapter = adapter instanceof RSESystemTypeAdapter ? (RSESystemTypeAdapter)adapter : null;
if (sysTypeAdapter != null) {
return sysTypeAdapter.acceptContextMenuActionContribution((IHost)element, SystemOpenExplorerPerspectiveAction.class);
}
}
return super.showOpenViewActions(element);
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#showProperties(java.lang.Object)
*/
public boolean showProperties(Object element) {
// 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.
if (element instanceof IHost) {
IRSESystemType sysType = getSystemTypeForHost((IHost)element);
Object adapter = sysType != null ? sysType.getAdapter(RSESystemTypeAdapter.class) : null;
RSESystemTypeAdapter sysTypeAdapter = adapter instanceof RSESystemTypeAdapter ? (RSESystemTypeAdapter)adapter : null;
if (sysTypeAdapter != null) {
return sysTypeAdapter.acceptContextMenuActionContribution((IHost)element, PropertyDialogAction.class);
}
}
return super.showProperties(element);
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#showRefresh(java.lang.Object)
*/
public boolean showRefresh(Object element) {
// 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.
if (element instanceof IHost) {
IRSESystemType sysType = getSystemTypeForHost((IHost)element);
Object adapter = sysType != null ? sysType.getAdapter(RSESystemTypeAdapter.class) : null;
RSESystemTypeAdapter sysTypeAdapter = adapter instanceof RSESystemTypeAdapter ? (RSESystemTypeAdapter)adapter : null;
if (sysTypeAdapter != null) {
return sysTypeAdapter.acceptContextMenuActionContribution((IHost)element, SystemRefreshAction.class);
}
}
return super.showRefresh(element);
}
/* (non-Javadoc)
* @see org.eclipse.rse.ui.view.AbstractSystemViewAdapter#showRename(java.lang.Object)
*/
public boolean showRename(Object element) {
// 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.
if (element instanceof IHost) {
IRSESystemType sysType = getSystemTypeForHost((IHost)element);
Object adapter = sysType != null ? sysType.getAdapter(RSESystemTypeAdapter.class) : null;
RSESystemTypeAdapter sysTypeAdapter = adapter instanceof RSESystemTypeAdapter ? (RSESystemTypeAdapter)adapter : null;
if (sysTypeAdapter != null) {
return sysTypeAdapter.acceptContextMenuActionContribution((IHost)element, SystemCommonRenameAction.class);
}
}
return super.showRename(element);
}
/**
* Returns an image descriptor for the image. More efficient than getting the image.
* @param element The element for which an image is desired

View file

@ -18,6 +18,7 @@
* Martin Oberhuber (Wind River) - [168975] Move RSE Events API to Core
* Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
* Martin Oberhuber (Wind River) - [181939] avoid subsystem plugin activation just for enablement checking
* Uwe Stieber (Wind River) - [199032] [api] Remove method acceptContextMenuActionContribution(...) from RSESystemTypeAdapter
********************************************************************************/
package org.eclipse.rse.ui;
@ -25,7 +26,6 @@ import java.net.MalformedURLException;
import java.net.URL;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.action.IMenuManager;
@ -34,16 +34,8 @@ import org.eclipse.rse.core.IRSESystemType;
import org.eclipse.rse.core.IRSESystemTypeConstants;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.core.RSEPreferencesManager;
import org.eclipse.rse.core.model.Host;
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.core.subsystems.ISubSystemConfigurationProxy;
import org.eclipse.rse.internal.core.RSESystemType;
import org.eclipse.rse.internal.ui.RSEAdapter;
import org.eclipse.rse.internal.ui.actions.SystemClearAllPasswordsAction;
import org.eclipse.rse.internal.ui.actions.SystemWorkOfflineAction;
import org.eclipse.rse.internal.ui.view.SystemViewConnectionAdapter;
import org.eclipse.rse.ui.wizards.registries.IRSEWizardDescriptor;
import org.eclipse.ui.IViewPart;
import org.osgi.framework.Bundle;
@ -288,47 +280,6 @@ public class RSESystemTypeAdapter extends RSEAdapter {
// 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
* specified host.
* <p>
* <b>Note:</b> 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.
*
* @param host The host object. Must be not <code>null</code>.
* @param actionClass The contributed action. Must be not <code>null</code>.
*
* @return <code>True</code> if the contributed action is accepted for the specified context, <code>false</code> otherwise.
*
* @deprecated Override {@link SystemViewConnectionAdapter#addActions(SystemMenuManager, org.eclipse.jface.viewers.IStructuredSelection, org.eclipse.swt.widgets.Shell, String)} instead.
* In order to do so, {@link RSESystemType#createNewHostInstance(org.eclipse.rse.core.model.ISystemProfile)} needs to return
* a subclass of {@link Host} where the {@link IAdaptable#getAdapter(Class)} method is overriden to return a extended
* {@link SystemViewConnectionAdapter} subclass.
*/
public boolean acceptContextMenuActionContribution(IHost host, Class actionClass) {
assert host != null && actionClass != null;
// The SystemWorkOfflineAction is accepted if isEnabledOffline is returning true
if (actionClass.equals(SystemWorkOfflineAction.class)) {
return isEnableOffline(host.getSystemType());
}
// SystemClearAllPasswordsAction is accepted only if passwords are supported
// by any of the sub systems.
if (actionClass.equals(SystemClearAllPasswordsAction.class)) {
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
IConnectorService[] connectorServices = registry.getConnectorServices(host);
boolean passwordsSupported = false;
for (int i = 0; i < connectorServices.length && passwordsSupported == false; i++) {
passwordsSupported |= connectorServices[i].supportsPassword();
}
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.