Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2002-11-13 10:43:19 +0000
committerDani Megert2002-11-13 10:43:19 +0000
commitbe83b0f1cbfb62ffb0a7ef1c87d8fc324e183e79 (patch)
tree9dd7091a7f55fb1f2b8c3ee0a4c8f206164906eb
parenta667d93d52dd0e296e3b405e64ab29dbbc0c6c72 (diff)
downloadeclipse.jdt.ui-be83b0f1cbfb62ffb0a7ef1c87d8fc324e183e79.tar.gz
eclipse.jdt.ui-be83b0f1cbfb62ffb0a7ef1c87d8fc324e183e79.tar.xz
eclipse.jdt.ui-be83b0f1cbfb62ffb0a7ef1c87d8fc324e183e79.zip
- Moved preference keys to JavaEditor
- Separate non-preference code from JavaEditorHoverConfigurationBlock
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java57
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorHoverConfigurationBlock.java153
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorPreferencePage.java18
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaEditorTextHoverDescriptor.java (renamed from org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorTextHoverDescriptor.java)127
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaEditorTextHoverProxy.java24
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaTextHover.java12
-rw-r--r--org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/JavaSourceViewerConfiguration.java8
7 files changed, 213 insertions, 186 deletions
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java
index ef966cab83..baf2334261 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaEditor.java
@@ -17,6 +17,9 @@ import java.util.Iterator;
import java.util.List;
import java.util.ResourceBundle;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BidiSegmentEvent;
import org.eclipse.swt.custom.BidiSegmentListener;
@@ -42,9 +45,6 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
@@ -120,6 +120,7 @@ import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.IContextMenuConstants;
import org.eclipse.jdt.ui.IWorkingCopyManager;
import org.eclipse.jdt.ui.PreferenceConstants;
+
import org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds;
import org.eclipse.jdt.ui.actions.JavaSearchActionGroup;
import org.eclipse.jdt.ui.actions.OpenEditorActionGroup;
@@ -131,9 +132,10 @@ import org.eclipse.jdt.ui.text.JavaTextTools;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.JavaPlugin;
+
import org.eclipse.jdt.internal.ui.actions.CompositeActionGroup;
import org.eclipse.jdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.jdt.internal.ui.preferences.JavaEditorHoverConfigurationBlock;
+
import org.eclipse.jdt.internal.ui.preferences.JavaEditorPreferencePage;
import org.eclipse.jdt.internal.ui.text.HTMLTextPresenter;
import org.eclipse.jdt.internal.ui.text.JavaPartitionScanner;
@@ -232,8 +234,8 @@ public abstract class JavaEditor extends StatusTextEditor implements IViewPartIn
IDocument document= sourceViewer.getDocument();
if (document != null)
- document.addDocumentListener(this);
-
+ document.addDocumentListener(this);
+
text.addKeyListener(this);
text.addMouseListener(this);
text.addMouseMoveListener(this);
@@ -485,6 +487,7 @@ public abstract class JavaEditor extends StatusTextEditor implements IViewPartIn
if (fDefaultCursor == null)
fDefaultCursor= new Cursor(display, SWT.CURSOR_IBEAM);
text.setCursor(fDefaultCursor);
+
if (fCursor != null) {
fCursor.dispose();
fCursor= null;
@@ -505,7 +508,7 @@ public abstract class JavaEditor extends StatusTextEditor implements IViewPartIn
deactivate();
return;
}
-
+
fActive= true;
ISourceViewer viewer= getSourceViewer();
@@ -515,7 +518,7 @@ public abstract class JavaEditor extends StatusTextEditor implements IViewPartIn
IRegion region= getCurrentTextRegion(viewer);
if (region == null)
return;
-
+
// removed for #25871
// highlightRegion(viewer, region);
// activateCursor(viewer);
@@ -541,7 +544,7 @@ public abstract class JavaEditor extends StatusTextEditor implements IViewPartIn
* @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
*/
public void mouseDown(MouseEvent event) {
-
+
if (!fActive)
return;
@@ -865,7 +868,28 @@ public abstract class JavaEditor extends StatusTextEditor implements IViewPartIn
public final static String LINE_NUMBER_COLOR= "lineNumberColor"; //$NON-NLS-1$
/** Preference key for the link color */
public final static String LINK_COLOR= "linkColor"; //$NON-NLS-1$
-
+
+ /** Preference key for the default hover */
+ public static final String DEFAULT_HOVER= "defaultHover"; //$NON-NLS-1$
+ /** Preference key for hover while no modifier is pressed */
+ public static final String NONE_HOVER= "noneHover"; //$NON-NLS-1$
+ /** Preference key for hover while Ctrl modifier is pressed */
+ public static final String CTRL_HOVER= "ctrlHover"; //$NON-NLS-1$
+ /** Preference key for hover while Shift modifier is pressed */
+ public static final String SHIFT_HOVER= "shiftHover"; //$NON-NLS-1$
+ /** Preference key for hover while Ctrl+Alt modifiers are pressed */
+ public static final String CTRL_ALT_HOVER= "ctrlAltHover"; //$NON-NLS-1$
+ /** Preference key for hover while Ctrl+Alt+Shift modifiers are pressed */
+ public static final String CTRL_ALT_SHIFT_HOVER= "ctrlAltShiftHover"; //$NON-NLS-1$
+ /** Preference key for hover while Ctrl+Shift modifiers are pressed */
+ public static final String CTRL_SHIFT_HOVER= "ctrlShiftHover"; //$NON-NLS-1$
+ /** Preference key for hover while Alt+Shift modifiers are pressed */
+ public static final String ALT_SHIFT_HOVER= "altShiftHover"; //$NON-NLS-1$
+ /** Id indicating no hover is configured */
+ public static final String NO_HOVER_CONFIGURED_ID= "noHoverConfiguredId"; //$NON-NLS-1$
+ /** Hover id indicating the default hover */
+ public static final String DEFAULT_HOVER_CONFIGURED_ID= "defaultHoverConfiguredId"; //$NON-NLS-1$
+
/** The outline page */
protected JavaOutlinePage fOutlinePage;
/** Outliner context menu Id */
@@ -1388,7 +1412,7 @@ public abstract class JavaEditor extends StatusTextEditor implements IViewPartIn
updateHoverBehavior();
}
- if (JavaEditorHoverConfigurationBlock.isAffectedBy(property)) {
+ if (isJavaEditorHoverProperty(property)) {
updateHoverBehavior();
}
@@ -1396,6 +1420,17 @@ public abstract class JavaEditor extends StatusTextEditor implements IViewPartIn
super.handlePreferenceStoreChanged(event);
}
}
+
+ private boolean isJavaEditorHoverProperty(String property) {
+ return JavaEditor.DEFAULT_HOVER.equals(property)
+ || JavaEditor.NONE_HOVER.equals(property)
+ || JavaEditor.CTRL_HOVER.equals(property)
+ || JavaEditor.SHIFT_HOVER.equals(property)
+ || JavaEditor.CTRL_ALT_HOVER.equals(property)
+ || JavaEditor.CTRL_SHIFT_HOVER.equals(property)
+ || JavaEditor.CTRL_ALT_SHIFT_HOVER.equals(property)
+ || JavaEditor.ALT_SHIFT_HOVER.equals(property);
+ }
/**
* Shows the line number ruler column.
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorHoverConfigurationBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorHoverConfigurationBlock.java
index 529afa5f44..95740b0ca9 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorHoverConfigurationBlock.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorHoverConfigurationBlock.java
@@ -42,35 +42,26 @@ import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaUIMessages;
+import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
+import org.eclipse.jdt.internal.ui.text.java.hover.*;
+import org.eclipse.jdt.internal.ui.text.java.hover.JavaSourceHover;
+import org.eclipse.jdt.internal.ui.text.java.hover.JavaTextHover;
+
/**
* Configures Java Editor hover preferences.
*
* @since 2.1
*/
-public class JavaEditorHoverConfigurationBlock {
+class JavaEditorHoverConfigurationBlock {
- private final static String NO_HOVER_CONFIGURED_ID= "noHoverConfiguredId"; //$NON-NLS-1$
private final static int NO_HOVER_CONFIGURED_INDEX= -1;
- private final static String DEFAULT_HOVER_CONFIGURED_ID= "defaultHoverConfiguredId"; //$NON-NLS-1$
private final static int DEFAULT_HOVER_CONFIGURED_INDEX= -2;
private final static String MODIFIER= "modifier"; //$NON-NLS-1$
private final static String HOVER= "hover"; //$NON-NLS-1$
- // Preference store constants
- final static String JAVA_EDITOR_HOVER= "JavaEditorHoverConfigurationBlock"; //$NON-NLS-1$
- final static String DEFAULT_HOVER= JAVA_EDITOR_HOVER + ".defaultHover"; //$NON-NLS-1$
- final static String NONE_HOVER= JAVA_EDITOR_HOVER + ".noneHover"; //$NON-NLS-1$
- final static String CTRL_HOVER= JAVA_EDITOR_HOVER + "ctrlHover"; //$NON-NLS-1$
- final static String SHIFT_HOVER= JAVA_EDITOR_HOVER + ".shiftHover"; //$NON-NLS-1$
- final static String CTRL_ALT_HOVER= JAVA_EDITOR_HOVER + "ctrlAltHover"; //$NON-NLS-1$
- final static String CTRL_ALT_SHIFT_HOVER= JAVA_EDITOR_HOVER + "ctrlAltShiftHover"; //$NON-NLS-1$
- final static String CTRL_SHIFT_HOVER= JAVA_EDITOR_HOVER + ".ctrlShiftHover"; //$NON-NLS-1$
- final static String ALT_SHIFT_HOVER= JAVA_EDITOR_HOVER + ".altShiftHover"; //$NON-NLS-1$
-
private static class HoverConfig {
@@ -83,9 +74,9 @@ public class JavaEditorHoverConfigurationBlock {
fModifier= modifier;
fStateMask= stateMask;
- if (NO_HOVER_CONFIGURED_ID.equals(hoverId))
+ if (JavaEditor.NO_HOVER_CONFIGURED_ID.equals(hoverId))
setHoverIndex(NO_HOVER_CONFIGURED_INDEX);
- else if (DEFAULT_HOVER_CONFIGURED_ID.equals(hoverId))
+ else if (JavaEditor.DEFAULT_HOVER_CONFIGURED_ID.equals(hoverId))
setHoverIndex(DEFAULT_HOVER_CONFIGURED_INDEX);
else {
// Find index
@@ -106,9 +97,9 @@ public class JavaEditorHoverConfigurationBlock {
private void setHoverIndex(int hoverIndex) {
fHoverIndex= hoverIndex;
if (hoverIndex == NO_HOVER_CONFIGURED_INDEX)
- fHoverId= NO_HOVER_CONFIGURED_ID;
+ fHoverId= JavaEditor.NO_HOVER_CONFIGURED_ID;
else if (hoverIndex == DEFAULT_HOVER_CONFIGURED_INDEX)
- fHoverId= DEFAULT_HOVER_CONFIGURED_ID;
+ fHoverId= JavaEditor.DEFAULT_HOVER_CONFIGURED_ID;
else if (hoverIndex >= 0 && hoverIndex < getContributedHovers().size())
fHoverId= ((JavaEditorTextHoverDescriptor)getContributedHovers().get(hoverIndex)).getId();
else
@@ -201,9 +192,6 @@ public class JavaEditorHoverConfigurationBlock {
}
- private static List fgContributedHovers;
- private static String fgDefaultHoverId;
-
private IPreferenceStore fStore;
private HoverConfig[] fHoverConfigs;
private TableViewer fTableViewer;
@@ -213,78 +201,8 @@ public class JavaEditorHoverConfigurationBlock {
fStore= store;
}
- public static JavaEditorTextHoverDescriptor getTextHoverDescriptor(int stateMask) {
- String key= null;
- switch (stateMask) {
- case ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK:
- key= DEFAULT_HOVER;
- break;
- case SWT.NONE:
- key= NONE_HOVER;
- break;
- case SWT.CTRL:
- key= CTRL_HOVER;
- break;
- case SWT.SHIFT:
- key= SHIFT_HOVER;
- break;
- case SWT.CTRL | SWT.ALT:
- key= CTRL_ALT_HOVER;
- break;
- case SWT.CTRL | SWT.SHIFT:
- key= CTRL_SHIFT_HOVER;
- break;
- case SWT.CTRL | SWT.ALT | SWT.SHIFT:
- key= CTRL_ALT_SHIFT_HOVER;
- break;
- case SWT.ALT | SWT.SHIFT:
- key= ALT_SHIFT_HOVER;
- break;
- default :
- return null;
- }
- String id= JavaPlugin.getDefault().getPreferenceStore().getString(key);
- if (DEFAULT_HOVER_CONFIGURED_ID.equals(id))
- id= JavaPlugin.getDefault().getPreferenceStore().getString(DEFAULT_HOVER);
- if (id == null)
- return null;
-
- Iterator iter= getContributedHovers().iterator();
- while (iter.hasNext()) {
- JavaEditorTextHoverDescriptor hoverDescriptor= (JavaEditorTextHoverDescriptor)iter.next();
- if (id.equals(hoverDescriptor.getId()))
- return hoverDescriptor;
- }
- return null;
- }
-
- public static boolean isDefaultTextHoverDescriptor(JavaEditorTextHoverDescriptor descriptor) {
- return (descriptor != null && descriptor.getId().equals(getDefaultHoverId()))
- || (descriptor == null && getDefaultHoverId().equals(NO_HOVER_CONFIGURED_ID));
- }
-
- public static String getDefaultHoverId() {
- if (fgDefaultHoverId == null)
- fgDefaultHoverId= JavaPlugin.getDefault().getPreferenceStore().getString(DEFAULT_HOVER);
-
- return fgDefaultHoverId;
- }
-
private static List getContributedHovers() {
- if (fgContributedHovers == null)
- fgContributedHovers= JavaEditorTextHoverDescriptor.getContributedHovers();
- return fgContributedHovers;
- }
-
- public static boolean isAffectedBy(String property) {
- return DEFAULT_HOVER.equals(property)
- || NONE_HOVER.equals(property)
- || CTRL_HOVER.equals(property)
- || SHIFT_HOVER.equals(property)
- || CTRL_ALT_HOVER.equals(property)
- || CTRL_SHIFT_HOVER.equals(property)
- || CTRL_ALT_SHIFT_HOVER.equals(property)
- || ALT_SHIFT_HOVER.equals(property);
+ return JavaEditorTextHoverDescriptor.getContributedHovers();
}
/**
@@ -362,28 +280,28 @@ public class JavaEditorHoverConfigurationBlock {
fHoverConfigs= new HoverConfig[8];
String label= JavaUIMessages.getString("JavaEditorHoverConfigurationBlock.defaultHover"); //$NON-NLS-1$
- fHoverConfigs[0]= new HoverConfig(label, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK, fStore.getString(DEFAULT_HOVER));
+ fHoverConfigs[0]= new HoverConfig(label, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK, fStore.getString(JavaEditor.DEFAULT_HOVER));
label= JavaUIMessages.getString("JavaEditorHoverConfigurationBlock.modifier.none"); //$NON-NLS-1$
- fHoverConfigs[1]= new HoverConfig(label, SWT.NONE, fStore.getString(NONE_HOVER));
+ fHoverConfigs[1]= new HoverConfig(label, SWT.NONE, fStore.getString(JavaEditor.NONE_HOVER));
label= JavaUIMessages.getString("JavaEditorHoverConfigurationBlock.modifier.ctrl"); //$NON-NLS-1$
- fHoverConfigs[2]= new HoverConfig(label, SWT.CTRL, fStore.getString(CTRL_HOVER));
+ fHoverConfigs[2]= new HoverConfig(label, SWT.CTRL, fStore.getString(JavaEditor.CTRL_HOVER));
label= JavaUIMessages.getString("JavaEditorHoverConfigurationBlock.modifier.shift"); //$NON-NLS-1$
- fHoverConfigs[3]= new HoverConfig(label, SWT.SHIFT, fStore.getString(SHIFT_HOVER));
+ fHoverConfigs[3]= new HoverConfig(label, SWT.SHIFT, fStore.getString(JavaEditor.SHIFT_HOVER));
label= JavaUIMessages.getString("JavaEditorHoverConfigurationBlock.modifier.ctrlShift"); //$NON-NLS-1$
- fHoverConfigs[4]= new HoverConfig(label, SWT.CTRL | SWT.SHIFT, fStore.getString(CTRL_SHIFT_HOVER));
+ fHoverConfigs[4]= new HoverConfig(label, SWT.CTRL | SWT.SHIFT, fStore.getString(JavaEditor.CTRL_SHIFT_HOVER));
label= JavaUIMessages.getString("JavaEditorHoverConfigurationBlock.modifier.ctrlAlt"); //$NON-NLS-1$
- fHoverConfigs[5]= new HoverConfig(label, SWT.CTRL | SWT.ALT, fStore.getString(CTRL_ALT_HOVER));
+ fHoverConfigs[5]= new HoverConfig(label, SWT.CTRL | SWT.ALT, fStore.getString(JavaEditor.CTRL_ALT_HOVER));
label= JavaUIMessages.getString("JavaEditorHoverConfigurationBlock.modifier.altShift"); //$NON-NLS-1$
- fHoverConfigs[6]= new HoverConfig(label, SWT.ALT | SWT.SHIFT, fStore.getString(ALT_SHIFT_HOVER));
+ fHoverConfigs[6]= new HoverConfig(label, SWT.ALT | SWT.SHIFT, fStore.getString(JavaEditor.ALT_SHIFT_HOVER));
label= JavaUIMessages.getString("JavaEditorHoverConfigurationBlock.modifier.ctrlAltShift"); //$NON-NLS-1$
- fHoverConfigs[7]= new HoverConfig(label, SWT.CTRL | SWT.ALT | SWT.SHIFT, fStore.getString(CTRL_ALT_SHIFT_HOVER));
+ fHoverConfigs[7]= new HoverConfig(label, SWT.CTRL | SWT.ALT | SWT.SHIFT, fStore.getString(JavaEditor.CTRL_ALT_SHIFT_HOVER));
fTableViewer.setInput(fHoverConfigs);
}
@@ -393,26 +311,25 @@ public class JavaEditorHoverConfigurationBlock {
}
void performOk() {
- fStore.setValue(DEFAULT_HOVER, fHoverConfigs[0].fHoverId);
- fgDefaultHoverId= fHoverConfigs[0].fHoverId;
- fStore.setValue(NONE_HOVER, fHoverConfigs[1].fHoverId);
- fStore.setValue(CTRL_HOVER, fHoverConfigs[2].fHoverId);
- fStore.setValue(SHIFT_HOVER, fHoverConfigs[3].fHoverId);
- fStore.setValue(CTRL_SHIFT_HOVER, fHoverConfigs[4].fHoverId);
- fStore.setValue(CTRL_ALT_HOVER, fHoverConfigs[5].fHoverId);
- fStore.setValue(ALT_SHIFT_HOVER, fHoverConfigs[6].fHoverId);
- fStore.setValue(CTRL_ALT_SHIFT_HOVER, fHoverConfigs[7].fHoverId);
+ fStore.setValue(JavaEditor.DEFAULT_HOVER, fHoverConfigs[0].fHoverId);
+ fStore.setValue(JavaEditor.NONE_HOVER, fHoverConfigs[1].fHoverId);
+ fStore.setValue(JavaEditor.CTRL_HOVER, fHoverConfigs[2].fHoverId);
+ fStore.setValue(JavaEditor.SHIFT_HOVER, fHoverConfigs[3].fHoverId);
+ fStore.setValue(JavaEditor.CTRL_SHIFT_HOVER, fHoverConfigs[4].fHoverId);
+ fStore.setValue(JavaEditor.CTRL_ALT_HOVER, fHoverConfigs[5].fHoverId);
+ fStore.setValue(JavaEditor.ALT_SHIFT_HOVER, fHoverConfigs[6].fHoverId);
+ fStore.setValue(JavaEditor.CTRL_ALT_SHIFT_HOVER, fHoverConfigs[7].fHoverId);
}
static void initDefaults(IPreferenceStore store) {
- store.setDefault(DEFAULT_HOVER, "org.eclipse.jdt.internal.ui.text.java.hover.JavaTextHover"); //$NON-NLS-1$
- store.setDefault(NONE_HOVER, DEFAULT_HOVER_CONFIGURED_ID);
- store.setDefault(CTRL_HOVER, "org.eclipse.jdt.internal.ui.text.java.hover.JavaSourceHover"); //$NON-NLS-1$
- store.setDefault(SHIFT_HOVER, DEFAULT_HOVER_CONFIGURED_ID);
- store.setDefault(CTRL_SHIFT_HOVER, DEFAULT_HOVER_CONFIGURED_ID);
- store.setDefault(CTRL_ALT_HOVER, DEFAULT_HOVER_CONFIGURED_ID);
- store.setDefault(ALT_SHIFT_HOVER, DEFAULT_HOVER_CONFIGURED_ID);
- store.setDefault(CTRL_ALT_SHIFT_HOVER, DEFAULT_HOVER_CONFIGURED_ID);
+ store.setDefault(JavaEditor.DEFAULT_HOVER, JavaTextHover.ID);
+ store.setDefault(JavaEditor.NONE_HOVER, JavaEditor.DEFAULT_HOVER_CONFIGURED_ID);
+ store.setDefault(JavaEditor.CTRL_HOVER, JavaSourceHover.ID);
+ store.setDefault(JavaEditor.SHIFT_HOVER, JavaEditor.DEFAULT_HOVER_CONFIGURED_ID);
+ store.setDefault(JavaEditor.CTRL_SHIFT_HOVER, JavaEditor.DEFAULT_HOVER_CONFIGURED_ID);
+ store.setDefault(JavaEditor.CTRL_ALT_HOVER, JavaEditor.DEFAULT_HOVER_CONFIGURED_ID);
+ store.setDefault(JavaEditor.ALT_SHIFT_HOVER, JavaEditor.DEFAULT_HOVER_CONFIGURED_ID);
+ store.setDefault(JavaEditor.CTRL_ALT_SHIFT_HOVER, JavaEditor.DEFAULT_HOVER_CONFIGURED_ID);
}
/**
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorPreferencePage.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorPreferencePage.java
index 3c2e4299a3..f9fc31faf3 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorPreferencePage.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorPreferencePage.java
@@ -207,15 +207,15 @@ public class JavaEditorPreferencePage extends PreferencePage implements IWorkben
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractTextEditor.PREFERENCE_NAVIGATION_SMART_HOME_END),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, JavaEditorHoverConfigurationBlock.DEFAULT_HOVER),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, JavaEditorHoverConfigurationBlock.NONE_HOVER),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, JavaEditorHoverConfigurationBlock.CTRL_HOVER),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, JavaEditorHoverConfigurationBlock.SHIFT_HOVER),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, JavaEditorHoverConfigurationBlock.CTRL_SHIFT_HOVER),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, JavaEditorHoverConfigurationBlock.CTRL_ALT_HOVER),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, JavaEditorHoverConfigurationBlock.CTRL_ALT_SHIFT_HOVER),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, JavaEditorHoverConfigurationBlock.CTRL_SHIFT_HOVER),
- new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, JavaEditorHoverConfigurationBlock.ALT_SHIFT_HOVER),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, JavaEditor.DEFAULT_HOVER),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, JavaEditor.NONE_HOVER),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, JavaEditor.CTRL_HOVER),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, JavaEditor.SHIFT_HOVER),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, JavaEditor.CTRL_SHIFT_HOVER),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, JavaEditor.CTRL_ALT_HOVER),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, JavaEditor.CTRL_ALT_SHIFT_HOVER),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, JavaEditor.CTRL_SHIFT_HOVER),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, JavaEditor.ALT_SHIFT_HOVER),
};
private final String[][] fSyntaxColorListModel= new String[][] {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorTextHoverDescriptor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaEditorTextHoverDescriptor.java
index 1a07a76ebe..e8e75c2a79 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorTextHoverDescriptor.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaEditorTextHoverDescriptor.java
@@ -9,11 +9,12 @@ Contributors:
IBM Corporation - Initial implementation
**********************************************************************/
-package org.eclipse.jdt.internal.ui.preferences;
+package org.eclipse.jdt.internal.ui.text.java.hover;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
@@ -25,15 +26,22 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
+import org.eclipse.swt.SWT;
+
import org.eclipse.jface.text.Assert;
+import org.eclipse.jface.text.ITextViewerExtension2;
import org.eclipse.jdt.ui.text.java.hover.IJavaEditorTextHover;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaUIMessages;
+import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
+
/**
* Describes a Java editor text hover.
+ *
+ * @since 2.1
*/
public class JavaEditorTextHoverDescriptor implements Comparable {
@@ -42,9 +50,76 @@ public class JavaEditorTextHoverDescriptor implements Comparable {
private static final String ID_ATTRIBUTE= "id"; //$NON-NLS-1$
private static final String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$
private static final String LABEL_ATTRIBUTE= "label"; //$NON-NLS-1$
+ private static final String ACTIVATE_PLUG_IN_ATTRIBUTE= "label"; //$NON-NLS-1$
- private IConfigurationElement fElement;
+ private static List fgContributedHovers;
+
+ private IConfigurationElement fElement;
+
+ /**
+ * Returns all Java editor text hovers contributed to the workbench.
+ */
+ public static List getContributedHovers() {
+ if (fgContributedHovers == null) {
+ IPluginRegistry registry= Platform.getPluginRegistry();
+ IConfigurationElement[] elements= registry.getConfigurationElementsFor(JAVA_EDITOR_TEXT_HOVER_EXTENSION_POINT);
+ fgContributedHovers= createDescriptors(elements);
+ }
+ return fgContributedHovers;
+ }
+
+ /**
+ * Returns the id of the configured default hover. */
+ public static String getDefaultHoverId() {
+ return JavaPlugin.getDefault().getPreferenceStore().getString(JavaEditor.DEFAULT_HOVER);
+ }
+
+ public static JavaEditorTextHoverDescriptor getTextHoverDescriptor(int stateMask) {
+ String key= null;
+ switch (stateMask) {
+ case ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK:
+ key= JavaEditor.DEFAULT_HOVER;
+ break;
+ case SWT.NONE:
+ key= JavaEditor.NONE_HOVER;
+ break;
+ case SWT.CTRL:
+ key= JavaEditor.CTRL_HOVER;
+ break;
+ case SWT.SHIFT:
+ key= JavaEditor.SHIFT_HOVER;
+ break;
+ case SWT.CTRL | SWT.ALT:
+ key= JavaEditor.CTRL_ALT_HOVER;
+ break;
+ case SWT.CTRL | SWT.SHIFT:
+ key= JavaEditor.CTRL_SHIFT_HOVER;
+ break;
+ case SWT.CTRL | SWT.ALT | SWT.SHIFT:
+ key= JavaEditor.CTRL_ALT_SHIFT_HOVER;
+ break;
+ case SWT.ALT | SWT.SHIFT:
+ key= JavaEditor.ALT_SHIFT_HOVER;
+ break;
+ default :
+ return null;
+ }
+ String id= JavaPlugin.getDefault().getPreferenceStore().getString(key);
+ if (JavaEditor.DEFAULT_HOVER_CONFIGURED_ID.equals(id))
+ id= JavaPlugin.getDefault().getPreferenceStore().getString(JavaEditor.DEFAULT_HOVER);
+ if (id == null)
+ return null;
+
+ Iterator iter= getContributedHovers().iterator();
+ while (iter.hasNext()) {
+ JavaEditorTextHoverDescriptor hoverDescriptor= (JavaEditorTextHoverDescriptor)iter.next();
+ if (id.equals(hoverDescriptor.getId()))
+ return hoverDescriptor;
+ }
+ return null;
+ }
+
/**
* Creates a new Java Editor text hover descriptor from the given configuration element.
*/
@@ -57,10 +132,13 @@ public class JavaEditorTextHoverDescriptor implements Comparable {
* Creates the Java editor text hover.
*/
public IJavaEditorTextHover createTextHover() {
- try {
- return (IJavaEditorTextHover)fElement.createExecutableExtension(CLASS_ATTRIBUTE);
- } catch (CoreException x) {
- JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), 0, JavaUIMessages.getString("JavaTextHover.createTextHover"), null)); //$NON-NLS-1$
+ boolean isHoversPlugInActivated= fElement.getDeclaringExtension().getDeclaringPluginDescriptor().isPluginActivated();
+ if (isHoversPlugInActivated || canActivatePlugIn()) {
+ try {
+ return (IJavaEditorTextHover)fElement.createExecutableExtension(CLASS_ATTRIBUTE);
+ } catch (CoreException x) {
+ JavaPlugin.log(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), 0, JavaUIMessages.getString("JavaTextHover.createTextHover"), null)); //$NON-NLS-1$
+ }
}
return null;
@@ -99,26 +177,12 @@ public class JavaEditorTextHoverDescriptor implements Comparable {
return label;
}
- /**
- * Returns all Java editor text hovers contributed to the workbench.
- */
- public static List getContributedHovers() {
- IPluginRegistry registry= Platform.getPluginRegistry();
- IConfigurationElement[] elements= registry.getConfigurationElementsFor(JAVA_EDITOR_TEXT_HOVER_EXTENSION_POINT);
- return createDescriptors(elements);
- }
+ public boolean canActivatePlugIn() {
+ return Boolean.valueOf(fElement.getAttribute(ACTIVATE_PLUG_IN_ATTRIBUTE)).booleanValue();
+ }
- private static List createDescriptors(IConfigurationElement[] elements) {
- List result= new ArrayList(5);
- for (int i= 0; i < elements.length; i++) {
- IConfigurationElement element= elements[i];
- if (HOVER_TAG.equals(element.getName())) {
- JavaEditorTextHoverDescriptor desc= new JavaEditorTextHoverDescriptor(element);
- result.add(desc);
- }
- }
- Collections.sort(result);
- return result;
+ public boolean isDefaultTextHoverDescriptor() {
+ return getId().equals(getDefaultHoverId());
}
public boolean equals(Object obj) {
@@ -167,4 +231,17 @@ public class JavaEditorTextHoverDescriptor implements Comparable {
return false;
}
+
+ private static List createDescriptors(IConfigurationElement[] elements) {
+ List result= new ArrayList(5);
+ for (int i= 0; i < elements.length; i++) {
+ IConfigurationElement element= elements[i];
+ if (HOVER_TAG.equals(element.getName())) {
+ JavaEditorTextHoverDescriptor desc= new JavaEditorTextHoverDescriptor(element);
+ result.add(desc);
+ }
+ }
+ Collections.sort(result);
+ return result;
+ }
} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaEditorTextHoverProxy.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaEditorTextHoverProxy.java
index cd26c76fca..f741c37c22 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaEditorTextHoverProxy.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaEditorTextHoverProxy.java
@@ -27,7 +27,6 @@ import org.eclipse.jdt.ui.text.java.hover.IJavaEditorTextHover;
import org.eclipse.jdt.internal.ui.JavaPlugin;
-import org.eclipse.jdt.internal.ui.preferences.JavaEditorTextHoverDescriptor;
/**
* Proxy for JavaEditorTextHovers.
@@ -37,6 +36,7 @@ import org.eclipse.jdt.internal.ui.preferences.JavaEditorTextHoverDescriptor;
public class JavaEditorTextHoverProxy extends AbstractJavaEditorTextHover {
+ // XXX: Can be removed if we decide we don't want enabling and disabling of hovers
class ListenerRemover implements IPartListener {
void dispose() {
@@ -70,6 +70,7 @@ public class JavaEditorTextHoverProxy extends AbstractJavaEditorTextHover {
};
+ // XXX: Can be removed if we decide we don't want enabling and disabling of hovers
class EnableStateUpdater implements IPropertyChangeListener {
/*
* @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
@@ -109,6 +110,7 @@ public class JavaEditorTextHoverProxy extends AbstractJavaEditorTextHover {
if (fHover != null)
fHover.setEditor(getEditor());
+// XXX: Can be removed if we decide we don't want enabling and disabling of hovers
// if (fEditor != null) {
// fListenerRemover= new ListenerRemover();
// IWorkbenchWindow window= fEditor.getSite().getWorkbenchWindow();
@@ -126,16 +128,6 @@ public class JavaEditorTextHoverProxy extends AbstractJavaEditorTextHover {
return true;
}
- private boolean isCreated() {
- return fHover != null;
- }
-
- private boolean createHover() {
- fHover= fHoverDescriptor.createTextHover();
- fHover.setEditor(getEditor());
- return isCreated();
- }
-
/*
* @see ITextHover#getHoverRegion(ITextViewer, int)
*/
@@ -167,4 +159,14 @@ public class JavaEditorTextHoverProxy extends AbstractJavaEditorTextHover {
}
+ private boolean isCreated() {
+ return fHover != null;
+ }
+
+ private boolean createHover() {
+ fHover= fHoverDescriptor.createTextHover();
+ if (fHover != null)
+ fHover.setEditor(getEditor());
+ return isCreated();
+ }
} \ No newline at end of file
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaTextHover.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaTextHover.java
index eb39e202ea..b72118ec1b 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaTextHover.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaTextHover.java
@@ -19,7 +19,6 @@ import org.eclipse.ui.IEditorPart;
import org.eclipse.jdt.ui.text.java.hover.IJavaEditorTextHover;
-import org.eclipse.jdt.internal.ui.preferences.JavaEditorTextHoverDescriptor;
/**
@@ -27,7 +26,7 @@ import org.eclipse.jdt.internal.ui.preferences.JavaEditorTextHoverDescriptor;
*/
public class JavaTextHover extends AbstractJavaEditorTextHover {
- private static String ID= "org.eclipse.jdt.internal.ui.text.java.hover.JavaTextHover"; //$NON-NLS-1$
+ public static final String ID= "org.eclipse.jdt.internal.ui.text.java.hover.JavaTextHover"; //$NON-NLS-1$
private static class JavaEditorTextHoverDescriptorComparator implements Comparator {
@@ -94,26 +93,23 @@ public class JavaTextHover extends AbstractJavaEditorTextHover {
if (!ID.equals(descriptor.getId()))
fTextHoverSpecifications.add(descriptor);
}
-
Collections.sort(fTextHoverSpecifications, new JavaEditorTextHoverDescriptorComparator());
}
-
private void checkTextHovers() {
if (fTextHoverSpecifications.size() == 0)
return;
- for (Iterator iterator= fTextHoverSpecifications.iterator(); iterator.hasNext(); ) {
+ for (Iterator iterator= new ArrayList(fTextHoverSpecifications).iterator(); iterator.hasNext(); ) {
JavaEditorTextHoverDescriptor spec= (JavaEditorTextHoverDescriptor) iterator.next();
IJavaEditorTextHover hover= spec.createTextHover();
if (hover != null) {
hover.setEditor(getEditor());
- addTextHover(hover);
+ addTextHover(hover);
+ fTextHoverSpecifications.remove(spec);
}
}
-
- fTextHoverSpecifications.clear();
}
protected void addTextHover(ITextHover hover) {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/JavaSourceViewerConfiguration.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/JavaSourceViewerConfiguration.java
index f0cf108c47..f577e8c1a1 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/JavaSourceViewerConfiguration.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/text/JavaSourceViewerConfiguration.java
@@ -54,8 +54,7 @@ import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.internal.ui.JavaPlugin;
-import org.eclipse.jdt.internal.ui.preferences.JavaEditorHoverConfigurationBlock;
-import org.eclipse.jdt.internal.ui.preferences.JavaEditorTextHoverDescriptor;
+import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
import org.eclipse.jdt.internal.ui.text.ContentAssistPreference;
import org.eclipse.jdt.internal.ui.text.HTMLTextPresenter;
import org.eclipse.jdt.internal.ui.text.JavaAnnotationHover;
@@ -68,6 +67,7 @@ import org.eclipse.jdt.internal.ui.text.java.JavaFormattingStrategy;
import org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy;
import org.eclipse.jdt.internal.ui.text.java.JavaStringAutoIndentStrategy;
import org.eclipse.jdt.internal.ui.text.java.JavaStringDoubleClickSelector;
+import org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverDescriptor;
import org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy;
import org.eclipse.jdt.internal.ui.text.java.hover.JavaInformationProvider;
import org.eclipse.jdt.internal.ui.text.javadoc.JavaDocAutoIndentStrategy;
@@ -362,11 +362,11 @@ public class JavaSourceViewerConfiguration extends SourceViewerConfiguration {
if (!enabled)
return null;
- JavaEditorTextHoverDescriptor descriptor= JavaEditorHoverConfigurationBlock.getTextHoverDescriptor(stateMask);
+ JavaEditorTextHoverDescriptor descriptor= JavaEditorTextHoverDescriptor.getTextHoverDescriptor(stateMask);
if (stateMask != ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK) {
// Ensure that no additional instance is created for default hover
- if (JavaEditorHoverConfigurationBlock.isDefaultTextHoverDescriptor(descriptor))
+ if ((descriptor == null && JavaEditorTextHoverDescriptor.getDefaultHoverId().equals(JavaEditor.NO_HOVER_CONFIGURED_ID)) ||(descriptor != null && descriptor.isDefaultTextHoverDescriptor()))
return null; // use default hover instance
}

Back to the top