1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-09 11:33:20 +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:
Andrew Gvozdev 2015-03-03 17:21:42 -05:00 committed by Gerrit Code Review @ Eclipse.org
parent 1e8964285e
commit 99e0af4db3
6 changed files with 100 additions and 20 deletions

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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_PreviousReference_tooltip;
public static String CHViewPart_Refresh_label; public static String CHViewPart_Refresh_label;
public static String CHViewPart_Refresh_tooltip; public static String CHViewPart_Refresh_tooltip;
public static String CHViewPart_RemoveFromView_label;
public static String CHViewPart_CopyCallHierarchy_label; public static String CHViewPart_CopyCallHierarchy_label;
public static String CHViewPart_ShowCallees_label; public static String CHViewPart_ShowCallees_label;
public static String CHViewPart_ShowCallees_tooltip; public static String CHViewPart_ShowCallees_tooltip;

View file

@ -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 # All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0 # are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at # which accompanies this distribution, and is available at
@ -34,6 +34,7 @@ CHViewPart_FocusOn_label=Focus On ''{0}''
CHViewPart_Open_label=Open CHViewPart_Open_label=Open
CHViewPart_Open_tooltip=Open CHViewPart_Open_tooltip=Open
CHViewPart_CopyCallHierarchy_label=Copy E&xpanded Hierarchy CHViewPart_CopyCallHierarchy_label=Copy E&xpanded Hierarchy
CHViewPart_RemoveFromView_label=Remove From View
CHLabelProvider_matches=matches CHLabelProvider_matches=matches
CHHistoryDropDownAction_ClearHistory_label=Clear History CHHistoryDropDownAction_ClearHistory_label=Clear History
CHHistoryListAction_HistoryDialog_title=Call Hierarchy History CHHistoryListAction_HistoryDialog_title=Call Hierarchy History

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.ICElement;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.ui.util.CoreUtility;
public class CHMultiDefNode extends CHNode { public class CHMultiDefNode extends CHNode {
private CHNode[] fChildren; private CHNode[] fChildren;

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.ITranslationUnit;
import org.eclipse.cdt.core.model.IVariableDeclaration; import org.eclipse.cdt.core.model.IVariableDeclaration;
import org.eclipse.cdt.internal.ui.util.CoreUtility;
/** /**
* Represents a node in the include browser * Represents a node in the include browser
*/ */

View file

@ -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());
}
}

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * 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.IToolBarManager;
import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator; 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.text.Region;
import org.eclipse.jface.util.LocalSelectionTransfer; import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.IOpenListener; import org.eclipse.jface.viewers.IOpenListener;
@ -48,6 +50,7 @@ import org.eclipse.ui.IMemento;
import org.eclipse.ui.IPartListener2; import org.eclipse.ui.IPartListener2;
import org.eclipse.ui.IViewReference; import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IViewSite; import org.eclipse.ui.IViewSite;
import org.eclipse.ui.IWorkbenchCommandConstants;
import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPartReference; import org.eclipse.ui.IWorkbenchPartReference;
import org.eclipse.ui.IWorkbenchPartSite; import org.eclipse.ui.IWorkbenchPartSite;
@ -55,8 +58,10 @@ import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.PartInitException; import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory; import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.TextActionHandler;
import org.eclipse.ui.contexts.IContextActivation; import org.eclipse.ui.contexts.IContextActivation;
import org.eclipse.ui.contexts.IContextService; import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.keys.IBindingService;
import org.eclipse.ui.navigator.ICommonMenuConstants; import org.eclipse.ui.navigator.ICommonMenuConstants;
import org.eclipse.ui.part.PageBook; import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.part.ViewPart; import org.eclipse.ui.part.ViewPart;
@ -129,6 +134,7 @@ public class CHViewPart extends ViewPart {
private Action fShowReference; private Action fShowReference;
private Action fOpenElement; private Action fOpenElement;
private Action fPinViewAction; private Action fPinViewAction;
private Action fRemoveFromViewAction;
private CopyTreeAction fCopyAction; private CopyTreeAction fCopyAction;
// action groups // action groups
@ -139,6 +145,9 @@ public class CHViewPart extends ViewPart {
private boolean fIsPinned = false; private boolean fIsPinned = false;
private IPartListener2 fPartListener; private IPartListener2 fPartListener;
private IBindingService bindingService;
private IBindingManagerListener bindingManagerListener;
@Override @Override
public void setFocus() { public void setFocus() {
fPagebook.setFocus(); fPagebook.setFocus();
@ -208,6 +217,22 @@ public class CHViewPart extends ViewPart {
createActions(); createActions();
createContextMenu(); 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); setMessage(CHMessages.CHViewPart_emptyPageMessage);
initializeActionStates(); initializeActionStates();
@ -257,9 +282,14 @@ public class CHViewPart extends ViewPart {
public void dispose() { public void dispose() {
if (fContextActivation != null) { if (fContextActivation != null) {
IContextService ctxService = (IContextService)getSite().getService(IContextService.class); IContextService ctxService = (IContextService)getSite().getService(IContextService.class);
if (ctxService != null) { if (ctxService != null) {
ctxService.deactivateContext(fContextActivation); ctxService.deactivateContext(fContextActivation);
} }
}
if (bindingService != null) {
bindingService.removeBindingManagerListener(bindingManagerListener);
bindingService = null;
} }
if (fOpenViewActionGroup != null) { if (fOpenViewActionGroup != null) {
@ -537,6 +567,7 @@ public class CHViewPart extends ViewPart {
fCopyAction= new CopyCallHierarchyAction(this, fTreeViewer); fCopyAction= new CopyCallHierarchyAction(this, fTreeViewer);
fPinViewAction= new CHPinAction(this); fPinViewAction= new CHPinAction(this);
fRemoveFromViewAction= new CHRemoveFromView(this);
// setup action bar // setup action bar
// global action hooks // global action hooks
@ -551,6 +582,9 @@ public class CHViewPart extends ViewPart {
actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), fRefreshAction); actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), fRefreshAction);
actionBars.updateActionBars(); actionBars.updateActionBars();
TextActionHandler textActionHandler = new TextActionHandler(actionBars);
textActionHandler.setDeleteAction(fRemoveFromViewAction);
// local toolbar // local toolbar
IToolBarManager tm = actionBars.getToolBarManager(); IToolBarManager tm = actionBars.getToolBarManager();
tm.add(fNextAction); 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); CUIPlugin.createStandardGroups(menu);
CHNode node= selectionToNode(fTreeViewer.getSelection()); CHNode node= selectionToNode(fTreeViewer.getSelection());
@ -751,14 +785,17 @@ public class CHViewPart extends ViewPart {
} }
if (fCopyAction.canActionBeAdded()) { 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)){ if (SelectionSearchGroup.canActionBeAdded(selection)){
fSelectionSearchGroup.fillContextMenu(menu); fSelectionSearchGroup.fillContextMenu(menu);
} }
fRefactoringActionGroup.fillContextMenu(menu); fRefactoringActionGroup.fillContextMenu(menu);
} }
private void showReference() { private void showReference() {
if (fNavigationNode != null) { if (fNavigationNode != null) {