View | Details | Raw Unified | Return to bug 154781 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.properties (+2 lines)
Lines 1014-1016 Link Here
1014
1014
1015
#--- Work in Progress
1015
#--- Work in Progress
1016
contentAssistAdvancedName= Advanced
1016
contentAssistAdvancedName= Advanced
1017
1018
JavaPropertiesTab=Java
(-)plugin.xml (+26 lines)
Lines 5479-5483 Link Here
5479
	         </selectionEnablement>
5479
	         </selectionEnablement>
5480
      	</linkHelper>          
5480
      	</linkHelper>          
5481
 </extension>
5481
 </extension>
5482
 <extension
5483
       point="org.eclipse.ui.views.properties.tabbed.propertyContributor">
5484
    <propertyContributor
5485
          contributorId="javaEditor"
5486
          selectionConverter="org.eclipse.jdt.internal.ui.javaeditor.JavaEditorSelectionConverter">
5487
       <propertyCategory category="java"/>
5488
    </propertyContributor>
5489
 </extension>
5490
   <extension point="org.eclipse.ui.views.properties.tabbed.propertyTabs">
5491
      <propertyTabs contributorId="javaEditor">
5492
         <propertyTab
5493
            category="java"
5494
               id="javaEditor.JavaTab"
5495
            label="%JavaPropertiesTab"/>
5496
      </propertyTabs>
5497
   </extension>
5498
   <extension point="org.eclipse.ui.views.properties.tabbed.propertySections">
5499
      <propertySections contributorId="javaEditor">
5500
         <propertySection
5501
               class="org.eclipse.ui.views.properties.tabbed.AdvancedPropertySection"
5502
               id="javaEditor.AdvancedSection"
5503
               tab="javaEditor.JavaTab">
5504
            <input type="org.eclipse.jdt.core.IJavaElement"/>
5505
         </propertySection>
5506
      </propertySections>
5507
   </extension>
5482
     
5508
     
5483
</plugin>
5509
</plugin>
(-)META-INF/MANIFEST.MF (-1 / +2 lines)
Lines 127-133 Link Here
127
 org.eclipse.ltk.ui.refactoring;bundle-version="[3.3.0,4.0.0)",
127
 org.eclipse.ltk.ui.refactoring;bundle-version="[3.3.0,4.0.0)",
128
 org.eclipse.ui.forms;bundle-version="[3.2.0,4.0.0)",
128
 org.eclipse.ui.forms;bundle-version="[3.2.0,4.0.0)",
129
 org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)",
129
 org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)",
130
 org.eclipse.jdt.core.manipulation;bundle-version="[1.1.0,2.0.0)"
130
 org.eclipse.jdt.core.manipulation;bundle-version="[1.1.0,2.0.0)",
131
 org.eclipse.ui.views.properties.tabbed;bundle-version="[3.2.0,4.0.0)"
131
Eclipse-LazyStart: true
132
Eclipse-LazyStart: true
132
Plugin-Class: org.eclipse.jdt.internal.ui.JavaPlugin
133
Plugin-Class: org.eclipse.jdt.internal.ui.JavaPlugin
133
Import-Package: com.ibm.icu.text
134
Import-Package: com.ibm.icu.text
(-)ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java (+15 lines)
Lines 155-160 Link Here
155
155
156
import org.eclipse.ui.views.contentoutline.ContentOutline;
156
import org.eclipse.ui.views.contentoutline.ContentOutline;
157
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
157
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
158
import org.eclipse.ui.views.properties.IPropertySheetPage;
159
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
160
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
158
161
159
import org.eclipse.jdt.core.IClassFile;
162
import org.eclipse.jdt.core.IClassFile;
160
import org.eclipse.jdt.core.ICompilationUnit;
163
import org.eclipse.jdt.core.ICompilationUnit;
Lines 2036-2045 Link Here
2036
2039
2037
		if (required == IContextProvider.class)
2040
		if (required == IContextProvider.class)
2038
			return JavaUIHelp.getHelpContextProvider(this, IJavaHelpContextIds.JAVA_EDITOR);
2041
			return JavaUIHelp.getHelpContextProvider(this, IJavaHelpContextIds.JAVA_EDITOR);
2042
		
2043
		if (required == IPropertySheetPage.class) {
2044
			return new TabbedPropertySheetPage(buildTabbedPropertySheetPageContributor());
2045
		}
2039
2046
2040
		return super.getAdapter(required);
2047
		return super.getAdapter(required);
2041
	}
2048
	}
2042
2049
2050
	private ITabbedPropertySheetPageContributor buildTabbedPropertySheetPageContributor() {
2051
		return new ITabbedPropertySheetPageContributor() {
2052
			public String getContributorId() {
2053
				return "javaEditor"; //$NON-NLS-1$
2054
			}
2055
		};
2056
	}
2057
	
2043
	/**
2058
	/**
2044
	 * React to changed selection.
2059
	 * React to changed selection.
2045
	 *
2060
	 *
(-)ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditorSelectionConverter.java (+109 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 Oracle. All rights reserved.
3
 * This program and the accompanying materials are made available under the terms of
4
 * the Eclipse Public License v1.0, which accompanies this distribution and is available at
5
 * http://www.eclipse.org/legal/epl-v10.html.
6
 * 
7
 * Contributors:
8
 *     Oracle - initial API and implementation
9
 ******************************************************************************/
10
package org.eclipse.jdt.internal.ui.javaeditor;
11
12
import org.eclipse.core.resources.IFile;
13
import org.eclipse.jface.viewers.ISelection;
14
import org.eclipse.jface.viewers.IStructuredSelection;
15
import org.eclipse.jface.viewers.StructuredSelection;
16
import org.eclipse.jface.text.ITextSelection;
17
import org.eclipse.ui.IEditorInput;
18
import org.eclipse.ui.IEditorPart;
19
import org.eclipse.ui.IFileEditorInput;
20
import org.eclipse.ui.IWorkbenchPage;
21
import org.eclipse.ui.views.properties.tabbed.ISelectionConverter;
22
import org.eclipse.jdt.core.IClassFile;
23
import org.eclipse.jdt.core.ICompilationUnit;
24
import org.eclipse.jdt.core.IJavaElement;
25
import org.eclipse.jdt.core.ISourceRange;
26
import org.eclipse.jdt.core.ISourceReference;
27
import org.eclipse.jdt.core.JavaCore;
28
import org.eclipse.jdt.core.JavaModelException;
29
import org.eclipse.jdt.internal.ui.JavaPlugin;
30
import org.eclipse.jdt.internal.ui.actions.SelectionConverter;
31
32
/**
33
 * An  implementation of the tabbed properties ISelectionConverter for the JavaEditor. 
34
 * It takes an ISelection which from the JavaEditor will be an ITextSelection and converts
35
 * it into an IStructuredSelection containing an IJavaElement.
36
 * 
37
 * 
38
 * @author Karen Moore
39
 */
40
public class JavaEditorSelectionConverter
41
		implements ISelectionConverter
42
{
43
	public IStructuredSelection structuredSelection(ISelection selection) {
44
		if (selection instanceof IStructuredSelection) {
45
			return (IStructuredSelection) selection;
46
		}
47
		
48
		int length = ((ITextSelection) selection).getLength();
49
		IJavaElement javaElement = getJavaElementAt(((ITextSelection) selection));
50
		
51
		if (javaElement == null) {
52
			return StructuredSelection.EMPTY;
53
		}
54
		if (javaElement instanceof ISourceReference) {
55
			//make sure only one JavaElement is in the selection.  Compare its length
56
			//to the length of the selection.
57
			ISourceRange range = null;
58
			try {
59
				range = ((ISourceReference) javaElement).getSourceRange();
60
			}
61
			catch (JavaModelException e) {
62
				JavaPlugin.log(e);
63
			}
64
			if (length > range.getLength()) {
65
				return StructuredSelection.EMPTY;
66
			}
67
		}
68
69
		return new StructuredSelection(javaElement);
70
	}
71
72
	
73
	private IJavaElement getJavaElementAt(ITextSelection textSelection) {
74
		IEditorPart editor = getActiveEditor();
75
		if (editor == null) {
76
			return null;
77
		}
78
		IEditorInput editorInput = editor.getEditorInput();
79
		if (editorInput instanceof IFileEditorInput) {
80
			IFile file = ((IFileEditorInput) editorInput).getFile();
81
			ICompilationUnit unit = JavaCore.createCompilationUnitFrom(file);
82
			try {
83
				return SelectionConverter.getElementAtOffset(unit, textSelection);
84
			}
85
			catch (JavaModelException e) {
86
				JavaPlugin.log(e);
87
			}
88
		}
89
		else if (editorInput instanceof IClassFileEditorInput) {
90
			IClassFile classFile = ((IClassFileEditorInput)editorInput).getClassFile();
91
			int offset = textSelection.getOffset();
92
			try {
93
				return classFile.getElementAt(offset);
94
			}
95
			catch (JavaModelException e) {
96
				JavaPlugin.log(e);
97
			}
98
		}
99
		return null;
100
	}
101
	
102
	private IEditorPart getActiveEditor() {
103
		IWorkbenchPage activePage = JavaPlugin.getActivePage();
104
		if (activePage == null) {
105
			return null;
106
		}
107
		return activePage.getActiveEditor();
108
	}
109
}

Return to bug 154781