diff options
author | Sarika Sinha | 2018-02-02 09:10:42 +0000 |
---|---|---|
committer | Sarika Sinha | 2018-02-02 09:10:42 +0000 |
commit | 3d64965ccd19d1c7007cfd2d550f2713a41a9eb0 (patch) | |
tree | fd14cba1b19f1ce8e9658781690ddf8deab62629 /org.eclipse.ui.console | |
parent | 694050ca6ce664e9f5df400eb3aef8bce219d8cc (diff) | |
download | eclipse.platform.debug-3d64965ccd19d1c7007cfd2d550f2713a41a9eb0.tar.gz eclipse.platform.debug-3d64965ccd19d1c7007cfd2d550f2713a41a9eb0.tar.xz eclipse.platform.debug-3d64965ccd19d1c7007cfd2d550f2713a41a9eb0.zip |
Bug 495658 - Auto scroll lock should be disableableI20180213-2000I20180213-0125I20180212-2000I20180211-2000I20180210-1500I20180209-2000I20180208-2000I20180207-2000I20180206-2000I20180206-0315I20180205-2000I20180204-2000I20180203-1500I20180202-2000
Change-Id: Ie5b39dad6843a62c95914fa685ef3f25f97a1ec7
Diffstat (limited to 'org.eclipse.ui.console')
6 files changed, 66 insertions, 11 deletions
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. * |