1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-02 22:55:26 +02:00

Bug 378691 - [terminal][api] Terminal Preferences should be maintained in the Widget (for font, invert, and buffer)

This commit is contained in:
Martin Oberhuber 2012-05-07 16:38:06 +00:00
parent 68a3645b49
commit d7789ca01d
27 changed files with 352 additions and 158 deletions

View file

@ -12,7 +12,7 @@
<feature
id="org.eclipse.rse.terminals"
label="%featureName"
version="1.1.100.qualifier"
version="1.2.0.qualifier"
provider-name="%providerName"
plugin="org.eclipse.rse.terminals.ui"
image="eclipse_update_120.jpg">

View file

@ -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

View file

@ -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<items.length; i++) {
Object control = items[i].getData(DATA_KEY_CONTROL);
if (control instanceof ITerminalViewControl) {
updateTheme((ITerminalViewControl) control);
}
}
}
}
public void updateTheme(final ITerminalViewControl control) {
if (control != null) {
IThemeManager mgr = PlatformUI.getWorkbench().getThemeManager();
Font font;
FontRegistry fr = mgr.getCurrentTheme().getFontRegistry();
if (fr.hasValueFor("terminal.views.view.font.definition")) { //$NON-NLS-1$
//Terminal View font if available
font = fr.get("terminal.views.view.font.definition"); //$NON-NLS-1$
} else if (fr.hasValueFor("REMOTE_COMMANDS_VIEW_FONT")) { //$NON-NLS-1$
//fallback: "Remote Shell Font"
font = fr.get("REMOTE_COMMANDS_VIEW_FONT"); //$NON-NLS-1$
} else {
//fallback: "Basic Text Font"
font = fr.get("org.eclipse.jface.textfont"); //$NON-NLS-1$
}
control.setFont(font);
if (propertyChangeListener == null) {
final TerminalViewTab myself = this;
propertyChangeListener = new IPropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
myself.propertyChange(event);
}
};
mgr.addPropertyChangeListener(propertyChangeListener);
}
}
}
public CTabItem createTabItem(IAdaptable root,
final String initialWorkingDirCmd) {
final CTabItem item = new CTabItem(tabFolder, SWT.CLOSE);
@ -301,7 +248,7 @@ public class TerminalViewTab extends Composite {
public void setTerminalTitle(String title) {
}
}, c, new ITerminalConnector[] { connector });
}, c, new ITerminalConnector[] { connector }, true);
// Specify Encoding for Terminal
try {
terminalControl.setEncoding(host.getDefaultEncoding(true));
@ -310,7 +257,6 @@ public class TerminalViewTab extends Composite {
}
terminalControl.setConnector(connector);
item.setData(DATA_KEY_CONTROL, terminalControl);
updateTheme(terminalControl);
terminalControl.connectTerminal();
}
item.setControl(c);

View file

@ -65,6 +65,9 @@
<activityPatternBinding
activityId="org.eclipse.tm.terminal.activity"
pattern="org\.eclipse\.tm\.terminal\..*/.*"/>
<activityPatternBinding
activityId="org.eclipse.tm.terminal.activity"
pattern="org\.eclipse\.tm\.terminal/.*"/>
</extension>
</plugin>

View file

@ -13,7 +13,7 @@
<feature
id="org.eclipse.tm.terminal"
label="%featureName"
version="3.1.100.qualifier"
version="3.2.0.qualifier"
provider-name="%providerName">
<description>

View file

@ -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,

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<!--
# Copyright (c) 2003, 2008 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
@ -15,6 +15,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
-->
<plugin>
<extension
@ -42,30 +43,6 @@
</view>
</perspectiveExtension>
</extension>
<extension
point="org.eclipse.ui.preferencePages">
<page
name="%terminal.views.view.name"
class="org.eclipse.tm.internal.terminal.view.TerminalPreferencePage"
id="org.eclipse.tm.terminal.TerminalPreferencePage">
</page>
</extension>
<extension
point="org.eclipse.ui.fontDefinitions">
<fontDefinition
label="%terminal.views.view.font.label"
defaultsTo="org.eclipse.jface.textfont"
id="terminal.views.view.font.definition">
<description>
%terminal.views.view.font.description
</description>
</fontDefinition>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer class="org.eclipse.tm.internal.terminal.view.TerminalPreferenceInitializer"/>
</extension>
<!-- ============================================ -->
<!-- Define Help Context -->

View file

@ -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;
}

View file

@ -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;

View file

@ -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

View file

@ -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,

View file

@ -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

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<!--
# 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
@ -11,6 +11,7 @@
# Michael Scharf (Wind River) - initial API and implementation
# Martin Oberhuber (Wind River) - fixed copyright headers and beautified
# Michael Scharf (Wind River) - [237425] undefined tm.terminal command
# Martin Oberhuber (Wind River) - [378691][api] push Preferences into the Widget
-->
<plugin>
<extension-point id="terminalConnectors" name="Terminal Connectors" schema="schema/terminalConnectors.exsd"/>
@ -106,4 +107,30 @@
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="Alt+W"/> <!-- Window -->
</extension>
<extension
point="org.eclipse.ui.preferencePages">
<page
name="%terminal.preferences.name"
class="org.eclipse.tm.internal.terminal.preferences.TerminalPreferencePage"
id="org.eclipse.tm.terminal.TerminalPreferencePage">
</page>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer class="org.eclipse.tm.internal.terminal.preferences.TerminalPreferenceInitializer"/>
<modifier class="org.eclipse.tm.internal.terminal.preferences.PreferenceModifyListener"/>
</extension>
<extension
point="org.eclipse.ui.themes" id="terminal.font">
<fontDefinition
defaultsTo="org.eclipse.jface.textfont"
id="terminal.views.view.font.definition"
label="%terminal.font.label">
<description>
%terminal.font.description
</description>
</fontDefinition>
</extension>
</plugin>

View file

@ -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 <code>true</code>, the Terminal widget will pick up settings
* from the <code>org.eclipse.tm.terminal.TerminalPreferencePage</code> 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);
}
}

View file

@ -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;
}

View file

@ -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:

View file

@ -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 <code>true</code>, the Terminal widget will pick up settings
* from the <code>org.eclipse.tm.terminal.TerminalPreferencePage</code> 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() {

View file

@ -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$
}

View file

@ -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);
}
}
}

View file

@ -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$
}
}
}

View file

@ -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);
}
}