Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 123198 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.properties (+11 lines)
Lines 930-935 Link Here
930
ViewCommand.callHierarchy.name= Java Call Hierarchy
930
ViewCommand.callHierarchy.name= Java Call Hierarchy
931
ViewCommand.callHierarchy.description= Show the Call Hierarchy view
931
ViewCommand.callHierarchy.description= Show the Call Hierarchy view
932
932
933
#--- Commands for surfacing java elements
934
command.openElementInEditor.name= Open Java Element
935
command.openElementInEditor.desc= Open a Java element in its editor
936
commandParameter.openElementInEditor.elementHandleId.name= Java element handle identifier
937
command.showElementInPackageView.name= Show Java Element in Package Explorer
938
command.showElementInPackageView.desc= Select Java element in the Package Explorer view
939
commandParameter.showElementInPackageView.elementHandleId.name= Java element handle identifier
940
command.showElementInTypeHierarchyView.name= Show Java Element Type Hierarchy
941
command.showElementInTypeHierarchyView.desc= Show a Java element in the Type Hierarchy view
942
commandParameter.showElementInTypeHierarchyView.elementHandleId.name= Java element handle identifier
943
933
#--- Call Hierarchy
944
#--- Call Hierarchy
934
callHierarchyViewName=Call Hierarchy
945
callHierarchyViewName=Call Hierarchy
935
946
(-)plugin.xml (+42 lines)
Lines 312-317 Link Here
312
		</command>
312
		</command>
313
	</extension>
313
	</extension>
314
	
314
	
315
	<!-- commands to surface java elements given handle id encoded parameter -->
316
	<extension
317
		point="org.eclipse.ui.commands">
318
		<commandParameterType
319
			converter="org.eclipse.jdt.internal.ui.commands.JavaElementHandleIdentifierConverter"
320
			id="org.eclipse.jdt.ui.commands.javaElementHandleIdentifier"
321
			type="org.eclipse.jdt.core.IJavaElement"/>
322
		<command
323
			description="%command.openElementInEditor.desc"
324
			id="org.eclipse.jdt.ui.commands.openElementInEditor"
325
			name="%command.openElementInEditor.name"
326
			defaultHandler="org.eclipse.jdt.internal.ui.commands.OpenElementInEditorHandler">
327
			<commandParameter
328
				id="elementHandleId"
329
				name="%commandParameter.openElementInEditor.elementHandleId.name"
330
				optional="false"
331
				typeId="org.eclipse.jdt.ui.commands.javaElementHandleIdentifier"/>
332
		</command>
333
		<command
334
			description="%command.showElementInPackageView.desc"
335
			id="org.eclipse.jdt.ui.commands.showElementInPackageView"
336
			name="%command.showElementInPackageView.name"
337
			defaultHandler="org.eclipse.jdt.internal.ui.commands.ShowElementInPackageViewHandler">
338
			<commandParameter
339
				id="elementHandleId"
340
				name="%commandParameter.showElementInPackageView.elementHandleId.name"
341
				optional="false"
342
				typeId="org.eclipse.jdt.ui.commands.javaElementHandleIdentifier"/>
343
		</command>
344
		<command
345
			description="%command.showElementInTypeHierarchyView.desc"
346
			id="org.eclipse.jdt.ui.commands.showElementInTypeHierarchyView"
347
			name="%command.showElementInTypeHierarchyView.name"
348
			defaultHandler="org.eclipse.jdt.internal.ui.commands.ShowElementInTypeHierarchyViewHandler">
349
			<commandParameter
350
				id="elementHandleId"
351
				name="%commandParameter.showElementInTypeHierarchyView.elementHandleId.name"
352
				optional="false"
353
				typeId="org.eclipse.jdt.ui.commands.javaElementHandleIdentifier"/>
354
		</command>
355
	</extension>
356
	
315
   <!-- Note: Do not change the sequence of those hover contributions -->
357
   <!-- Note: Do not change the sequence of those hover contributions -->
316
   <extension
358
   <extension
317
         point="org.eclipse.jdt.ui.javaEditorTextHovers">
359
         point="org.eclipse.jdt.ui.javaEditorTextHovers">
(-)ui/org/eclipse/jdt/internal/ui/commands/ShowElementInPackageViewHandler.java (+42 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.jdt.internal.ui.commands;
12
13
import org.eclipse.core.commands.AbstractHandler;
14
import org.eclipse.core.commands.ExecutionEvent;
15
import org.eclipse.core.commands.ExecutionException;
16
17
import org.eclipse.jdt.core.IJavaElement;
18
19
import org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart;
20
21
/**
22
 * A command handler to show a java element in the package view.
23
 * 
24
 * @since 3.2
25
 */
26
public class ShowElementInPackageViewHandler extends AbstractHandler {
27
28
	private static final String PARAM_ID_ELEMENT_HANDLE_ID = "elementHandleId"; //$NON-NLS-1$
29
30
	public Object execute(ExecutionEvent event) throws ExecutionException {
31
32
		IJavaElement javaElement = (IJavaElement) event
33
				.getObjectParameterForExecution(PARAM_ID_ELEMENT_HANDLE_ID);
34
35
		PackageExplorerPart view = PackageExplorerPart
36
				.openInActivePerspective();
37
		view.tryToReveal(javaElement);
38
39
		return null;
40
	}
41
42
}
(-)ui/org/eclipse/jdt/internal/ui/commands/JavaElementHandleIdentifierConverter.java (+52 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.jdt.internal.ui.commands;
12
13
import org.eclipse.core.commands.AbstractParameterValueConverter;
14
import org.eclipse.core.commands.ParameterValueConversionException;
15
16
import org.eclipse.jdt.core.IJavaElement;
17
import org.eclipse.jdt.core.JavaCore;
18
19
/**
20
 * A command parameter value converter to convert between Java elements and
21
 * their handle identifiers.
22
 * 
23
 * @since 3.2
24
 */
25
public class JavaElementHandleIdentifierConverter extends AbstractParameterValueConverter {
26
	
27
	public Object convertToObject(String parameterValue)
28
			throws ParameterValueConversionException {
29
30
		IJavaElement javaElement = JavaCore.create(parameterValue);
31
32
		if ((javaElement != null) && javaElement.exists()) {
33
			return javaElement;
34
		}
35
36
		throw new ParameterValueConversionException(
37
				"parameterValue must be the handle identifier to an existing IJavaElement"); //$NON-NLS-1$
38
	}
39
40
	public String convertToString(Object parameterValue)
41
			throws ParameterValueConversionException {
42
43
		if (parameterValue instanceof IJavaElement) {
44
			IJavaElement javaElement = (IJavaElement) parameterValue;
45
			return javaElement.getHandleIdentifier();
46
		}
47
48
		throw new ParameterValueConversionException(
49
				"parameterValue must be an IJavaElement"); //$NON-NLS-1$
50
	}
51
52
}
(-)ui/org/eclipse/jdt/internal/ui/commands/OpenElementInEditorHandler.java (+53 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.jdt.internal.ui.commands;
12
13
import org.eclipse.core.commands.AbstractHandler;
14
import org.eclipse.core.commands.ExecutionEvent;
15
import org.eclipse.core.commands.ExecutionException;
16
17
import org.eclipse.ui.IEditorPart;
18
import org.eclipse.ui.PartInitException;
19
20
import org.eclipse.jdt.core.IJavaElement;
21
import org.eclipse.jdt.core.JavaModelException;
22
23
import org.eclipse.jdt.ui.JavaUI;
24
25
/**
26
 * A command handler to open a java element in its editor.
27
 * 
28
 * @since 3.2
29
 */
30
public class OpenElementInEditorHandler extends AbstractHandler {
31
32
	private static final String PARAM_ID_ELEMENT_HANDLE_ID = "elementHandleId"; //$NON-NLS-1$
33
34
	public Object execute(ExecutionEvent event) throws ExecutionException {
35
36
		IJavaElement javaElement = (IJavaElement) event
37
				.getObjectParameterForExecution(PARAM_ID_ELEMENT_HANDLE_ID);
38
39
		try {
40
			IEditorPart editorPart = JavaUI.openInEditor(javaElement);
41
			JavaUI.revealInEditor(editorPart, javaElement);
42
		} catch (JavaModelException ex) {
43
			throw new ExecutionException(
44
					"Error opening java element in editor", ex); //$NON-NLS-1$
45
		} catch (PartInitException ex) {
46
			throw new ExecutionException(
47
					"Error opening java element in editor", ex); //$NON-NLS-1$
48
		}
49
50
		return null;
51
	}
52
53
}
(-)ui/org/eclipse/jdt/internal/ui/commands/ShowElementInTypeHierarchyViewHandler.java (+54 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
11
package org.eclipse.jdt.internal.ui.commands;
12
13
import org.eclipse.core.commands.AbstractHandler;
14
import org.eclipse.core.commands.ExecutionEvent;
15
import org.eclipse.core.commands.ExecutionException;
16
17
import org.eclipse.ui.IWorkbench;
18
import org.eclipse.ui.IWorkbenchWindow;
19
import org.eclipse.ui.PlatformUI;
20
21
import org.eclipse.jdt.core.IJavaElement;
22
23
import org.eclipse.jdt.internal.ui.util.OpenTypeHierarchyUtil;
24
25
/**
26
 * A command handler to show a java element in the type hierarchy view.
27
 * 
28
 * @since 3.2
29
 */
30
public class ShowElementInTypeHierarchyViewHandler extends AbstractHandler {
31
32
	private static final String PARAM_ID_ELEMENT_HANDLE_ID = "elementHandleId"; //$NON-NLS-1$
33
34
	public Object execute(ExecutionEvent event) throws ExecutionException {
35
36
		IWorkbenchWindow window = getWorkbenchWindow();
37
		if (window == null)
38
			return null;
39
40
		IJavaElement javaElement = (IJavaElement) event
41
				.getObjectParameterForExecution(PARAM_ID_ELEMENT_HANDLE_ID);
42
43
		OpenTypeHierarchyUtil.open(javaElement, window);
44
45
		return null;
46
	}
47
48
	private IWorkbenchWindow getWorkbenchWindow() {
49
		IWorkbench workbench = PlatformUI.getWorkbench();
50
		IWorkbenchWindow activeWindow = workbench.getActiveWorkbenchWindow();
51
		return activeWindow;
52
	}
53
54
}

Return to bug 123198