mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Bug 407405: Limit wrapping in Build Console
If the build console is too long word wrapping is very slow. The underlying issue is Bug 168557, this is just a workaround so users don't fall down this particular rabbit hole. Change-Id: I1be3540003d475e2d5431295219198ae2db7862f
This commit is contained in:
parent
e082f73b56
commit
39b6373f66
5 changed files with 121 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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))
|
||||
|
|
Loading…
Add table
Reference in a new issue