Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.ui.workbench.texteditor')
-rw-r--r--org.eclipse.ui.workbench.texteditor/.project2
-rw-r--r--org.eclipse.ui.workbench.texteditor/plugin.xml11
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java83
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java44
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java185
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextNavigationAction.java4
6 files changed, 300 insertions, 29 deletions
diff --git a/org.eclipse.ui.workbench.texteditor/.project b/org.eclipse.ui.workbench.texteditor/.project
index ba6f6a3796a..afcc4bd52e6 100644
--- a/org.eclipse.ui.workbench.texteditor/.project
+++ b/org.eclipse.ui.workbench.texteditor/.project
@@ -4,8 +4,10 @@
<comment></comment>
<projects>
<project>org.eclipse.core.runtime.compatibility</project>
+ <project>org.eclipse.jface</project>
<project>org.eclipse.jface.text</project>
<project>org.eclipse.ui</project>
+ <project>org.eclipse.ui.workbench</project>
</projects>
<buildSpec>
<buildCommand>
diff --git a/org.eclipse.ui.workbench.texteditor/plugin.xml b/org.eclipse.ui.workbench.texteditor/plugin.xml
index 4dd2cd678b6..a2e0556bbe0 100644
--- a/org.eclipse.ui.workbench.texteditor/plugin.xml
+++ b/org.eclipse.ui.workbench.texteditor/plugin.xml
@@ -431,6 +431,17 @@
keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
keySequence="Ctrl+Shift+E">
</keyBinding>
+ <keyBinding
+ platform="gtk"
+ keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ keySequence="Ctrl+Shift+E">
+ </keyBinding>
+ <keyBinding
+ platform="gtk"
+ commandId="org.eclipse.ui.edit.text.delete.line.to.end"
+ keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ keySequence="Esc Ctrl+E">
+ </keyBinding>
<keyBinding
commandId="org.eclipse.ui.edit.findNext"
contextId="org.eclipse.ui.textEditorScope"
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java
index f5b942db778..44966115be7 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java
@@ -54,7 +54,35 @@ import org.eclipse.ui.internal.texteditor.TextEditorPlugin;
*/
public class AnnotationPreference {
- /** IDs for presentation preference attributes */
+ /* String constants for style enumeration */
+
+ /**
+ * Constant defining no decoration for the show in text style preference.
+ * @since 3.0
+ */
+ public static final String STYLE_NONE= "NONE"; //$NON-NLS-1$
+ /**
+ * Constant defining squiggly decoration for the show in text style preference.
+ * @since 3.0
+ */
+ public static final String STYLE_SQUIGGLES= "SQUIGGLES"; //$NON-NLS-1$
+ /**
+ * Constant defining box decoration for the show in text style preference.
+ * @since 3.0
+ */
+ public static final String STYLE_BOX= "BOX"; //$NON-NLS-1$
+ /**
+ * Constant defining underline decoration for the show in text style preference.
+ * @since 3.0
+ */
+ public static final String STYLE_UNDERLINE= "UNDERLINE"; //$NON-NLS-1$
+ /**
+ * Constant defining i-beam decoration for the show in text style preference.
+ * @since 3.0
+ */
+ public static final String STYLE_IBEAM= "IBEAM"; //$NON-NLS-1$
+
+ /* IDs for presentation preference attributes */
/** The image to be used for drawing in the vertical ruler. */
protected final static Object IMAGE_DESCRIPTOR= new Object();
@@ -103,6 +131,10 @@ public class AnnotationPreference {
protected final static Object SHOW_IN_NAVIGATION_DROPDOWN_KEY= new Object();
/** The value for the visibility in the next/previous drop down toolbar action. */
protected final static Object SHOW_IN_NAVIGATION_DROPDOWN_VALUE= new Object();
+ /** The preference key for the decoration style. */
+ protected final static Object TEXT_STYLE_PREFERENCE_KEY= new Object();
+ /** The value for the text decoration style. */
+ protected final static Object TEXT_STYLE_PREFERENCE_VALUE= new Object();
/**
* Array of all supported attributes.
@@ -129,7 +161,9 @@ public class AnnotationPreference {
OVERVIEW_RULER_PREFERENCE_KEY,
OVERVIEW_RULER_PREFERENCE_VALUE,
SHOW_IN_NAVIGATION_DROPDOWN_KEY,
- SHOW_IN_NAVIGATION_DROPDOWN_VALUE
+ SHOW_IN_NAVIGATION_DROPDOWN_VALUE,
+ TEXT_STYLE_PREFERENCE_KEY,
+ TEXT_STYLE_PREFERENCE_VALUE
};
/** The annotation type */
@@ -299,6 +333,7 @@ public class AnnotationPreference {
key.equals(getStringValue(OVERVIEW_RULER_PREFERENCE_KEY)) ||
key.equals(getStringValue(TEXT_PREFERENCE_KEY)) ||
key.equals(getStringValue(HIGHLIGHT_PREFERENCE_KEY)) ||
+ key.equals(getStringValue(TEXT_STYLE_PREFERENCE_KEY)) ||
key.equals(getStringValue(VERTICAL_RULER_PREFERENCE_KEY));
}
@@ -732,6 +767,50 @@ public class AnnotationPreference {
}
/**
+ * Sets the preference key for the text style property.
+ *
+ * @param key the new key
+ * @since 3.0
+ */
+ public void setTextStylePreferenceKey(String key) {
+ setValue(TEXT_STYLE_PREFERENCE_KEY, key);
+ }
+
+ /**
+ * Returns the preference key for the decoration style used when the annotation is shown in text.
+ *
+ * @return the preference key for the decoration style or <code>null</code> if the key is undefined
+ */
+ public String getTextStylePreferenceKey() {
+ return getStringValue(TEXT_STYLE_PREFERENCE_KEY);
+ }
+
+ /**
+ * Returns the value for the decoration style used when the annotation is shown in text.
+ *
+ * @return the value for the decoration style or <code>null</code> if the key is undefined
+ * @since 3.0
+ */
+ public String getTextStyleValue() {
+ return getStringValue(TEXT_STYLE_PREFERENCE_VALUE);
+ }
+
+ /**
+ * Sets the value for the text style property.
+ *
+ * @param value the new text decoration style
+ * @since 3.0
+ */
+ public void setTextStyleValue(String value) {
+ if (!STYLE_NONE.equals(value) && !STYLE_BOX.equals(value)
+ && !STYLE_IBEAM.equals(value) && !STYLE_SQUIGGLES.equals(value)
+ && !STYLE_UNDERLINE.equals(value))
+ throw new IllegalArgumentException();
+
+ setValue(TEXT_STYLE_PREFERENCE_VALUE, value);
+ }
+
+ /**
* Returns the image descriptor for the image to be drawn in the vertical ruler. The provided
* image is only used, if <code>getAnnotationImageProvider</code> returns <code>null</code>.
*
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java
index b3006225222..a78c038b92e 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java
@@ -466,13 +466,33 @@ class FindReplaceDialog extends Dialog {
fProposalPopupBackgroundColor= new Color(getShell().getDisplay(), new RGB(254, 241, 233));
fProposalPopupForegroundColor= new Color(getShell().getDisplay(), new RGB(0, 0, 0));
+ return panel;
+ }
+
+ private void ensureContentAssistantsInstalled() {
+ if (fFindFieldContentAssistant != null)
+ return;
+
fFindFieldContentAssistAdapter= new ComboContentAssistSubjectAdapter(fFindField);
fFindFieldContentAssistant= createContentAssistant(fFindField, fFindFieldContentAssistAdapter);
fReplaceFieldContentAssistAdapter= new ComboContentAssistSubjectAdapter(fReplaceField);
fReplaceFieldContentAssistant= createContentAssistant(fReplaceField, fReplaceFieldContentAssistAdapter);
+ }
+
+ private void ensureContentAssistantsUninstalled() {
+ if (fFindFieldContentAssistant == null)
+ return;
- return panel;
+ fFindFieldContentAssistant.uninstall();
+ fFindFieldContentAssistant= null;
+ fFindFieldContentAssistAdapter.uninstall();
+ fFindFieldContentAssistAdapter= null;
+ fReplaceFieldContentAssistant.uninstall();
+ fReplaceFieldContentAssistant= null;
+ fReplaceFieldContentAssistAdapter.uninstall();
+ fReplaceFieldContentAssistAdapter= null;
}
+
/**
* Creates the direction defining part of the options defining section
@@ -735,10 +755,10 @@ class FindReplaceDialog extends Dialog {
fWholeWordCheckBox.setEnabled(!newState);
updateButtonState();
storeSettings();
- fFindFieldContentAssistant.enableAutoActivation(newState);
- fFindFieldContentAssistAdapter.enableContentAssistCue(newState);
- fReplaceFieldContentAssistant.enableAutoActivation(newState);
- fReplaceFieldContentAssistAdapter.enableContentAssistCue(newState);
+ if (newState)
+ ensureContentAssistantsInstalled();
+ else
+ ensureContentAssistantsUninstalled();
}
});
fWholeWordCheckBox.setEnabled(!isRegExSearchAvailableAndChecked());
@@ -995,8 +1015,7 @@ class FindReplaceDialog extends Dialog {
if (fTarget != null && fTarget instanceof IFindReplaceTargetExtension)
((IFindReplaceTargetExtension) fTarget).endSession();
- fFindFieldContentAssistant.uninstall();
- fReplaceFieldContentAssistant.uninstall();
+ ensureContentAssistantsUninstalled();
fProposalPopupBackgroundColor.dispose();
fProposalPopupForegroundColor.dispose();
@@ -1004,8 +1023,7 @@ class FindReplaceDialog extends Dialog {
// prevent leaks
fActiveShell= null;
fTarget= null;
- fFindFieldContentAssistant= null;
- fReplaceFieldContentAssistant= null;
+
}
/**
@@ -1619,10 +1637,10 @@ class FindReplaceDialog extends Dialog {
updateButtonState();
}
- fFindFieldContentAssistant.enableAutoActivation(isRegExSearchAvailableAndChecked());
- fFindFieldContentAssistAdapter.enableContentAssistCue(isRegExSearchAvailableAndChecked());
- fReplaceFieldContentAssistant.enableAutoActivation(isRegExSearchAvailableAndChecked());
- fReplaceFieldContentAssistAdapter.enableContentAssistCue(isRegExSearchAvailableAndChecked());
+ if (isRegExSearchAvailableAndChecked())
+ ensureContentAssistantsInstalled();
+ else
+ ensureContentAssistantsUninstalled();
}
/**
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java
index 9efc6d046d2..4b060c5d5d0 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java
@@ -17,9 +17,16 @@ import java.util.Map;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
import org.eclipse.jface.text.CursorLinePainter;
import org.eclipse.jface.text.IPainter;
import org.eclipse.jface.text.ITextViewerExtension2;
@@ -32,11 +39,7 @@ import org.eclipse.jface.text.source.IOverviewRuler;
import org.eclipse.jface.text.source.ISharedTextColors;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.MatchingCharacterPainter;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.text.source.AnnotationPainter.IDrawingStrategy;
/**
* Support for source viewer decoration.
@@ -46,6 +49,114 @@ import org.eclipse.jface.util.PropertyChangeEvent;
public class SourceViewerDecorationSupport {
+ /**
+ * Underline drawing strategy.
+ *
+ * @since 3.0
+ */
+ private static final class UnderlineDrawingStrategy implements IDrawingStrategy {
+ /**
+ * {@inheritdoc}
+ */
+ public void draw(GC gc, StyledText textWidget, int offset, int length, Color color) {
+ if (gc != null) {
+
+ Point left= textWidget.getLocationAtOffset(offset);
+ Point right= textWidget.getLocationAtOffset(offset + length);
+ int y= left.y + textWidget.getLineHeight() - 1;
+
+ gc.setForeground(color);
+ gc.drawLine(left.x, y, right.x, y);
+
+ } else {
+ textWidget.redrawRange(offset, length, true);
+ }
+ }
+ }
+
+ /**
+ * Draws a box around a given range.
+ *
+ * @since 3.0
+ */
+ private static final class BoxDrawingStrategy implements IDrawingStrategy {
+ /**
+ * {@inheritdoc}
+ */
+ public void draw(GC gc, StyledText textWidget, int offset, int length, Color color) {
+ if (gc != null) {
+
+ Point left= textWidget.getLocationAtOffset(offset);
+ Point right= textWidget.getLocationAtOffset(offset + length);
+ int x1= left.x;
+ int x2= right.x - 1;
+ int y1= left.y;
+ int y2= y1 + textWidget.getLineHeight() - 1;
+
+ gc.setForeground(color);
+ gc.drawRectangle(x1, y1, x2 - x1, y2 - y1);
+
+ } else {
+ textWidget.redrawRange(offset, length, true);
+ }
+ }
+ }
+
+ /**
+ * Draws an iBeam at the given offset, the length is ignored.
+ *
+ * @since 3.0
+ */
+ private static final class IBeamStrategy implements IDrawingStrategy {
+ /**
+ * {@inheritdoc}
+ */
+ public void draw(GC gc, StyledText textWidget, int offset, int length, Color color) {
+ if (gc != null) {
+
+ Point left= textWidget.getLocationAtOffset(offset);
+ int x1= left.x;
+ int y1= left.y + 1;
+
+ gc.setForeground(color);
+ gc.drawLine(x1, y1, x1, left.y + textWidget.getLineHeight() - 2);
+
+ } else {
+ textWidget.redrawRange(offset, length, true);
+ }
+ }
+ }
+
+ /**
+ * The box drawing strategy.
+ * @since 3.0
+ */
+ private static IDrawingStrategy fgBoxStrategy= new BoxDrawingStrategy();
+
+ /**
+ * The null drawing strategy.
+ * @since 3.0
+ */
+ private static IDrawingStrategy fgNullStrategy= new AnnotationPainter.NullStrategy();
+
+ /**
+ * The underline drawing strategy.
+ * @since 3.0
+ */
+ private static IDrawingStrategy fgUnderlineStrategy= new UnderlineDrawingStrategy();
+
+ /**
+ * The iBeam drawing strategy.
+ * @since 3.0
+ */
+ private static IDrawingStrategy fgIBeamStrategy= new IBeamStrategy();
+
+ /**
+ * The squiggles drawing strategy.
+ * @since 3.0
+ */
+ private static IDrawingStrategy fgSquigglesStrategy= new AnnotationPainter.SquigglesStrategy();
+
/*
* @see IPropertyChangeListener
*/
@@ -170,7 +281,8 @@ public class SourceViewerDecorationSupport {
Iterator e= fAnnotationTypeKeyMap.keySet().iterator();
while (e.hasNext()) {
Object type= e.next();
- if (areAnnotationsShown(type))
+ Object style= getAnnotationDecorationType(type);
+ if (style != AnnotationPreference.STYLE_NONE)
showAnnotations(type, false, false);
else
hideAnnotations(type, false, false);
@@ -178,11 +290,35 @@ public class SourceViewerDecorationSupport {
showAnnotations(type, true, false);
else
hideAnnotations(type, true, false);
+
}
updateAnnotationPainter();
}
/**
+ * Returns the annotation decoration style used for the show in text preference for
+ * a given annotation type.
+ *
+ * @param type the annotation type being looked up
+ * @return the decoration style for <code>type</code>
+ * @since 3.0
+ */
+ private Object getAnnotationDecorationType(Object annotationType) {
+ if (areAnnotationsShown(annotationType) && fPreferenceStore != null) {
+ AnnotationPreference info= (AnnotationPreference) fAnnotationTypeKeyMap.get(annotationType);
+ if (info != null) {
+ String key= info.getTextStylePreferenceKey();
+ if (key != null)
+ return fPreferenceStore.getString(key);
+ else
+ // legacy
+ return AnnotationPreference.STYLE_SQUIGGLES;
+ }
+ }
+ return AnnotationPreference.STYLE_NONE;
+ }
+
+ /**
* Updates the annotation overview for all configured annotation types.
*/
public void updateOverviewDecorations() {
@@ -392,8 +528,9 @@ public class SourceViewerDecorationSupport {
return;
}
- if (info.getTextPreferenceKey().equals(p)) {
- if (areAnnotationsShown(info.getAnnotationType()))
+ if (info.getTextPreferenceKey().equals(p) || info.getTextStylePreferenceKey() != null && info.getTextStylePreferenceKey().equals(p)) {
+ Object style= getAnnotationDecorationType(info.getAnnotationType());
+ if (AnnotationPreference.STYLE_NONE != style)
showAnnotations(info.getAnnotationType(), false, true);
else
hideAnnotations(info.getAnnotationType(), false, true);
@@ -408,6 +545,12 @@ public class SourceViewerDecorationSupport {
return;
}
+ Object style= getAnnotationDecorationType(info.getAnnotationType());
+ if (style != AnnotationPreference.STYLE_NONE)
+ showAnnotations(info.getAnnotationType(), false, false);
+ else
+ hideAnnotations(info.getAnnotationType(), false, false);
+
if (info.getOverviewRulerPreferenceKey().equals(p)) {
if (isAnnotationOverviewShown(info.getAnnotationType()))
showAnnotationOverview(info.getAnnotationType());
@@ -609,7 +752,7 @@ public class SourceViewerDecorationSupport {
private void showAnnotations(Object annotationType, boolean highlighting, boolean updatePainter) {
if (fSourceViewer instanceof ITextViewerExtension2) {
if (fAnnotationPainter == null) {
- fAnnotationPainter= new AnnotationPainter(fSourceViewer, fAnnotationAccess);
+ fAnnotationPainter= createAnnotationPainter();
if (fSourceViewer instanceof ITextViewerExtension4)
((ITextViewerExtension4)fSourceViewer).addTextPresentationListener(fAnnotationPainter);
ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer;
@@ -618,8 +761,9 @@ public class SourceViewerDecorationSupport {
fAnnotationPainter.setAnnotationTypeColor(annotationType, getAnnotationTypeColor(annotationType));
if (highlighting)
fAnnotationPainter.addHighlightAnnotationType(annotationType);
- else
- fAnnotationPainter.addAnnotationType(annotationType);
+ else {
+ fAnnotationPainter.addAnnotationType(annotationType, getAnnotationDecorationType(annotationType));
+ }
if (updatePainter)
updateAnnotationPainter();
@@ -627,6 +771,24 @@ public class SourceViewerDecorationSupport {
}
/**
+ * Creates and configures the annotation painter and configures.
+ * @return an annotation painter
+ * @since 3.0
+ */
+ protected AnnotationPainter createAnnotationPainter() {
+ AnnotationPainter painter= new AnnotationPainter(fSourceViewer, fAnnotationAccess);
+
+ // TODO add extension point for drawing strategies?
+ painter.addDrawingStrategy(AnnotationPreference.STYLE_BOX, fgBoxStrategy);
+ painter.addDrawingStrategy(AnnotationPreference.STYLE_NONE, fgNullStrategy);
+ painter.addDrawingStrategy(AnnotationPreference.STYLE_SQUIGGLES, fgSquigglesStrategy);
+ painter.addDrawingStrategy(AnnotationPreference.STYLE_UNDERLINE, fgUnderlineStrategy);
+ painter.addDrawingStrategy(AnnotationPreference.STYLE_IBEAM, fgIBeamStrategy);
+
+ return painter;
+ }
+
+ /**
* Updates the annotation painter.
*/
private void updateAnnotationPainter() {
@@ -742,7 +904,6 @@ public class SourceViewerDecorationSupport {
/**
* Hides the annotation overview.
- * @param annotationType the annotation type
*/
public void hideAnnotationOverview() {
if (fOverviewRuler != null) {
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextNavigationAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextNavigationAction.java
index 4531b7d8c87..1db2b5bd48f 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextNavigationAction.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextNavigationAction.java
@@ -64,7 +64,7 @@ public class TextNavigationAction implements IAction {
* @see IAction#run()
*/
public void run() {
- Point selection= fTextWidget.getSelectionRange();
+ Point selection= fTextWidget.getSelection();
fTextWidget.invokeAction(fAction);
fireSelectionChanged(selection);
}
@@ -94,7 +94,7 @@ public class TextNavigationAction implements IAction {
* @since 3.0
*/
protected void fireSelectionChanged(Point oldSelection) {
- Point selection= fTextWidget.getSelectionRange();
+ Point selection= fTextWidget.getSelection();
if (oldSelection == null || !selection.equals(oldSelection))
doFireSelectionChanged(selection);
}

Back to the top