Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2018-02-26 18:23:29 +0000
committerAndrey Loskutov2018-02-26 18:23:29 +0000
commiteefc0750ec8bcb8d08a4a3581b7d36f17f9d6163 (patch)
tree095fbea7e1e94ec300fe3e871d166c7630cc61d7 /org.eclipse.ui.console/src/org/eclipse
parent7eb257cfdc47b24e181fc7e9f0fe35ac6518a2b3 (diff)
downloadeclipse.platform.debug-eefc0750ec8bcb8d08a4a3581b7d36f17f9d6163.tar.gz
eclipse.platform.debug-eefc0750ec8bcb8d08a4a3581b7d36f17f9d6163.tar.xz
eclipse.platform.debug-eefc0750ec8bcb8d08a4a3581b7d36f17f9d6163.zip
Bug 495658 - auto scroll lock should work with all consolesI20180227-2000
Moved the logic and the preference value from debug.ui down to the console.ui plugin. Change-Id: I9c85c6cf52001c58dbd520a8fada42631e065614 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'org.eclipse.ui.console/src/org/eclipse')
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsole.java30
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleUIPreferenceInitializer.java30
2 files changed, 56 insertions, 4 deletions
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 eedaaf537..9b7ac7046 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
@@ -13,7 +13,9 @@ package org.eclipse.ui.console;
import java.util.HashMap;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.BadLocationException;
@@ -22,12 +24,14 @@ import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.Region;
+import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.ui.internal.console.ConsoleDocument;
import org.eclipse.ui.internal.console.ConsoleHyperlinkPosition;
import org.eclipse.ui.internal.console.ConsolePatternMatcher;
import org.eclipse.ui.part.IPageBookViewPage;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
/**
* An abstract text console that supports regular expression matching and
@@ -98,11 +102,9 @@ public abstract class TextConsole extends AbstractConsole {
private HashMap<String, Object> fAttributes = new HashMap<String, Object>();
private IConsoleManager fConsoleManager = ConsolePlugin.getDefault().getConsoleManager();
+ private ScopedPreferenceStore store;
+ private IPropertyChangeListener propListener;
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.AbstractConsole#dispose()
- */
@Override
protected void dispose() {
super.dispose();
@@ -110,6 +112,9 @@ public abstract class TextConsole extends AbstractConsole {
synchronized(fAttributes) {
fAttributes.clear();
}
+ if (store != null) {
+ store.removePropertyChangeListener(propListener);
+ }
}
/**
* Constructs a console with the given name, image descriptor, and lifecycle
@@ -187,6 +192,23 @@ public abstract class TextConsole extends AbstractConsole {
}
}
+ @Override
+ protected void init() {
+ super.init();
+ String qualifier = ConsolePlugin.getUniqueIdentifier();
+ String key = IConsoleConstants.P_CONSOLE_AUTO_SCROLL_LOCK;
+ setConsoleAutoScrollLock(Platform.getPreferencesService().getBoolean(qualifier, key, true, null));
+ store = new ScopedPreferenceStore(InstanceScope.INSTANCE, qualifier);
+
+ propListener = event -> {
+ String property = event.getProperty();
+ if (key.equals(property)) {
+ setConsoleAutoScrollLock(store.getBoolean(key));
+ }
+ };
+ store.addPropertyChangeListener(propListener);
+ }
+
/**
* Sets the width of this console in characters. Any value greater than zero
* will cause this console to have a fixed width.
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleUIPreferenceInitializer.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleUIPreferenceInitializer.java
new file mode 100644
index 000000000..beb34fcb6
--- /dev/null
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleUIPreferenceInitializer.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Andrey Loskutov <loskutov@gmx.de> 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:
+ * Andrey Loskutov <loskutov@gmx.de> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.internal.console;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsoleConstants;
+
+public class ConsoleUIPreferenceInitializer extends AbstractPreferenceInitializer {
+
+ public ConsoleUIPreferenceInitializer() {
+ super();
+ }
+
+ @Override
+ public void initializeDefaultPreferences() {
+ IPreferenceStore prefs = ConsolePlugin.getDefault().getPreferenceStore();
+ prefs.setDefault(IConsoleConstants.P_CONSOLE_AUTO_SCROLL_LOCK, true);
+ }
+
+}

Back to the top