mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-13 03:55:22 +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
|
* Tobias Schwarz (Wind River) - Fix 166343 getChildCount() counts invalid items
|
||||||
* Martin Oberhuber (Wind River) - Improve fix for 166343 getChildCount()
|
* Martin Oberhuber (Wind River) - Improve fix for 166343 getChildCount()
|
||||||
* Uwe Stieber (Wind River) - [172492] Use SafeTreeViewer
|
* 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
|
* 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.TreePath;
|
||||||
import org.eclipse.jface.viewers.ViewerFilter;
|
import org.eclipse.jface.viewers.ViewerFilter;
|
||||||
import org.eclipse.jface.window.SameShellProvider;
|
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.SystemAdapterHelpers;
|
||||||
import org.eclipse.rse.core.SystemBasePlugin;
|
import org.eclipse.rse.core.SystemBasePlugin;
|
||||||
import org.eclipse.rse.core.filters.ISystemFilter;
|
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.ISystemDeleteTarget;
|
||||||
import org.eclipse.rse.ui.ISystemMessages;
|
import org.eclipse.rse.ui.ISystemMessages;
|
||||||
import org.eclipse.rse.ui.ISystemRenameTarget;
|
import org.eclipse.rse.ui.ISystemRenameTarget;
|
||||||
|
import org.eclipse.rse.ui.RSESystemTypeAdapter;
|
||||||
import org.eclipse.rse.ui.RSEUIPlugin;
|
import org.eclipse.rse.ui.RSEUIPlugin;
|
||||||
import org.eclipse.rse.ui.SystemMenuManager;
|
import org.eclipse.rse.ui.SystemMenuManager;
|
||||||
import org.eclipse.rse.ui.SystemPreferencesManager;
|
import org.eclipse.rse.ui.SystemPreferencesManager;
|
||||||
|
@ -896,16 +901,16 @@ ISelectionChangedListener, ITreeViewerListener, ISystemResourceChangeEvents, ISy
|
||||||
|
|
||||||
// GO INTO ACTION...
|
// GO INTO ACTION...
|
||||||
// OPEN IN NEW WINDOW ACTION...
|
// OPEN IN NEW WINDOW ACTION...
|
||||||
if (fromSystemViewPart && showOpenViewActions()) {
|
if (fromSystemViewPart) {
|
||||||
|
|
||||||
|
|
||||||
GoIntoAction goIntoAction = getGoIntoAction();
|
GoIntoAction goIntoAction = getGoIntoAction();
|
||||||
goIntoAction.setEnabled(selection.size() == 1);
|
goIntoAction.setEnabled(selection.size() == 1);
|
||||||
menu.appendToGroup(ISystemContextMenuConstants.GROUP_GOTO, goIntoAction);
|
menu.appendToGroup(ISystemContextMenuConstants.GROUP_GOTO, goIntoAction);
|
||||||
|
|
||||||
|
if (showOpenViewActions()) {
|
||||||
SystemOpenExplorerPerspectiveAction openToPerspectiveAction = getOpenToPerspectiveAction();
|
SystemOpenExplorerPerspectiveAction openToPerspectiveAction = getOpenToPerspectiveAction();
|
||||||
openToPerspectiveAction.setSelection(selection);
|
openToPerspectiveAction.setSelection(selection);
|
||||||
menu.appendToGroup(openToPerspectiveAction.getContextMenuGroup(), openToPerspectiveAction);
|
menu.appendToGroup(openToPerspectiveAction.getContextMenuGroup(), openToPerspectiveAction);
|
||||||
|
}
|
||||||
|
|
||||||
if (showGenericShowInTableAction()) {
|
if (showGenericShowInTableAction()) {
|
||||||
|
|
||||||
|
@ -993,6 +998,16 @@ ISelectionChangedListener, ITreeViewerListener, ISystemResourceChangeEvents, ISy
|
||||||
menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_REPLACEWITH));
|
menu.add(new GroupMarker(ISystemContextMenuConstants.GROUP_REPLACEWITH));
|
||||||
menu.add(new Separator(ISystemContextMenuConstants.GROUP_PROPERTIES)); // Properties
|
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;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -259,12 +259,7 @@ public class SystemViewConnectionAdapter
|
||||||
Object adapter = sysType != null ? sysType.getAdapter(IRSESystemType.class) : null;
|
Object adapter = sysType != null ? sysType.getAdapter(IRSESystemType.class) : null;
|
||||||
RSESystemTypeAdapter sysTypeAdapter = adapter instanceof RSESystemTypeAdapter ? (RSESystemTypeAdapter)adapter : null;
|
RSESystemTypeAdapter sysTypeAdapter = adapter instanceof RSESystemTypeAdapter ? (RSESystemTypeAdapter)adapter : null;
|
||||||
if (sysTypeAdapter != null) {
|
if (sysTypeAdapter != null) {
|
||||||
boolean accepted = false;
|
return sysTypeAdapter.acceptContextMenuActionContribution((IHost)element, SystemOpenExplorerPerspectiveAction.class);
|
||||||
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 super.showOpenViewActions(element);
|
return super.showOpenViewActions(element);
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.net.URL;
|
||||||
import org.eclipse.core.runtime.FileLocator;
|
import org.eclipse.core.runtime.FileLocator;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
import org.eclipse.jface.action.IMenuManager;
|
||||||
import org.eclipse.jface.resource.ImageDescriptor;
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
import org.eclipse.rse.core.IRSESystemType;
|
import org.eclipse.rse.core.IRSESystemType;
|
||||||
import org.eclipse.rse.core.IRSESystemTypeConstants;
|
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.IHost;
|
||||||
import org.eclipse.rse.core.model.ISystemRegistry;
|
import org.eclipse.rse.core.model.ISystemRegistry;
|
||||||
import org.eclipse.rse.core.subsystems.IConnectorService;
|
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.SystemClearAllPasswordsAction;
|
||||||
import org.eclipse.rse.ui.actions.SystemWorkOfflineAction;
|
import org.eclipse.rse.ui.actions.SystemWorkOfflineAction;
|
||||||
import org.eclipse.rse.ui.wizards.registries.IRSEWizardDescriptor;
|
import org.eclipse.rse.ui.wizards.registries.IRSEWizardDescriptor;
|
||||||
|
@ -39,7 +41,7 @@ import org.osgi.framework.Bundle;
|
||||||
/**
|
/**
|
||||||
* Adapter for RSE system types.
|
* Adapter for RSE system types.
|
||||||
*/
|
*/
|
||||||
public class RSESystemTypeAdapter extends RSEAdapter implements IRSESystemTypeConstants {
|
public class RSESystemTypeAdapter extends RSEAdapter {
|
||||||
|
|
||||||
public RSESystemTypeAdapter() {
|
public RSESystemTypeAdapter() {
|
||||||
super();
|
super();
|
||||||
|
@ -51,7 +53,7 @@ public class RSESystemTypeAdapter extends RSEAdapter implements IRSESystemTypeCo
|
||||||
* @see org.eclipse.ui.model.WorkbenchAdapter#getImageDescriptor(java.lang.Object)
|
* @see org.eclipse.ui.model.WorkbenchAdapter#getImageDescriptor(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public ImageDescriptor getImageDescriptor(Object 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);
|
if (img==null) img = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_CONNECTION_ID);
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
@ -68,8 +70,8 @@ public class RSESystemTypeAdapter extends RSEAdapter implements IRSESystemTypeCo
|
||||||
* @return ImageDescriptor
|
* @return ImageDescriptor
|
||||||
*/
|
*/
|
||||||
public ImageDescriptor getLiveImageDescriptor(Object object) {
|
public ImageDescriptor getLiveImageDescriptor(Object object) {
|
||||||
ImageDescriptor img = getImage(object, ICON_LIVE);
|
ImageDescriptor img = getImage(object, IRSESystemTypeConstants.ICON_LIVE);
|
||||||
if (img==null) img = getImage(object, ICON);
|
if (img==null) img = getImage(object, IRSESystemTypeConstants.ICON);
|
||||||
if (img==null) img = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_CONNECTIONLIVE_ID);
|
if (img==null) img = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_CONNECTIONLIVE_ID);
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
@ -166,7 +168,7 @@ public class RSESystemTypeAdapter extends RSEAdapter implements IRSESystemTypeCo
|
||||||
|
|
||||||
public boolean isEnableOffline(Object object) {
|
public boolean isEnableOffline(Object object) {
|
||||||
if ((object != null) && (object instanceof IRSESystemType)) {
|
if ((object != null) && (object instanceof IRSESystemType)) {
|
||||||
String property = ((IRSESystemType)object).getProperty(ENABLE_OFFLINE);
|
String property = ((IRSESystemType)object).getProperty(IRSESystemTypeConstants.ENABLE_OFFLINE);
|
||||||
if (property != null) {
|
if (property != null) {
|
||||||
return Boolean.valueOf(property).booleanValue();
|
return Boolean.valueOf(property).booleanValue();
|
||||||
}
|
}
|
||||||
|
@ -246,6 +248,15 @@ public class RSESystemTypeAdapter extends RSEAdapter implements IRSESystemTypeCo
|
||||||
return result;
|
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
|
* 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
|
* <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
|
* actions might be denied, but all other action contributions, including unknown
|
||||||
* action contributions, should be accepted.
|
* 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 host The host object. Must be not <code>null</code>.
|
||||||
* @param actionClass The contributed action. 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