Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gvozdev2015-03-03 22:21:42 +0000
committerGerrit Code Review @ Eclipse.org2015-03-09 13:48:58 +0000
commit99e0af4db3d5ddc59eae7c14963020c829dc7093 (patch)
tree4663e025db70a3fceb28b28d83b9b57ac22c8d34
parent1e8964285e768952dbbad805084962ab99f97f27 (diff)
downloadorg.eclipse.cdt-99e0af4db3d5ddc59eae7c14963020c829dc7093.tar.gz
org.eclipse.cdt-99e0af4db3d5ddc59eae7c14963020c829dc7093.tar.xz
org.eclipse.cdt-99e0af4db3d5ddc59eae7c14963020c829dc7093.zip
Bug 461342: Allow to remove items from Call Hierarchy view
Change-Id: I72dfa22b80a35839f21eb3e46e54774bae84aabe Signed-off-by: Andrew Gvozdev <angvoz.dev@gmail.com>
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.properties5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefNode.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHNode.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHRemoveFromView.java45
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java59
6 files changed, 100 insertions, 20 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.java
index b3ddf2c313e..71f02f6ac13 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2014 Wind River Systems, Inc. and others.
+ * Copyright (c) 2006, 2015 Wind River Systems, Inc. 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
@@ -34,6 +34,7 @@ public class CHMessages extends NLS {
public static String CHViewPart_PreviousReference_tooltip;
public static String CHViewPart_Refresh_label;
public static String CHViewPart_Refresh_tooltip;
+ public static String CHViewPart_RemoveFromView_label;
public static String CHViewPart_CopyCallHierarchy_label;
public static String CHViewPart_ShowCallees_label;
public static String CHViewPart_ShowCallees_tooltip;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.properties
index b5d0593693c..73e1ffe23b6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2006, 2014 Wind River Systems, Inc. and others.
+# Copyright (c) 2006, 2015 Wind River Systems, Inc. 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
@@ -34,6 +34,7 @@ CHViewPart_FocusOn_label=Focus On ''{0}''
CHViewPart_Open_label=Open
CHViewPart_Open_tooltip=Open
CHViewPart_CopyCallHierarchy_label=Copy E&xpanded Hierarchy
+CHViewPart_RemoveFromView_label=Remove From View
CHLabelProvider_matches=matches
CHHistoryDropDownAction_ClearHistory_label=Clear History
CHHistoryListAction_HistoryDialog_title=Call Hierarchy History
@@ -52,4 +53,4 @@ OpenElementInCallHierarchyAction_message=&Choose an element (? = any character,
OpenElementInCallHierarchyAction_errorNoDefinition=Could not locate definition of element ''{0}''
CHPinAction_label=Pi&n Call Hierarchy View
CHPinAction_tooltip=Pin the Call Hierarchy View
-CHProviderManager_InvalidCallHierarchyProvider=Ignoring unrecognized implementation of ICallHierarchyProvider contributed by {0} \ No newline at end of file
+CHProviderManager_InvalidCallHierarchyProvider=Ignoring unrecognized implementation of ICallHierarchyProvider contributed by {0}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefNode.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefNode.java
index 5c6f414962a..147a79d81b2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefNode.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHMultiDefNode.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
+ * Copyright (c) 2006, 2015 Wind River Systems, Inc. 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
@@ -15,8 +15,6 @@ import java.util.Objects;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.ui.util.CoreUtility;
-
public class CHMultiDefNode extends CHNode {
private CHNode[] fChildren;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHNode.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHNode.java
index c60dba50cc6..9fc46f009f1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHNode.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHNode.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
+ * Copyright (c) 2006, 2015 Wind River Systems, Inc. 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
@@ -23,8 +23,6 @@ import org.eclipse.cdt.core.model.IMacro;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IVariableDeclaration;
-import org.eclipse.cdt.internal.ui.util.CoreUtility;
-
/**
* Represents a node in the include browser
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHRemoveFromView.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHRemoveFromView.java
new file mode 100644
index 00000000000..f215671a8e2
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHRemoveFromView.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2015 Andrew Gvozdev 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:
+ * Andrew Gvozdev - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.callhierarchy;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Action to remove items from the C++ Call Hierarchy View.
+ */
+public class CHRemoveFromView extends Action {
+ private CHViewPart fView;
+
+ /**
+ * Constructs a Remove From View action.
+ *
+ * @param view the Call Hierarchy view
+ */
+ public CHRemoveFromView(CHViewPart view) {
+ super(CHMessages.CHViewPart_RemoveFromView_label);
+ fView= view;
+ ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
+ setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_ELCL_REMOVE));
+ setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
+ }
+
+ @Override
+ public void run() {
+ TreeViewer tree = fView.getTreeViewer();
+ ITreeSelection selection = (ITreeSelection) tree.getSelection();
+ tree.setSelection(null); // should stay before removal
+ tree.remove(selection.toArray());
+ }
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java
index 34a937d3aaf..88993160b5e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHViewPart.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 Wind River Systems, Inc. and others.
+ * Copyright (c) 2006, 2015 Wind River Systems, Inc. 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
@@ -20,6 +20,8 @@ import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.bindings.BindingManagerEvent;
+import org.eclipse.jface.bindings.IBindingManagerListener;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.IOpenListener;
@@ -48,6 +50,7 @@ import org.eclipse.ui.IMemento;
import org.eclipse.ui.IPartListener2;
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchCommandConstants;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPartReference;
import org.eclipse.ui.IWorkbenchPartSite;
@@ -55,8 +58,10 @@ import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.TextActionHandler;
import org.eclipse.ui.contexts.IContextActivation;
import org.eclipse.ui.contexts.IContextService;
+import org.eclipse.ui.keys.IBindingService;
import org.eclipse.ui.navigator.ICommonMenuConstants;
import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.part.ViewPart;
@@ -129,8 +134,9 @@ public class CHViewPart extends ViewPart {
private Action fShowReference;
private Action fOpenElement;
private Action fPinViewAction;
+ private Action fRemoveFromViewAction;
private CopyTreeAction fCopyAction;
-
+
// action groups
private OpenViewActionGroup fOpenViewActionGroup;
private SelectionSearchGroup fSelectionSearchGroup;
@@ -138,7 +144,10 @@ public class CHViewPart extends ViewPart {
private IContextActivation fContextActivation;
private boolean fIsPinned = false;
private IPartListener2 fPartListener;
-
+
+ private IBindingService bindingService;
+ private IBindingManagerListener bindingManagerListener;
+
@Override
public void setFocus() {
fPagebook.setFocus();
@@ -208,6 +217,22 @@ public class CHViewPart extends ViewPart {
createActions();
createContextMenu();
+ bindingService = (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class);
+ if (bindingService != null) {
+ bindingManagerListener = new IBindingManagerListener() {
+ @Override
+ public void bindingManagerChanged(BindingManagerEvent event) {
+ if (event.isActiveBindingsChanged()) {
+ String keyBinding = bindingService.getBestActiveBindingFormattedFor(IWorkbenchCommandConstants.EDIT_DELETE);
+ if (keyBinding != null) {
+ fRemoveFromViewAction.setText(CHMessages.CHViewPart_RemoveFromView_label + '\t'+ keyBinding);
+ }
+ }
+ }
+ };
+ bindingService.addBindingManagerListener(bindingManagerListener);
+ }
+
setMessage(CHMessages.CHViewPart_emptyPageMessage);
initializeActionStates();
@@ -257,9 +282,14 @@ public class CHViewPart extends ViewPart {
public void dispose() {
if (fContextActivation != null) {
IContextService ctxService = (IContextService)getSite().getService(IContextService.class);
- if (ctxService != null) {
- ctxService.deactivateContext(fContextActivation);
- }
+ if (ctxService != null) {
+ ctxService.deactivateContext(fContextActivation);
+ }
+ }
+
+ if (bindingService != null) {
+ bindingService.removeBindingManagerListener(bindingManagerListener);
+ bindingService = null;
}
if (fOpenViewActionGroup != null) {
@@ -537,6 +567,7 @@ public class CHViewPart extends ViewPart {
fCopyAction= new CopyCallHierarchyAction(this, fTreeViewer);
fPinViewAction= new CHPinAction(this);
+ fRemoveFromViewAction= new CHRemoveFromView(this);
// setup action bar
// global action hooks
@@ -550,7 +581,10 @@ public class CHViewPart extends ViewPart {
actionBars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), fPreviousAction);
actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), fRefreshAction);
actionBars.updateActionBars();
-
+
+ TextActionHandler textActionHandler = new TextActionHandler(actionBars);
+ textActionHandler.setDeleteAction(fRemoveFromViewAction);
+
// local toolbar
IToolBarManager tm = actionBars.getToolBarManager();
tm.add(fNextAction);
@@ -718,7 +752,7 @@ public class CHViewPart extends ViewPart {
}
}
- protected void onContextMenuAboutToShow(IMenuManager menu) {
+ protected void onContextMenuAboutToShow(IMenuManager menu) {
CUIPlugin.createStandardGroups(menu);
CHNode node= selectionToNode(fTreeViewer.getSelection());
@@ -751,15 +785,18 @@ public class CHViewPart extends ViewPart {
}
if (fCopyAction.canActionBeAdded()) {
- menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, fCopyAction);
+ menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, fCopyAction);
+ }
+ if (node != null) {
+ menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, fRemoveFromViewAction);
}
if (SelectionSearchGroup.canActionBeAdded(selection)){
fSelectionSearchGroup.fillContextMenu(menu);
}
fRefactoringActionGroup.fillContextMenu(menu);
- }
-
+ }
+
private void showReference() {
if (fNavigationNode != null) {
ITranslationUnit file= fNavigationNode.getFileOfReferences();

Back to the top