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 (+119 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.IWorkbenchWindow;
22
import org.eclipse.ui.views.properties.tabbed.ISelectionConverter;
23
import org.eclipse.jdt.core.ICompilationUnit;
24
import org.eclipse.jdt.core.IJavaElement;
25
import org.eclipse.jdt.core.JavaCore;
26
import org.eclipse.jdt.core.JavaModelException;
27
import org.eclipse.jdt.internal.ui.JavaPlugin;
28
29
/**
30
 * An  implementation of the tabbed properties ISelectionConverter for the JavaEditor. 
31
 * It takes an ISelection which from the JavaEditor will be an ITextSelection and converts
32
 * it into an IStructuredSelection containing an IJavaElement.
33
 * 
34
 * An empty StructuredSelection is returned if multiple IJavaElements are included 
35
 * in the ITextSelection 
36
 * 
37
 * @author Karen Moore
38
 */
39
public class JavaEditorSelectionConverter
40
		implements ISelectionConverter
41
	{
42
		public IStructuredSelection structuredSelection(ISelection selection) {
43
			if (selection instanceof IStructuredSelection) {
44
				return (IStructuredSelection) selection;
45
			}
46
			int offset = ((ITextSelection) selection).getOffset();
47
			int length = ((ITextSelection) selection).getLength();
48
			
49
			ICompilationUnit unit = getCompilationUnit();
50
			IJavaElement firstJavaElement = javaElementAt(offset, unit);
51
			if (firstJavaElement == null) {
52
				return StructuredSelection.EMPTY;
53
			}
54
			for (int i = offset+1; i < offset + length; i++) {
55
				IJavaElement nextJavaElement = javaElementAt(i, unit);
56
				if (!firstJavaElement.equals(nextJavaElement)) {
57
					return StructuredSelection.EMPTY;
58
				}
59
			}
60
			return new StructuredSelection(firstJavaElement);
61
		}
62
63
		private IJavaElement javaElementAt(int offset, ICompilationUnit compilationUnit) {
64
			IJavaElement javaElement = null;
65
			if (compilationUnit != null) {
66
				try {
67
					javaElement = compilationUnit.getElementAt(offset);
68
				} catch (JavaModelException ex) {
69
					// fall through
70
				}
71
			}
72
			return javaElement;
73
		}
74
		
75
		private ICompilationUnit getCompilationUnit() {
76
			IEditorPart editor = getActiveEditor();
77
			if (editor == null) {
78
				return null;
79
			}
80
			IEditorInput editorInput = editor.getEditorInput();
81
			if (editorInput instanceof IFileEditorInput) {
82
				IFileEditorInput fileInput = (IFileEditorInput) editorInput;
83
				IFile file = fileInput.getFile();
84
				return JavaCore.createCompilationUnitFrom(file);
85
			}
86
			return null;
87
		}
88
		
89
		private IEditorPart getActiveEditor() {
90
			IWorkbenchWindow activeWorkbenchWindow = JavaPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
91
			if (activeWorkbenchWindow == null) {
92
				return null;
93
			}
94
			IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
95
			if (activePage == null) {
96
				return null;
97
			}
98
			return activePage.getActiveEditor();
99
		}
100
101
//	
102
//		public IJpaFile persistenceFileFor(IEditorInput input) {
103
//			IFile file = null;
104
//			if (input instanceof IFileEditorInput) {
105
//				IFileEditorInput fileInput = (IFileEditorInput) input;
106
//				file = fileInput.getFile();
107
//			}
108
//			else if (input instanceof IClassFileEditorInput) {
109
//				IClassFileEditorInput classFileEditorInput = (IClassFileEditorInput) input;
110
//				IClassFile classFile = classFileEditorInput.getClassFile();
111
//				classFile.getResource();
112
//				
113
//			}
114
//			if (file == null) {
115
//				return null;
116
//			}
117
//			return JpaCorePlugin.getJpaFile(file);
118
//		}
119
	}

Return to bug 154781