diff options
12 files changed, 85 insertions, 17 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java index f9f0a4303..087fc9f49 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2016 IBM Corporation and others. + * Copyright (c) 2004, 2018 IBM Corporation 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 @@ -74,6 +74,7 @@ public class DebugUIPreferenceInitializer extends AbstractPreferenceInitializer //ConsolePreferencePage prefs.setDefault(IDebugPreferenceConstants.CONSOLE_WRAP, false); prefs.setDefault(IDebugPreferenceConstants.CONSOLE_WIDTH, 80); + prefs.setDefault(IDebugPreferenceConstants.CONSOLE_AUTO_SCROLL_LOCK, true); prefs.setDefault(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT, true); prefs.setDefault(IDebugPreferenceConstants.CONSOLE_OPEN_ON_ERR, true); prefs.setDefault(IDebugPreferenceConstants.CONSOLE_LIMIT_CONSOLE_OUTPUT, true); 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 9c67df184..14e0bd801 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation 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 @@ -140,6 +140,7 @@ public class ConsolePreferencePage extends FieldEditorPreferencePage implements fTabSizeEditor.setValidRange(1,100); fTabSizeEditor.setErrorMessage(DebugPreferencesMessages.ConsolePreferencePage_13); + addField(new BooleanFieldEditor(IDebugPreferenceConstants.CONSOLE_AUTO_SCROLL_LOCK, DebugPreferencesMessages.ConsolePreferencePage_Show__Console_View_enable_auto_scroll_lock, SWT.NONE, getFieldEditorParent())); addField(new BooleanFieldEditor(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT, DebugPreferencesMessages.ConsolePreferencePage_Show__Console_View_when_there_is_program_output_3, SWT.NONE, getFieldEditorParent())); addField(new BooleanFieldEditor(IDebugPreferenceConstants.CONSOLE_OPEN_ON_ERR, DebugPreferencesMessages.ConsolePreferencePage_Show__Console_View_when_there_is_program_error_3, SWT.NONE, getFieldEditorParent())); diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java index 80e32a20b..c45eb771a 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2016 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation 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 @@ -20,6 +20,7 @@ public class DebugPreferencesMessages extends NLS { public static String ConsolePreferencePage_Console_settings; public static String ConsolePreferencePage_Show__Console_View_when_there_is_program_error_3; public static String ConsolePreferencePage_Show__Console_View_when_there_is_program_output_3; + public static String ConsolePreferencePage_Show__Console_View_enable_auto_scroll_lock; public static String ConsolePreferencePage_Standard_Error__3; public static String ConsolePreferencePage_Standard_In__4; public static String ConsolePreferencePage_Standard_Out__2; 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 b4a626577..94f525275 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 @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2000, 2016 IBM Corporation and others. +# Copyright (c) 2000, 2018 IBM Corporation 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 @@ -12,6 +12,7 @@ ConsolePreferencePage_Console_settings=Debug Console Settings. ConsolePreferencePage_Show__Console_View_when_there_is_program_error_3=Show when &program writes to standard error ConsolePreferencePage_Show__Console_View_when_there_is_program_output_3=&Show when program writes to standard out +ConsolePreferencePage_Show__Console_View_enable_auto_scroll_lock=Enable &auto scroll lock ConsolePreferencePage_Standard_Error__3=Standard &Error text color: ConsolePreferencePage_Standard_In__4=Standard &In text color: ConsolePreferencePage_Standard_Out__2=Standard &Out text color: 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 7188985c2..45fd9cd0f 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation 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 @@ -60,6 +60,11 @@ public interface IDebugPreferenceConstants { public static final String CONSOLE_WIDTH = "Console.width"; //$NON-NLS-1$ /** + * (boolean) Whether or not the console view will enable auto scroll lock + */ + public static final String CONSOLE_AUTO_SCROLL_LOCK = "DEBUG.autoScrollLock"; //$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/ProcessConsole.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java index 1619261bb..2ca9e09ff 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation 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 @@ -320,6 +320,9 @@ public class ProcessConsole extends IOConsole implements IConsole, IDebugEventSe } else if (property.equals(IDebugPreferenceConstants.CONSOLE_TAB_WIDTH)) { int tabWidth = store.getInt(IDebugPreferenceConstants.CONSOLE_TAB_WIDTH); setTabWidth(tabWidth); + } else if (property.equals(IDebugPreferenceConstants.CONSOLE_AUTO_SCROLL_LOCK)) { + boolean autoScrollLock = store.getBoolean(IDebugPreferenceConstants.CONSOLE_AUTO_SCROLL_LOCK); + setConsoleAutoScrollLock(autoScrollLock); } else if (property.equals(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT)) { boolean activateOnOut = store.getBoolean(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT); @SuppressWarnings("resource") @@ -449,6 +452,7 @@ public class ProcessConsole extends IOConsole implements IConsole, IDebugEventSe setConsoleWidth(store.getInt(IDebugPreferenceConstants.CONSOLE_WIDTH)); } setTabWidth(store.getInt(IDebugPreferenceConstants.CONSOLE_TAB_WIDTH)); + setConsoleAutoScrollLock(store.getBoolean(IDebugPreferenceConstants.CONSOLE_AUTO_SCROLL_LOCK)); if (store.getBoolean(IDebugPreferenceConstants.CONSOLE_LIMIT_CONSOLE_OUTPUT)) { int highWater = store.getInt(IDebugPreferenceConstants.CONSOLE_HIGH_WATER_MARK); diff --git a/org.eclipse.ui.console/META-INF/MANIFEST.MF b/org.eclipse.ui.console/META-INF/MANIFEST.MF index a3cd1cbe5..a581616ec 100644 --- a/org.eclipse.ui.console/META-INF/MANIFEST.MF +++ b/org.eclipse.ui.console/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.ui.console; singleton:=true -Bundle-Version: 3.7.100.qualifier +Bundle-Version: 3.8.0.qualifier Bundle-Activator: org.eclipse.ui.console.ConsolePlugin Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/org.eclipse.ui.console/pom.xml b/org.eclipse.ui.console/pom.xml index df2058e0a..9d4f5d616 100644 --- a/org.eclipse.ui.console/pom.xml +++ b/org.eclipse.ui.console/pom.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - Copyright (c) 2012, 2017 Eclipse Foundation and others. + Copyright (c) 2012, 2018 Eclipse Foundation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Distribution License v1.0 which accompanies this distribution, and is available at @@ -18,6 +18,6 @@ </parent> <groupId>org.eclipse.ui</groupId> <artifactId>org.eclipse.ui.console</artifactId> - <version>3.7.100-SNAPSHOT</version> + <version>3.8.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project> diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleConstants.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleConstants.java index 27e8b0969..7df3fa27a 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleConstants.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleConstants.java @@ -126,6 +126,13 @@ public interface IConsoleConstants { public static final String P_TAB_SIZE = ConsolePlugin.getUniqueIdentifier() + ".P_TAB_SIZE"; //$NON-NLS-1$ /** + * Property constant indicating the user preference for auto scroll lock enabling. + * + * @since 3.8 + */ + public static final String P_CONSOLE_AUTO_SCROLL_LOCK = ConsolePlugin.getUniqueIdentifier() + ".P_CONSOLE_AUTO_SCROLL_LOCK"; //$NON-NLS-1$ + + /** * Property constant indicating the width of a fixed width console has changed. * * @since 3.1 diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsole.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsole.java index 02c17158f..eedaaf537 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsole.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsole.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation 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 @@ -89,6 +89,8 @@ public abstract class TextConsole extends AbstractConsole { */ private boolean fCompleteFired = false; + private boolean fConsoleAutoScrollLock = true; + /** * Map of client defined attributes @@ -161,11 +163,36 @@ public abstract class TextConsole extends AbstractConsole { } /** + * Returns the user preference for enabling auto scroll lock feature. + * + * @return auto scroll lock + * @since 3.8 + */ + public boolean isConsoleAutoScrollLock() { + return fConsoleAutoScrollLock; + } + + /** + * Sets the auto scroll lock preference. + * + * @param autoScrollLockPref enable auto scroll lock preference. + * @since 3.8 + */ + public void setConsoleAutoScrollLock(boolean autoScrollLockPref) { + if (fConsoleAutoScrollLock != autoScrollLockPref) { + boolean old = fConsoleAutoScrollLock; + fConsoleAutoScrollLock = autoScrollLockPref; + + firePropertyChange(this, IConsoleConstants.P_CONSOLE_AUTO_SCROLL_LOCK, Boolean.valueOf(old), Boolean.valueOf(fConsoleAutoScrollLock)); + } + } + + /** * Sets the width of this console in characters. Any value greater than zero * will cause this console to have a fixed width. * * @param width the width to make this console. Values of 0 or less imply - * the console does not have any fixed width. + * the console does not have any fixed width. */ public void setConsoleWidth(int width) { if (fConsoleWidth != width) { diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsolePage.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsolePage.java index a0fefa943..ef372d18a 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsolePage.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsolePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2018 IBM Corporation 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 @@ -258,6 +258,8 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen } else if (source.equals(fConsole) && property.equals(IConsoleConstants.P_TAB_SIZE)) { Integer tabSize = (Integer)event.getNewValue(); fViewer.setTabWidth(tabSize.intValue()); + } else if (source.equals(fConsole) && property.equals(IConsoleConstants.P_CONSOLE_AUTO_SCROLL_LOCK)) { + fViewer.setConsoleAutoScrollLock(fConsole.isConsoleAutoScrollLock()); } else if (source.equals(fConsole) && property.equals(IConsoleConstants.P_CONSOLE_WIDTH)) { fViewer.setConsoleWidth(fConsole.getConsoleWidth()); } else if (IConsoleConstants.P_BACKGROUND_COLOR.equals(property)) { diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java index f1fbae356..16ffa8053 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java @@ -89,6 +89,9 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener private TextConsole console; + private boolean consoleAutoScrollLock = true; + + private IPropertyChangeListener propertyChangeListener; private IScrollLockStateProvider scrollLockStateProvider; @@ -166,10 +169,13 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener } /* - * Check if the document is empty or the line count is smaller than each + * Check if user preference is enabled for auto scroll lock and the document is empty or the line count is smaller than each * vertical scroll */ - private boolean isEmptyDocument() { + private boolean isAutoScrollLockNotApplicable() { + if (!consoleAutoScrollLock) { + return true; + } StyledText textWidget = getTextWidget(); if (textWidget != null && !textWidget.isDisposed()) { return (textWidget.getLineCount() <= textWidget.getVerticalBar().getIncrement()); @@ -237,6 +243,7 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener public TextConsoleViewer(Composite parent, TextConsole console) { super(parent, null, SWT.V_SCROLL | SWT.H_SCROLL); this.console = console; + this.consoleAutoScrollLock = console.isConsoleAutoScrollLock(); IDocument document = console.getDocument(); setDocument(document); @@ -254,7 +261,7 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener styledText.getVerticalBar().addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { - if (isEmptyDocument()) { + if (isAutoScrollLockNotApplicable()) { return; } // scroll lock if vertical scroll bar dragged, OR selection on @@ -284,7 +291,7 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener styledText.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { - if (isEmptyDocument()) { + if (isAutoScrollLockNotApplicable()) { return; } // lock the scroll if PAGE_UP ,HOME or TOP selected @@ -304,7 +311,7 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener styledText.addMouseWheelListener(new MouseWheelListener() { @Override public void mouseScrolled(MouseEvent e) { - if (isEmptyDocument()) { + if (isAutoScrollLockNotApplicable()) { return; } if (e.count < 0) { // Mouse dragged down @@ -724,6 +731,18 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener } /** + * Sets the user preference for console auto scroll lock. + * + * @param autoScrollLock user preference for console auto scroll lock + * @since 3.8 + */ + public void setConsoleAutoScrollLock(boolean autoScrollLock) { + if (consoleAutoScrollLock != autoScrollLock) { + consoleAutoScrollLock = autoScrollLock; + } + } + + /** * Sets the console to have a fixed character width. Use -1 to indicate that * a fixed width should not be used. * |