Lines 33-38
Link Here
|
33 |
import org.eclipse.core.runtime.preferences.IEclipsePreferences; |
33 |
import org.eclipse.core.runtime.preferences.IEclipsePreferences; |
34 |
import org.eclipse.core.runtime.preferences.IScopeContext; |
34 |
import org.eclipse.core.runtime.preferences.IScopeContext; |
35 |
|
35 |
|
|
|
36 |
import org.eclipse.core.resources.IFile; |
36 |
import org.eclipse.core.resources.IResource; |
37 |
import org.eclipse.core.resources.IResource; |
37 |
import org.eclipse.core.resources.ProjectScope; |
38 |
import org.eclipse.core.resources.ProjectScope; |
38 |
|
39 |
|
Lines 117-122
Link Here
|
117 |
|
118 |
|
118 |
import org.eclipse.ui.IEditorInput; |
119 |
import org.eclipse.ui.IEditorInput; |
119 |
import org.eclipse.ui.IEditorPart; |
120 |
import org.eclipse.ui.IEditorPart; |
|
|
121 |
import org.eclipse.ui.IFileEditorInput; |
120 |
import org.eclipse.ui.IPageLayout; |
122 |
import org.eclipse.ui.IPageLayout; |
121 |
import org.eclipse.ui.IPartListener2; |
123 |
import org.eclipse.ui.IPartListener2; |
122 |
import org.eclipse.ui.IPartService; |
124 |
import org.eclipse.ui.IPartService; |
Lines 155-160
Link Here
|
155 |
|
157 |
|
156 |
import org.eclipse.ui.views.contentoutline.ContentOutline; |
158 |
import org.eclipse.ui.views.contentoutline.ContentOutline; |
157 |
import org.eclipse.ui.views.contentoutline.IContentOutlinePage; |
159 |
import org.eclipse.ui.views.contentoutline.IContentOutlinePage; |
|
|
160 |
import org.eclipse.ui.views.properties.IPropertySheetPage; |
161 |
import org.eclipse.ui.views.properties.tabbed.IStructuredSelectionProvider; |
162 |
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor; |
163 |
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; |
158 |
|
164 |
|
159 |
import org.eclipse.jdt.core.IClassFile; |
165 |
import org.eclipse.jdt.core.IClassFile; |
160 |
import org.eclipse.jdt.core.ICompilationUnit; |
166 |
import org.eclipse.jdt.core.ICompilationUnit; |
Lines 1552-1557
Link Here
|
1552 |
public void partInputChanged(IWorkbenchPartReference partRef) {} |
1558 |
public void partInputChanged(IWorkbenchPartReference partRef) {} |
1553 |
} |
1559 |
} |
1554 |
|
1560 |
|
|
|
1561 |
public static class StructuredSelectionProvider |
1562 |
implements IStructuredSelectionProvider |
1563 |
{ |
1564 |
public IStructuredSelection structuredSelection(ISelection selection) { |
1565 |
if (selection instanceof IStructuredSelection) { |
1566 |
return (IStructuredSelection) selection; |
1567 |
} |
1568 |
int offset = ((ITextSelection) selection).getOffset(); |
1569 |
|
1570 |
ICompilationUnit unit = getCompilationUnit(); |
1571 |
IJavaElement javaElement = null; |
1572 |
if (unit != null) { |
1573 |
try { |
1574 |
javaElement = unit.getElementAt(offset); |
1575 |
} catch (JavaModelException ex) { |
1576 |
// fall through |
1577 |
} |
1578 |
} |
1579 |
|
1580 |
if (javaElement == null) { |
1581 |
return StructuredSelection.EMPTY; |
1582 |
} |
1583 |
return new StructuredSelection(javaElement); |
1584 |
} |
1585 |
|
1586 |
private ICompilationUnit getCompilationUnit() { |
1587 |
IEditorPart editor = getActiveEditor(); |
1588 |
if (editor == null) { |
1589 |
return null; |
1590 |
} |
1591 |
IEditorInput editorInput = editor.getEditorInput(); |
1592 |
if (editorInput instanceof IFileEditorInput) { |
1593 |
IFileEditorInput fileInput = (IFileEditorInput) editorInput; |
1594 |
IFile file = fileInput.getFile(); |
1595 |
return JavaCore.createCompilationUnitFrom(file); |
1596 |
} |
1597 |
return null; |
1598 |
} |
1599 |
|
1600 |
private IEditorPart getActiveEditor() { |
1601 |
IWorkbenchWindow activeWorkbenchWindow = JavaPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); |
1602 |
if (activeWorkbenchWindow == null) { |
1603 |
return null; |
1604 |
} |
1605 |
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage(); |
1606 |
if (activePage == null) { |
1607 |
return null; |
1608 |
} |
1609 |
return activePage.getActiveEditor(); |
1610 |
} |
1611 |
|
1612 |
// |
1613 |
// public IJpaFile persistenceFileFor(IEditorInput input) { |
1614 |
// IFile file = null; |
1615 |
// if (input instanceof IFileEditorInput) { |
1616 |
// IFileEditorInput fileInput = (IFileEditorInput) input; |
1617 |
// file = fileInput.getFile(); |
1618 |
// } |
1619 |
// else if (input instanceof IClassFileEditorInput) { |
1620 |
// IClassFileEditorInput classFileEditorInput = (IClassFileEditorInput) input; |
1621 |
// IClassFile classFile = classFileEditorInput.getClassFile(); |
1622 |
// classFile.getResource(); |
1623 |
// |
1624 |
// } |
1625 |
// if (file == null) { |
1626 |
// return null; |
1627 |
// } |
1628 |
// return JpaCorePlugin.getJpaFile(file); |
1629 |
// } |
1630 |
} |
1631 |
|
1555 |
/** Preference key for matching brackets */ |
1632 |
/** Preference key for matching brackets */ |
1556 |
protected final static String MATCHING_BRACKETS= PreferenceConstants.EDITOR_MATCHING_BRACKETS; |
1633 |
protected final static String MATCHING_BRACKETS= PreferenceConstants.EDITOR_MATCHING_BRACKETS; |
1557 |
/** Preference key for matching brackets color */ |
1634 |
/** Preference key for matching brackets color */ |
Lines 2036-2045
Link Here
|
2036 |
|
2113 |
|
2037 |
if (required == IContextProvider.class) |
2114 |
if (required == IContextProvider.class) |
2038 |
return JavaUIHelp.getHelpContextProvider(this, IJavaHelpContextIds.JAVA_EDITOR); |
2115 |
return JavaUIHelp.getHelpContextProvider(this, IJavaHelpContextIds.JAVA_EDITOR); |
|
|
2116 |
|
2117 |
if (required == IPropertySheetPage.class) { |
2118 |
return new TabbedPropertySheetPage(buildTabbedPropertySheetPageContributor()); |
2119 |
} |
2039 |
|
2120 |
|
2040 |
return super.getAdapter(required); |
2121 |
return super.getAdapter(required); |
2041 |
} |
2122 |
} |
2042 |
|
2123 |
|
|
|
2124 |
private ITabbedPropertySheetPageContributor buildTabbedPropertySheetPageContributor() { |
2125 |
return new ITabbedPropertySheetPageContributor() { |
2126 |
public String getContributorId() { |
2127 |
return "javaEditor"; //$NON-NLS-1$ |
2128 |
} |
2129 |
}; |
2130 |
} |
2131 |
|
2043 |
/** |
2132 |
/** |
2044 |
* React to changed selection. |
2133 |
* React to changed selection. |
2045 |
* |
2134 |
* |