Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2018-02-26 13:23:29 -0500
committerAndrey Loskutov2018-02-26 13:23:29 -0500
commiteefc0750ec8bcb8d08a4a3581b7d36f17f9d6163 (patch)
tree095fbea7e1e94ec300fe3e871d166c7630cc61d7
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>
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/ConsolePreferencePage.java31
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ProcessConsole.java6
-rw-r--r--org.eclipse.ui.console/plugin.xml19
-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
6 files changed, 87 insertions, 33 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 087fc9f49..f0abb3999 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
@@ -29,9 +29,6 @@ public class DebugUIPreferenceInitializer extends AbstractPreferenceInitializer
super();
}
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
- */
@Override
public void initializeDefaultPreferences() {
IPreferenceStore prefs = DebugUIPlugin.getDefault().getPreferenceStore();
@@ -74,7 +71,6 @@ 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 14e0bd801..b891e5b93 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
@@ -28,6 +28,8 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsoleConstants;
import com.ibm.icu.text.MessageFormat;
@@ -67,13 +69,14 @@ public class ConsolePreferencePage extends FieldEditorPreferencePage implements
}
}
- private BooleanFieldEditor2 fWrapEditor = null;
- private ConsoleIntegerFieldEditor fWidthEditor = null;
+ private BooleanFieldEditor2 fWrapEditor;
+ private ConsoleIntegerFieldEditor fWidthEditor;
- private BooleanFieldEditor2 fUseBufferSize = null;
- private ConsoleIntegerFieldEditor fBufferSizeEditor = null;
+ private BooleanFieldEditor2 fUseBufferSize;
+ private ConsoleIntegerFieldEditor fBufferSizeEditor;
- private ConsoleIntegerFieldEditor fTabSizeEditor = null;
+ private ConsoleIntegerFieldEditor fTabSizeEditor;
+ private BooleanFieldEditor autoScrollLockEditor;
/**
* Create the console page.
@@ -84,9 +87,6 @@ public class ConsolePreferencePage extends FieldEditorPreferencePage implements
setPreferenceStore(DebugUIPlugin.getDefault().getPreferenceStore());
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.PreferencePage#createControl(Composite)
- */
@Override
public void createControl(Composite parent) {
super.createControl(parent);
@@ -140,7 +140,8 @@ 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()));
+ autoScrollLockEditor = new BooleanFieldEditor(IConsoleConstants.P_CONSOLE_AUTO_SCROLL_LOCK, DebugPreferencesMessages.ConsolePreferencePage_Show__Console_View_enable_auto_scroll_lock, SWT.NONE, getFieldEditorParent());
+ addField(autoScrollLockEditor);
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()));
@@ -162,9 +163,6 @@ public class ConsolePreferencePage extends FieldEditorPreferencePage implements
public void init(IWorkbench workbench) {
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
@Override
public boolean performOk() {
boolean ok= super.performOk();
@@ -183,10 +181,19 @@ public class ConsolePreferencePage extends FieldEditorPreferencePage implements
protected void initialize() {
super.initialize();
updateWidthEditor();
+ updateAutoScrollLockEditor();
updateBufferSizeEditor();
}
/**
+ * Because the autoscroll value is in another plugin we must update the preference store manually
+ */
+ protected void updateAutoScrollLockEditor() {
+ autoScrollLockEditor.setPreferenceStore(ConsolePlugin.getDefault().getPreferenceStore());
+ autoScrollLockEditor.load();
+ }
+
+ /**
* Update enablement of width editor based on enablement of 'fixed width' editor.
*/
protected void updateWidthEditor() {
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 2ca9e09ff..c341c6fa3 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
@@ -320,10 +320,7 @@ 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)) {
+ } else if (property.equals(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT)) {
boolean activateOnOut = store.getBoolean(IDebugPreferenceConstants.CONSOLE_OPEN_ON_OUT);
@SuppressWarnings("resource")
IOConsoleOutputStream stream = getStream(IDebugUIConstants.ID_STANDARD_OUTPUT_STREAM);
@@ -452,7 +449,6 @@ 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/plugin.xml b/org.eclipse.ui.console/plugin.xml
index c2d548e66..b9ab44e67 100644
--- a/org.eclipse.ui.console/plugin.xml
+++ b/org.eclipse.ui.console/plugin.xml
@@ -6,7 +6,7 @@
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:
IBM Corporation - initial API and implementation
-->
@@ -30,12 +30,12 @@
</view>
</extension>
<!-- commands and their bindings
-NOTE:
-M1 = CTRL/COMMAND
-M2 = SHIFT
-M3 = ALT
+NOTE:
+M1 = CTRL/COMMAND
+M2 = SHIFT
+M3 = ALT
M4 = Platform-specific fourth key
--->
+-->
<extension point="org.eclipse.ui.bindings">
<key
commandId="org.eclipse.ui.views.showView"
@@ -46,10 +46,10 @@ M4 = Platform-specific fourth key
value="org.eclipse.ui.console.ConsoleView">
</parameter>
</key>
- <key
+ <key
platform="carbon"
sequence="M2+M3+Q C"
-
+
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
<key
commandId="org.eclipse.ui.views.showView"
@@ -88,4 +88,7 @@ M4 = Platform-specific fourth key
</context>
</extension>
+ <extension point="org.eclipse.core.runtime.preferences">
+ <initializer class="org.eclipse.ui.internal.console.ConsoleUIPreferenceInitializer"/>
+ </extension>
</plugin>
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