mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 17:35:35 +02:00
Bug 461342: Allow to remove items from Call Hierarchy view
Change-Id: I72dfa22b80a35839f21eb3e46e54774bae84aabe Signed-off-by: Andrew Gvozdev <angvoz.dev@gmail.com>
This commit is contained in:
parent
1e8964285e
commit
99e0af4db3
6 changed files with 100 additions and 20 deletions
|
@ -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;
|
||||
|
|
|
@ -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}
|
||||
CHProviderManager_InvalidCallHierarchyProvider=Ignoring unrecognized implementation of ICallHierarchyProvider contributed by {0}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue