Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2003-10-20 14:36:45 +0000
committerDani Megert2003-10-20 14:36:45 +0000
commitab45c472e9dc1cde169161b9a5cccaee13ac22e2 (patch)
treee9ab8c8aa12e3f174c2d5e97b0759faac6852816
parentc859d726e8f749fdf3914ee71ab04ff303ccfaf6 (diff)
downloadeclipse.platform.text-ab45c472e9dc1cde169161b9a5cccaee13ac22e2.tar.gz
eclipse.platform.text-ab45c472e9dc1cde169161b9a5cccaee13ac22e2.tar.xz
eclipse.platform.text-ab45c472e9dc1cde169161b9a5cccaee13ac22e2.zip
Implemented feature 45124: Place incremental find status into separate status line item
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java53
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IStatusFieldExtension.java65
2 files changed, 104 insertions, 14 deletions
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java
index 3726d6b6d..a95048673 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java
@@ -20,6 +20,8 @@ import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
+import org.eclipse.jface.text.Assert;
+
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchActionConstants;
@@ -63,14 +65,35 @@ public class BasicTextEditorActionContributor extends EditorActionBarContributor
ITextEditorActionConstants.REVERT
};
+ /**
+ * Status field definition.
+ * @since 3.0
+ */
+ private static class StatusFieldDef {
+
+ private String category;
+ private String actionId;
+ private boolean visible;
+ private int widthInChars;
+
+ private StatusFieldDef(String category, String actionId, boolean visible, int widthInChars) {
+ Assert.isNotNull(category);
+ this.category= category;
+ this.actionId= actionId;
+ this.visible= visible;
+ this.widthInChars= widthInChars;
+ }
+ }
+
/**
* The status fields to be set to the editor
* @since 2.0
*/
- private final static String[][] STATUSFIELDS= {
- { ITextEditorActionConstants.STATUS_CATEGORY_ELEMENT_STATE, null },
- { ITextEditorActionConstants.STATUS_CATEGORY_INPUT_MODE, ITextEditorActionDefinitionIds.TOGGLE_OVERWRITE },
- { ITextEditorActionConstants.STATUS_CATEGORY_INPUT_POSITION, ITextEditorActionConstants.GOTO_LINE }
+ private final static StatusFieldDef[] STATUS_FIELD_DEFS= {
+ new StatusFieldDef(ITextEditorActionConstants.STATUS_CATEGORY_FIND_FIELD, null, false, EditorMessages.getString("Editor.FindIncremental.reverse.name").length() + 15), //$NON-NLS-1$
+ new StatusFieldDef(ITextEditorActionConstants.STATUS_CATEGORY_ELEMENT_STATE, null, true, StatusLineContributionItem.DEFAULT_WIDTH_IN_CHARS),
+ new StatusFieldDef(ITextEditorActionConstants.STATUS_CATEGORY_INPUT_MODE, ITextEditorActionDefinitionIds.TOGGLE_OVERWRITE, true, StatusLineContributionItem.DEFAULT_WIDTH_IN_CHARS),
+ new StatusFieldDef(ITextEditorActionConstants.STATUS_CATEGORY_INPUT_POSITION, ITextEditorActionConstants.GOTO_LINE, true, StatusLineContributionItem.DEFAULT_WIDTH_IN_CHARS)
};
/**
@@ -128,8 +151,10 @@ public class BasicTextEditorActionContributor extends EditorActionBarContributor
fGotoLine.setActionDefinitionId(ITextEditorActionDefinitionIds.LINE_GOTO);
fStatusFields= new HashMap(3);
- for (int i= 0; i < STATUSFIELDS.length; i++)
- fStatusFields.put(STATUSFIELDS[i], new StatusLineContributionItem(STATUSFIELDS[i][0]));
+ for (int i= 0; i < STATUS_FIELD_DEFS.length; i++) {
+ StatusFieldDef fieldDef= STATUS_FIELD_DEFS[i];
+ fStatusFields.put(fieldDef, new StatusLineContributionItem(fieldDef.category, fieldDef.visible, fieldDef.widthInChars));
+ }
}
/**
@@ -165,8 +190,8 @@ public class BasicTextEditorActionContributor extends EditorActionBarContributor
if (fActiveEditorPart instanceof ITextEditorExtension) {
ITextEditorExtension extension= (ITextEditorExtension) fActiveEditorPart;
- for (int i= 0; i < STATUSFIELDS.length; i++)
- extension.setStatusField(null, STATUSFIELDS[i][0]);
+ for (int i= 0; i < STATUS_FIELD_DEFS.length; i++)
+ extension.setStatusField(null, STATUS_FIELD_DEFS[i].category);
}
fActiveEditorPart= part;
@@ -184,12 +209,12 @@ public class BasicTextEditorActionContributor extends EditorActionBarContributor
fIncrementalFindReverse.setAction(getAction(editor, ITextEditorActionConstants.FIND_INCREMENTAL_REVERSE));
fGotoLine.setAction(getAction(editor, ITextEditorActionConstants.GOTO_LINE));
- for (int i= 0; i < STATUSFIELDS.length; i++) {
- StatusLineContributionItem statusField= (StatusLineContributionItem) fStatusFields.get(STATUSFIELDS[i]);
- statusField.setActionHandler(getAction(editor, STATUSFIELDS[i][1]));
+ for (int i= 0; i < STATUS_FIELD_DEFS.length; i++) {
if (fActiveEditorPart instanceof ITextEditorExtension) {
+ StatusLineContributionItem statusField= (StatusLineContributionItem) fStatusFields.get(STATUS_FIELD_DEFS[i]);
+ statusField.setActionHandler(getAction(editor, STATUS_FIELD_DEFS[i].actionId));
ITextEditorExtension extension= (ITextEditorExtension) fActiveEditorPart;
- extension.setStatusField(statusField, STATUSFIELDS[i][0]);
+ extension.setStatusField(statusField, STATUS_FIELD_DEFS[i].category);
}
}
}
@@ -231,8 +256,8 @@ public class BasicTextEditorActionContributor extends EditorActionBarContributor
*/
public void contributeToStatusLine(IStatusLineManager statusLineManager) {
super.contributeToStatusLine(statusLineManager);
- for (int i= 0; i < STATUSFIELDS.length; i++)
- statusLineManager.add((IContributionItem) fStatusFields.get(STATUSFIELDS[i]));
+ for (int i= 0; i < STATUS_FIELD_DEFS.length; i++)
+ statusLineManager.add((IContributionItem)fStatusFields.get(STATUS_FIELD_DEFS[i]));
}
/*
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IStatusFieldExtension.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IStatusFieldExtension.java
new file mode 100644
index 000000000..51dfd45ba
--- /dev/null
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IStatusFieldExtension.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.ui.texteditor;
+
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Extends <code>IStatusField</code> with the following concepts:
+ * <ul>
+ * <li>set error text and image</li>
+ * <li>set tool tip</li>
+ * <li>control visibility</li>
+ * </ul>
+ *
+ * @see org.eclipse.ui.texteditor.IStatusField
+ * @since 3.0
+ */
+public interface IStatusFieldExtension {
+ /**
+ * Sets the text of this status field.
+ * <p>
+ * The error text overrides the current text until the error
+ * text is cleared (set to <code>null</code>).
+ * </p>
+ *
+ * @param text the error text shown in the status field or <code>null</code> to clear
+ * @see IStatusField#setText(String)
+ */
+ void setErrorText(String text);
+
+ /**
+ * Sets the error image of this status field.
+ * <p>
+ * The error image overrides the current image until the error
+ * image is cleared (set to <code>null</code>).
+ * </p>
+ *
+ * @param image the error image shown in the status field or <code>null</code> to clear
+ * @see IStatusField#setImage(Image)
+ */
+ void setErrorImage(Image image);
+
+ /**
+ * Sets tool tip text for this status field.
+ *
+ * @param string the new tool tip text or <code>null</code> to clear
+ */
+ void setToolTipText (String string);
+
+ /**
+ * Sets whether this status field is visible within the status line.
+ *
+ * @param visible <code>true</code> if this item should be visible, <code>false</code> otherwise
+ */
+ void setVisible(boolean visible);
+}

Back to the top