Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.properties2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.xml5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractCustomFormToolkitEditorPage.java91
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/ShowInSystemManagementHandler.java19
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.properties2
6 files changed, 23 insertions, 98 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.properties
index 34dc6b530..d203f7e48 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.properties
@@ -82,5 +82,5 @@ command.reset.description = Reset quick filter in a tree viewer
command.reset.name = Reset Quick Filter
command.showInSM.name=Show In System Management View Command
-command.showInSM.description=Shows the active editor context in the System Management view.
+command.showInSM.description=Show In System Management
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.xml
index 91afdc1ce..bcead5a3b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.xml
@@ -580,6 +580,10 @@
<extension point="org.eclipse.ui.commandImages">
<image
+ commandId="org.eclipse.tcf.te.ui.command.showIn.systemManagement"
+ icon="icons/eview16/targets_view.gif">
+ </image>
+ <image
commandId="org.eclipse.tcf.te.ui.views.command.find"
icon="icons/obj16/search.gif">
</image>
@@ -693,7 +697,6 @@
</activeWhen>
</handler>
-
<handler
class="org.eclipse.tcf.te.ui.views.handler.ConfigFiltersHandler"
commandId="org.eclipse.tcf.te.ui.views.command.filters">
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractCustomFormToolkitEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractCustomFormToolkitEditorPage.java
index 2bb37639a..7ffacde55 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractCustomFormToolkitEditorPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractCustomFormToolkitEditorPage.java
@@ -9,20 +9,12 @@
*******************************************************************************/
package org.eclipse.tcf.te.ui.views.editor.pages;
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.ParameterizedCommand;
-import org.eclipse.core.expressions.EvaluationContext;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ContributionManager;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.tcf.te.ui.forms.CustomFormToolkit;
@@ -30,12 +22,9 @@ import org.eclipse.tcf.te.ui.forms.FormLayoutFactory;
import org.eclipse.tcf.te.ui.views.activator.UIPlugin;
import org.eclipse.tcf.te.ui.views.interfaces.ImageConsts;
import org.eclipse.tcf.te.ui.views.nls.Messages;
-import org.eclipse.ui.ISources;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.menus.IMenuService;
/**
@@ -79,58 +68,6 @@ public abstract class AbstractCustomFormToolkitEditorPage extends AbstractEditor
}
}
- // The default "Show In System Management" view action
- static protected class ShowInSystemManagementAction extends Action {
- private final AbstractCustomFormToolkitEditorPage parentPage;
-
- /**
- * Constructor.
- */
- public ShowInSystemManagementAction(AbstractCustomFormToolkitEditorPage parentPage) {
- super(Messages.AbstractCustomFormToolkitEditorPage_ShowInSystemManagementCommandAction_label, IAction.AS_PUSH_BUTTON);
- setToolTipText(Messages.AbstractCustomFormToolkitEditorPage_ShowInSystemManagementCommandAction_tooltip);
- setImageDescriptor(UIPlugin.getImageDescriptor(ImageConsts.VIEW));
-
- Assert.isNotNull(parentPage);
- this.parentPage = parentPage;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.Action#run()
- */
- @Override
- public void run() {
- ICommandService service = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
- Command command = service != null ? service.getCommand("org.eclipse.tcf.te.ui.command.showIn.systemManagement") : null; //$NON-NLS-1$
- if (command != null && command.isDefined() && command.isEnabled()) {
- try {
- ISelection selection = new StructuredSelection(parentPage.getEditorInputNode());
- EvaluationContext ctx = new EvaluationContext(null, selection);
- ctx.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, selection);
- ctx.addVariable(ISources.ACTIVE_MENU_SELECTION_NAME, selection);
- ctx.addVariable(ISources.ACTIVE_WORKBENCH_WINDOW_NAME, parentPage.getSite().getWorkbenchWindow());
- ctx.addVariable(ISources.ACTIVE_PART_ID_NAME, parentPage.getSite().getId());
- ctx.addVariable(ISources.ACTIVE_PART_NAME, parentPage.getSite().getPart());
- ctx.addVariable(ISources.ACTIVE_SITE_NAME, parentPage.getSite());
- ctx.addVariable(ISources.ACTIVE_SHELL_NAME, parentPage.getSite().getShell());
- ctx.setAllowPluginActivation(true);
-
- ParameterizedCommand pCmd = ParameterizedCommand.generateCommand(command, null);
- Assert.isNotNull(pCmd);
- IHandlerService handlerSvc = (IHandlerService)PlatformUI.getWorkbench().getService(IHandlerService.class);
- Assert.isNotNull(handlerSvc);
- handlerSvc.executeCommandInContext(pCmd, null, ctx);
- } catch (Exception e) {
- // If the platform is in debug mode, we print the exception to the log view
- if (Platform.inDebugMode()) {
- IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), e.getLocalizedMessage(), e);
- UIPlugin.getDefault().getLog().log(status);
- }
- }
- }
- }
- }
-
/**
* Returns the custom form toolkit instance.
*
@@ -262,16 +199,10 @@ public abstract class AbstractCustomFormToolkitEditorPage extends AbstractEditor
protected void createToolbarContributionItems(IToolBarManager manager) {
Assert.isNotNull(manager);
- // If the page does have "Show In System Management", add the action into the toolbar
- if (hasShowInSystemMangementAction()) {
- Action showInAction = doCreateShowInSystemManagementAction();
- if (showInAction != null) manager.add(showInAction);
- }
-
// If the page is associated with a context help id, add a default
// help action button into the toolbar
if (getContextHelpId() != null) {
- if (hasShowInSystemMangementAction()) manager.add(new Separator());
+ manager.add(new Separator());
Action helpAction = doCreateHelpAction(getContextHelpId());
if(helpAction != null) manager.add(helpAction);
}
@@ -289,26 +220,6 @@ public abstract class AbstractCustomFormToolkitEditorPage extends AbstractEditor
}
/**
- * Returns if or if not the page has the "Show In System Management" action.
- * <p>
- * The default implementation returns <code>false</code>.
- *
- * @return <code>True</code> if the action is visible in the form toolbar, <code>false</code> otherwise.
- */
- protected boolean hasShowInSystemMangementAction() {
- return false;
- }
-
- /**
- * Creates the "Show In System Management" action.
- *
- * @return The action or <code>null</code>.
- */
- protected Action doCreateShowInSystemManagementAction() {
- return new ShowInSystemManagementAction(this);
- }
-
- /**
* Do create the managed form content.
*
* @param parent The parent composite. Must not be <code>null</code>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/ShowInSystemManagementHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/ShowInSystemManagementHandler.java
index d6028cb5f..caf9ea5e1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/ShowInSystemManagementHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/ShowInSystemManagementHandler.java
@@ -14,9 +14,13 @@ import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.tcf.te.ui.views.ViewsUtil;
import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.part.EditorPart;
/**
* "Show In System Management" command handler implementation.
@@ -31,10 +35,21 @@ public class ShowInSystemManagementHandler extends AbstractHandler {
// Show the view
ViewsUtil.show(IUIConstants.ID_EXPLORER);
- // Get the active selection
+ // Get the active part
+ IWorkbenchPart part = HandlerUtil.getActivePart(event);
+ // Get the current selection
ISelection selection = HandlerUtil.getCurrentSelection(event);
+
+ // If the handler is invoked from an editor part, than we do not have a selection.
+ // Determine the active editor input and construct a fake selection object from it.
+ if ((selection == null || selection.isEmpty()) && part instanceof EditorPart) {
+ IEditorInput input = ((EditorPart)part).getEditorInput();
+ Object element = input != null ? input.getAdapter(Object.class) : null;
+ if (element != null) selection = new StructuredSelection(element);
+ }
+
+ // Pass on to the view
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
- // Pass on to the view
ViewsUtil.setSelection(IUIConstants.ID_EXPLORER, selection);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.java
index 58750b3d7..f2ca1d7a4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.java
@@ -46,8 +46,6 @@ public class Messages extends NLS {
public static String AbstractCustomFormToolkitEditorPage_HelpAction_label;
public static String AbstractCustomFormToolkitEditorPage_HelpAction_tooltip;
- public static String AbstractCustomFormToolkitEditorPage_ShowInSystemManagementCommandAction_label;
- public static String AbstractCustomFormToolkitEditorPage_ShowInSystemManagementCommandAction_tooltip;
public static String ButtonsPanelControl_applyButton_label;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.properties
index e54672baf..1126160b9 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.properties
@@ -29,8 +29,6 @@ RestoreJob_Task2Name=Restoring the expanded paths
AbstractCustomFormToolkitEditorPage_HelpAction_label=Help
AbstractCustomFormToolkitEditorPage_HelpAction_tooltip=Help
-AbstractCustomFormToolkitEditorPage_ShowInSystemManagementCommandAction_label=Show In System Management
-AbstractCustomFormToolkitEditorPage_ShowInSystemManagementCommandAction_tooltip=Show In System Management
ButtonsPanelControl_applyButton_label=Apply

Back to the top