### 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.435 diff -u -r1.435 plugin.properties --- plugin.properties 6 Sep 2006 16:20:45 -0000 1.435 +++ plugin.properties 19 Oct 2006 14:46:08 -0000 @@ -1014,3 +1014,5 @@ #--- Work in Progress contentAssistAdvancedName= Advanced + +JavaPropertiesTab=Java Index: plugin.xml =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/plugin.xml,v retrieving revision 1.705 diff -u -r1.705 plugin.xml --- plugin.xml 6 Sep 2006 16:20:45 -0000 1.705 +++ plugin.xml 19 Oct 2006 14:46:11 -0000 @@ -5479,5 +5479,31 @@ + + + + + + + + + + + + + + + + + Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/META-INF/MANIFEST.MF,v retrieving revision 1.43 diff -u -r1.43 MANIFEST.MF --- META-INF/MANIFEST.MF 11 Sep 2006 13:19:18 -0000 1.43 +++ META-INF/MANIFEST.MF 19 Oct 2006 14:46:11 -0000 @@ -127,7 +127,8 @@ org.eclipse.ltk.ui.refactoring;bundle-version="[3.3.0,4.0.0)", org.eclipse.ui.forms;bundle-version="[3.2.0,4.0.0)", org.eclipse.ui.navigator;bundle-version="[3.2.0,4.0.0)", - org.eclipse.jdt.core.manipulation;bundle-version="[1.1.0,2.0.0)" + org.eclipse.jdt.core.manipulation;bundle-version="[1.1.0,2.0.0)", + org.eclipse.ui.views.properties.tabbed;bundle-version="[3.2.0,4.0.0)" Eclipse-LazyStart: true Plugin-Class: org.eclipse.jdt.internal.ui.JavaPlugin Import-Package: com.ibm.icu.text Index: ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java,v retrieving revision 1.409 diff -u -r1.409 JavaEditor.java --- ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java 17 Aug 2006 13:29:59 -0000 1.409 +++ ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java 19 Oct 2006 14:46:12 -0000 @@ -155,6 +155,9 @@ import org.eclipse.ui.views.contentoutline.ContentOutline; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; +import org.eclipse.ui.views.properties.IPropertySheetPage; +import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor; +import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.ICompilationUnit; @@ -2036,10 +2039,22 @@ if (required == IContextProvider.class) return JavaUIHelp.getHelpContextProvider(this, IJavaHelpContextIds.JAVA_EDITOR); + + if (required == IPropertySheetPage.class) { + return new TabbedPropertySheetPage(buildTabbedPropertySheetPageContributor()); + } return super.getAdapter(required); } + private ITabbedPropertySheetPageContributor buildTabbedPropertySheetPageContributor() { + return new ITabbedPropertySheetPageContributor() { + public String getContributorId() { + return "javaEditor"; //$NON-NLS-1$ + } + }; + } + /** * React to changed selection. * Index: ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditorSelectionConverter.java =================================================================== RCS file: ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditorSelectionConverter.java diff -N ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditorSelectionConverter.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditorSelectionConverter.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,109 @@ +/******************************************************************************* + * Copyright (c) 2006 Oracle. 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: + * Oracle - initial API and implementation + ******************************************************************************/ +package org.eclipse.jdt.internal.ui.javaeditor; + +import org.eclipse.core.resources.IFile; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.text.ITextSelection; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.views.properties.tabbed.ISelectionConverter; +import org.eclipse.jdt.core.IClassFile; +import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.core.IJavaElement; +import org.eclipse.jdt.core.ISourceRange; +import org.eclipse.jdt.core.ISourceReference; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.internal.ui.JavaPlugin; +import org.eclipse.jdt.internal.ui.actions.SelectionConverter; + +/** + * An implementation of the tabbed properties ISelectionConverter for the JavaEditor. + * It takes an ISelection which from the JavaEditor will be an ITextSelection and converts + * it into an IStructuredSelection containing an IJavaElement. + * + * + * @author Karen Moore + */ +public class JavaEditorSelectionConverter + implements ISelectionConverter +{ + public IStructuredSelection structuredSelection(ISelection selection) { + if (selection instanceof IStructuredSelection) { + return (IStructuredSelection) selection; + } + + int length = ((ITextSelection) selection).getLength(); + IJavaElement javaElement = getJavaElementAt(((ITextSelection) selection)); + + if (javaElement == null) { + return StructuredSelection.EMPTY; + } + if (javaElement instanceof ISourceReference) { + //make sure only one JavaElement is in the selection. Compare its length + //to the length of the selection. + ISourceRange range = null; + try { + range = ((ISourceReference) javaElement).getSourceRange(); + } + catch (JavaModelException e) { + JavaPlugin.log(e); + } + if (length > range.getLength()) { + return StructuredSelection.EMPTY; + } + } + + return new StructuredSelection(javaElement); + } + + + private IJavaElement getJavaElementAt(ITextSelection textSelection) { + IEditorPart editor = getActiveEditor(); + if (editor == null) { + return null; + } + IEditorInput editorInput = editor.getEditorInput(); + if (editorInput instanceof IFileEditorInput) { + IFile file = ((IFileEditorInput) editorInput).getFile(); + ICompilationUnit unit = JavaCore.createCompilationUnitFrom(file); + try { + return SelectionConverter.getElementAtOffset(unit, textSelection); + } + catch (JavaModelException e) { + JavaPlugin.log(e); + } + } + else if (editorInput instanceof IClassFileEditorInput) { + IClassFile classFile = ((IClassFileEditorInput)editorInput).getClassFile(); + int offset = textSelection.getOffset(); + try { + return classFile.getElementAt(offset); + } + catch (JavaModelException e) { + JavaPlugin.log(e); + } + } + return null; + } + + private IEditorPart getActiveEditor() { + IWorkbenchPage activePage = JavaPlugin.getActivePage(); + if (activePage == null) { + return null; + } + return activePage.getActiveEditor(); + } +}