Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 32802 Details for
Bug 123198
add parameterized commands to open/show java elements
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
revised patch - specifies categoryId for commands
java-commands-patch2.txt (text/plain), 12.93 KB, created by
Christopher Daly
on 2006-01-10 17:43:11 EST
(
hide
)
Description:
revised patch - specifies categoryId for commands
Filename:
MIME Type:
Creator:
Christopher Daly
Created:
2006-01-10 17:43:11 EST
Size:
12.93 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.ui >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/plugin.properties,v >retrieving revision 1.368 >diff -u -r1.368 plugin.properties >--- plugin.properties 19 Dec 2005 14:31:36 -0000 1.368 >+++ plugin.properties 10 Jan 2006 22:37:58 -0000 >@@ -930,6 +930,17 @@ > ViewCommand.callHierarchy.name= Java Call Hierarchy > ViewCommand.callHierarchy.description= Show the Call Hierarchy view > >+#--- Commands for surfacing java elements >+command.openElementInEditor.name= Open Java Element >+command.openElementInEditor.desc= Open a Java element in its editor >+commandParameter.openElementInEditor.elementHandleId.name= Java element handle identifier >+command.showElementInPackageView.name= Show Java Element in Package Explorer >+command.showElementInPackageView.desc= Select Java element in the Package Explorer view >+commandParameter.showElementInPackageView.elementHandleId.name= Java element handle identifier >+command.showElementInTypeHierarchyView.name= Show Java Element Type Hierarchy >+command.showElementInTypeHierarchyView.desc= Show a Java element in the Type Hierarchy view >+commandParameter.showElementInTypeHierarchyView.elementHandleId.name= Java element handle identifier >+ > #--- Call Hierarchy > callHierarchyViewName=Call Hierarchy > >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/plugin.xml,v >retrieving revision 1.590 >diff -u -r1.590 plugin.xml >--- plugin.xml 23 Dec 2005 14:39:11 -0000 1.590 >+++ plugin.xml 10 Jan 2006 22:38:03 -0000 >@@ -312,6 +312,51 @@ > </command> > </extension> > >+ <!-- commands to surface java elements given handle id encoded parameter --> >+ <extension >+ point="org.eclipse.ui.commands"> >+ <commandParameterType >+ converter="org.eclipse.jdt.internal.ui.commands.JavaElementHandleIdentifierConverter" >+ id="org.eclipse.jdt.ui.commands.javaElementHandleIdentifier" >+ type="org.eclipse.jdt.core.IJavaElement"/> >+ <command >+ categoryId="org.eclipse.ui.category.navigate" >+ defaultHandler="org.eclipse.jdt.internal.ui.commands.OpenElementInEditorHandler" >+ description="%command.openElementInEditor.desc" >+ id="org.eclipse.jdt.ui.commands.openElementInEditor" >+ name="%command.openElementInEditor.name"> >+ <commandParameter >+ id="elementHandleId" >+ name="%commandParameter.openElementInEditor.elementHandleId.name" >+ optional="false" >+ typeId="org.eclipse.jdt.ui.commands.javaElementHandleIdentifier"/> >+ </command> >+ <command >+ categoryId="org.eclipse.ui.category.navigate" >+ defaultHandler="org.eclipse.jdt.internal.ui.commands.ShowElementInPackageViewHandler" >+ description="%command.showElementInPackageView.desc" >+ id="org.eclipse.jdt.ui.commands.showElementInPackageView" >+ name="%command.showElementInPackageView.name"> >+ <commandParameter >+ id="elementHandleId" >+ name="%commandParameter.showElementInPackageView.elementHandleId.name" >+ optional="false" >+ typeId="org.eclipse.jdt.ui.commands.javaElementHandleIdentifier"/> >+ </command> >+ <command >+ categoryId="org.eclipse.ui.category.navigate" >+ defaultHandler="org.eclipse.jdt.internal.ui.commands.ShowElementInTypeHierarchyViewHandler" >+ description="%command.showElementInTypeHierarchyView.desc" >+ id="org.eclipse.jdt.ui.commands.showElementInTypeHierarchyView" >+ name="%command.showElementInTypeHierarchyView.name"> >+ <commandParameter >+ id="elementHandleId" >+ name="%commandParameter.showElementInTypeHierarchyView.elementHandleId.name" >+ optional="false" >+ typeId="org.eclipse.jdt.ui.commands.javaElementHandleIdentifier"/> >+ </command> >+ </extension> >+ > <!-- Note: Do not change the sequence of those hover contributions --> > <extension > point="org.eclipse.jdt.ui.javaEditorTextHovers"> >Index: ui/org/eclipse/jdt/internal/ui/commands/ShowElementInPackageViewHandler.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/ui/commands/ShowElementInPackageViewHandler.java >diff -N ui/org/eclipse/jdt/internal/ui/commands/ShowElementInPackageViewHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/ui/commands/ShowElementInPackageViewHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,42 @@ >+/******************************************************************************* >+ * Copyright (c) 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.eclipse.jdt.internal.ui.commands; >+ >+import org.eclipse.core.commands.AbstractHandler; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+ >+import org.eclipse.jdt.core.IJavaElement; >+ >+import org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart; >+ >+/** >+ * A command handler to show a java element in the package view. >+ * >+ * @since 3.2 >+ */ >+public class ShowElementInPackageViewHandler extends AbstractHandler { >+ >+ private static final String PARAM_ID_ELEMENT_HANDLE_ID = "elementHandleId"; //$NON-NLS-1$ >+ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ >+ IJavaElement javaElement = (IJavaElement) event >+ .getObjectParameterForExecution(PARAM_ID_ELEMENT_HANDLE_ID); >+ >+ PackageExplorerPart view = PackageExplorerPart >+ .openInActivePerspective(); >+ view.tryToReveal(javaElement); >+ >+ return null; >+ } >+ >+} >Index: ui/org/eclipse/jdt/internal/ui/commands/JavaElementHandleIdentifierConverter.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/ui/commands/JavaElementHandleIdentifierConverter.java >diff -N ui/org/eclipse/jdt/internal/ui/commands/JavaElementHandleIdentifierConverter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/ui/commands/JavaElementHandleIdentifierConverter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,52 @@ >+/******************************************************************************* >+ * Copyright (c) 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.eclipse.jdt.internal.ui.commands; >+ >+import org.eclipse.core.commands.AbstractParameterValueConverter; >+import org.eclipse.core.commands.ParameterValueConversionException; >+ >+import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.JavaCore; >+ >+/** >+ * A command parameter value converter to convert between Java elements and >+ * their handle identifiers. >+ * >+ * @since 3.2 >+ */ >+public class JavaElementHandleIdentifierConverter extends AbstractParameterValueConverter { >+ >+ public Object convertToObject(String parameterValue) >+ throws ParameterValueConversionException { >+ >+ IJavaElement javaElement = JavaCore.create(parameterValue); >+ >+ if ((javaElement != null) && javaElement.exists()) { >+ return javaElement; >+ } >+ >+ throw new ParameterValueConversionException( >+ "parameterValue must be the handle identifier to an existing IJavaElement"); //$NON-NLS-1$ >+ } >+ >+ public String convertToString(Object parameterValue) >+ throws ParameterValueConversionException { >+ >+ if (parameterValue instanceof IJavaElement) { >+ IJavaElement javaElement = (IJavaElement) parameterValue; >+ return javaElement.getHandleIdentifier(); >+ } >+ >+ throw new ParameterValueConversionException( >+ "parameterValue must be an IJavaElement"); //$NON-NLS-1$ >+ } >+ >+} >Index: ui/org/eclipse/jdt/internal/ui/commands/OpenElementInEditorHandler.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/ui/commands/OpenElementInEditorHandler.java >diff -N ui/org/eclipse/jdt/internal/ui/commands/OpenElementInEditorHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/ui/commands/OpenElementInEditorHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,53 @@ >+/******************************************************************************* >+ * Copyright (c) 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.eclipse.jdt.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.IEditorPart; >+import org.eclipse.ui.PartInitException; >+ >+import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.JavaModelException; >+ >+import org.eclipse.jdt.ui.JavaUI; >+ >+/** >+ * A command handler to open a java element in its editor. >+ * >+ * @since 3.2 >+ */ >+public class OpenElementInEditorHandler extends AbstractHandler { >+ >+ private static final String PARAM_ID_ELEMENT_HANDLE_ID = "elementHandleId"; //$NON-NLS-1$ >+ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ >+ IJavaElement javaElement = (IJavaElement) event >+ .getObjectParameterForExecution(PARAM_ID_ELEMENT_HANDLE_ID); >+ >+ try { >+ IEditorPart editorPart = JavaUI.openInEditor(javaElement); >+ JavaUI.revealInEditor(editorPart, javaElement); >+ } catch (JavaModelException ex) { >+ throw new ExecutionException( >+ "Error opening java element in editor", ex); //$NON-NLS-1$ >+ } catch (PartInitException ex) { >+ throw new ExecutionException( >+ "Error opening java element in editor", ex); //$NON-NLS-1$ >+ } >+ >+ return null; >+ } >+ >+} >Index: ui/org/eclipse/jdt/internal/ui/commands/ShowElementInTypeHierarchyViewHandler.java >=================================================================== >RCS file: ui/org/eclipse/jdt/internal/ui/commands/ShowElementInTypeHierarchyViewHandler.java >diff -N ui/org/eclipse/jdt/internal/ui/commands/ShowElementInTypeHierarchyViewHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ ui/org/eclipse/jdt/internal/ui/commands/ShowElementInTypeHierarchyViewHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,54 @@ >+/******************************************************************************* >+ * Copyright (c) 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.eclipse.jdt.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.IWorkbench; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.PlatformUI; >+ >+import org.eclipse.jdt.core.IJavaElement; >+ >+import org.eclipse.jdt.internal.ui.util.OpenTypeHierarchyUtil; >+ >+/** >+ * A command handler to show a java element in the type hierarchy view. >+ * >+ * @since 3.2 >+ */ >+public class ShowElementInTypeHierarchyViewHandler extends AbstractHandler { >+ >+ private static final String PARAM_ID_ELEMENT_HANDLE_ID = "elementHandleId"; //$NON-NLS-1$ >+ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ >+ IWorkbenchWindow window = getWorkbenchWindow(); >+ if (window == null) >+ return null; >+ >+ IJavaElement javaElement = (IJavaElement) event >+ .getObjectParameterForExecution(PARAM_ID_ELEMENT_HANDLE_ID); >+ >+ OpenTypeHierarchyUtil.open(javaElement, window); >+ >+ return null; >+ } >+ >+ private IWorkbenchWindow getWorkbenchWindow() { >+ IWorkbench workbench = PlatformUI.getWorkbench(); >+ IWorkbenchWindow activeWindow = workbench.getActiveWorkbenchWindow(); >+ return activeWindow; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 123198
:
32742
|
32802
|
33451