mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-19 15:05:36 +02:00
Fix for 182312, adds 'Open Type in Hierarchy' action.
This commit is contained in:
parent
5b6432c384
commit
25f6e085ff
8 changed files with 215 additions and 16 deletions
|
@ -297,10 +297,15 @@ ActionDefinition.open.hierarchy.description= Open the hierarchy of the selected
|
|||
OpenTypeInHierarchyAction.label=Open Type in Hierarch&y...
|
||||
OpenTypeInHierarchyAction.description=Opens a type selected from the all types dialog in a type hierarchy
|
||||
OpenTypeInHierarchyAction.tooltip=Opens a Type in a Type Hierarchy
|
||||
OpenElementInCallHierarchyAction.label=Open Element in Ca&ll Hierarchy...
|
||||
OpenElementInCallHierarchyAction.description=Opens an element selected from a dialog in the call hierarchy
|
||||
OpenElementInCallHierarchyAction.tooltip=Opens an Element in the Call Hierarchy
|
||||
ActionDefinition.openTypeInHierarchy.name= Open Type in Hierarchy
|
||||
ActionDefinition.openTypeInHierarchy.description= Open a type in the type hierarchy view
|
||||
ActionDefinition.openTypeHierarchy.name= Open Type Hierarchy
|
||||
ActionDefinition.openTypeHierarchy.description= Open a type hierarchy on the selected element
|
||||
ActionDefinition.openElementInCallHierarchy.name= Open Element in Call Hierarchy
|
||||
ActionDefinition.openElementInCallHierarchy.description= Open an element in the call hierarchy view
|
||||
OpenTypeHierarchyAction.label=Open Type Hie&rarchy
|
||||
OpenTypeHierarchyAction.tooltip=Opens a Type Hierarchy for the Selected Element
|
||||
ViewCommand.typeHierarchy.name= C Type Hierarchy
|
||||
|
|
|
@ -942,6 +942,24 @@
|
|||
description="%CNavigationActionSet.description"
|
||||
visible="false"
|
||||
id="org.eclipse.cdt.ui.NavigationActionSet">
|
||||
<!-- enable only after the open symbol dialog can handle functions
|
||||
action
|
||||
id="org.eclipse.cdt.ui.actions.openElementInCallHierarchy"
|
||||
class="org.eclipse.cdt.internal.ui.callhierarchy.OpenElementInCallHierarchyAction"
|
||||
definitionId="org.eclipse.cdt.ui.navigate.open.element.in.call.hierarchy"
|
||||
label="%OpenElementInCallHierarchyAction.label"
|
||||
menubarPath="navigate/open.ext2"
|
||||
tooltip="%OpenElementInCallHierarchyAction.tooltip">
|
||||
</action-->
|
||||
<action
|
||||
id="org.eclipse.cdt.ui.actions.openTypeInHierarchy"
|
||||
class="org.eclipse.cdt.internal.ui.typehierarchy.OpenTypeInHierarchyAction"
|
||||
definitionId="org.eclipse.cdt.ui.navigate.open.type.in.hierarchy"
|
||||
label="%OpenTypeInHierarchyAction.label"
|
||||
helpContextId="org.eclipse.cdt.ui.open_type_in_hierarchy_action"
|
||||
menubarPath="navigate/open.ext2"
|
||||
tooltip="%OpenTypeInHierarchyAction.tooltip">
|
||||
</action>
|
||||
<action
|
||||
id="org.eclipse.cdt.ui.actions.OpenType"
|
||||
toolbarPath="org.eclipse.search.searchActionSet/Search"
|
||||
|
@ -953,15 +971,6 @@
|
|||
menubarPath="navigate/open.ext2"
|
||||
tooltip="%OpenTypeAction.tooltip">
|
||||
</action>
|
||||
<!--action
|
||||
id="org.eclipse.cdt.ui.actions.openTypeInHierarchy"
|
||||
class="org.eclipse.cdt.internal.ui.browser.typehierarchy.OpenTypeInHierarchyAction"
|
||||
definitionId="org.eclipse.cdt.ui.navigate.open.type.in.hierarchy"
|
||||
label="%OpenTypeInHierarchyAction.label"
|
||||
helpContextId="org.eclipse.cdt.ui.open_type_in_hierarchy_action"
|
||||
menubarPath="navigate/open.ext2"
|
||||
tooltip="%OpenTypeInHierarchyAction.tooltip">
|
||||
</action-->
|
||||
</actionSet>
|
||||
<actionSet
|
||||
label="%COpenActionSet.label"
|
||||
|
@ -1106,8 +1115,6 @@
|
|||
description="%cEditor.description"
|
||||
id="org.eclipse.cdt.ui.cEditorScope">
|
||||
</context>
|
||||
</extension>
|
||||
<extension point="org.eclipse.ui.contexts">
|
||||
<context
|
||||
name="%cViewScope.name"
|
||||
description="%cViewScope.description"
|
||||
|
@ -1204,11 +1211,16 @@
|
|||
contextId="org.eclipse.cdt.ui.cViewScope"
|
||||
commandId="org.eclipse.cdt.ui.edit.open.type.hierarchy"
|
||||
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
|
||||
<!--key
|
||||
<key
|
||||
sequence="M1+M2+H"
|
||||
contextId="org.eclipse.cdt.ui.cEditorScope"
|
||||
commandId="org.eclipse.cdt.ui.navigate.open.type.in.hierarchy"
|
||||
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/-->
|
||||
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
|
||||
<key
|
||||
sequence="M1+M2+H"
|
||||
contextId="org.eclipse.cdt.ui.cViewScope"
|
||||
commandId="org.eclipse.cdt.ui.navigate.open.type.in.hierarchy"
|
||||
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
|
||||
<key
|
||||
sequence="M1+M2+N"
|
||||
contextId="org.eclipse.cdt.ui.cEditorScope"
|
||||
|
@ -1327,12 +1339,18 @@
|
|||
categoryId="org.eclipse.ui.category.navigate"
|
||||
id="org.eclipse.cdt.ui.edit.open.type.hierarchy">
|
||||
</command>
|
||||
<!--command
|
||||
<command
|
||||
name="%ActionDefinition.openTypeInHierarchy.name"
|
||||
description="%ActionDefinition.openTypeInHierarchy.description"
|
||||
categoryId="org.eclipse.ui.category.navigate"
|
||||
id="org.eclipse.cdt.ui.navigate.open.type.in.hierarchy">
|
||||
</command-->
|
||||
</command>
|
||||
<command
|
||||
name="%ActionDefinition.openElementInCallHierarchy.name"
|
||||
description="%ActionDefinition.openElementInCallHierarchy.description"
|
||||
categoryId="org.eclipse.ui.category.navigate"
|
||||
id="org.eclipse.cdt.ui.navigate.open.element.in.call.hierarchy">
|
||||
</command>
|
||||
<command
|
||||
name="%ActionDefinition.addInclude.name"
|
||||
description="%ActionDefinition.addInclude.description"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2007 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
|
||||
|
@ -51,6 +51,8 @@ public class CHMessages extends NLS {
|
|||
public static String CHHistoryDropDownAction_ShowHistoryList_tooltip;
|
||||
public static String OpenCallHierarchyAction_label;
|
||||
public static String OpenCallHierarchyAction_tooltip;
|
||||
public static String OpenElementInCallHierarchyAction_errorDlgTitle;
|
||||
public static String OpenElementInCallHierarchyAction_errorNoDefinition;
|
||||
static {
|
||||
// initialize resource bundle
|
||||
NLS.initializeMessages(BUNDLE_NAME, CHMessages.class);
|
||||
|
|
|
@ -44,3 +44,5 @@ OpenCallHierarchyAction_label=Open Call H&ierarchy
|
|||
OpenCallHierarchyAction_tooltip=Open Call Hierarchy
|
||||
CallHierarchyUI_label=Open Call Hierarchy
|
||||
CallHierarchyUI_selectMessage=Select one element from the list
|
||||
OpenElementInCallHierarchyAction_errorDlgTitle=Open Element in Call Hierarchy
|
||||
OpenElementInCallHierarchyAction_errorNoDefinition=Could not locate definition of element '{0}'
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.callhierarchy;
|
||||
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
|
||||
|
||||
import org.eclipse.cdt.core.browser.ITypeInfo;
|
||||
import org.eclipse.cdt.core.browser.ITypeReference;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.browser.opentype.OpenTypeDialog;
|
||||
|
||||
public class OpenElementInCallHierarchyAction implements IWorkbenchWindowActionDelegate {
|
||||
|
||||
private static final int[] VISIBLE_TYPES = {
|
||||
ICElement.C_FUNCTION, ICElement.C_METHOD, ICElement.C_VARIABLE, ICElement.C_ENUMERATOR,
|
||||
ICElement.C_FUNCTION_DECLARATION, ICElement.C_METHOD_DECLARATION, ICElement.C_VARIABLE_DECLARATION };
|
||||
|
||||
private IWorkbenchWindow fWorkbenchWindow;
|
||||
|
||||
public OpenElementInCallHierarchyAction() {
|
||||
}
|
||||
|
||||
public void run(IAction action) {
|
||||
OpenTypeDialog dialog = new OpenTypeDialog(getShell());
|
||||
configureDialog(dialog);
|
||||
int result = dialog.open();
|
||||
if (result != IDialogConstants.OK_ID)
|
||||
return;
|
||||
|
||||
ITypeInfo info = (ITypeInfo) dialog.getFirstResult();
|
||||
if (info == null)
|
||||
return;
|
||||
|
||||
ICElement[] elements= null;
|
||||
ITypeReference location = info.getResolvedReference();
|
||||
if (location != null) {
|
||||
elements= location.getCElements();
|
||||
}
|
||||
if (elements == null || elements.length == 0) {
|
||||
String title = CHMessages.OpenElementInCallHierarchyAction_errorDlgTitle;
|
||||
String message = NLS.bind(CHMessages.OpenElementInCallHierarchyAction_errorNoDefinition, info.getQualifiedTypeName().toString());
|
||||
MessageDialog.openError(getShell(), title, message);
|
||||
}
|
||||
else {
|
||||
CallHierarchyUI.open(elements[0], fWorkbenchWindow);
|
||||
}
|
||||
}
|
||||
|
||||
private void configureDialog(OpenTypeDialog dialog) {
|
||||
dialog.setVisibleTypes(VISIBLE_TYPES);
|
||||
}
|
||||
|
||||
private Shell getShell() {
|
||||
return fWorkbenchWindow.getShell();
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
fWorkbenchWindow= null;
|
||||
}
|
||||
|
||||
public void init(IWorkbenchWindow window) {
|
||||
fWorkbenchWindow= window;
|
||||
}
|
||||
|
||||
public void selectionChanged(IAction action, ISelection selection) {
|
||||
}
|
||||
}
|
|
@ -17,6 +17,8 @@ public class Messages extends NLS {
|
|||
private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.typehierarchy.messages"; //$NON-NLS-1$
|
||||
public static String OpenTypeHierarchyAction_label;
|
||||
public static String OpenTypeHierarchyAction_tooltip;
|
||||
public static String OpenTypeInHierarchyAction_errorNoDefinition;
|
||||
public static String OpenTypeInHierarchyAction_errorTitle;
|
||||
public static String THGraph_error_elementNotFound;
|
||||
public static String THHierarchyModel_errorComputingHierarchy;
|
||||
public static String THHierarchyModel_Job_title;
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.typehierarchy;
|
||||
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
|
||||
|
||||
import org.eclipse.cdt.core.browser.ITypeInfo;
|
||||
import org.eclipse.cdt.core.browser.ITypeReference;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.browser.opentype.OpenTypeDialog;
|
||||
|
||||
public class OpenTypeInHierarchyAction implements IWorkbenchWindowActionDelegate {
|
||||
|
||||
private static final int[] VISIBLE_TYPES = {
|
||||
ICElement.C_CLASS, ICElement.C_STRUCT, ICElement.C_TYPEDEF, ICElement.C_ENUMERATION,
|
||||
ICElement.C_UNION };
|
||||
|
||||
private IWorkbenchWindow fWorkbenchWindow;
|
||||
|
||||
public OpenTypeInHierarchyAction() {
|
||||
}
|
||||
|
||||
public void run(IAction action) {
|
||||
OpenTypeDialog dialog = new OpenTypeDialog(getShell());
|
||||
configureDialog(dialog);
|
||||
int result = dialog.open();
|
||||
if (result != IDialogConstants.OK_ID)
|
||||
return;
|
||||
|
||||
ITypeInfo info = (ITypeInfo) dialog.getFirstResult();
|
||||
if (info == null)
|
||||
return;
|
||||
|
||||
ICElement[] elements= null;
|
||||
ITypeReference location = info.getResolvedReference();
|
||||
if (location != null) {
|
||||
elements= location.getCElements();
|
||||
}
|
||||
if (elements == null || elements.length == 0) {
|
||||
String title = Messages.OpenTypeInHierarchyAction_errorTitle;
|
||||
String message = NLS.bind(Messages.OpenTypeInHierarchyAction_errorNoDefinition, info.getQualifiedTypeName().toString());
|
||||
MessageDialog.openError(getShell(), title, message);
|
||||
}
|
||||
else {
|
||||
TypeHierarchyUI.open(elements[0], fWorkbenchWindow);
|
||||
}
|
||||
}
|
||||
|
||||
private void configureDialog(OpenTypeDialog dialog) {
|
||||
dialog.setVisibleTypes(VISIBLE_TYPES);
|
||||
}
|
||||
|
||||
private Shell getShell() {
|
||||
return fWorkbenchWindow.getShell();
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
fWorkbenchWindow= null;
|
||||
}
|
||||
|
||||
public void init(IWorkbenchWindow window) {
|
||||
fWorkbenchWindow= window;
|
||||
}
|
||||
|
||||
public void selectionChanged(IAction action, ISelection selection) {
|
||||
}
|
||||
}
|
|
@ -51,5 +51,7 @@ TypeHierarchyUI_OpenTypeHierarchy=Open Type Hierarchy
|
|||
TypeHierarchyUI_SelectFromList=Select one element from the list
|
||||
OpenTypeHierarchyAction_label=Open Type Hierarchy
|
||||
OpenTypeHierarchyAction_tooltip=Open Type Hierarchy
|
||||
OpenTypeInHierarchyAction_errorTitle=Open Type in Hierarchy
|
||||
THInformationControl_regularTitle=Type Hierarchy of {0}
|
||||
THInformationControl_showDefiningTypesTitle=Types defining or implementing {0}
|
||||
OpenTypeInHierarchyAction_errorNoDefinition=Could not locate definition of type '{0}'
|
||||
|
|
Loading…
Add table
Reference in a new issue