diff options
author | Winnie Lai | 2012-03-09 22:38:29 +0000 |
---|---|---|
committer | Pawel Piech | 2012-03-09 22:38:29 +0000 |
commit | c98ef3633d90d05ac5a82c928a9e20cd46435f3f (patch) | |
tree | c152c8eeb70108b5300abae168b90f93adb7c498 | |
parent | e1cfa4e493a500be8451fd45d5dd8b0d16610320 (diff) | |
download | eclipse.platform.debug-c98ef3633d90d05ac5a82c928a9e20cd46435f3f.tar.gz eclipse.platform.debug-c98ef3633d90d05ac5a82c928a9e20cd46435f3f.tar.xz eclipse.platform.debug-c98ef3633d90d05ac5a82c928a9e20cd46435f3f.zip |
Bug 344023 - [var] Need a way to override Find action of Variables view
and its derived classes.
Original contributed patch.
2 files changed, 54 insertions, 0 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IViewActionOverride.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IViewActionOverride.java new file mode 100644 index 000000000..931d12369 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IViewActionOverride.java @@ -0,0 +1,35 @@ +/***************************************************************** + * Copyright (c) 2011 Texas Instruments and others + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Texas Instruments - View action override (Bug 344023) + *****************************************************************/ +package org.eclipse.debug.internal.ui.viewers.model.provisional; + +import org.eclipse.jface.action.IAction; + + +/** + * An interface that allows an implementation to provide (contribute) its own + * action which is used to override an action for the same action id. + * + * @since 3.7 + */ +public interface IViewActionOverride { + /** + * Get action for a given presentation context and action id. Implementation + * class can use presentation context to figure out the view part or view + * model (IVMProvider) which wants to provide (contribute) an action. Once + * the view part or view model is known, the dedicated action for the view + * can be figured out by the implementation, view model, or some other + * classes. + * @param presentationContext presentation context + * @param actionID action id + * @return action or null + */ + public IAction getAction(IPresentationContext presentationContext, String actionID); +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java index 4f4b4a40c..615faa630 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; +import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.ListenerList; @@ -43,12 +44,15 @@ import org.eclipse.debug.internal.ui.actions.variables.ChangeVariableValueAction import org.eclipse.debug.internal.ui.actions.variables.ShowTypesAction; import org.eclipse.debug.internal.ui.actions.variables.ToggleDetailPaneAction; import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants; +import org.eclipse.debug.internal.ui.viewers.model.ViewerAdapterService; import org.eclipse.debug.internal.ui.viewers.model.VirtualFindAction; import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelChangedListener; import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta; import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDeltaVisitor; import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxy; import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewActionOverride; +import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputProvider; import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputRequestor; import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate; import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate; @@ -931,6 +935,21 @@ public class VariablesView extends AbstractDebugView implements IDebugContextLis action= new VirtualFindAction(getVariablesViewer()); setAction(VARIABLES_FIND_ELEMENT_ACTION, action); } + + + public IAction getAction(String actionID) { + IViewerInputProvider inputProvider = ViewerAdapterService.getInputProvider(getViewer().getInput()); + if (inputProvider instanceof IAdaptable) { + Object x = ((IAdaptable) inputProvider).getAdapter(IViewActionOverride.class); + if (x instanceof IViewActionOverride) { + IAction action = ((IViewActionOverride) x).getAction(getPresentationContext(), actionID); + if (action != null) { + return action; + } + } + } + return super.getAction(actionID); + } /* (non-Javadoc) * |