From d7789ca01d454f674e69d8efbe3d447f1da07383 Mon Sep 17 00:00:00 2001 From: Martin Oberhuber < martin.oberhuber@windriver.com> Date: Mon, 7 May 2012 16:38:06 +0000 Subject: [PATCH] Bug 378691 - [terminal][api] Terminal Preferences should be maintained in the Widget (for font, invert, and buffer) --- .../feature.xml | 2 +- .../META-INF/MANIFEST.MF | 4 +- .../terminals/ui/views/TerminalViewTab.java | 60 +--------------- .../plugin.xml | 3 + .../feature.xml | 2 +- .../META-INF/MANIFEST.MF | 2 +- .../META-INF/MANIFEST.MF | 2 +- .../META-INF/MANIFEST.MF | 2 +- .../META-INF/MANIFEST.MF | 2 +- .../META-INF/MANIFEST.MF | 2 +- .../META-INF/MANIFEST.MF | 2 +- .../plugin.properties | 3 +- .../org.eclipse.tm.terminal.view/plugin.xml | 27 +------- .../internal/terminal/view/TerminalView.java | 51 ++------------ .../internal/terminal/view/ViewMessages.java | 6 +- .../terminal/view/ViewMessages.properties | 6 +- .../META-INF/MANIFEST.MF | 3 +- .../org.eclipse.tm.terminal/plugin.properties | 7 +- terminal/org.eclipse.tm.terminal/plugin.xml | 29 +++++++- .../control/TerminalViewControlFactory.java | 26 ++++++- .../control/impl/TerminalMessages.java | 8 ++- .../control/impl/TerminalMessages.properties | 6 +- .../emulator/VT100TerminalControl.java | 69 ++++++++++++++++++- .../preferences/ITerminalConstants.java | 26 +++++++ .../preferences/PreferenceModifyListener.java | 48 +++++++++++++ .../TerminalPreferenceInitializer.java | 44 ++++++++++++ .../preferences/TerminalPreferencePage.java | 68 ++++++++++++++++++ 27 files changed, 352 insertions(+), 158 deletions(-) create mode 100644 terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/preferences/ITerminalConstants.java create mode 100644 terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/preferences/PreferenceModifyListener.java create mode 100644 terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java create mode 100644 terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java diff --git a/rse/features/org.eclipse.rse.terminals-feature/feature.xml b/rse/features/org.eclipse.rse.terminals-feature/feature.xml index 3445dd96ddf..64f7d041e2f 100644 --- a/rse/features/org.eclipse.rse.terminals-feature/feature.xml +++ b/rse/features/org.eclipse.rse.terminals-feature/feature.xml @@ -12,7 +12,7 @@ diff --git a/rse/plugins/org.eclipse.rse.terminals.ui/META-INF/MANIFEST.MF b/rse/plugins/org.eclipse.rse.terminals.ui/META-INF/MANIFEST.MF index 4fbf322535a..0d7d075667f 100644 --- a/rse/plugins/org.eclipse.rse.terminals.ui/META-INF/MANIFEST.MF +++ b/rse/plugins/org.eclipse.rse.terminals.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.rse.terminals.ui;singleton:=true -Bundle-Version: 1.1.100.qualifier +Bundle-Version: 1.2.0.qualifier Bundle-Activator: org.eclipse.rse.internal.terminals.ui.Activator Require-Bundle: org.eclipse.core.runtime, org.eclipse.core.expressions, @@ -12,7 +12,7 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.rse.core;bundle-version="[3.0.0,4.0.0)", org.eclipse.rse.ui;bundle-version="[3.1.0,4.0.0)", org.eclipse.rse.subsystems.terminals.core;bundle-version="[1.0.0,2.0.0)", - org.eclipse.tm.terminal;bundle-version="[3.1.0,3.2.0)" + org.eclipse.tm.terminal;bundle-version="[3.2.0,3.3.0)" Bundle-ActivationPolicy: lazy Eclipse-LazyStart: true Bundle-Vendor: %providerName diff --git a/rse/plugins/org.eclipse.rse.terminals.ui/src/org/eclipse/rse/internal/terminals/ui/views/TerminalViewTab.java b/rse/plugins/org.eclipse.rse.terminals.ui/src/org/eclipse/rse/internal/terminals/ui/views/TerminalViewTab.java index 1aa256892b8..3b6b85ad11f 100644 --- a/rse/plugins/org.eclipse.rse.terminals.ui/src/org/eclipse/rse/internal/terminals/ui/views/TerminalViewTab.java +++ b/rse/plugins/org.eclipse.rse.terminals.ui/src/org/eclipse/rse/internal/terminals/ui/views/TerminalViewTab.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2009 IBM Corporation and others. + * Copyright (c) 2002, 2012 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 @@ -21,6 +21,7 @@ * Anna Dushistova (MontaVista) - [244437] [rseterminal] Possible race condition when multiple Terminals are launched after each other * Martin Oberhuber (Wind River) - [247700] Terminal uses ugly fonts in JEE package * Anna Dushistova (MontaVista) - [267609] [rseterminal] The first "Launch Terminal" command creates no terminal tab + * Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Terminal Widget ********************************************************************************/ package org.eclipse.rse.internal.terminals.ui.views; @@ -31,9 +32,6 @@ import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; -import org.eclipse.jface.resource.FontRegistry; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.events.ISystemResourceChangeEvents; import org.eclipse.rse.core.events.SystemResourceChangeEvent; @@ -50,7 +48,6 @@ import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.MenuEvent; import org.eclipse.swt.events.MenuListener; -import org.eclipse.swt.graphics.Font; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; @@ -67,8 +64,6 @@ import org.eclipse.tm.internal.terminal.control.actions.TerminalActionPaste; import org.eclipse.tm.internal.terminal.control.actions.TerminalActionSelectAll; import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.themes.IThemeManager; /** * This is the desktop view wrapper of the System View viewer. @@ -79,8 +74,6 @@ public class TerminalViewTab extends Composite { private final CTabFolder tabFolder; - private IPropertyChangeListener propertyChangeListener; - private Menu menu; private boolean fMenuAboutToShow; @@ -133,11 +126,6 @@ public class TerminalViewTab extends Composite { } public void dispose() { - if (propertyChangeListener != null) { - IThemeManager mgr = PlatformUI.getWorkbench().getThemeManager(); - mgr.removePropertyChangeListener(propertyChangeListener); - propertyChangeListener = null; - } if (!tabFolder.isDisposed()) { tabFolder.dispose(); } @@ -202,47 +190,6 @@ public class TerminalViewTab extends Composite { } } - public void propertyChange(PropertyChangeEvent e) { - // for now always update - if (tabFolder!=null) { - CTabItem[] items = tabFolder.getItems(); - for (int i=0; i + diff --git a/terminal/org.eclipse.tm.terminal-feature/feature.xml b/terminal/org.eclipse.tm.terminal-feature/feature.xml index 5bf70cce5da..f46dea62671 100644 --- a/terminal/org.eclipse.tm.terminal-feature/feature.xml +++ b/terminal/org.eclipse.tm.terminal-feature/feature.xml @@ -13,7 +13,7 @@ diff --git a/terminal/org.eclipse.tm.terminal.local/META-INF/MANIFEST.MF b/terminal/org.eclipse.tm.terminal.local/META-INF/MANIFEST.MF index 33241a2ce07..97bfb3fc0de 100644 --- a/terminal/org.eclipse.tm.terminal.local/META-INF/MANIFEST.MF +++ b/terminal/org.eclipse.tm.terminal.local/META-INF/MANIFEST.MF @@ -6,7 +6,7 @@ Bundle-Version: 0.2.100.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.local.LocalTerminalActivator Bundle-Localization: plugin Bundle-Vendor: %providerName -Require-Bundle: org.eclipse.tm.terminal;bundle-version="[3.1.0,3.2.0)", +Require-Bundle: org.eclipse.tm.terminal;bundle-version="[3.2.0,3.3.0)", org.eclipse.cdt.core;bundle-version="5.2.0", org.eclipse.core.runtime, org.eclipse.debug.core, diff --git a/terminal/org.eclipse.tm.terminal.serial/META-INF/MANIFEST.MF b/terminal/org.eclipse.tm.terminal.serial/META-INF/MANIFEST.MF index d81cf00368a..3e1f4363584 100644 --- a/terminal/org.eclipse.tm.terminal.serial/META-INF/MANIFEST.MF +++ b/terminal/org.eclipse.tm.terminal.serial/META-INF/MANIFEST.MF @@ -7,7 +7,7 @@ Bundle-Localization: plugin Import-Package: gnu.io;resolution:=optional Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, - org.eclipse.tm.terminal;bundle-version="[3.1.0,3.2.0)" + org.eclipse.tm.terminal;bundle-version="[3.2.0,3.3.0)" Bundle-ActivationPolicy: lazy Eclipse-LazyStart: true Eclipse-BuddyPolicy: ext diff --git a/terminal/org.eclipse.tm.terminal.ssh/META-INF/MANIFEST.MF b/terminal/org.eclipse.tm.terminal.ssh/META-INF/MANIFEST.MF index e2539d30f98..087f213bba5 100644 --- a/terminal/org.eclipse.tm.terminal.ssh/META-INF/MANIFEST.MF +++ b/terminal/org.eclipse.tm.terminal.ssh/META-INF/MANIFEST.MF @@ -7,7 +7,7 @@ Bundle-Vendor: %providerName Bundle-Localization: plugin Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, - org.eclipse.tm.terminal;bundle-version="[3.1.0,3.2.0)", + org.eclipse.tm.terminal;bundle-version="[3.2.0,3.3.0)", com.jcraft.jsch;bundle-version="[0.1.31,1.0.0)", org.eclipse.jsch.core;bundle-version="[1.0.0,2.0.0)" Bundle-RequiredExecutionEnvironment: J2SE-1.4 diff --git a/terminal/org.eclipse.tm.terminal.telnet/META-INF/MANIFEST.MF b/terminal/org.eclipse.tm.terminal.telnet/META-INF/MANIFEST.MF index e9ac8a0b0cc..ba7c00d8e01 100644 --- a/terminal/org.eclipse.tm.terminal.telnet/META-INF/MANIFEST.MF +++ b/terminal/org.eclipse.tm.terminal.telnet/META-INF/MANIFEST.MF @@ -7,7 +7,7 @@ Bundle-Vendor: %providerName Bundle-Localization: plugin Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, - org.eclipse.tm.terminal;bundle-version="[3.1.0,3.2.0)" + org.eclipse.tm.terminal;bundle-version="[3.2.0,3.3.0)" Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1, J2SE-1.4 Export-Package: org.eclipse.tm.internal.terminal.telnet;x-internal:=true diff --git a/terminal/org.eclipse.tm.terminal.test/META-INF/MANIFEST.MF b/terminal/org.eclipse.tm.terminal.test/META-INF/MANIFEST.MF index ee3a27997d7..ea99cb13bc2 100644 --- a/terminal/org.eclipse.tm.terminal.test/META-INF/MANIFEST.MF +++ b/terminal/org.eclipse.tm.terminal.test/META-INF/MANIFEST.MF @@ -6,7 +6,7 @@ Bundle-Version: 2.2.0.qualifier Bundle-Vendor: %providerName Bundle-Localization: plugin Require-Bundle: org.junit, - org.eclipse.tm.terminal;bundle-version="[3.1.0,3.2.0)", + org.eclipse.tm.terminal;bundle-version="[3.2.0,3.3.0)", org.eclipse.core.runtime, org.eclipse.ui Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/terminal/org.eclipse.tm.terminal.view/META-INF/MANIFEST.MF b/terminal/org.eclipse.tm.terminal.view/META-INF/MANIFEST.MF index 9fcc12af27b..d266162b80a 100644 --- a/terminal/org.eclipse.tm.terminal.view/META-INF/MANIFEST.MF +++ b/terminal/org.eclipse.tm.terminal.view/META-INF/MANIFEST.MF @@ -7,7 +7,7 @@ Bundle-Activator: org.eclipse.tm.internal.terminal.view.TerminalViewPlugin Bundle-Localization: plugin Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, - org.eclipse.tm.terminal;bundle-version="[3.1.0,3.2.0)" + org.eclipse.tm.terminal;bundle-version="[3.2.0,3.3.0)" Bundle-ActivationPolicy: lazy Eclipse-LazyStart: true Bundle-RequiredExecutionEnvironment: J2SE-1.4 diff --git a/terminal/org.eclipse.tm.terminal.view/plugin.properties b/terminal/org.eclipse.tm.terminal.view/plugin.properties index 523ed9c45ec..98ad1451b30 100644 --- a/terminal/org.eclipse.tm.terminal.view/plugin.properties +++ b/terminal/org.eclipse.tm.terminal.view/plugin.properties @@ -13,10 +13,9 @@ # Contributors: # Michael Scharf (Wind River) - split into core, view and connector plugins # Martin Oberhuber (Wind River) - fixed copyright headers and beautified +# Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget ########################################################################## pluginName = Target Management Terminal View providerName = Eclipse TM Project terminal.views.category.name = Terminal terminal.views.view.name = Terminal -terminal.views.view.font.description = The font for the terminal console. -terminal.views.view.font.label = Terminal Console Font diff --git a/terminal/org.eclipse.tm.terminal.view/plugin.xml b/terminal/org.eclipse.tm.terminal.view/plugin.xml index dbb050174da..b43368431ee 100644 --- a/terminal/org.eclipse.tm.terminal.view/plugin.xml +++ b/terminal/org.eclipse.tm.terminal.view/plugin.xml @@ -1,7 +1,7 @@ - - - - - - - - - %terminal.views.view.font.description - - - - - - diff --git a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalView.java b/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalView.java index c1ed64ebb16..a378fe2c2a0 100644 --- a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalView.java +++ b/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalView.java @@ -26,13 +26,13 @@ * Michael Scharf (Wind River) - [262996] get rid of TerminalState.OPENED * Martin Oberhuber (Wind River) - [205486] Enable ScrollLock * Ahmet Alptekin (Tubitak) - [244405] Add a UI Control for setting the Terminal's encoding + * Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget *******************************************************************************/ package org.eclipse.tm.internal.terminal.view; import java.util.HashSet; import java.util.Set; -import org.eclipse.core.runtime.Preferences; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; @@ -68,6 +68,7 @@ import org.eclipse.tm.internal.terminal.control.actions.TerminalActionCopy; import org.eclipse.tm.internal.terminal.control.actions.TerminalActionCut; import org.eclipse.tm.internal.terminal.control.actions.TerminalActionPaste; import org.eclipse.tm.internal.terminal.control.actions.TerminalActionSelectAll; +import org.eclipse.tm.internal.terminal.preferences.ITerminalConstants; import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore; import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; import org.eclipse.tm.internal.terminal.provisional.api.LayeredSettingsStore; @@ -95,7 +96,7 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalVi private static final String STORE_TITLE = "Title"; //$NON-NLS-1$ - public static final String FONT_DEFINITION = "terminal.views.view.font.definition"; //$NON-NLS-1$ + public static final String FONT_DEFINITION = ITerminalConstants.FONT_DEFINITION; protected ITerminalViewControl fCtlTerminal; @@ -135,18 +136,6 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalVi private SettingsStore fStore; private final ITerminalViewConnectionManager fMultiConnectionManager=new TerminalViewConnectionManager(); - /** - * Listens to changes in the preferences - */ - private final IPropertyChangeListener fPreferenceListener=new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - if(event.getProperty().equals(TerminalPreferencePage.PREF_LIMITOUTPUT) - || event.getProperty().equals(TerminalPreferencePage.PREF_BUFFERLINES) - || event.getProperty().equals(TerminalPreferencePage.PREF_INVERT_COLORS)) { - updatePreferences(); - } - } - }; private PageBook fPageBook; @@ -230,23 +219,6 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalVi uniqueTitle=title+" "+i++; //$NON-NLS-1$ } } - /** - * Update the text limits from the preferences - */ - private void updatePreferences() { - Preferences preferences = TerminalViewPlugin.getDefault().getPluginPreferences(); -// boolean limitOutput = preferences.getBoolean(TerminalPreferencePage.PREF_LIMITOUTPUT); -// if(!limitOutput) -// bufferLineLimit=-1; - int bufferLineLimit = preferences.getInt(TerminalPreferencePage.PREF_BUFFERLINES); - boolean invert=preferences.getBoolean(TerminalPreferencePage.PREF_INVERT_COLORS); - // update the preferences for all controls - ITerminalViewConnection[] conn=fMultiConnectionManager.getConnections(); - for (int i = 0; i < conn.length; i++) { - conn[i].getCtlTerminal().setBufferLineLimit(bufferLineLimit); - conn[i].getCtlTerminal().setInvertedColors(invert); - } - } /** * Display a new Terminal view. This method is called when the user clicks the New * Terminal button in any Terminal view's toolbar. @@ -404,12 +376,7 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalVi } public void onTerminalFontChanged() { - // set the font for all - Font font=JFaceResources.getFont(FONT_DEFINITION); - ITerminalViewConnection[] conn=fMultiConnectionManager.getConnections(); - for (int i = 0; i < conn.length; i++) { - conn[i].getCtlTerminal().setFont(font); - } + // set the font for all - empty hook for extenders } // ViewPart interface @@ -448,8 +415,6 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalVi legacyLoadState(); legacySetTitle(); - // make sure we take the values defined in the preferences - updatePreferences(); refresh(); onTerminalFontChanged(); @@ -459,8 +424,6 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalVi public void dispose() { Logger.log("entered."); //$NON-NLS-1$ - TerminalViewPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPreferenceListener); - JFaceResources.getFontRegistry().removeListener(fPropertyChangeHandler); // dispose all connections @@ -485,14 +448,12 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalVi fMultiConnectionManager.addConnection(conn); fMultiConnectionManager.setActiveConnection(conn); setupContextMenus(fCtlTerminal.getControl()); - // make sure we take the values defined in the preferences - updatePreferences(); } private ITerminalViewConnection makeViewConnection() { ITerminalConnector[] connectors = makeConnectors(); TerminalListener listener=new TerminalListener(); - ITerminalViewControl ctrl = TerminalViewControlFactory.makeControl(listener, fPageBook, connectors); + ITerminalViewControl ctrl = TerminalViewControlFactory.makeControl(listener, fPageBook, connectors, true); setTerminalControl(ctrl); ITerminalViewConnection conn = new TerminalViewConnection(fCtlTerminal); listener.setConnection(conn); @@ -502,8 +463,6 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalVi // set the connector.... ctrl.setConnector(connector); - TerminalViewPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPreferenceListener); - return conn; } diff --git a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ViewMessages.java b/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ViewMessages.java index 30b76eabbfe..ef6dc75e7c2 100644 --- a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ViewMessages.java +++ b/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ViewMessages.java @@ -17,6 +17,7 @@ * Martin Oberhuber (Wind River) - [206917] Add validation for Terminal Settings * Martin Oberhuber (Wind River) - [262996] get rid of TerminalState.OPENED * Ahmet Alptekin (Tubitak) - [244405] Add a UI Control for setting the Terminal's encoding + * Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget *******************************************************************************/ package org.eclipse.tm.internal.terminal.view; @@ -40,11 +41,6 @@ public class ViewMessages extends NLS { public static String ENCODING; public static String ENCODING_WITH_PARENTHESES; - public static String INVERT_COLORS; - public static String BUFFERLINES; - public static String SERIALTIMEOUT; - public static String NETWORKTIMEOUT; - public static String STATE_CONNECTED; public static String STATE_CONNECTING; public static String STATE_CLOSED; diff --git a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ViewMessages.properties b/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ViewMessages.properties index c47c18fe850..92321c96442 100644 --- a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ViewMessages.properties +++ b/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ViewMessages.properties @@ -17,6 +17,7 @@ # Martin Oberhuber (Wind River) - [206917] Add validation for Terminal Settings # Martin Oberhuber (Wind River) - [262996] get rid of TerminalState.OPENED # Ahmet Alptekin (Tubitak) - [244405] Add a UI Control for setting the Terminal's encoding +# Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget ############################################################################### NO_CONNECTION_SELECTED = No Connection Selected PROP_TITLE = Terminal @@ -32,11 +33,6 @@ INVALID_SETTINGS = The specified settings are invalid, please review or ENCODING = Encoding: ENCODING_WITH_PARENTHESES = Encoding: ({0}) -INVERT_COLORS = Invert terminal colors -BUFFERLINES = Terminal buffer lines: -SERIALTIMEOUT = Serial timeout (seconds): -NETWORKTIMEOUT = Network timeout (seconds): - STATE_CONNECTED = CONNECTED STATE_CONNECTING = CONNECTING... STATE_CLOSED = CLOSED diff --git a/terminal/org.eclipse.tm.terminal/META-INF/MANIFEST.MF b/terminal/org.eclipse.tm.terminal/META-INF/MANIFEST.MF index 07f9489c1e5..888dd771023 100644 --- a/terminal/org.eclipse.tm.terminal/META-INF/MANIFEST.MF +++ b/terminal/org.eclipse.tm.terminal/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.tm.terminal; singleton:=true -Bundle-Version: 3.1.100.qualifier +Bundle-Version: 3.2.0.qualifier Bundle-Activator: org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -19,6 +19,7 @@ Export-Package: org.eclipse.tm.internal.terminal.connector;x-friends:="org.eclip org.eclipse.tm.internal.terminal.control.impl;x-friends:="org.eclipse.tm.terminal.test", org.eclipse.tm.internal.terminal.emulator;x-friends:="org.eclipse.tm.terminal.test", org.eclipse.tm.internal.terminal.model;x-friends:="org.eclipse.tm.terminal.test", + org.eclipse.tm.internal.terminal.preferences;x-friends:="org.eclipse.tm.terminal.view", org.eclipse.tm.internal.terminal.provisional.api; x-friends:="org.eclipse.tm.terminal.serial, org.eclipse.tm.terminal.ssh, diff --git a/terminal/org.eclipse.tm.terminal/plugin.properties b/terminal/org.eclipse.tm.terminal/plugin.properties index 78a6ff7e325..2120813cbe7 100644 --- a/terminal/org.eclipse.tm.terminal/plugin.properties +++ b/terminal/org.eclipse.tm.terminal/plugin.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2003, 2011 Wind River Systems, Inc. and others. +# Copyright (c) 2003, 2012 Wind River Systems, Inc. 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 @@ -13,6 +13,7 @@ # Contributors: # Michael Scharf (Wind River) - split into core, view and connector plugins # Martin Oberhuber (Wind River) - fixed copyright headers and beautified +# Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget ############################################################################### # NLS_MESSAGEFORMAT_NONE @@ -26,3 +27,7 @@ terminal.context.description=Override ALT+x menu access keys terminal.insertion.description=Terminal view insertion terminal.insertion.name=Terminal view insert terminal.insertion.category.name=Terminal view commands + +terminal.preferences.name = Terminal +terminal.font.description = The font for the terminal console. +terminal.font.label = Terminal Console Font diff --git a/terminal/org.eclipse.tm.terminal/plugin.xml b/terminal/org.eclipse.tm.terminal/plugin.xml index 1a1a59cedad..1115912c7e6 100644 --- a/terminal/org.eclipse.tm.terminal/plugin.xml +++ b/terminal/org.eclipse.tm.terminal/plugin.xml @@ -1,7 +1,7 @@ @@ -106,4 +107,30 @@ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" sequence="Alt+W"/> + + + + + + + + + + + + + %terminal.font.description + + + + diff --git a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/TerminalViewControlFactory.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/TerminalViewControlFactory.java index 69e11952144..5fb3d8c8571 100644 --- a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/TerminalViewControlFactory.java +++ b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/TerminalViewControlFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2012 Wind River Systems, Inc. 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 @@ -8,6 +8,7 @@ * Contributors: * Michael Scharf (Wind River) - initial API and implementation * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget *******************************************************************************/ package org.eclipse.tm.internal.terminal.control; @@ -16,7 +17,28 @@ import org.eclipse.tm.internal.terminal.emulator.VT100TerminalControl; import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; public class TerminalViewControlFactory { + /** + * Instantiate a Terminal widget. + * @param target Callback for notifying the owner of Terminal state changes. + * @param wndParent The Window parent to embed the Terminal in. + * @param connectors Provided connectors. + */ public static ITerminalViewControl makeControl(ITerminalListener target, Composite wndParent, ITerminalConnector[] connectors) { - return new VT100TerminalControl(target, wndParent, connectors); + return makeControl(target, wndParent, connectors, false); } + + /** + * Instantiate a Terminal widget. + * @param target Callback for notifying the owner of Terminal state changes. + * @param wndParent The Window parent to embed the Terminal in. + * @param connectors Provided connectors. + * @param useCommonPrefs If true, the Terminal widget will pick up settings + * from the org.eclipse.tm.terminal.TerminalPreferencePage Preference page. + * Otherwise, clients need to maintain settings themselves. + * @since 3.2 + */ + public static ITerminalViewControl makeControl(ITerminalListener target, Composite wndParent, ITerminalConnector[] connectors, boolean useCommonPrefs) { + return new VT100TerminalControl(target, wndParent, connectors, useCommonPrefs); + } + } diff --git a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.java index a54f02e6d25..a3f26a37c1a 100644 --- a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.java +++ b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2012 Wind River Systems, Inc. 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 @@ -8,6 +8,7 @@ * Contributors: * Michael Scharf (Wind River) - initial API and implementation * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget *******************************************************************************/ package org.eclipse.tm.internal.terminal.control.impl; @@ -23,4 +24,9 @@ public class TerminalMessages extends NLS { public static String IOError; public static String CannotConnectTo; public static String NotInitialized; + + //Preference Page + public static String INVERT_COLORS; + public static String BUFFERLINES; + } diff --git a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.properties b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.properties index c77d4ee2d13..9916dadcf5f 100644 --- a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.properties +++ b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/impl/TerminalMessages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2003, 2009 Wind River Systems, Inc. and others. +# Copyright (c) 2003, 2012 Wind River Systems, Inc. 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 @@ -13,6 +13,7 @@ # Contributors: # Michael Scharf (Wind River) - split into core, view and connector plugins # Martin Oberhuber (Wind River) - fixed copyright headers and beautified +# Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget ############################################################################### # NLS_MESSAGEFORMAT_VAR @@ -22,3 +23,6 @@ SocketError = Socket Error IOError = IO Error CannotConnectTo = Cannot initialize {0}:\n{1} NotInitialized = Not Initialized + +INVERT_COLORS = Invert terminal colors +BUFFERLINES = Terminal buffer lines: diff --git a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java index 0657030515f..089ade83788 100644 --- a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java +++ b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java @@ -31,6 +31,7 @@ * Martin Oberhuber (Wind River) - [348700] Terminal unusable after disconnect * Simon Bernard (Sierra Wireless) - [351424] [terminal] Terminal does not support del and insert key * Martin Oberhuber (Wind River) - [265352][api] Allow setting fonts programmatically + * Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget *******************************************************************************/ package org.eclipse.tm.internal.terminal.emulator; @@ -43,9 +44,12 @@ import java.net.SocketException; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.Clipboard; @@ -74,6 +78,7 @@ import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; import org.eclipse.tm.internal.terminal.control.impl.ITerminalControlForText; import org.eclipse.tm.internal.terminal.control.impl.TerminalMessages; import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin; +import org.eclipse.tm.internal.terminal.preferences.ITerminalConstants; import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl; import org.eclipse.tm.internal.terminal.provisional.api.Logger; @@ -121,6 +126,8 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC private FocusListener fFocusListener; private ITerminalConnector fConnector; private final ITerminalConnector[] fConnectors; + private final boolean fUseCommonPrefs; + PipedInputStream fInputStream; private static final String defaultEncoding = new java.io.InputStreamReader(new java.io.ByteArrayInputStream(new byte[0])).getEncoding(); private String fEncoding = defaultEncoding; @@ -132,13 +139,47 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC private final ITerminalTextData fTerminalModel; + /** + * Listens to changes in the preferences + */ + private final IPropertyChangeListener fPreferenceListener=new IPropertyChangeListener() { + public void propertyChange(PropertyChangeEvent event) { + if(event.getProperty().equals(ITerminalConstants.PREF_BUFFERLINES) + || event.getProperty().equals(ITerminalConstants.PREF_INVERT_COLORS)) { + updatePreferences(); + } + } + }; + private final IPropertyChangeListener fFontListener = new IPropertyChangeListener() { + public void propertyChange(PropertyChangeEvent event) { + if (event.getProperty().equals(ITerminalConstants.FONT_DEFINITION)) { + onTerminalFontChanged(); + } + } + }; + /** * Is protected by synchronize on this */ volatile private Job fJob; public VT100TerminalControl(ITerminalListener target, Composite wndParent, ITerminalConnector[] connectors) { + this(target, wndParent, connectors, false); + } + + /** + * Instantiate a Terminal widget. + * @param target Callback for notifying the owner of Terminal state changes. + * @param wndParent The Window parent to embed the Terminal in. + * @param connectors Provided connectors. + * @param useCommonPrefs If true, the Terminal widget will pick up settings + * from the org.eclipse.tm.terminal.TerminalPreferencePage Preference page. + * Otherwise, clients need to maintain settings themselves. + * @since 3.2 + */ + public VT100TerminalControl(ITerminalListener target, Composite wndParent, ITerminalConnector[] connectors, boolean useCommonPrefs) { fConnectors=connectors; + fUseCommonPrefs = useCommonPrefs; fTerminalListener=target; fTerminalModel=TerminalTextDataFactory.makeTerminalTextData(); fTerminalModel.setMaxHeight(1000); @@ -318,6 +359,10 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC */ public void disposeTerminal() { Logger.log("entered."); //$NON-NLS-1$ + if(fUseCommonPrefs) { + TerminalPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPreferenceListener); + JFaceResources.getFontRegistry().removeListener(fFontListener); + } disconnectTerminal(); fClipboard.dispose(); getTerminalText().dispose(); @@ -554,9 +599,31 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC fState=TerminalState.CLOSED; setupControls(parent); setupListeners(); + if (fUseCommonPrefs) { + updatePreferences(); + onTerminalFontChanged(); + TerminalPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPreferenceListener); + JFaceResources.getFontRegistry().addListener(fFontListener); + } setupHelp(fWndParent, TerminalPlugin.HELP_VIEW); } + /* + * (non-Javadoc) + * @see org.eclipse.tm.internal.terminal.control.ITerminalViewControl#updatePreferences() + */ + private void updatePreferences() { + int bufferLineLimit = Platform.getPreferencesService().getInt(TerminalPlugin.PLUGIN_ID, ITerminalConstants.PREF_BUFFERLINES, 0, null); + boolean invert = Platform.getPreferencesService().getBoolean(TerminalPlugin.PLUGIN_ID, ITerminalConstants.PREF_INVERT_COLORS, false, null); + setBufferLineLimit(bufferLineLimit); + setInvertedColors(invert); + } + + private void onTerminalFontChanged() { + // set the font for all + setFont(ITerminalConstants.FONT_DEFINITION); + } + /* * (non-Javadoc) * @see org.eclipse.tm.internal.terminal.control.ITerminalViewControl#setFont(java.lang.String) @@ -635,7 +702,7 @@ public class VT100TerminalControl implements ITerminalControlForText, ITerminalC fDisplay = getCtlText().getDisplay(); fClipboard = new Clipboard(fDisplay); // fViewer.setDocument(new TerminalDocument()); - setFont(JFaceResources.getTextFont()); +// setFont(JFaceResources.getTextFont()); } protected void setupListeners() { diff --git a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/preferences/ITerminalConstants.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/preferences/ITerminalConstants.java new file mode 100644 index 00000000000..0c3bae84c49 --- /dev/null +++ b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/preferences/ITerminalConstants.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2006, 2012 Wind River Systems, Inc. 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: + * Michael Scharf (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.preferences; + +public interface ITerminalConstants { + + public static final String PREF_HAS_MIGRATED = "TerminalPref.migrated"; //$NON-NLS-1$ + + public static final String PREF_BUFFERLINES = "TerminalPrefBufferLines"; //$NON-NLS-1$ + public static final String PREF_INVERT_COLORS = "TerminalPrefInvertColors"; //$NON-NLS-1$ + public static final int DEFAULT_BUFFERLINES = 1000; + public static final boolean DEFAULT_INVERT_COLORS = false; + + public static final String FONT_DEFINITION = "terminal.views.view.font.definition"; //$NON-NLS-1$ + +} diff --git a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/preferences/PreferenceModifyListener.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/preferences/PreferenceModifyListener.java new file mode 100644 index 00000000000..9e4e635cdf0 --- /dev/null +++ b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/preferences/PreferenceModifyListener.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2007, 2012 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + * Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.preferences; + +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin; +import org.osgi.service.prefs.Preferences; + +public class PreferenceModifyListener extends + org.eclipse.core.runtime.preferences.PreferenceModifyListener { + + public PreferenceModifyListener() { + // Nothing to do + } + + /** + * Intercept programmatic access to old Terminal Preferences such as "invert" + */ + public IEclipsePreferences preApply(IEclipsePreferences node) { + migrateTerminalPreferences(node.node("instance")); //$NON-NLS-1$ + return super.preApply(node); + } + + public static void migrateTerminalPreferences(Preferences node) { + Preferences terminalPrefs = node.node(TerminalPlugin.PLUGIN_ID); + Preferences oldPrefs = node.node("org.eclipse.tm.terminal.view"); //$NON-NLS-1$ + String oldInvert = oldPrefs.get(ITerminalConstants.PREF_INVERT_COLORS, null); + String oldBuflines = oldPrefs.get(ITerminalConstants.PREF_BUFFERLINES, null); + if (oldInvert != null) { + terminalPrefs.put(ITerminalConstants.PREF_INVERT_COLORS, oldInvert); + oldPrefs.remove(ITerminalConstants.PREF_INVERT_COLORS); + } + if (oldBuflines != null) { + terminalPrefs.put(ITerminalConstants.PREF_BUFFERLINES, oldBuflines); + oldPrefs.remove(ITerminalConstants.PREF_BUFFERLINES); + } + } + +} diff --git a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java new file mode 100644 index 00000000000..060a0843e1e --- /dev/null +++ b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferenceInitializer.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2006, 2012 Wind River Systems, Inc. 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: + * Michael Scharf (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.preferences; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.core.runtime.preferences.DefaultScope; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.InstanceScope; +import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin; + +public class TerminalPreferenceInitializer extends AbstractPreferenceInitializer { + + public TerminalPreferenceInitializer() { + } + + public void initializeDefaultPreferences() { + IEclipsePreferences defaultPrefs = DefaultScope.INSTANCE.getNode(TerminalPlugin.PLUGIN_ID); + defaultPrefs.putBoolean(ITerminalConstants.PREF_INVERT_COLORS, ITerminalConstants.DEFAULT_INVERT_COLORS); + defaultPrefs.putInt(ITerminalConstants.PREF_BUFFERLINES, ITerminalConstants.DEFAULT_BUFFERLINES); + migrateTerminalPreferences(); + } + + /** + * Migrate settings from the older org.eclipse.tm.terminal.view bundle into the o.e.tm.terminal bundle + */ + public static void migrateTerminalPreferences() { + IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(TerminalPlugin.PLUGIN_ID); + if (!prefs.getBoolean(ITerminalConstants.PREF_HAS_MIGRATED, false)) { + prefs.putBoolean(ITerminalConstants.PREF_HAS_MIGRATED, true); + PreferenceModifyListener.migrateTerminalPreferences(InstanceScope.INSTANCE.getNode("")); //$NON-NLS-1$ + } + } + +} diff --git a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java new file mode 100644 index 00000000000..c002e3850f0 --- /dev/null +++ b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2003, 2012 Wind River Systems, Inc. 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 + * + * Initial Contributors: + * The following Wind River employees contributed to the Terminal component + * that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, + * Helmut Haigermoser and Ted Williams. + * + * Contributors: + * Michael Scharf (Wind River) - split into core, view and connector plugins + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.preferences; + +import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.IntegerFieldEditor; +import org.eclipse.tm.internal.terminal.control.impl.TerminalMessages; +import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +public class TerminalPreferencePage extends FieldEditorPreferencePage implements + IWorkbenchPreferencePage { + protected BooleanFieldEditor fInvertColors; + + protected IntegerFieldEditor fEditorBufferSize; + + public TerminalPreferencePage() { + super(GRID); + } + protected void createFieldEditors() { + setupPage(); + } + public void init(IWorkbench workbench) { + // do nothing + } + protected void setupPage() { + setupData(); + setupEditors(); + } + protected void setupData() { + TerminalPlugin plugin; + IPreferenceStore preferenceStore; + + plugin = TerminalPlugin.getDefault(); + preferenceStore = plugin.getPreferenceStore(); + setPreferenceStore(preferenceStore); + } + protected void setupEditors() { + fInvertColors = new BooleanFieldEditor( + ITerminalConstants.PREF_INVERT_COLORS, TerminalMessages.INVERT_COLORS, + getFieldEditorParent()); + fEditorBufferSize = new IntegerFieldEditor(ITerminalConstants.PREF_BUFFERLINES, + TerminalMessages.BUFFERLINES, getFieldEditorParent()); + + fEditorBufferSize.setValidRange(0, Integer.MAX_VALUE); + + addField(fInvertColors); + addField(fEditorBufferSize); + } +}