Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJared Burns2001-10-03 17:49:38 +0000
committerJared Burns2001-10-03 17:49:38 +0000
commit6bdd49d56e53321cbb07c8b381c8b4da1dbb7447 (patch)
treea64677c32934faafcf0b15c3cd96cebab6ef8647
parent2a9b8e3ebfb73065f764ca1c53633af711c85299 (diff)
downloadeclipse.platform.debug-6bdd49d56e53321cbb07c8b381c8b4da1dbb7447.tar.gz
eclipse.platform.debug-6bdd49d56e53321cbb07c8b381c8b4da1dbb7447.tar.xz
eclipse.platform.debug-6bdd49d56e53321cbb07c8b381c8b4da1dbb7447.zip
Console preference cleanupv203
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ConsoleDocument.java21
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ConsolePreferencePage.java118
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugPreferenceConstants.java1
3 files changed, 109 insertions, 31 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ConsoleDocument.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ConsoleDocument.java
index a432dc261..936eed874 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ConsoleDocument.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ConsoleDocument.java
@@ -33,6 +33,7 @@ public class ConsoleDocument extends AbstractDocument implements IDebugEventList
private int fLastSourceStream= ConsoleDocument.OUT;
private int fMaxSysText= 0; // Maximum amount of text displayed from sys.out and sys.err
+ private boolean fSetMaxSysText= false;
private boolean fCropping= false;
private List fStyleRanges= new ArrayList(2);
@@ -58,14 +59,13 @@ public class ConsoleDocument extends AbstractDocument implements IDebugEventList
public ConsoleDocument(IProcess process) {
super();
fProcess= process;
+
IPreferenceStore store= DebugUIPlugin.getDefault().getPreferenceStore();
store.addPropertyChangeListener(this);
fMaxSysText= store.getInt(ConsolePreferencePage.CONSOLE_MAX_OUTPUT_SIZE);
- if (fMaxSysText > 0) {
- setTextStore(new ConsoleOutputTextStore(fMaxSysText));
- } else {
- setTextStore(new ConsoleOutputTextStore(2500));
- }
+ fSetMaxSysText= store.getBoolean(ConsolePreferencePage.CONSOLE_SET_MAX_OUTPUT);
+
+ setTextStore(new ConsoleOutputTextStore(2500));
setLineTracker(new DefaultLineTracker());
if (process != null) {
@@ -199,7 +199,7 @@ public class ConsoleDocument extends AbstractDocument implements IDebugEventList
int appendedLength= text.length();
int totalSize= getStore().getLength() + appendedLength;
fNewStreamWriteEnd= fLastStreamWriteEnd + appendedLength;
- if (fMaxSysText > 0 && totalSize > fMaxSysText) {
+ if (fSetMaxSysText && totalSize > fMaxSysText) {
crop(totalSize - fMaxSysText);
}
ConsoleDocument.this.replace0(fLastStreamWriteEnd, 0, text, source);
@@ -251,12 +251,12 @@ public class ConsoleDocument extends AbstractDocument implements IDebugEventList
/**
* Crop the contents of the store to fit the specified maximum
* size (fMaxSysText).
- * Do nothing if the document has 1 or fewer characters.
+ * Do nothing if the document has no characters.
*/
private void cropContentToFit() {
int totalSize= getStore().getLength();
int amountToLose= totalSize-fMaxSysText;
- if (fMaxSysText <= 0 || totalSize <= 1 || amountToLose <= 0) {
+ if (!fSetMaxSysText || totalSize <= 0 || amountToLose <= 0) {
return;
}
crop(amountToLose);
@@ -412,10 +412,13 @@ public class ConsoleDocument extends AbstractDocument implements IDebugEventList
}
IPreferenceStore store= DebugUIPlugin.getDefault().getPreferenceStore();
+ fSetMaxSysText= store.getBoolean(ConsolePreferencePage.CONSOLE_SET_MAX_OUTPUT);
int newMax= store.getInt(ConsolePreferencePage.CONSOLE_MAX_OUTPUT_SIZE);
if (newMax != fMaxSysText) {
fMaxSysText= newMax;
- cropContentToFit();
+ if (fSetMaxSysText) {
+ cropContentToFit();
+ }
}
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ConsolePreferencePage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ConsolePreferencePage.java
index 2ba8d160f..fb4e2e2d3 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ConsolePreferencePage.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ConsolePreferencePage.java
@@ -5,11 +5,9 @@ package org.eclipse.debug.internal.ui;
* All Rights Reserved.
*/
-import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.preference.*;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -22,9 +20,11 @@ import org.eclipse.ui.texteditor.WorkbenchChainedTextFontFieldEditor;
/**
* A page to set the preferences for the console
*/
-public class ConsolePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage, IDebugPreferenceConstants, ModifyListener {
+public class ConsolePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage, IDebugPreferenceConstants {
- Text fMaxOutputField;
+ private Text fMaxOutputField;
+ private Button fMaxOutputButton;
+ private Label fMaxOutputLabel;
/**
* Create the console page.
@@ -63,9 +63,9 @@ public class ConsolePreferencePage extends FieldEditorPreferencePage implements
addField(sysin);
addField(editor);
- String defaultText= (new Integer(getConsoleMaxOutputSize())).toString();
- createLabelledTextArea(parent, defaultText, "Number of characters displayed (enter 0 for no limit):");
-
+ String maxText= (new Integer(getConsoleMaxOutputSize())).toString();
+ boolean set= getSetConsoleMaxOutputSize();
+ createMaxOutputWidget(parent, maxText, set, "Set maximum number of characters displayed:", "Toggle whether a maximum number of characters is set at all");
}
/**
@@ -84,7 +84,13 @@ public class ConsolePreferencePage extends FieldEditorPreferencePage implements
data.widthHint = 60;
text.setLayoutData(data);
fMaxOutputField= text;
- text.addModifyListener(this);
+ text.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (e.widget == fMaxOutputField) {
+ doMaxOutputChanged();
+ }
+ }
+ });
return text;
}
@@ -101,36 +107,64 @@ public class ConsolePreferencePage extends FieldEditorPreferencePage implements
GridData data= new GridData();
label.setLayoutData(data);
+ setMaxOutputLabel(label);
+
return label;
}
+ private Button createButton(Composite parent, boolean enabled, String labelText, String tooltipText) {
+
+ Button button= new Button(parent, SWT.CHECK | SWT.LEFT);
+ button.setText(labelText);
+ button.setToolTipText(tooltipText);
+ button.setSelection(enabled);
+
+ GridData data= new GridData();
+ button.setLayoutData(data);
+
+ button.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent se) {
+ setMaxOutputEnabled(fMaxOutputButton.getSelection());
+ }
+ public void widgetDefaultSelected(SelectionEvent se) {
+ }
+ });
+
+ setMaxOutputButton(button);
+
+ return button;
+ }
+
/**
- * Creates a text widget with a label
+ * Creates a text widget with a label and a toggle button
*/
- private Composite createLabelledTextArea(Composite parent, String defaultText, String labelText) {
+ private Composite createMaxOutputWidget(Composite parent, String defaultText, boolean set, String labelText, String tooltipText) {
Composite textArea= new Composite(parent, SWT.SHADOW_NONE);
GridLayout layout= new GridLayout();
- layout.numColumns= 2;
+ layout.numColumns= 3;
textArea.setLayout(layout);
- Label label= createLabel(textArea, labelText);
+ Button button= createButton(textArea, set, labelText, tooltipText);
Text text= createTextBox(textArea, defaultText);
GridData data= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
data.horizontalSpan= 2;
textArea.setLayoutData(data);
+ setMaxOutputEnabled(set);
+
return textArea;
}
/**
- * @see ModifyListener
+ * Enable or disable the appropriate fields associated with the "set max output" option
*/
- public void modifyText(ModifyEvent e) {
- if (e.widget == fMaxOutputField) {
- doMaxOutputChanged();
+ protected void setMaxOutputEnabled(boolean enabled) {
+ if (!enabled) {
+ fMaxOutputField.clearSelection();
}
- }
+ fMaxOutputField.setEnabled(enabled);
+ }
/**
* @see IPreferencePage
@@ -138,10 +172,15 @@ public class ConsolePreferencePage extends FieldEditorPreferencePage implements
public boolean performOk() {
super.performOk(); // store the fields.
IPreferenceStore store = getPreferenceStore();
+ int currentValue= store.getInt(CONSOLE_MAX_OUTPUT_SIZE);
+ int newValue= Integer.parseInt(fMaxOutputField.getText());
+ boolean enabled= fMaxOutputButton.getSelection();
- int value= Integer.parseInt(fMaxOutputField.getText());
- store.setValue(CONSOLE_MAX_OUTPUT_SIZE, value);
- getPreferenceStore().firePropertyChangeEvent(CONSOLE_MAX_OUTPUT_SIZE, new Integer(0), new Integer(value));
+ store.setValue(CONSOLE_SET_MAX_OUTPUT, enabled);
+ store.setValue(CONSOLE_MAX_OUTPUT_SIZE, newValue);
+
+ getPreferenceStore().firePropertyChangeEvent(CONSOLE_MAX_OUTPUT_SIZE, new Integer(currentValue), new Integer(newValue));
+
return true;
}
@@ -215,6 +254,15 @@ public class ConsolePreferencePage extends FieldEditorPreferencePage implements
}
/**
+ * Returns whether the console enforces a maximum size
+ */
+ public static boolean getSetConsoleMaxOutputSize() {
+ IPreferenceStore prefs= DebugUIPlugin.getDefault().getPreferenceStore();
+ boolean set= prefs.getBoolean(CONSOLE_SET_MAX_OUTPUT);
+ return set;
+ }
+
+ /**
* Initialize the default values of the preferences associated with this page
*/
public static void initDefaults(IPreferenceStore store) {
@@ -223,6 +271,32 @@ public class ConsolePreferencePage extends FieldEditorPreferencePage implements
PreferenceConverter.setDefault(store, CONSOLE_SYS_OUT_RGB, new RGB(0, 0, 255));
PreferenceConverter.setDefault(store, CONSOLE_SYS_IN_RGB, new RGB(0, 200, 125));
PreferenceConverter.setDefault(store, CONSOLE_SYS_ERR_RGB, new RGB(255, 0, 0));
- store.setDefault(CONSOLE_MAX_OUTPUT_SIZE, 0);
+ store.setDefault(CONSOLE_MAX_OUTPUT_SIZE, 1024);
+ store.setDefault(CONSOLE_SET_MAX_OUTPUT, false);
}
+
+ private void setMaxOutputField(Text field) {
+ fMaxOutputField= field;
+ }
+
+ private Text getMaxOutputField() {
+ return fMaxOutputField;
+ }
+
+ private void setMaxOutputButton(Button button) {
+ fMaxOutputButton= button;
+ }
+
+ private Button getMaxOutputButton() {
+ return fMaxOutputButton;
+ }
+
+ private void setMaxOutputLabel(Label label) {
+ fMaxOutputLabel= label;
+ }
+
+ private Label getMaxOutputLabel() {
+ return fMaxOutputLabel;
+ }
+
} \ No newline at end of file
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugPreferenceConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugPreferenceConstants.java
index ad29846c3..61fca70d1 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugPreferenceConstants.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugPreferenceConstants.java
@@ -24,6 +24,7 @@ public interface IDebugPreferenceConstants {
public static final String CONSOLE_SYS_OUT_RGB= "Console.stdOutColor";
public static final String CONSOLE_SYS_IN_RGB= "Console.stdInColor";
+ public static final String CONSOLE_SET_MAX_OUTPUT= "Console.setMaxOutput";
public static final String CONSOLE_MAX_OUTPUT_SIZE= "Console.maxOutputSize";
/**

Back to the top