Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2002-06-09 17:24:44 -0400
committerDarin Wright2002-06-09 17:24:44 -0400
commitf521dae77fc61e131c940eb0643c05f70d4ec07a (patch)
tree10cf3c14b1830341ad903193cde106d08e94cdfb /org.eclipse.debug.ui
parent2040e23a706fc1bdc36bbcc4b984171e477c4f0a (diff)
downloadeclipse.platform.debug-f521dae77fc61e131c940eb0643c05f70d4ec07a.tar.gz
eclipse.platform.debug-f521dae77fc61e131c940eb0643c05f70d4ec07a.tar.xz
eclipse.platform.debug-f521dae77fc61e131c940eb0643c05f70d4ec07a.zip
bug 17462
Diffstat (limited to 'org.eclipse.debug.ui')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/BooleanFieldEditor2.java50
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ConsolePreferencePage.java51
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties3
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java5
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocument.java113
5 files changed, 211 insertions, 11 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/BooleanFieldEditor2.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/BooleanFieldEditor2.java
new file mode 100644
index 000000000..8c6b40e4b
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/BooleanFieldEditor2.java
@@ -0,0 +1,50 @@
+package org.eclipse.debug.internal.ui.preferences;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * A boolean field editor that provides access to this editors boolean
+ * button.
+ */
+public class BooleanFieldEditor2 extends BooleanFieldEditor {
+
+ private Button fChangeControl;
+
+ /**
+ * @see BooleanFieldEditor#BooleanFieldEditor(java.lang.String, java.lang.String, int, org.eclipse.swt.widgets.Composite)
+ */
+ public BooleanFieldEditor2(
+ String name,
+ String labelText,
+ int style,
+ Composite parent) {
+ super(name, labelText, style, parent);
+ }
+
+ /**
+ * @see BooleanFieldEditor#BooleanFieldEditor(java.lang.String, java.lang.String, org.eclipse.swt.widgets.Composite)
+ */
+ public BooleanFieldEditor2(String name, String label, Composite parent) {
+ super(name, label, parent);
+ }
+
+ /**
+ * @see org.eclipse.jface.preference.BooleanFieldEditor#getChangeControl(Composite)
+ */
+ public Button getChangeControl(Composite parent) {
+ if (fChangeControl == null) {
+ fChangeControl = super.getChangeControl(parent);
+ }
+ return fChangeControl;
+ }
+
+
+}
+
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ConsolePreferencePage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ConsolePreferencePage.java
index 8f7b5053e..c22bc8620 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ConsolePreferencePage.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ConsolePreferencePage.java
@@ -11,10 +11,15 @@ import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.ColorFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
@@ -25,6 +30,9 @@ import org.eclipse.ui.texteditor.WorkbenchChainedTextFontFieldEditor;
* A page to set the preferences for the console
*/
public class ConsolePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+
+ private BooleanFieldEditor2 fWrapEditor = null;
+ private IntegerFieldEditor fWidthEditor = null;
/**
* Create the console page.
*/
@@ -49,7 +57,20 @@ public class ConsolePreferencePage extends FieldEditorPreferencePage implements
*/
public void createFieldEditors() {
- addField(new BooleanFieldEditor(IDebugPreferenceConstants.CONSOLE_WRAP, DebugPreferencesMessages.getString("ConsolePreferencePage.Wrap_text_1"), SWT.NONE, getFieldEditorParent())); //$NON-NLS-1$
+ fWrapEditor = new BooleanFieldEditor2(IDebugPreferenceConstants.CONSOLE_WRAP, DebugPreferencesMessages.getString("ConsolePreferencePage.Wrap_text_1"), SWT.NONE, getFieldEditorParent()); //$NON-NLS-1$
+ addField(fWrapEditor);
+
+ fWidthEditor = new IntegerFieldEditor(IDebugPreferenceConstants.CONSOLE_WIDTH, DebugPreferencesMessages.getString("ConsolePreferencePage.Console_width"), getFieldEditorParent()); //$NON-NLS-1$
+ addField(fWidthEditor);
+ fWidthEditor.setValidRange(1, Integer.MAX_VALUE);
+
+ fWrapEditor.getChangeControl(getFieldEditorParent()).addSelectionListener(
+ new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ updateWidthEditor();
+ }
+ }
+ );
addField(new BooleanFieldEditor(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT, DebugPreferencesMessages.getString("ConsolePreferencePage.Show_&Console_View_when_there_is_program_output_3"), SWT.NONE, getFieldEditorParent())); //$NON-NLS-1$
addField(new BooleanFieldEditor(IDebugPreferenceConstants.CONSOLE_OPEN_ON_ERR, DebugPreferencesMessages.getString("ConsolePreferencePage.Show_&Console_View_when_there_is_program_error_3"), SWT.NONE, getFieldEditorParent())); //$NON-NLS-1$
@@ -86,6 +107,7 @@ public class ConsolePreferencePage extends FieldEditorPreferencePage implements
public static void initDefaults(IPreferenceStore store) {
store.setDefault(IDebugPreferenceConstants.CONSOLE_WRAP, false);
+ store.setDefault(IDebugPreferenceConstants.CONSOLE_WIDTH, 80);
store.setDefault(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT, true);
store.setDefault(IDebugPreferenceConstants.CONSOLE_OPEN_ON_ERR, true);
WorkbenchChainedTextFontFieldEditor.startPropagate(store, IDebugPreferenceConstants.CONSOLE_FONT);
@@ -104,4 +126,31 @@ public class ConsolePreferencePage extends FieldEditorPreferencePage implements
return ok;
}
+ /**
+ * @see org.eclipse.jface.preference.FieldEditorPreferencePage#initialize()
+ */
+ protected void initialize() {
+ super.initialize();
+ updateWidthEditor();
+ }
+
+ /**
+ * Update enablement of width editor based on enablement of 'fixed width' editor.
+ */
+ protected void updateWidthEditor() {
+ Button b = fWrapEditor.getChangeControl(getFieldEditorParent());
+ fWidthEditor.getTextControl(getFieldEditorParent()).setEnabled(b.getSelection());
+ fWidthEditor.getLabelControl(getFieldEditorParent()).setEnabled(b.getSelection());
+ }
+
+
+ /**
+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+ */
+ protected void performDefaults() {
+ super.performDefaults();
+ updateWidthEditor();
+ }
+
+
} \ No newline at end of file
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties
index b28ff0a03..a5af17924 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties
@@ -16,7 +16,8 @@ ConsolePreferencePage.Show_&Console_View_when_there_is_program_output_3=&Show wh
ConsolePreferencePage.Standard_Error__3=Standard &Error Text Color:
ConsolePreferencePage.Standard_In__4=Standard &In Text Color:
ConsolePreferencePage.Standard_Out__2=Standard &Out Text Color:
-ConsolePreferencePage.Wrap_text_1=&Wrap text (will take effect after workbench restart)
+ConsolePreferencePage.Wrap_text_1=Fixed &width console
+ConsolePreferencePage.Console_width=&Maximum character width:
DebugActionGroupsPreferencePage.&Available_Debug_Action_Groups__2=A&vailable Debug Action Groups:
DebugActionGroupsPreferencePage.Actions_in_Group__3=Actions in &Group:
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java
index 9e773a151..a6b4b440c 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java
@@ -37,6 +37,11 @@ public interface IDebugPreferenceConstants {
public static final String CONSOLE_WRAP= "Console.wrap"; //$NON-NLS-1$
/**
+ * (int) The maximum console character width, if wrapping.
+ */
+ public static final String CONSOLE_WIDTH = "Console.width"; //$NON-NLS-1$
+
+ /**
* (boolean) Whether or not the console view is shown
* when there is program output.
*/
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocument.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocument.java
index 0c5a02208..35665045c 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocument.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleDocument.java
@@ -20,16 +20,19 @@ import org.eclipse.debug.core.model.IStreamMonitor;
import org.eclipse.debug.core.model.IStreamsProxy;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.preferences.IDebugPreferenceConstants;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.AbstractDocument;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DefaultLineTracker;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.ITextStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;
-public class ConsoleDocument extends AbstractDocument implements IDebugEventSetListener {
+public class ConsoleDocument extends AbstractDocument implements IDebugEventSetListener, IPropertyChangeListener {
private boolean fClosed= false;
private boolean fKilled= false;
@@ -100,10 +103,25 @@ public class ConsoleDocument extends AbstractDocument implements IDebugEventSetL
private boolean fPoll = false;
/**
+ * The length of the current line
+ */
+ private int fLineLength = 0;
+
+ /**
+ * Maximum line length before wrapping.
+ */
+ private int fMaxLineLength = 80;
+
+ /**
+ * Whether using auto-wrap mode
+ */
+ private boolean fWrap = false;
+
+ /**
* The base number of milliseconds to pause
* between polls.
*/
- private static final long BASE_DELAY= 50L;
+ private static final long BASE_DELAY= 100L;
public static final int OUT= 0;
public static final int ERR= 1;
@@ -129,6 +147,10 @@ public class ConsoleDocument extends AbstractDocument implements IDebugEventSetL
public ConsoleDocument(IProcess process) {
super();
fProcess= process;
+ IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore();
+ fWrap = store.getBoolean(IDebugPreferenceConstants.CONSOLE_WRAP);
+ fMaxLineLength = store.getInt(IDebugPreferenceConstants.CONSOLE_WIDTH);
+ store.addPropertyChangeListener(this);
if (process != null) {
fProxy= process.getStreamsProxy();
fTerminated = process.isTerminated();
@@ -148,6 +170,7 @@ public class ConsoleDocument extends AbstractDocument implements IDebugEventSetL
fClosed= true;
stopReading();
DebugPlugin.getDefault().removeDebugEventListener(this);
+ DebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
fStyleRanges= Collections.EMPTY_LIST;
set(""); //$NON-NLS-1$
}
@@ -296,18 +319,46 @@ public class ConsoleDocument extends AbstractDocument implements IDebugEventSetL
StreamEntry prev = null;
int processed = 0;
int amount = 0;
+ String[] lds = getLegalLineDelimiters();
while (!fKilled && processed < fQueue.size() && amount < 8096) {
StreamEntry entry = (StreamEntry)fQueue.get(processed);
- if (prev == null) {
- buffer = new StringBuffer(entry.getText());
- } else {
- if (prev.getKind() == entry.getKind()) {
- buffer.append(entry.getText());
+ if (prev == null || prev.getKind() == entry.getKind()) {
+ String text = entry.getText();
+ if (buffer == null) {
+ buffer = new StringBuffer(text.length());
+ }
+ if (isWrap()) {
+ for (int i = 0; i < text.length(); i++) {
+ if (fLineLength >= fMaxLineLength) {
+ String d = getLineDelimiter(text, i, lds);
+ if (d == null) {
+ buffer.append(lds[0]);
+ } else {
+ buffer.append(d);
+ i = i + d.length();
+ }
+ fLineLength = 0;
+ }
+ if (i < text.length()) {
+ String lineDelimiter = getLineDelimiter(text, i, lds);
+ if (lineDelimiter == null) {
+ buffer.append(text.charAt(i));
+ fLineLength++;
+ } else {
+ buffer.append(lineDelimiter);
+ fLineLength = 0;
+ i = i + lineDelimiter.length() - 1;
+ }
+ }
+ }
} else {
- // only do one append per poll
- break;
+ buffer.append(text);
}
+ } else {
+ // only do one append per poll
+ break;
}
+
prev = entry;
processed++;
amount+= entry.getText().length();
@@ -321,6 +372,37 @@ public class ConsoleDocument extends AbstractDocument implements IDebugEventSetL
}
}
+ /**
+ * Returns the longest line delimiter at the given position in the given text,
+ * or <code>null</code> if none.
+ *
+ * @param text the text in which to look for a line delimiter
+ * @param pos the position at which to look for a line delimiter
+ * @param lineDelimiters the line delimiters to look for
+ */
+ protected String getLineDelimiter(String text, int pos, String[] lineDelimiters) {
+ String ld = null;
+ for (int i = 0; i < lineDelimiters.length; i++) {
+ if (text.regionMatches(pos, lineDelimiters[i], 0, lineDelimiters[i].length())) {
+ if (ld == null) {
+ ld = lineDelimiters[i];
+ } else {
+ if (ld.length() < lineDelimiters[i].length()) {
+ ld = lineDelimiters[i];
+ }
+ }
+ }
+ }
+ return ld;
+ }
+
+ /**
+ * Returns whether this console document is performing auto-wrap
+ */
+ protected boolean isWrap() {
+ return fWrap;
+ }
+
protected void stopReading() {
fPoll = false;
if (fProxy == null) {
@@ -579,4 +661,17 @@ public class ConsoleDocument extends AbstractDocument implements IDebugEventSetL
protected boolean isAppendInProgress() {
return fAppending;
}
+
+ /**
+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(IDebugPreferenceConstants.CONSOLE_WRAP)) {
+ fWrap = DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IDebugPreferenceConstants.CONSOLE_WRAP);
+ } else if (event.getProperty().equals(IDebugPreferenceConstants.CONSOLE_WIDTH)) {
+ fMaxLineLength = DebugUIPlugin.getDefault().getPreferenceStore().getInt(IDebugPreferenceConstants.CONSOLE_WIDTH);
+ }
+ }
+
+
} \ No newline at end of file

Back to the top