mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 23:25:26 +02:00
[177537] [api] Dynamic system type provider need a hook to add dynamic system type specific menu groups
This commit is contained in:
parent
6178ce1f28
commit
1071df698c
3 changed files with 38 additions and 23 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 <code>null</code>.
|
||||
*/
|
||||
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
|
|||
* <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.
|
||||
* <p>
|
||||
* This method is called from:<br>
|
||||
* <ul>
|
||||
* <li>SystemViewConnectionAdapter.addActions(...)</li>
|
||||
* <li>SystemViewConnectionAdapter.showDelete(...)</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param host The host object. Must be not <code>null</code>.
|
||||
* @param actionClass The contributed action. Must be not <code>null</code>.
|
||||
|
|
Loading…
Add table
Reference in a new issue