Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/WrapLinesAction.java23
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BooleanFieldEditor2.java32
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java64
5 files changed, 121 insertions, 7 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties
index abccb0816d..7caff2d504 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties
@@ -24,6 +24,9 @@ ConsolePreferencePage.consoleWrapLines.label=Wrap lines on the console
ConsolePreferencePage.consoleLines.label=Limit console output (number of lines):
ConsolePreferencePage.consoleLines.tooltip=This is a fuzzy limit, optimized for best performance. The actual limit will be between this value and 2 times this value.
ConsolePreferencePage.consoleLines.errorMessage=Value must be an integer between 10 and 2147483647
+ConsolePreferencePage.wrapLinesMax.label=Maximum number of lines to enable word wrap for:
+ConsolePreferencePage.wrapLinesMax.tooltip=If the "Limit console output" is set greater than this value, the wrap lines will not be enabled.
+ConsolePreferencePage.wrapLinesMax.errorMessage=Value must be an integer between 0 and 2147483647
ConsolePreferencePage.consoleUpdateDelay.label=Delay updated between console updates (milliseconds):
ConsolePreferencePage.consoleUpdateDelay.tooltip=The number of milliseconds between each console view update to allow other operations to perform UI operations.
ConsolePreferencePage.consoleUpdateDelay.errorMessage=Value must be an integer between 0 and 2147483647
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java
index 3581ae5abc..c28e1214e2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java
@@ -298,8 +298,10 @@ public class BuildConsolePage extends Page
setTabs(CUIPlugin.getDefault().getPreferenceStore().getInt(BuildConsolePreferencePage.PREF_BUILDCONSOLE_TAB_WIDTH));
} else if (IConsoleConstants.P_BACKGROUND_COLOR.equals(property)) {
fViewer.getTextWidget().setBackground(fConsole.getBackground());
- } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_WRAP_LINES)) {
- fWrapAction.setChecked(BuildConsolePreferencePage.isConsoleWrapLines());
+ } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_WRAP_LINES)
+ || property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_LINES)
+ || property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_WRAP_LINES_MAX)) {
+ fWrapAction.propertyChange();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/WrapLinesAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/WrapLinesAction.java
index f51928f0c1..d358238a95 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/WrapLinesAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/WrapLinesAction.java
@@ -31,16 +31,33 @@ public class WrapLinesAction extends Action {
public WrapLinesAction(BuildConsoleViewer viewer) {
super(ConsoleMessages.WrapLinesAction_WrapLines);
fConsoleViewer = viewer;
- setChecked(BuildConsolePreferencePage.isConsoleWrapLines());
-
+ propertyChange();
setToolTipText(ConsoleMessages.WrapLinesAction_WrapLines);
setImageDescriptor(CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_WRAP_LINE));
}
+ public void propertyChange() {
+ if (BuildConsolePreferencePage.isConsoleWrapLinesAllowed()) {
+ setEnabled(true);
+ setChecked(BuildConsolePreferencePage.isConsoleWrapLines());
+ } else {
+ setEnabled(false);
+ setChecked(false);
+ }
+ }
+
private void setWordWrap(boolean wrap) {
StyledText styledText = fConsoleViewer.getTextWidget();
if (styledText != null) {
- styledText.setWordWrap(wrap);
+ // It should not be possible for setWordWrap when disabled (aka
+ // isConsoleWrapLinesAllowed != true) - however if someone calls
+ // the method (or setChecked) programatically, ensure we don't
+ // let the wordwrap come on
+ if (BuildConsolePreferencePage.isConsoleWrapLinesAllowed() && wrap) {
+ styledText.setWordWrap(wrap);
+ } else {
+ styledText.setWordWrap(false);
+ }
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BooleanFieldEditor2.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BooleanFieldEditor2.java
new file mode 100644
index 0000000000..7215c0b472
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BooleanFieldEditor2.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Kichwa Coders and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Jonah Graham (Kichwa Coders) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.preferences;
+
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Provide access to the checkbox, this makes it equivalent to
+ * org.eclipse.jface.preference.StringFieldEditor
+ */
+public class BooleanFieldEditor2 extends BooleanFieldEditor {
+
+ public BooleanFieldEditor2(String prefBuildconsoleWrapLines, String resourceString, Composite parent) {
+ super(prefBuildconsoleWrapLines, resourceString, parent);
+ }
+
+ @Override
+ public Button getChangeControl(Composite parent) {
+ return super.getChangeControl(parent);
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java
index bb29105683..538f032e6f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/BuildConsolePreferencePage.java
@@ -17,6 +17,7 @@ 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.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
@@ -28,7 +29,10 @@ import org.eclipse.ui.PlatformUI;
import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.internal.core.pdom.WritablePDOM;
+
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.GenerateGettersAndSettersWizard;
public class BuildConsolePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
@@ -36,6 +40,10 @@ public class BuildConsolePreferencePage extends FieldEditorPreferencePage implem
private static final String PREF_CONSOLE_ON_TOP = "consoleOnTop"; //$NON-NLS-1$
private static final String PREF_AUTO_OPEN_CONSOLE = "autoOpenConsole"; //$NON-NLS-1$
public static final String PREF_BUILDCONSOLE_WRAP_LINES = "buildConsoleWrapLines"; //$NON-NLS-1$
+ /**
+ * Maximum number of lines for which the wrap lines is enabled in the build console
+ */
+ public static final String PREF_BUILDCONSOLE_WRAP_LINES_MAX = "buildConsoleWrapLinesMax"; //$NON-NLS-1$
// In font registry
public static final String PREF_BUILDCONSOLE_FONT = "org.eclipse.cdt.ui.buildconsole.ConsoleFont"; //$NON-NLS-1$
@@ -66,6 +74,9 @@ public class BuildConsolePreferencePage extends FieldEditorPreferencePage implem
* delay.
*/
public static final int DEFAULT_BUILDCONSOLE_UPDATE_DELAY_MS = 75;
+ private BooleanFieldEditor2 consoleWrapLines;
+ private IntegerFieldEditor buildCount;
+ private IntegerFieldEditor wrapLinesMax;
public BuildConsolePreferencePage() {
@@ -92,11 +103,12 @@ public class BuildConsolePreferencePage extends FieldEditorPreferencePage implem
BooleanFieldEditor consoleOnTop = new BooleanFieldEditor(PREF_CONSOLE_ON_TOP,
CUIPlugin.getResourceString("ConsolePreferencePage.consoleOnTop.label"), parent); //$NON-NLS-1$
addField(consoleOnTop);
- BooleanFieldEditor consoleWrapLines = new BooleanFieldEditor(PREF_BUILDCONSOLE_WRAP_LINES,
+ consoleWrapLines = new BooleanFieldEditor2(PREF_BUILDCONSOLE_WRAP_LINES,
CUIPlugin.getResourceString("ConsolePreferencePage.consoleWrapLines.label"), parent); //$NON-NLS-1$
addField(consoleWrapLines);
+ setWrapLinesEnablement();
- IntegerFieldEditor buildCount = new IntegerFieldEditor(PREF_BUILDCONSOLE_LINES,
+ buildCount = new IntegerFieldEditor(PREF_BUILDCONSOLE_LINES,
CUIPlugin.getResourceString("ConsolePreferencePage.consoleLines.label"), parent); //$NON-NLS-1$
buildCount.getLabelControl(parent).setToolTipText(CUIPlugin.getResourceString("ConsolePreferencePage.consoleLines.tooltip")); //$NON-NLS-1$
buildCount.getTextControl(parent).setToolTipText(CUIPlugin.getResourceString("ConsolePreferencePage.consoleLines.tooltip")); //$NON-NLS-1$
@@ -112,6 +124,17 @@ public class BuildConsolePreferencePage extends FieldEditorPreferencePage implem
updateDelay.setValidRange(0, Integer.MAX_VALUE);
addField(updateDelay);
+ wrapLinesMax = new IntegerFieldEditor(PREF_BUILDCONSOLE_WRAP_LINES_MAX,
+ CUIPlugin.getResourceString("ConsolePreferencePage.wrapLinesMax.label"), parent); //$NON-NLS-1$
+ wrapLinesMax.getLabelControl(parent).setToolTipText(
+ CUIPlugin.getResourceString("ConsolePreferencePage.wrapLinesMax.tooltip")); //$NON-NLS-1$
+ wrapLinesMax.getTextControl(parent).setToolTipText(
+ CUIPlugin.getResourceString("ConsolePreferencePage.wrapLinesMax.tooltip")); //$NON-NLS-1$
+ wrapLinesMax.setErrorMessage(
+ CUIPlugin.getResourceString("ConsolePreferencePage.wrapLinesMax.errorMessage")); //$NON-NLS-1$
+ wrapLinesMax.setValidRange(0, Integer.MAX_VALUE);
+ addField(wrapLinesMax);
+
IntegerFieldEditor tabSize = new IntegerFieldEditor(PREF_BUILDCONSOLE_TAB_WIDTH,
CUIPlugin.getResourceString("ConsolePreferencePage.tabWidth.label"), parent); //$NON-NLS-1$
addField(tabSize);
@@ -138,6 +161,29 @@ public class BuildConsolePreferencePage extends FieldEditorPreferencePage implem
CUIPlugin.getResourceString("ConsolePreferencePage.problemHighlightedColor.label"), parent)); //$NON-NLS-1$
}
+ /**
+ * @see #isConsoleWrapLinesAllowed()
+ */
+ private void setWrapLinesEnablement() {
+ if ((buildCount == null || buildCount.isValid()) && (wrapLinesMax == null || wrapLinesMax.isValid())) {
+ int lineCount = buildCount != null ? buildCount.getIntValue() : buildConsoleLines();
+ int maxCount = wrapLinesMax != null ? wrapLinesMax.getIntValue() : wrapLinesMax();
+ boolean enabled = lineCount <= maxCount;
+ if (consoleWrapLines != null) {
+ consoleWrapLines.setEnabled(enabled, getFieldEditorParent());
+ if (!enabled) {
+ consoleWrapLines.getChangeControl(getFieldEditorParent()).setSelection(false);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ setWrapLinesEnablement();
+ super.propertyChange(event);
+ }
+
private Label createLabel(Composite parent, String text) {
Label label = new Label(parent, SWT.LEFT);
label.setText(text);
@@ -177,6 +223,18 @@ public class BuildConsolePreferencePage extends FieldEditorPreferencePage implem
return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PREF_BUILDCONSOLE_WRAP_LINES);
}
+ /**
+ * Bug 407405: This is a workaround for Bug 168557 in which wrapping is too slow to make it usable
+ * for the build console unless there are not many lines.
+ */
+ public static boolean isConsoleWrapLinesAllowed() {
+ return buildConsoleLines() <= wrapLinesMax();
+ }
+
+ public static int wrapLinesMax() {
+ return CUIPlugin.getDefault().getPreferenceStore().getInt(PREF_BUILDCONSOLE_WRAP_LINES_MAX);
+ }
+
public static int buildConsoleLines() {
return CUIPlugin.getDefault().getPreferenceStore().getInt(PREF_BUILDCONSOLE_LINES);
}
@@ -200,6 +258,8 @@ public class BuildConsolePreferencePage extends FieldEditorPreferencePage implem
prefs.setDefault(PREF_BUILDCONSOLE_WRAP_LINES, false);
if(!prefs.contains(PREF_BUILDCONSOLE_LINES))
prefs.setDefault(PREF_BUILDCONSOLE_LINES, 500);
+ if(!prefs.contains(PREF_BUILDCONSOLE_WRAP_LINES_MAX))
+ prefs.setDefault(PREF_BUILDCONSOLE_WRAP_LINES_MAX, 5000);
if(!prefs.contains(PREF_BUILDCONSOLE_UPDATE_DELAY_MS))
prefs.setDefault(PREF_BUILDCONSOLE_UPDATE_DELAY_MS, DEFAULT_BUILDCONSOLE_UPDATE_DELAY_MS);
if(!prefs.contains(PREF_BUILDCONSOLE_TAB_WIDTH))

Back to the top