|
From: <caw...@us...> - 2007-07-19 15:41:23
|
Revision: 2798
http://svn.sourceforge.net/rubyeclipse/?rev=2798&view=rev
Author: cawilliams
Date: 2007-07-19 08:41:22 -0700 (Thu, 19 Jul 2007)
Log Message:
-----------
first working prototype of type hierarchy
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/plugin.properties
trunk/org.rubypeople.rdt.ui/plugin.xml
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/ActionMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/ActionMessages.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditorActionContributor.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/IContextMenuConstants.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyUI.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/actions/IRubyEditorActionDefinitionIds.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/OpenTypeInHierarchyAction.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/commands/
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/commands/RubyElementReferenceConverter.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/commands/ShowElementInTypeHierarchyViewHandler.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyViewPart.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/util/OpenTypeHierarchyUtil.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/workingsets/WorkingSetMessages.properties
Modified: trunk/org.rubypeople.rdt.ui/plugin.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.properties 2007-07-19 15:40:45 UTC (rev 2797)
+++ trunk/org.rubypeople.rdt.ui/plugin.properties 2007-07-19 15:41:22 UTC (rev 2798)
@@ -31,6 +31,7 @@
PreferencePage.rdtDebuggerPreferences=Debugger
viewCategoryName=Ruby
+hierarchyViewName=Hierarchy
appearancePrefName=Appearance
problemSeveritiesPrefName=Errors/Warnings
@@ -137,6 +138,12 @@
ActionDefinition.open.structure.name= Open Structure
ActionDefinition.open.structure.description= Show the structure of the selected element
+ActionDefinition.open.hierarchy.name= Quick Hierarchy
+ActionDefinition.open.hierarchy.description= Show the quick hierarchy of the selected element
+
+ActionDefinition.openTypeInHierarchy.name= Open Type in Hierarchy
+ActionDefinition.openTypeInHierarchy.description= Open a type in the type hierarchy view
+
scope.rubyEditor.name=Ruby Editor
scope.rubyEditor.description=Ruby Editor
@@ -181,4 +188,9 @@
OpenAction.label=&Open
OpenAction.tooltip=Open an Editor on the Selected Element
OpenTypeAction.label=Open &Type...
-OpenTypeAction.tooltip=Open an Editor on a Type
\ No newline at end of file
+OpenTypeAction.tooltip=Open an Editor on a Type
+
+OpenTypeHierarchyAction.label=Ope&n Type Hierarchy
+
+OpenTypeInHierarchyAction.label=Open Type in Hierarch&y...
+OpenTypeInHierarchyAction.tooltip=Opens a Type in a Type Hierarchy
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.ui/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.xml 2007-07-19 15:40:45 UTC (rev 2797)
+++ trunk/org.rubypeople.rdt.ui/plugin.xml 2007-07-19 15:41:22 UTC (rev 2798)
@@ -385,6 +385,13 @@
class="org.rubypeople.rdt.internal.ui.infoviews.RIView"
id="org.rubypeople.rdt.ui.views.RIView">
</view>
+ <view
+ name="%hierarchyViewName"
+ icon="$nl$/icons/full/eview16/class_hi.gif"
+ category="org.rubypeople.rdt.ui.ruby"
+ class="org.rubypeople.rdt.internal.ui.typehierarchy.TypeHierarchyViewPart"
+ id="org.rubypeople.rdt.ui.TypeHierarchy">
+ </view>
</extension>
<extension point="org.eclipse.ui.editors">
<editor
@@ -473,6 +480,10 @@
commandId="org.rubypeople.rdt.ui.edit.text.ruby.goto.matching.bracket"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
<key
+ sequence="M1+M2+H"
+ commandId="org.rubypeople.rdt.ui.navigate.open.type.in.hierarchy"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+ <key
sequence="F3"
contextId="org.rubypeople.rdt.ui.rubyEditorScope"
commandId="org.rubypeople.rdt.ui.edit.text.ruby.open.editor"
@@ -488,6 +499,11 @@
commandId="org.rubypeople.rdt.ui.edit.text.ruby.show.outline"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
<key
+ sequence="M1+T"
+ contextId="org.rubypeople.rdt.ui.rubyEditorScope"
+ commandId="org.rubypeople.rdt.ui.edit.text.ruby.open.hierarchy"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+ <key
sequence="M1+F3"
contextId="org.rubypeople.rdt.ui.rubyEditorScope"
commandId="org.rubypeople.rdt.ui.navigate.ruby.open.structure"
@@ -581,13 +597,25 @@
id="org.rubypeople.rdt.ui.edit.text.ruby.open.type"
name="%OpenTypeAction.label">
</command>
- <command
+ <command
+ name="%ActionDefinition.openTypeInHierarchy.name"
+ description="%ActionDefinition.openTypeInHierarchy.description"
+ categoryId="org.eclipse.ui.category.navigate"
+ id="org.rubypeople.rdt.ui.navigate.open.type.in.hierarchy">
+ </command>
+ <command
name="%ActionDefinition.show.outline.name"
description="%ActionDefinition.show.outline.description"
categoryId="org.eclipse.ui.category.navigate"
id="org.rubypeople.rdt.ui.edit.text.ruby.show.outline">
</command>
<command
+ name="%ActionDefinition.open.hierarchy.name"
+ description="%ActionDefinition.open.hierarchy.description"
+ categoryId="org.eclipse.ui.category.navigate"
+ id="org.rubypeople.rdt.ui.edit.text.ruby.open.hierarchy">
+ </command>
+ <command
name="%ActionDefinition.open.structure.name"
description="%ActionDefinition.open.structure.description"
categoryId="org.eclipse.ui.category.navigate"
@@ -654,8 +682,29 @@
categoryId="org.eclipse.search.ui.category.search"
id="org.rubypeople.rdt.ui.edit.text.ruby.search.read.access.in.working.set">
</command>
+
</extension>
<extension
+ point="org.eclipse.ui.commands">
+ <commandParameterType
+ converter="org.rubypeople.rdt.internal.ui.commands.RubyElementReferenceConverter"
+ id="org.rubypeople.rdt.ui.commands.rubyElementReference"
+ type="org.rubypeople.rdt.core.IRubyElement"/>
+ <command
+ categoryId="org.eclipse.ui.category.navigate"
+ defaultHandler="org.rubypeople.rdt.internal.ui.commands.ShowElementInTypeHierarchyViewHandler"
+ description="%command.showElementInTypeHierarchyView.desc"
+ id="org.rubypeople.rdt.ui.commands.showElementInTypeHierarchyView"
+ name="%command.showElementInTypeHierarchyView.name">
+ <commandParameter
+ id="elementRef"
+ name="%commandParameter.showElementInTypeHierarchyView.elementRef.name"
+ optional="false"
+ typeId="org.rubypeople.rdt.ui.commands.rubyElementReference"/>
+ </command>
+ </extension>
+
+ <extension
point="org.eclipse.ui.actionSets">
<actionSet
label="%RubyActionSet.label"
@@ -669,8 +718,25 @@
name="editGroup">
</separator>
</menu>
-
<action
+ class="org.rubypeople.rdt.ui.actions.OpenTypeAction"
+ definitionId="org.rubypeople.rdt.ui.edit.text.ruby.open.type"
+ id="org.rubypeople.rdt.ui.actions.OpenType"
+ label="%OpenTypeAction.label"
+ icon="icons/full/etool16/opentype.gif"
+ menubarPath="navigate/open.ext"
+ tooltip="%OpenTypeAction.tooltip">
+ </action>
+ <action
+ definitionId="org.rubypeople.rdt.ui.navigate.open.type.in.hierarchy"
+ label="%OpenTypeInHierarchyAction.label"
+ helpContextId="org.rubypeople.rdt.ui.open_type_in_hierarchy_action"
+ tooltip="%OpenTypeInHierarchyAction.tooltip"
+ class="org.rubypeople.rdt.internal.ui.actions.OpenTypeInHierarchyAction"
+ menubarPath="navigate/open.ext2"
+ id="openTypeInHierarchy">
+ </action>
+ <action
definitionId="org.rubypeople.rdt.ui.generate.rdoc"
label="%GenerateRdocAction.label"
helpContextId="org.rubypeople.rdt.ui.generate_rdoc_action"
@@ -759,14 +825,12 @@
allowLabelUpdate="true"
id="org.rubypeople.rdt.ui.actions.Open">
</action>
- <action
- class="org.rubypeople.rdt.ui.actions.OpenTypeAction"
- definitionId="org.rubypeople.rdt.ui.edit.text.ruby.open.type"
- id="org.rubypeople.rdt.ui.actions.OpenType"
- label="%OpenTypeAction.label"
- icon="icons/full/etool16/opentype.gif"
+ <action
+ definitionId="org.eclipse.jdt.ui.edit.text.java.open.type.hierarchy"
+ label="%OpenTypeHierarchyAction.label"
+ retarget="true"
menubarPath="navigate/open.ext"
- tooltip="%OpenTypeAction.tooltip">
+ id="org.eclipse.jdt.ui.actions.OpenTypeHierarchy">
</action>
</actionSet>
</extension>
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.java 2007-07-19 15:40:45 UTC (rev 2797)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.java 2007-07-19 15:41:22 UTC (rev 2798)
@@ -89,6 +89,11 @@
public static String OpenTypeAction_errorMessage;
public static String RubyOutlineControl_statusFieldText_hideInheritedMembers;
public static String RubyOutlineControl_statusFieldText_showInheritedMembers;
+ public static String OpenTypeHierarchyUtil_selectionDialog_title;
+ public static String OpenTypeHierarchyUtil_selectionDialog_message;
+ public static String OpenTypeHierarchyUtil_error_open_perspective;
+ public static String OpenTypeHierarchyUtil_error_open_editor;
+ public static String OpenTypeHierarchyUtil_error_open_view;
private RubyUIMessages() {
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties 2007-07-19 15:40:45 UTC (rev 2797)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties 2007-07-19 15:41:22 UTC (rev 2798)
@@ -120,6 +120,15 @@
RubyElementLabels_declseparator_string=\ :\
RubyElementLabels_import_container=require/load declarations
+HistoryListAction_remove=&Remove
+HistoryListAction_remove_all=Remove &All
+HistoryListAction_max_entries_constraint=Please enter a positive integer smaller than {0}.
+OpenTypeHierarchyUtil_error_open_view=Problems opening Type Hierarchy View
+OpenTypeHierarchyUtil_error_open_perspective=Problems opening Type Hierarchy Perspective
+OpenTypeHierarchyUtil_error_open_editor=Problems opening Ruby Editor
+OpenTypeHierarchyUtil_selectionDialog_title=Open In Type Hierarchy
+OpenTypeHierarchyUtil_selectionDialog_message=&Select the type to be shown in the Type Hierarchy:
+
#########
# misc
#########
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/ActionMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/ActionMessages.java 2007-07-19 15:40:45 UTC (rev 2797)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/ActionMessages.java 2007-07-19 15:41:22 UTC (rev 2798)
@@ -63,6 +63,11 @@
public static String SelectAllAction_label;
public static String SelectAllAction_tooltip;
public static String NewWizardsActionGroup_new;
+ public static String OpenTypeInHierarchyAction_label;
+ public static String OpenTypeInHierarchyAction_description;
+ public static String OpenTypeInHierarchyAction_tooltip;
+ public static String OpenTypeInHierarchyAction_dialogTitle;
+ public static String OpenTypeInHierarchyAction_dialogMessage;
static {
NLS.initializeMessages(BUNDLE_NAME, ActionMessages.class);
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/ActionMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/ActionMessages.properties 2007-07-19 15:40:45 UTC (rev 2797)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/ActionMessages.properties 2007-07-19 15:41:22 UTC (rev 2798)
@@ -60,3 +60,20 @@
OpenNewRubyProjectWizardAction_description=Opens the new Ruby project wizard
OpenNewRubyProjectWizardAction_tooltip=Opens the new Ruby project wizard
+OpenTypeHierarchyAction_label=Ope&n Type Hierarchy
+OpenTypeHierarchyAction_tooltip=Open a Type Hierarchy on the Selected Element
+OpenTypeHierarchyAction_description=Open a type hierarchy on the selected element
+OpenTypeHierarchyAction_dialog_title=Open Type Hierarchy
+OpenTypeHierarchyAction_messages_title=Cannot create type hierarchy
+OpenTypeHierarchyAction_messages_no_java_element=A Ruby element must be selected.
+OpenTypeHierarchyAction_messages_no_java_resources=The selected package does not contain any Ruby resource.
+OpenTypeHierarchyAction_messages_no_types=The selected compilation unit does not contain a type.
+OpenTypeHierarchyAction_messages_no_valid_java_element=A valid Ruby element must be selected.
+OpenTypeHierarchyAction_messages_unknown_import_decl=The selected import declaration can not be resolved.
+
+OpenTypeInHierarchyAction_label=Open Type in Hierarchy...
+OpenTypeInHierarchyAction_description=Open a type in a type hierarchy
+
+OpenTypeInHierarchyAction_tooltip=Open a Type in a Type Hierarchy
+OpenTypeInHierarchyAction_dialogMessage=&Choose a type (? = any character, * = any string):
+OpenTypeInHierarchyAction_dialogTitle=Open Type in Hierarchy
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/OpenTypeInHierarchyAction.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/OpenTypeInHierarchyAction.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/OpenTypeInHierarchyAction.java 2007-07-19 15:41:22 UTC (rev 2798)
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.ui.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.PlatformUI;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.search.IRubySearchConstants;
+import org.rubypeople.rdt.core.search.SearchEngine;
+import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.dialogs.OpenTypeSelectionDialog2;
+import org.rubypeople.rdt.internal.ui.util.OpenTypeHierarchyUtil;
+
+public class OpenTypeInHierarchyAction extends Action implements IWorkbenchWindowActionDelegate {
+
+ private IWorkbenchWindow fWindow;
+
+ public OpenTypeInHierarchyAction() {
+ super();
+ setText(ActionMessages.OpenTypeInHierarchyAction_label);
+ setDescription(ActionMessages.OpenTypeInHierarchyAction_description);
+ setToolTipText(ActionMessages.OpenTypeInHierarchyAction_tooltip);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IRubyHelpContextIds.OPEN_TYPE_IN_HIERARCHY_ACTION);
+ }
+
+ public void run() {
+ Shell parent= RubyPlugin.getActiveWorkbenchShell();
+ OpenTypeSelectionDialog2 dialog= new OpenTypeSelectionDialog2(parent, false,
+ PlatformUI.getWorkbench().getProgressService(),
+ SearchEngine.createWorkspaceScope(), IRubySearchConstants.TYPE);
+
+ dialog.setTitle(ActionMessages.OpenTypeInHierarchyAction_dialogTitle);
+ dialog.setMessage(ActionMessages.OpenTypeInHierarchyAction_dialogMessage);
+ int result= dialog.open();
+ if (result != IDialogConstants.OK_ID)
+ return;
+
+ Object[] types= dialog.getResult();
+ if (types != null && types.length > 0) {
+ IType type= (IType)types[0];
+ OpenTypeHierarchyUtil.open(new IType[] { type }, fWindow);
+ }
+ }
+
+ //---- IWorkbenchWindowActionDelegate ------------------------------------------------
+
+ public void run(IAction action) {
+ run();
+ }
+
+ public void dispose() {
+ fWindow= null;
+ }
+
+ public void init(IWorkbenchWindow window) {
+ fWindow= window;
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ // do nothing. Action doesn't depend on selection.
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/actions/OpenTypeInHierarchyAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/commands/RubyElementReferenceConverter.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/commands/RubyElementReferenceConverter.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/commands/RubyElementReferenceConverter.java 2007-07-19 15:41:22 UTC (rev 2798)
@@ -0,0 +1,197 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.rubypeople.rdt.internal.ui.commands;
+
+import org.eclipse.core.commands.AbstractParameterValueConverter;
+import org.eclipse.core.commands.ParameterValueConversionException;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.rubypeople.rdt.core.IField;
+import org.rubypeople.rdt.core.IMethod;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyModel;
+import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.core.RubyModelException;
+
+/**
+ * A command parameter value converter to convert between Ruby elements and
+ * String references that identify them.
+ * <p>
+ * References can be made to Ruby types, methods and fields. The reference
+ * identifies the project to use as a search scope as well as the java element
+ * information. Note that non-source elements may be referenced (such as
+ * java.lang.Object), but they must be resolved within the scope of some
+ * project.
+ * </p>
+ * <p>
+ * References take the form:
+ *
+ * <pre>
+ * elementRef := typeRef | fieldRef | methodRef
+ * typeRef := projectName '/' fullyQualifiedTypeName
+ * fieldRef := typeRef '#' fieldName
+ * methodRef := typeRef '#' methodName '(' parameterSignatures ')'
+ * </pre>
+ *
+ * where <code>parameterSignatures</code> uses the signature format documented
+ * in the {@link org.eclipse.jdt.core.Signature Signature} class.
+ * </p>
+ *
+ * @since 3.2
+ */
+public class RubyElementReferenceConverter extends AbstractParameterValueConverter {
+
+ private static final char PROJECT_END_CHAR= '/';
+
+ private static final char TYPE_END_CHAR= '#';
+
+
+ public Object convertToObject(String parameterValue) throws ParameterValueConversionException {
+
+ assertWellFormed(parameterValue != null);
+
+ final int projectEndPosition= parameterValue.indexOf(PROJECT_END_CHAR);
+ assertWellFormed(projectEndPosition != -1);
+
+ String projectName= parameterValue.substring(0, projectEndPosition);
+ String javaElementRef= parameterValue.substring(projectEndPosition + 1);
+
+ IRubyModel javaModel= RubyCore.create(ResourcesPlugin.getWorkspace().getRoot());
+ assertExists(javaModel);
+
+ IRubyProject javaProject= javaModel.getRubyProject(projectName);
+ assertExists(javaProject);
+
+ final int typeEndPosition= javaElementRef.indexOf(TYPE_END_CHAR);
+ String typeName;
+ if (typeEndPosition == -1) {
+ typeName= javaElementRef;
+ } else {
+ typeName= javaElementRef.substring(0, typeEndPosition);
+ }
+
+ IType type= null;
+ try {
+ type= javaProject.findType(typeName);
+ } catch (RubyModelException ex) {
+ // type == null
+ }
+ assertExists(type);
+
+ if (typeEndPosition == -1) {
+ return type;
+ }
+
+ String memberRef= javaElementRef.substring(typeEndPosition + 1);
+
+// final int paramStartPosition= memberRef.indexOf(PARAM_START_CHAR);
+// if (paramStartPosition == -1) {
+ IField field= type.getField(memberRef);
+ if (field != null && field.exists()){
+// assertExists(field);
+ return field;
+ }
+// }
+// String methodName= memberRef.substring(0, paramStartPosition);
+// String signature= memberRef.substring(paramStartPosition);
+ String[] parameterTypes= null;
+// try {
+// parameterTypes= Signature.getParameterTypes(signature);
+// } catch (IllegalArgumentException ex) {
+// // parameterTypes == null
+// }
+// assertWellFormed(parameterTypes != null);
+ IMethod method= type.getMethod(memberRef, parameterTypes);
+ assertExists(method);
+ return method;
+ }
+
+ /**
+ * Throws a <code>ParameterValueConversionException</code> if the java
+ * element reference string does not meet some well-formedness condition.
+ *
+ * @param assertion
+ * a boolean check for well-formedness
+ * @throws ParameterValueConversionException
+ */
+ private void assertWellFormed(boolean assertion) throws ParameterValueConversionException {
+ if (!assertion) {
+ throw new ParameterValueConversionException("Malformed parameterValue"); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Throws a <code>ParameterValueConversionException</code> if the java
+ * element reference string identifies an element that does not exist.
+ *
+ * @param javaElement
+ * an element to check for existence
+ * @throws ParameterValueConversionException
+ */
+ private void assertExists(IRubyElement javaElement) throws ParameterValueConversionException {
+ if ((javaElement == null) || (!javaElement.exists())) {
+ throw new ParameterValueConversionException("parameterValue must reference an existing IRubyElement"); //$NON-NLS-1$
+ }
+ }
+
+ public String convertToString(Object parameterValue) throws ParameterValueConversionException {
+
+ if (!(parameterValue instanceof IRubyElement)) {
+ throw new ParameterValueConversionException("parameterValue must be an IRubyElement"); //$NON-NLS-1$
+ }
+
+ IRubyElement javaElement= (IRubyElement) parameterValue;
+
+ IRubyProject javaProject= javaElement.getRubyProject();
+ if (javaProject == null) {
+ throw new ParameterValueConversionException("Could not get IRubyProject for element"); //$NON-NLS-1$
+ }
+
+ StringBuffer buffer;
+
+ if (javaElement instanceof IType) {
+ IType type= (IType) javaElement;
+ buffer= composeTypeReference(type);
+ } else
+ if (javaElement instanceof IMethod) {
+ IMethod method= (IMethod) javaElement;
+ buffer= composeTypeReference(method.getDeclaringType());
+ buffer.append(TYPE_END_CHAR);
+ buffer.append(method.getElementName());
+// String[] parameterTypes= method.getParameterTypes();
+// buffer.append(PARAM_START_CHAR);
+// for (int i= 0; i < parameterTypes.length; i++) {
+// buffer.append(parameterTypes[i]);
+// }
+// buffer.append(PARAM_END_CHAR);
+ } else
+ if (javaElement instanceof IField) {
+ IField field= (IField) javaElement;
+ buffer= composeTypeReference(field.getDeclaringType());
+ buffer.append(TYPE_END_CHAR);
+ buffer.append(field.getElementName());
+ } else {
+ throw new ParameterValueConversionException("Unsupported IRubyElement type"); //$NON-NLS-1$
+ }
+
+ return buffer.toString();
+ }
+
+ private StringBuffer composeTypeReference(IType type) {
+ StringBuffer buffer= new StringBuffer();
+ buffer.append(type.getRubyProject().getElementName());
+ buffer.append(PROJECT_END_CHAR);
+ buffer.append(type.getFullyQualifiedName());
+ return buffer;
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/commands/RubyElementReferenceConverter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/commands/ShowElementInTypeHierarchyViewHandler.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/commands/ShowElementInTypeHierarchyViewHandler.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/commands/ShowElementInTypeHierarchyViewHandler.java 2007-07-19 15:41:22 UTC (rev 2798)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+package org.rubypeople.rdt.internal.ui.commands;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.util.OpenTypeHierarchyUtil;
+
+/**
+ * A command handler to show a ruby element in the type hierarchy view.
+ *
+ * @since 1.0
+ */
+public class ShowElementInTypeHierarchyViewHandler extends AbstractHandler {
+
+ private static final String PARAM_ID_ELEMENT_REF= "elementRef"; //$NON-NLS-1$
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ IWorkbenchWindow window= RubyPlugin.getActiveWorkbenchWindow();
+ if (window == null)
+ return null;
+
+ IRubyElement rubyElement= (IRubyElement) event.getObjectParameterForExecution(PARAM_ID_ELEMENT_REF);
+
+ OpenTypeHierarchyUtil.open(rubyElement, window);
+
+ return null;
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/commands/ShowElementInTypeHierarchyViewHandler.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditorActionContributor.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditorActionContributor.java 2007-07-19 15:40:45 UTC (rev 2797)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditorActionContributor.java 2007-07-19 15:41:22 UTC (rev 2798)
@@ -32,6 +32,7 @@
protected RetargetTextEditorAction contentAssistProposal;
private RetargetTextEditorAction fGotoMatchingBracket;
private RetargetTextEditorAction fShowOutline;
+ private RetargetTextEditorAction fOpenHierarchy;
private RetargetTextEditorAction fQuickAssistAction;
private RetargetAction fRetargetShowRubyDoc;
@@ -48,6 +49,9 @@
fShowOutline= new RetargetTextEditorAction(RubyEditorMessages.getBundleForConstructedKeys(), "ShowOutline."); //$NON-NLS-1$
fShowOutline.setActionDefinitionId(IRubyEditorActionDefinitionIds.SHOW_OUTLINE);
+ fOpenHierarchy= new RetargetTextEditorAction(RubyEditorMessages.getBundleForConstructedKeys(), "OpenHierarchy."); //$NON-NLS-1$
+ fOpenHierarchy.setActionDefinitionId(IRubyEditorActionDefinitionIds.OPEN_HIERARCHY);
+
contentAssistProposal = new RetargetTextEditorAction(RubyUIMessages.getResourceBundle(),
"ContentAssistProposal.");
fGotoMatchingBracket = new RetargetTextEditorAction(b, "GotoMatchingBracket."); //$NON-NLS-1$
@@ -76,15 +80,14 @@
IMenuManager navigateMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_NAVIGATE);
if (navigateMenu != null) {
navigateMenu.appendToGroup(IWorkbenchActionConstants.SHOW_EXT, fShowOutline);
+ navigateMenu.appendToGroup(IWorkbenchActionConstants.SHOW_EXT, fOpenHierarchy);
}
IMenuManager gotoMenu= menu.findMenuUsingPath("navigate/goTo"); //$NON-NLS-1$
if (gotoMenu != null) {
gotoMenu.add(new Separator("additions2")); //$NON-NLS-1$
gotoMenu.appendToGroup("additions2", fGotoMatchingBracket); //$NON-NLS-1$
- }
-
-
+ }
}
public void setActiveEditor(IEditorPart part) {
@@ -98,6 +101,7 @@
GotoMatchingBracketAction.GOTO_MATCHING_BRACKET));
fQuickAssistAction.setAction(getAction(textEditor, ITextEditorActionConstants.QUICK_ASSIST));
fShowOutline.setAction(getAction(textEditor, IRubyEditorActionDefinitionIds.SHOW_OUTLINE));
+ fOpenHierarchy.setAction(getAction(textEditor, IRubyEditorActionDefinitionIds.OPEN_HIERARCHY));
fShowRubyDoc.setAction(getAction(textEditor, "ShowRDoc")); //$NON-NLS-1$
if (part instanceof RubyEditor) {
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyViewPart.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyViewPart.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/typehierarchy/TypeHierarchyViewPart.java 2007-07-19 15:41:22 UTC (rev 2798)
@@ -0,0 +1,1633 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.ui.typehierarchy;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IStatusLineManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.util.TransferDragSourceListener;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
+import org.eclipse.jface.viewers.IBasicPropertyConstants;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.search.internal.ui.text.ResourceTransferDragAdapter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.custom.ViewForm;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTarget;
+import org.eclipse.swt.dnd.DropTargetAdapter;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.ScrollBar;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPartListener2;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartReference;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.part.IShowInSource;
+import org.eclipse.ui.part.IShowInTargetList;
+import org.eclipse.ui.part.PageBook;
+import org.eclipse.ui.part.ResourceTransfer;
+import org.eclipse.ui.part.ShowInContext;
+import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
+import org.rubypeople.rdt.core.IMember;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.ITypeHierarchy;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.internal.core.util.Messages;
+import org.rubypeople.rdt.internal.ui.IRubyHelpContextIds;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.actions.CompositeActionGroup;
+import org.rubypeople.rdt.internal.ui.actions.NewWizardsActionGroup;
+import org.rubypeople.rdt.internal.ui.actions.SelectAllAction;
+import org.rubypeople.rdt.internal.ui.dnd.RdtViewerDragAdapter;
+import org.rubypeople.rdt.internal.ui.packageview.SelectionTransferDragAdapter;
+import org.rubypeople.rdt.internal.ui.preferences.MembersOrderPreferenceCache;
+import org.rubypeople.rdt.internal.ui.rubyeditor.EditorUtility;
+import org.rubypeople.rdt.internal.ui.util.ExceptionHandler;
+import org.rubypeople.rdt.internal.ui.viewsupport.IViewPartInputProvider;
+import org.rubypeople.rdt.internal.ui.viewsupport.RubyUILabelProvider;
+import org.rubypeople.rdt.internal.ui.viewsupport.SelectionProviderMediator;
+import org.rubypeople.rdt.internal.ui.viewsupport.StatusBarUpdater;
+import org.rubypeople.rdt.internal.ui.workingsets.WorkingSetFilterActionGroup;
+import org.rubypeople.rdt.ui.IContextMenuConstants;
+import org.rubypeople.rdt.ui.ITypeHierarchyViewPart;
+import org.rubypeople.rdt.ui.PreferenceConstants;
+import org.rubypeople.rdt.ui.RubyElementLabels;
+import org.rubypeople.rdt.ui.RubyUI;
+import org.rubypeople.rdt.ui.actions.OpenEditorActionGroup;
+import org.rubypeople.rdt.ui.actions.RubySearchActionGroup;
+
+/**
+ * view showing the super types/sub types of its input.
+ */
+public class TypeHierarchyViewPart extends ViewPart implements ITypeHierarchyViewPart, IViewPartInputProvider {
+
+ public static final int VIEW_ID_TYPE= 2;
+ public static final int VIEW_ID_SUPER= 0;
+ public static final int VIEW_ID_SUB= 1;
+
+ public static final int VIEW_ORIENTATION_VERTICAL= 0;
+ public static final int VIEW_ORIENTATION_HORIZONTAL= 1;
+ public static final int VIEW_ORIENTATION_SINGLE= 2;
+ public static final int VIEW_ORIENTATION_AUTOMATIC= 3;
+
+ private static final String DIALOGSTORE_HIERARCHYVIEW= "TypeHierarchyViewPart.hierarchyview"; //$NON-NLS-1$
+ private static final String DIALOGSTORE_VIEWORIENTATION= "TypeHierarchyViewPart.orientation"; //$NON-NLS-1$
+
+ private static final String TAG_INPUT= "input"; //$NON-NLS-1$
+ private static final String TAG_VIEW= "view"; //$NON-NLS-1$
+ private static final String TAG_ORIENTATION= "orientation"; //$NON-NLS-1$
+ private static final String TAG_RATIO= "ratio"; //$NON-NLS-1$
+ private static final String TAG_SELECTION= "selection"; //$NON-NLS-1$
+ private static final String TAG_VERTICAL_SCROLL= "vertical_scroll"; //$NON-NLS-1$
+
+ private static final String GROUP_FOCUS= "group.focus"; //$NON-NLS-1$
+
+
+ // the selected type in the hierarchy view
+ private IType fSelectedType;
+ // input element or null
+ private IRubyElement fInputElement;
+
+ // history of input elements. No duplicates
+ private ArrayList fInputHistory;
+
+ private IMemento fMemento;
+ private IDialogSettings fDialogSettings;
+
+ private TypeHierarchyLifeCycle fHierarchyLifeCycle;
+ private ITypeHierarchyLifeCycleListener fTypeHierarchyLifeCycleListener;
+
+ private IPropertyChangeListener fPropertyChangeListener;
+
+ private SelectionProviderMediator fSelectionProviderMediator;
+ private ISelectionChangedListener fSelectionChangedListener;
+ private IPartListener2 fPartListener;
+
+ private int fCurrentOrientation;
+ int fOrientation= VIEW_ORIENTATION_AUTOMATIC;
+ boolean fInComputeOrientation= false;
+
+ private boolean fLinkingEnabled;
+ private boolean fSelectInEditor;
+
+ private boolean fIsVisible;
+ private boolean fNeedRefresh;
+ private boolean fIsEnableMemberFilter;
+ private boolean fIsRefreshRunnablePosted;
+
+ private int fCurrentViewerIndex;
+ private TypeHierarchyViewer[] fAllViewers;
+
+ private MethodsViewer fMethodsViewer;
+
+ private SashForm fTypeMethodsSplitter;
+ private PageBook fViewerbook;
+ private PageBook fPagebook;
+
+ private Label fNoHierarchyShownLabel;
+ private Label fEmptyTypesViewer;
+
+ private ViewForm fTypeViewerViewForm;
+ private ViewForm fMethodViewerViewForm;
+
+ private CLabel fMethodViewerPaneLabel;
+ private RubyUILabelProvider fPaneLabelProvider;
+ private Composite fParent;
+
+ private ToggleViewAction[] fViewActions;
+ private ToggleLinkingAction fToggleLinkingAction;
+ private HistoryDropDownAction fHistoryDropDownAction;
+ private ToggleOrientationAction[] fToggleOrientationActions;
+ private EnableMemberFilterAction fEnableMemberFilterAction;
+ private ShowQualifiedTypeNamesAction fShowQualifiedTypeNamesAction;
+ private FocusOnTypeAction fFocusOnTypeAction;
+ private FocusOnSelectionAction fFocusOnSelectionAction;
+ private CompositeActionGroup fActionGroups;
+ private SelectAllAction fSelectAllAction;
+
+ private WorkingSetFilterActionGroup fWorkingSetActionGroup;
+ private Job fRestoreStateJob;
+
+ public TypeHierarchyViewPart() {
+ fSelectedType= null;
+ fInputElement= null;
+ fIsVisible= false;
+ fIsRefreshRunnablePosted= false;
+ fSelectInEditor= true;
+ fRestoreStateJob= null;
+
+ fHierarchyLifeCycle= new TypeHierarchyLifeCycle();
+ fTypeHierarchyLifeCycleListener= new ITypeHierarchyLifeCycleListener() {
+ public void typeHierarchyChanged(TypeHierarchyLifeCycle typeHierarchy, IType[] changedTypes) {
+ doTypeHierarchyChanged(typeHierarchy, changedTypes);
+ }
+ };
+ fHierarchyLifeCycle.addChangedListener(fTypeHierarchyLifeCycleListener);
+
+ fPropertyChangeListener= new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ doPropertyChange(event);
+ }
+ };
+ PreferenceConstants.getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener);
+
+ fIsEnableMemberFilter= false;
+
+ fInputHistory= new ArrayList();
+ fAllViewers= null;
+
+ fViewActions= new ToggleViewAction[] {
+ new ToggleViewAction(this, VIEW_ID_TYPE),
+ new ToggleViewAction(this, VIEW_ID_SUPER),
+ new ToggleViewAction(this, VIEW_ID_SUB)
+ };
+
+ fDialogSettings= RubyPlugin.getDefault().getDialogSettings();
+
+ fHistoryDropDownAction= new HistoryDropDownAction(this);
+ fHistoryDropDownAction.setEnabled(false);
+
+ fToggleOrientationActions= new ToggleOrientationAction[] {
+ new ToggleOrientationAction(this, VIEW_ORIENTATION_VERTICAL),
+ new ToggleOrientationAction(this, VIEW_ORIENTATION_HORIZONTAL),
+ new ToggleOrientationAction(this, VIEW_ORIENTATION_AUTOMATIC),
+ new ToggleOrientationAction(this, VIEW_ORIENTATION_SINGLE)
+ };
+
+ fEnableMemberFilterAction= new EnableMemberFilterAction(this, false);
+ fShowQualifiedTypeNamesAction= new ShowQualifiedTypeNamesAction(this, false);
+
+ fFocusOnTypeAction= new FocusOnTypeAction(this);
+
+ fPaneLabelProvider= new RubyUILabelProvider();
+
+ fFocusOnSelectionAction= new FocusOnSelectionAction(this);
+
+ fPartListener= new IPartListener2() {
+ public void partVisible(IWorkbenchPartReference ref) {
+ IWorkbenchPart part= ref.getPart(false);
+ if (part == TypeHierarchyViewPart.this) {
+ visibilityChanged(true);
+ }
+ }
+
+ public void partHidden(IWorkbenchPartReference ref) {
+ IWorkbenchPart part= ref.getPart(false);
+ if (part == TypeHierarchyViewPart.this) {
+ visibilityChanged(false);
+ }
+ }
+
+ public void partActivated(IWorkbenchPartReference ref) {
+ IWorkbenchPart part= ref.getPart(false);
+ if (part instanceof IEditorPart)
+ editorActivated((IEditorPart) part);
+ }
+
+ public void partInputChanged(IWorkbenchPartReference ref) {
+ IWorkbenchPart part= ref.getPart(false);
+ if (part instanceof IEditorPart)
+ editorActivated((IEditorPart) part);
+ }
+
+ public void partBroughtToTop(IWorkbenchPartReference ref) {}
+ public void partClosed(IWorkbenchPartReference ref) {}
+ public void partDeactivated(IWorkbenchPartReference ref) {}
+ public void partOpened(IWorkbenchPartReference ref) {}
+ };
+
+ fSelectionChangedListener= new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ doSelectionChanged(event);
+ }
+ };
+
+ fLinkingEnabled= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.LINK_TYPEHIERARCHY_TO_EDITOR);
+ }
+
+ /**
+ * Method doPropertyChange.
+ * @param event
+ */
+ protected void doPropertyChange(PropertyChangeEvent event) {
+ String property= event.getProperty();
+ if (fMethodsViewer != null) {
+ if (MembersOrderPreferenceCache.isMemberOrderProperty(event.getProperty())) {
+ fMethodsViewer.refresh();
+ }
+ }
+ if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE.equals(property)) {
+ updateHierarchyViewer(true);
+ updateTitle();
+ }
+ }
+
+ /**
+ * Adds the entry if new. Inserted at the beginning of the history entries list.
+ * @param entry The new entry
+ */
+ private void addHistoryEntry(IRubyElement entry) {
+ if (fInputHistory.contains(entry)) {
+ fInputHistory.remove(entry);
+ }
+ fInputHistory.add(0, entry);
+ fHistoryDropDownAction.setEnabled(true);
+ }
+
+ private void updateHistoryEntries() {
+ for (int i= fInputHistory.size() - 1; i >= 0; i--) {
+ IRubyElement type= (IRubyElement) fInputHistory.get(i);
+ if (!type.exists()) {
+ fInputHistory.remove(i);
+ }
+ }
+ fHistoryDropDownAction.setEnabled(!fInputHistory.isEmpty());
+ }
+
+ /**
+ * Goes to the selected entry, without updating the order of history entries.
+ * @param entry The entry to open
+ */
+ public void gotoHistoryEntry(IRubyElement entry) {
+ if (fInputHistory.contains(entry)) {
+ updateInput(entry);
+ }
+ }
+
+ /**
+ * Gets all history entries.
+ * @return All history entries
+ */
+ public IRubyElement[] getHistoryEntries() {
+ if (fInputHistory.size() > 0) {
+ updateHistoryEntries();
+ }
+ return (IRubyElement[]) fInputHistory.toArray(new IRubyElement[fInputHistory.size()]);
+ }
+
+ /**
+ * Sets the history entries
+ * @param elems The history elements to set
+ */
+ public void setHistoryEntries(IRubyElement[] elems) {
+ fInputHistory.clear();
+ for (int i= 0; i < elems.length; i++) {
+ fInputHistory.add(elems[i]);
+ }
+ updateHistoryEntries();
+ }
+
+ /**
+ * Selects an member in the methods list or in the current hierarchy.
+ * @param member The member to select
+ */
+ public void selectMember(IMember member) {
+ fSelectInEditor= false;
+ if (member.getElementType() != IRubyElement.TYPE) {
+ Control methodControl= fMethodsViewer.getControl();
+ if (methodControl != null && !methodControl.isDisposed()) {
+ methodControl.setFocus();
+ }
+
+ fMethodsViewer.setSelection(new StructuredSelection(member), true);
+ } else {
+ Control viewerControl= getCurrentViewer().getControl();
+ if (viewerControl != null && !viewerControl.isDisposed()) {
+ viewerControl.setFocus();
+ }
+
+ if (!member.equals(fSelectedType)) {
+ getCurrentViewer().setSelection(new StructuredSelection(member), true);
+ }
+ }
+ fSelectInEditor= true;
+ }
+
+ /**
+ * @return The input type
+ * @deprecated
+ */
+ public IType getInput() {
+ if (fInputElement instanceof IType) {
+ return (IType) fInputElement;
+ }
+ return null;
+ }
+
+ /**
+ * Sets the input to a new type
+ * @param type The new input type
+ * @deprecated
+ */
+ public void setInput(IType type) {
+ setInputElement(type);
+ }
+
+ /**
+ * Returns the input element of the type hierarchy.
+ * Can be of type <code>IType</code> or <code>IPackageFragment</code>
+ * @return the input element
+ */
+ public IRubyElement getInputElement() {
+ return fInputElement;
+ }
+
+
+ /**
+ * Sets the input to a new element.
+ * @param element the input element
+ */
+ public void setInputElement(IRubyElement element) {
+ IMember memberToSelect= null;
+ if (element != null) {
+ if (element instanceof IMember) {
+ if (element.getElementType() != IRubyElement.TYPE) {
+ memberToSelect= (IMember) element;
+ element= memberToSelect.getDeclaringType();
+
+ }
+ if (!element.exists()) {
+ MessageDialog.openError(getSite().getShell(), TypeHierarchyMessages.TypeHierarchyViewPart_error_title, TypeHierarchyMessages.TypeHierarchyViewPart_error_message);
+ return;
+ }
+ } else {
+ int kind= element.getElementType();
+ if (kind != IRubyElement.RUBY_PROJECT && kind != IRubyElement.SOURCE_FOLDER_ROOT && kind != IRubyElement.SOURCE_FOLDER) {
+ element= null;
+ RubyPlugin.logErrorMessage("Invalid type hierarchy input type.");//$NON-NLS-1$
+ }
+ }
+ }
+ if (element != null && !element.equals(fInputElement)) {
+ addHistoryEntry(element);
+ }
+
+ updateInput(element);
+ if (memberToSelect != null) {
+ selectMember(memberToSelect);
+ }
+ }
+
+ /*
+ * Changes the input to a new type
+ * @param inputElement
+ */
+ private void updateInput(IRubyElement inputElement) {
+ IRubyElement prevInput= fInputElement;
+
+ synchronized (this) {
+ if (fRestoreStateJob != null) {
+ fRestoreStateJob.cancel();
+ try {
+ fRestoreStateJob.join();
+ } catch (InterruptedException e) {
+ // ignore
+ } finally {
+ fRestoreStateJob= null;
+ }
+ }
+ }
+
+ // Make sure the UI got repainted before we execute a long running
+ // operation. This can be removed if we refresh the hierarchy in a
+ // separate thread.
+ // Work-araound for http://dev.eclipse.org/bugs/show_bug.cgi?id=30881
+ processOutstandingEvents();
+ if (inputElement == null) {
+ clearInput();
+ } else {
+ fInputElement= inputElement;
+ try {
+ fHierarchyLifeCycle.ensureRefreshedTypeHierarchy(inputElement, RubyPlugin.getActiveWorkbenchWindow());
+ // fHierarchyLifeCycle.ensureRefreshedTypeHierarchy(inputElement, getSite().getWorkbenchWindow());
+ } catch (InvocationTargetException e) {
+ ExceptionHandler.handle(e, getSite().getShell(), TypeHierarchyMessages.TypeHierarchyViewPart_exception_title, TypeHierarchyMessages.TypeHierarchyViewPart_exception_message);
+ clearInput();
+ return;
+ } catch (InterruptedException e) {
+ return;
+ }
+
+ if (inputElement.getElementType() != IRubyElement.TYPE) {
+ setView(VIEW_ID_TYPE);
+ }
+ // turn off member filtering
+ fSelectInEditor= false;
+ setMemberFilter(null);
+ internalSelectType(null, false); // clear selection
+ fIsEnableMemberFilter= false;
+ if (!inputElement.equals(prevInput)) {
+ updateHierarchyViewer(true);
+ }
+ IType root= getSelectableType(inputElement);
+ internalSelectType(root, true);
+ updateMethodViewer(root);
+ updateToolbarButtons();
+ updateTitle();
+ enableMemberFilter(false);
+ fPagebook.showPage(fTypeMethodsSplitter);
+ fSelectInEditor= true;
+ }
+ }
+
+ private void processOutstandingEvents() {
+ Display display= getDisplay();
+ if (display != null && !display.isDisposed())
+ display.update();
+ }
+
+ private void clearInput() {
+ fInputElement= null;
+ fHierarchyLifeCycle.freeHierarchy();
+
+ updateHierarchyViewer(false);
+ updateToolbarButtons();
+ }
+
+ /*
+ * @see IWorbenchPart#setFocus
+ */
+ public void setFocus() {
+ fPagebook.setFocus();
+ }
+
+ /*
+ * @see IWorkbenchPart#dispose
+ */
+ public void dispose() {
+ fHierarchyLifeCycle.freeHierarchy();
+ fHierarchyLifeCycle.removeChangedListener(fTypeHierarchyLifeCycleListener);
+ fPaneLabelProvider.dispose();
+
+ if (fMethodsViewer != null) {
+ fMethodsViewer.dispose();
+ }
+
+ if (fPropertyChangeListener != null) {
+ RubyPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener);
+ fPropertyChangeListener= null;
+ }
+
+ getSite().getPage().removePartListener(fPartListener);
+
+ if (fActionGroups != null)
+ fActionGroups.dispose();
+
+ if (fWorkingSetActionGroup != null) {
+ fWorkingSetActionGroup.dispose();
+ }
+
+ super.dispose();
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ public Object getAdapter(Class key) {
+ if (key == IShowInSource.class) {
+ return getShowInSource();
+ }
+ if (key == IShowInTargetList.class) {
+ return new IShowInTargetList() {
+ public String[] getShowInTargetIds() {
+ return new String[] { RubyUI.ID_RUBY_RESOURCE_VIEW, IPageLayout.ID_RES_NAV };
+ }
+
+ };
+ }
+// if (key == IContextProvider.class) {
+// return RubyUIHelp.getHelpContextProvider(this, IRubyHelpContextIds.TYPE_HIERARCHY_VIEW);
+// }
+ return super.getAdapter(key);
+ }
+
+ private Control createTypeViewerControl(Composite parent) {
+ fViewerbook= new PageBook(parent, SWT.NULL);
+
+ KeyListener keyListener= createKeyListener();
+
+ // Create the viewers
+ TypeHierarchyViewer superTypesViewer= new SuperTypeHierarchyViewer(fViewerbook, fHierarchyLifeCycle, this);
+ initializeTypesViewer(superTypesViewer, keyListener, IContextMenuConstants.TARGET_ID_SUPERTYPES_VIEW);
+
+ TypeHierarchyViewer subTypesViewer= new SubTypeHierarchyViewer(fViewerbook, fHierarchyLifeCycle, this);
+ initializeTypesViewer(subTypesViewer, keyListener, IContextMenuConstants.TARGET_ID_SUBTYPES_VIEW);
+
+ TypeHierarchyViewer vajViewer= new TraditionalHierarchyViewer(fViewerbook, fHierarchyLifeCycle, this);
+ initializeTypesViewer(vajViewer, keyListener, IContextMenuConstants.TARGET_ID_HIERARCHY_VIEW);
+
+ fAllViewers= new TypeHierarchyViewer[3];
+ fAllViewers[VIEW_ID_SUPER]= superTypesViewer;
+ fAllViewers[VIEW_ID_SUB]= subTypesViewer;
+ fAllViewers[VIEW_ID_TYPE]= vajViewer;
+
+ int currViewerIndex;
+ try {
+ currViewerIndex= fDialogSettings.getInt(DIALOGSTORE_HIERARCHYVIEW);
+ if (currViewerIndex < 0 || currViewerIndex > 2) {
+ currViewerIndex= VIEW_ID_TYPE;
+ }
+ } catch (NumberFormatException e) {
+ currViewerIndex= VIEW_ID_TYPE;
+ }
+
+ fEmptyTypesViewer= new Label(fViewerbook, SWT.TOP | SWT.LEFT | SWT.WRAP);
+
+ for (int i= 0; i < fAllViewers.length; i++) {
+ fAllViewers[i].setInput(fAllViewers[i]);
+ }
+
+ // force the update
+ fCurrentViewerIndex= -1;
+ setView(currViewerIndex);
+
+ return fViewerbook;
+ }
+
+ private KeyListener createKeyListener() {
+ return new KeyAdapter() {
+ public void keyReleased(KeyEvent event) {
+ if (event.stateMask == 0) {
+ if (event.keyCode == SWT.F5) {
+ ITypeHierarchy hierarchy= fHierarchyLifeCycle.getHierarchy();
+ if (hierarchy != null) {
+ fHierarchyLifeCycle.typeHierarchyChanged(hierarchy);
+ doTypeHierarchyChangedOnViewers(null);
+ }
+ updateHierarchyViewer(false);
+ return;
+ }
+ }
+ }
+ };
+ }
+
+
+ private void initializeTypesViewer(final TypeHierarchyViewer typesViewer, KeyListener keyListener, String cotextHelpId) {
+ typesViewer.getControl().setVisible(false);
+ typesViewer.getControl().addKeyListener(keyListener);
+ typesViewer.initContextMenu(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager menu) {
+ fillTypesViewerContextMenu(typesViewer, menu);
+ }
+ }, cotextHelpId, getSite());
+ typesViewer.addPostSelectionChangedListener(fSelectionChangedListener);
+ typesViewer.setQualifiedTypeName(isShowQualifiedTypeNames());
+ typesViewer.setWorkingSetFilter(fWorkingSetActionGroup.getWorkingSetFilter());
+ }
+
+ private Control createMethodViewerControl(Composite parent) {
+ fMethodsViewer= new MethodsViewer(parent, fHierarchyLifeCycle, this);
+ fMethodsViewer.initContextMenu(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager menu) {
+ fillMethodsViewerContextMenu(menu);
+ }
+ }, IContextMenuConstants.TARGET_ID_MEMBERS_VIEW, getSite());
+ fMethodsViewer.addPostSelectionChangedListener(fSelectionChangedListener);
+
+ Control control= fMethodsViewer.getTable();
+ control.addKeyListener(createKeyListener());
+ control.addFocusListener(new FocusListener() {
+ public void focusGained(FocusEvent e) {
+ fSelectAllAction.setEnabled(true);
+ }
+
+ public void focusLost(FocusEvent e) {
+ fSelectAllAction.setEnabled(false);
+ }
+ });
+
+ return control;
+ }
+
+ private void initDragAndDrop() {
+ for (int i= 0; i < fAllViewers.length; i++) {
+ addDragAdapters(fAllViewers[i]);
+ addDropAdapters(fAllViewers[i]);
+ }
+ addDragAdapters(fMethodsViewer);
+ fMethodsViewer.addDropSupport(DND.DROP_NONE, new Transfer[0], new DropTargetAdapter());
+
+ //DND on empty hierarchy
+ DropTarget dropTarget = new DropTarget(fPagebook, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT);
+ dropTarget.setTransfer(new Transfer[] { LocalSelectionTransfer.getInstance() });
+// dropTarget.addDropListener(new TypeHierarchyTransferDropAdapter(this, fAllViewers[0]));
+ }
+
+ private void addDropAdapters(AbstractTreeViewer viewer) {
+// Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance() };
+// int ops= DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK | DND.DROP_DEFAULT;
+//
+// TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] {
+// new TypeHierarchyTransferDropAdapter(this, viewer)
+// };
+// viewer.addDropSupport(ops, transfers, new DelegatingDropAdapter(dropListeners));
+ }
+
+ private void addDragAdapters(StructuredViewer viewer) {
+ int ops= DND.DROP_COPY | DND.DROP_LINK;
+ Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance(), ResourceTransfer.getInstance()};
+
+ TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] {
+ new SelectionTransferDragAdapter(viewer),
+ new ResourceTransferDragAdapter(viewer)
+ };
+ viewer.addDragSupport(ops, transfers, new RdtViewerDragAdapter(viewer, dragListeners));
+ }
+
+ /**
+ * Returns the inner component in a workbench part.
+ * @see IWorkbenchPart#createPartControl(Composite)
+ */
+ public void createPartControl(Composite container) {
+ fParent= container;
+ addResizeListener(container);
+
+ fPagebook= new PageBook(container, SWT.NONE);
+ fWorkingSetActionGroup= new WorkingSetFilterActionGroup(getSite(), fPropertyChangeListener);
+
+ // page 1 of page book (no hierarchy label)
+
+ fNoHierarchyShownLabel= new Label(fPagebook, SWT.TOP + SWT.LEFT + SWT.WRAP);
+ fNoHierarchyShownLabel.setText(TypeHierarchyMessages.TypeHierarchyViewPart_empty);
+
+ // page 2 of page book (viewers)
+
+ fTypeMethodsSplitter= new SashForm(fPagebook, SWT.VERTICAL);
+ fTypeMethodsSplitter.setVisible(false);
+
+ fTypeViewerViewForm= new ViewForm(fTypeMethodsSplitter, SWT.NONE);
+
+ Control typeViewerControl= createTypeViewerControl(fTypeViewerViewForm);
+ fTypeViewerViewForm.setContent(typeViewerControl);
+
+ fMethodViewerViewForm= new ViewForm(fTypeMethodsSplitter, SWT.NONE);
+ fTypeMethodsSplitter.setWeights(new int[] {35, 65});
+
+ Control methodViewerPart= createMethodViewerControl(fMethodViewerViewForm);
+ fMethodViewerViewForm.setContent(methodViewerPart);
+
+ fMethodViewerPaneLabel= new CLabel(fMethodViewerViewForm, SWT.NONE);
+ fMethodViewerViewForm.setTopLeft(fMethodViewerPaneLabel);
+
+ ToolBar methodViewerToolBar= new ToolBar(fMethodViewerViewForm, SWT.FLAT | SWT.WRAP);
+ fMethodViewerViewForm.setTopCenter(methodViewerToolBar);
+
+ initDragAndDrop();
+
+ MenuManager menu= new MenuManager();
+ menu.add(fFocusOnTypeAction);
+ fNoHierarchyShownLabel.setMenu(menu.createContextMenu(fNoHierarchyShownLabel));
+
+ fPagebook.showPage(fNoHierarchyShownLabel);
+
+ try {
+ fOrientation= fDialogSettings.getInt(DIALOGSTORE_VIEWORIENTATION);
+ if (fOrientation < 0 || fOrientation > 3) {
+ fOrientation= VIEW_ORIENTATION_VERTICAL;
+ }
+ } catch (NumberFormatException e) {
+ fOrientation= VIEW_ORIENTATION_AUTOMATIC;
+ }
+ // force the update
+ fCurrentOrientation= -1;
+ // will fill the main tool bar
+ setOrientation(fOrientation);
+
+ if (fMemento != null) { // restore state before creating action
+ restoreLinkingEnabled(fMemento);
+ }
+ fToggleLinkingAction= new ToggleLinkingAction(this);
+
+ // set the filter menu items
+ IActionBars actionBars= getViewSite().getActionBars();
+ IMenuManager viewMenu= actionBars.getMenuManager();
+ for (int i= 0; i < fViewActions.length; i++) {
+ ToggleViewAction action= f...
[truncated message content] |