June 5, 2007
+The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at http://www.eclipse.org/legal/epl-v10.html. +For purposes of the EPL, "Program" will mean the Content.
+ +If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at http://www.eclipse.org.
+ + + + \ No newline at end of file diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/about.ini b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/about.ini new file mode 100644 index 00000000000..3adc27ab587 --- /dev/null +++ b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/about.ini @@ -0,0 +1,27 @@ +# about.ini +# contains information about a feature +# java.io.Properties file (ISO 8859-1 with "\" escapes) +# "%key" are externalized strings defined in about.properties +# This file does not need to be translated. + +# Property "aboutText" contains blurb for "About" dialog (translated) +aboutText=%blurb + +# Property "windowImage" contains path to window icon (16x16) +# needed for primary features only + +# Property "featureImage" contains path to feature image (32x32) +featureImage=tm32.png + +# Property "aboutImage" contains path to product image (500x330 or 115x164) +# needed for primary features only + +# Property "appName" contains name of the application (not translated) +# needed for primary features only + +# Property "welcomePage" contains path to welcome page (special XML-based format) +# optional + +# Property "welcomePerspective" contains the id of the perspective in which the +# welcome page is to be opened. +# optional \ No newline at end of file diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/about.mappings b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/about.mappings new file mode 100644 index 00000000000..bddaab43109 --- /dev/null +++ b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/about.mappings @@ -0,0 +1,6 @@ +# about.mappings +# contains fill-ins for about.properties +# java.io.Properties file (ISO 8859-1 with "\" escapes) +# This file does not need to be translated. + +0=@build@ \ No newline at end of file diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/about.properties b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/about.properties new file mode 100644 index 00000000000..10075af5412 --- /dev/null +++ b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/about.properties @@ -0,0 +1,25 @@ +################################################################################ +# Copyright (c) 2006, 2015 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: +# Martin Oberhuber - initial API and implementation +################################################################################ +# about.properties +# contains externalized strings for about.ini +# java.io.Properties file (ISO 8859-1 with "\" escapes) +# fill-ins are supplied by about.mappings +# This file should be translated. +# +# Do not translate any values surrounded by {} + +blurb=Target Management Terminal View (Deprecated)\n\ +\n\ +Version: {featureVersion}\n\ +Build id: {0}\n\ +\n\ +(c) Copyright Wind River Systems, Inc. and others 2003, 2014. All rights reserved.\n\ +Visit http://www.eclipse.org/tm diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/build.properties b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/build.properties new file mode 100644 index 00000000000..51984c14501 --- /dev/null +++ b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/build.properties @@ -0,0 +1,33 @@ +################################################################################ +# Copyright (c) 2003, 2015 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 +################################################################################ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + icons/,\ + plugin.properties,\ + about.html,\ + about.ini,\ + about.mappings,\ + about.properties,\ + tm32.png,\ + HelpContexts.xml,\ + doc/,\ + toc.xml,\ + TerminalContexts.xml +src.includes = about.html diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/doc/book.css b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/doc/book.css new file mode 100644 index 00000000000..faa4199fe34 --- /dev/null +++ b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/doc/book.css @@ -0,0 +1 @@ +@import "../../PRODUCT_PLUGIN/book.css"; diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/doc/html/01_terminalview.html b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/doc/html/01_terminalview.html new file mode 100644 index 00000000000..c423cbf8be5 --- /dev/null +++ b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/doc/html/01_terminalview.html @@ -0,0 +1,46 @@ + + + + + + + + ++The Terminal view provides a raw serial or network connection to your target board. +This view is useful for monitoring output on a target's serial port or making a telnet +connection to a device. +
+The Terminal view is activated by choosing Window > Show View > Other > Terminal > Terminal. +
Button |
+ Description |
+
Connect to selected target. |
+ |
Disconnect from selected connection. |
+ |
Open the Terminal Settings dialog. + While connected, only the connection's title can be changed. |
+ |
Toggle the Command Input field, + for editing complex command lines on dumb terminals. |
+ |
Toggle Scroll Lock in the current terminal connection. |
+ |
Select a Terminal connection to show in this view instance. + Only available when multiple connections have been defined in this view. |
+ |
Open another Terminal connection in the current view, or in a new Terminal view instance. |
+ |
Remove the currently selected Terminal Connection from this view. + Only available when multiple connections have been defined in this view. |
+
+
+ ++ Each instance of the Terminal view can hold multiple connections, each of which can in + turn be connected to a different remote endpoint + (either serial or network). Of course, the number of serial connections is limited by the + number of serial ports. + |
+Use the Terminal Settings dialog to configure your connection. + |
+In the Connection Type field choose Serial, SSH or Telnet. + |
+The View Title field allows giving a name to your Terminal View instance. + |
+If you choose a serial connection, the Settings area has seven options: + Port, Baud Rate, Data Bits, Stop Bits, Parity, Flow Control, + and Timeout. + |
+When you have entered your settings, click OK. This initiates your connection. |
+Your connection information appears in the header of the Terminal view. +A cursor appears in the view itself. Hit ENTER to get a >NET> +prompt. |
+ NOTE:When using the Terminal view on Linux or Solaris, + serial ports ttyS0 and ttyS1 must have appropriate permissions + set in order to connect to them, unless you are running the Workbench as root. + | |
+ |
+If you choose an SSH connection, the Settings area has six options.
+In the Host and Port fields, enter the IP Address and port of the host
+you wish to connect to.
+The User field specifies the remote user id to use.
+The Password field is optional, since SSH can re-use your private keys
+as specified on the Eclipse Preferences, General, Network Page.
+The Timeout can be changed for very slow networks. The
+KeepAlive value specifies an interval in seconds, by which the Terminal
+automatically sends a packet to the remote host in order to keep the connection
+alive even in case of inactivity.
+ When all settings are specified, click +OK. This initiates your connection. |
+If you choose a Telnet connection, the Settings area has three options. +In the Host field, enter the IP Address of the host you wish to connect to. +In the Port field, select the network port you wish to use. +The Timeout can be changed for very slow networks. Then click +OK. This initiates your connection. |
+Your connection information appears in the header of the Terminal view. +A cursor appears in the view itself. Hit ENTER to get a >NET> prompt. + |
+The Terminal view is an ANSI-conformant terminal emulator. You can use the +Terminal view to telnet into a remote UNIX host. + |
+To do so, set the TERM environment variable on the remote host to ansi. +This enables programs on the remote host, such as vi and Emacs, +to display text properly. +The Terminal view does not currently support other emulation modes, such as VT100. + |
+The size of the terminal window as understood by the remote is automatically +adjusted as the size of your Terminal view changes. +The colors and font used by the Terminal can be configured in the +Eclipse Preferences, Appearance section. A separate Terminal Preference +Page allows inverting the terminal colors easily if desired. + |
+The optional Command Input Field can be enabled when sending commands to a dumb +terminal that does not support cursor keys for editing. In such a case, the +Command Input Field provides a full editor that supports cursor navigation, copy +and paste, as well as a history of previous commands that can be accessed by +Ctrl+Space content assist. + |
+If more space than the default single editing line is needed for very complex commands, +the Command Input Field can be enlarged by dragging its upper handle up with +the mouse. + |
+The material in this guide is Copyright (c) Wind River Systems, Inc. and others 2004, 2012. +
++Terms and conditions regarding the use of this guide. +
+ + \ No newline at end of file diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/clcl16/command_input_field.gif b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/clcl16/command_input_field.gif new file mode 100644 index 00000000000..9e3a547c145 Binary files /dev/null and b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/clcl16/command_input_field.gif differ diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/clcl16/connect_co.gif b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/clcl16/connect_co.gif new file mode 100644 index 00000000000..556b230da56 Binary files /dev/null and b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/clcl16/connect_co.gif differ diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/clcl16/disconnect_co.gif b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/clcl16/disconnect_co.gif new file mode 100644 index 00000000000..f1d5fb31e51 Binary files /dev/null and b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/clcl16/disconnect_co.gif differ diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/clcl16/lock_co.gif b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/clcl16/lock_co.gif new file mode 100644 index 00000000000..68fd6cf39ca Binary files /dev/null and b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/clcl16/lock_co.gif differ diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/clcl16/newterminal.gif b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/clcl16/newterminal.gif new file mode 100644 index 00000000000..80201e0d469 Binary files /dev/null and b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/clcl16/newterminal.gif differ diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/clcl16/properties_tsk.gif b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/clcl16/properties_tsk.gif new file mode 100644 index 00000000000..41b5adbd543 Binary files /dev/null and b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/clcl16/properties_tsk.gif differ diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/cview16/terminal_view.gif b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/cview16/terminal_view.gif new file mode 100644 index 00000000000..bbb6a9e153e Binary files /dev/null and b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/cview16/terminal_view.gif differ diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/dlcl16/command_input_field.gif b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/dlcl16/command_input_field.gif new file mode 100644 index 00000000000..f538ca707fc Binary files /dev/null and b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/dlcl16/command_input_field.gif differ diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/dlcl16/connect_co.gif b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/dlcl16/connect_co.gif new file mode 100644 index 00000000000..ae5e64b9f6f Binary files /dev/null and b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/dlcl16/connect_co.gif differ diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/dlcl16/disconnect_co.gif b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/dlcl16/disconnect_co.gif new file mode 100644 index 00000000000..24a628713dc Binary files /dev/null and b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/dlcl16/disconnect_co.gif differ diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/dlcl16/lock_co.gif b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/dlcl16/lock_co.gif new file mode 100644 index 00000000000..b7764789356 Binary files /dev/null and b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/dlcl16/lock_co.gif differ diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/dlcl16/newterminal.gif b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/dlcl16/newterminal.gif new file mode 100644 index 00000000000..80201e0d469 Binary files /dev/null and b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/dlcl16/newterminal.gif differ diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/dlcl16/properties_tsk.gif b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/dlcl16/properties_tsk.gif new file mode 100644 index 00000000000..c307524a7a4 Binary files /dev/null and b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/dlcl16/properties_tsk.gif differ diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/dlcl16/rem_co.gif b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/dlcl16/rem_co.gif new file mode 100644 index 00000000000..559e462985f Binary files /dev/null and b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/dlcl16/rem_co.gif differ diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/elcl16/command_input_field.gif b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/elcl16/command_input_field.gif new file mode 100644 index 00000000000..f538ca707fc Binary files /dev/null and b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/elcl16/command_input_field.gif differ diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/elcl16/connect_co.gif b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/elcl16/connect_co.gif new file mode 100644 index 00000000000..c0de0d32dd6 Binary files /dev/null and b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/elcl16/connect_co.gif differ diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/elcl16/disconnect_co.gif b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/elcl16/disconnect_co.gif new file mode 100644 index 00000000000..ef5bfa8ad71 Binary files /dev/null and b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/elcl16/disconnect_co.gif differ diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/elcl16/lock_co.gif b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/elcl16/lock_co.gif new file mode 100644 index 00000000000..68fd6cf39ca Binary files /dev/null and b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/elcl16/lock_co.gif differ diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/elcl16/newterminal.gif b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/elcl16/newterminal.gif new file mode 100644 index 00000000000..80201e0d469 Binary files /dev/null and b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/elcl16/newterminal.gif differ diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/elcl16/properties_tsk.gif b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/elcl16/properties_tsk.gif new file mode 100644 index 00000000000..41b5adbd543 Binary files /dev/null and b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/elcl16/properties_tsk.gif differ diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/elcl16/rem_co.gif b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/elcl16/rem_co.gif new file mode 100644 index 00000000000..2cd9c544436 Binary files /dev/null and b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/elcl16/rem_co.gif differ diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/eview16/terminal_view.gif b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/eview16/terminal_view.gif new file mode 100644 index 00000000000..bbb6a9e153e Binary files /dev/null and b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/icons/eview16/terminal_view.gif differ diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/plugin.properties b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/plugin.properties new file mode 100644 index 00000000000..8bc93b55917 --- /dev/null +++ b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/plugin.properties @@ -0,0 +1,21 @@ +########################################################################## +# Copyright (c) 2003, 2015 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 +########################################################################## +pluginName = Target Management Terminal View (Deprecated) +providerName = Eclipse TM Project +terminal.views.category.name = Terminal +terminal.views.view.name = Terminal diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/plugin.xml b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/plugin.xml new file mode 100644 index 00000000000..b43368431ee --- /dev/null +++ b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/plugin.xml @@ -0,0 +1,58 @@ + + + +Shell
by the specified amounts.
+ * Do not increase the size of the Shell beyond the bounds of the Display.
+ */
+ protected void setShellSize(Point size) {
+ Rectangle bounds = getShell().getMonitor().getClientArea();
+ getShell().setSize(Math.min(size.x, bounds.width), Math.min(size.y, bounds.height));
+ }
+
+ protected void okPressed() {
+ if (!validateSettings()) {
+ showErrorMessage(ViewMessages.INVALID_SETTINGS);
+ return;
+ }
+ if (!updateValidState()) {
+ showErrorMessage(ViewMessages.ENCODING_NOT_AVAILABLE);
+ return;
+ }
+ if(fSelectedConnector>=0) {
+ getPage(fSelectedConnector).saveSettings();
+ }
+ fTerminalTitle=fTerminalTitleText.getText();
+ fEncoding = fEncodingCombo.getText();
+ super.okPressed();
+ }
+ protected void cancelPressed() {
+ fSelectedConnector=-1;
+ super.cancelPressed();
+ }
+ public int open() {
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ return super.open();
+ }
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+
+ newShell.setText(fTitle);
+ }
+ protected Control createDialogArea(Composite parent) {
+ Composite ctlComposite = (Composite) super.createDialogArea(parent);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(ctlComposite, TerminalViewPlugin.HELPPREFIX + "terminal_settings"); //$NON-NLS-1$
+
+ setupPanel(ctlComposite);
+ setupListeners();
+ initFields();
+
+ return ctlComposite;
+ }
+ public void create() {
+ super.create();
+ // initialize the OK button after creating the all dialog elements
+ updateOKButton();
+ }
+ private void initFields() {
+ // Load controls
+ for (int i = 0; i < fConnectors.length; i++) {
+ fCtlConnTypeCombo.add(fConnectors[i].getName());
+ }
+ int selectedConnector=getInitialConnector();
+ if(selectedConnector>=0) {
+ fCtlConnTypeCombo.select(selectedConnector);
+ selectPage(selectedConnector);
+ }
+ doLoad();
+ setCombo(fEncodingCombo, fEncoding);
+ }
+ /**
+ * @return the connector to show when the dialog opens
+ */
+ private int getInitialConnector() {
+ // if there is a selection, use it
+ if(fSelectedConnector>=0)
+ return fSelectedConnector;
+ // try the telnet connector, because it is the cheapest
+ for (int i = 0; i < fConnectors.length; i++) {
+ if("org.eclipse.tm.internal.terminal.telnet.TelnetConnector".equals(fConnectors[i].getId())) //$NON-NLS-1$
+ return i;
+ }
+ // if no telnet connector available, use the first one in the list
+ if(fConnectors.length>0)
+ return 0;
+ return -1;
+ }
+ private boolean validateSettings() {
+ if(fSelectedConnector<0)
+ return true;
+ return getPage(fSelectedConnector).validateSettings();
+ }
+ private void setupPanel(Composite wndParent) {
+ setupSettingsTypePanel(wndParent);
+ //setupEncodingPanel(wndParent);
+ if(fConnectors.length>0) {
+ setupConnTypePanel(wndParent);
+ setupSettingsGroup(wndParent);
+ }
+ }
+ private void setupSettingsTypePanel(Composite wndParent) {
+ Group wndGroup;
+ GridLayout gridLayout;
+
+ wndGroup = new Group(wndParent, SWT.NONE);
+ gridLayout = new GridLayout(2, false);
+ wndGroup.setLayout(gridLayout);
+ wndGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ wndGroup.setText(ViewMessages.VIEW_SETTINGS);
+
+
+ Label label=new Label(wndGroup,SWT.NONE);
+ label.setText(ViewMessages.VIEW_TITLE);
+ label.setLayoutData(new GridData(GridData.BEGINNING));
+
+ fTerminalTitleText = new Text(wndGroup, SWT.BORDER);
+ fTerminalTitleText.setText(fTerminalTitle);
+ fTerminalTitleText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ Label encodingLabel=new Label(wndGroup,SWT.NONE);
+ encodingLabel.setText(ViewMessages.ENCODING);
+ encodingLabel.setLayoutData(new GridData(GridData.BEGINNING));
+
+ fEncodingCombo = new Combo(wndGroup, SWT.DROP_DOWN);
+ fEncodingCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ }
+ private void setupConnTypePanel(Composite wndParent) {
+ Group wndGroup;
+ GridLayout gridLayout;
+ GridData gridData;
+
+ wndGroup = new Group(wndParent, SWT.NONE);
+ gridLayout = new GridLayout(1, true);
+ gridData = new GridData(GridData.FILL_HORIZONTAL);
+
+ wndGroup.setLayout(gridLayout);
+ wndGroup.setLayoutData(gridData);
+ wndGroup.setText(ViewMessages.CONNECTIONTYPE + ":"); //$NON-NLS-1$
+
+ fCtlConnTypeCombo = new Combo(wndGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
+ gridData = new GridData(GridData.FILL_HORIZONTAL);
+ gridData.widthHint = 200;
+ fCtlConnTypeCombo.setLayoutData(gridData);
+ }
+
+ private void setupSettingsGroup(Composite parent) {
+ Group group = new Group(parent, SWT.NONE);
+ group.setText(ViewMessages.SETTINGS + ":"); //$NON-NLS-1$
+ group.setLayout(new GridLayout());
+ group.setLayoutData(new GridData(GridData.FILL_BOTH));
+ fPageBook=new PageBook(group,SWT.NONE);
+ fPageBook.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ }
+
+ private void setupListeners() {
+ if(fCtlConnTypeCombo==null)
+ return;
+ fCtlConnTypeCombo.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent event) {
+ selectPage(fCtlConnTypeCombo.getSelectionIndex());
+ }
+ });
+ }
+ public ITerminalConnector getConnector() {
+ if(fSelectedConnector>=0)
+ return fConnectors[fSelectedConnector];
+ return null;
+ }
+ private void selectPage(int index) {
+ fSelectedConnector=index;
+ getPage(index);
+ Control[] pages=fPageBook.getChildren();
+ fPageBook.showPage(pages[fPageIndex[fSelectedConnector]]);
+ updateOKButton();
+
+ }
+ /**
+ * enables the OK button if the user can create a connection
+ */
+ private void updateOKButton() {
+ // TODO: allow contributions to enable the OK button
+ // enable the OK button if we have a valid connection selected
+ if(getButton(IDialogConstants.OK_ID)!=null) {
+ boolean enable=false;
+ if(getConnector()!=null)
+ enable=getConnector().getInitializationErrorMessage()==null;
+ // enable the OK button if no connectors are available
+ if(!enable && fConnectors.length==0)
+ enable=true;
+ getButton(IDialogConstants.OK_ID).setEnabled(enable);
+ }
+ }
+ protected IDialogSettings getDialogBoundsSettings() {
+ IDialogSettings ds=TerminalViewPlugin.getDefault().getDialogSettings();
+ fDialogSettings = ds.getSection(getClass().getName());
+ if (fDialogSettings == null) {
+ fDialogSettings = ds.addNewSection(getClass().getName());
+ }
+ return fDialogSettings;
+ }
+ public void setTerminalTitle(String partName) {
+ fTerminalTitle=partName;
+
+ }
+ public String getTerminalTitle() {
+ return fTerminalTitle;
+ }
+ private void doLoad() {
+ if (fEncodingCombo != null) {
+ List encodings = new ArrayList();
+ encodings.add("ISO-8859-1"); //$NON-NLS-1$
+ encodings.add("UTF-8"); //$NON-NLS-1$
+ //TODO when moving to J2SE-1.5, restore the simpler way getting the default encoding
+ //String hostEncoding =Charset.defaultCharset().displayName();
+ String hostEncoding = new java.io.InputStreamReader(new java.io.ByteArrayInputStream(new byte[0])).getEncoding();
+ if (!encodings.contains(hostEncoding))
+ encodings.add(hostEncoding);
+ populateEncodingsCombo(encodings);
+
+ }
+ }
+ private void populateEncodingsCombo(List encodings) {
+ String[] encodingStrings = new String[encodings.size()];
+ encodings.toArray(encodingStrings);
+ fEncodingCombo.setItems(encodingStrings);
+ }
+ private boolean isEncodingValid() {
+ return isValidEncoding(fEncodingCombo.getText());
+ }
+ private boolean isValidEncoding(String enc) {
+ try {
+ return Charset.isSupported(enc);
+ } catch (IllegalCharsetNameException e) {
+ return false;
+ }
+
+ }
+ private boolean updateValidState() {
+ boolean isValid = true;
+ boolean isValidNow = isEncodingValid();
+ if (isValidNow != isValid) {
+ isValid = isValidNow;
+ }
+ return isValid;
+ }
+ private void showErrorMessage(String message) {
+ String strTitle = ViewMessages.TERMINALSETTINGS;
+ MessageBox mb = new MessageBox(getShell(), SWT.ICON_ERROR | SWT.OK);
+ mb.setText(strTitle);
+ mb.setMessage(message);
+ mb.open();
+ return;
+ }
+
+ private void setCombo(Combo combo,String value) {
+ if(value==null)
+ return;
+ int nIndex = combo.indexOf(value);
+ if (nIndex == -1) {
+ if((combo.getStyle() & SWT.READ_ONLY)==0) {
+ combo.add(value);
+ nIndex = combo.indexOf(value);
+ } else {
+ return;
+ }
+ }
+
+ combo.select(nIndex);
+
+ }
+ public String getEncoding() {
+ return fEncoding;
+ }
+ public void setEncoding(String fEncoding) {
+ this.fEncoding = fEncoding;
+ }
+}
diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalView.java b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalView.java
new file mode 100644
index 00000000000..029a80091cc
--- /dev/null
+++ b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalView.java
@@ -0,0 +1,709 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2015 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) - [206892] State handling: Only allow connect when CLOSED
+ * Michael Scharf (Wind River) - [209656] ClassCastException in TerminalView under Eclipse-3.4M3
+ * Michael Scharf (Wind River) - [189774] Ctrl+V does not work in the command input field.
+ * Michael Scharf (Wind River) - [217999] Duplicate context menu entries in Terminal
+ * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin
+ * Martin Oberhuber (Wind River) - [168186] Add Terminal User Docs
+ * Michael Scharf (Wind River) - [172483] switch between connections
+ * Michael Scharf (Wind River) - [240023] Get rid of the terminal's "Pin" button
+ * Michael Scharf (Wind River) - [196454] Initial connection settings dialog should not be blank
+ * Michael Scharf (Wind River) - [241096] Secondary terminals in same view do not observe the "invert colors" Preference
+ * 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
+ * Kris De Volder (VMWare) - [392092] Extend ITerminalView API to allow programmatically opening a UI-less connector
+ *******************************************************************************/
+package org.eclipse.tm.internal.terminal.view;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MenuEvent;
+import org.eclipse.swt.events.MenuListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.tm.internal.terminal.actions.TerminalAction;
+import org.eclipse.tm.internal.terminal.actions.TerminalActionConnect;
+import org.eclipse.tm.internal.terminal.actions.TerminalActionDisconnect;
+import org.eclipse.tm.internal.terminal.actions.TerminalActionNewTerminal;
+import org.eclipse.tm.internal.terminal.actions.TerminalActionRemove;
+import org.eclipse.tm.internal.terminal.actions.TerminalActionScrollLock;
+import org.eclipse.tm.internal.terminal.actions.TerminalActionSelectionDropDown;
+import org.eclipse.tm.internal.terminal.actions.TerminalActionSettings;
+import org.eclipse.tm.internal.terminal.actions.TerminalActionToggleCommandInputField;
+import org.eclipse.tm.internal.terminal.control.ITerminalListener;
+import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
+import org.eclipse.tm.internal.terminal.control.TerminalViewControlFactory;
+import org.eclipse.tm.internal.terminal.control.actions.TerminalActionClearAll;
+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;
+import org.eclipse.tm.internal.terminal.provisional.api.Logger;
+import org.eclipse.tm.internal.terminal.provisional.api.PreferenceSettingStore;
+import org.eclipse.tm.internal.terminal.provisional.api.TerminalConnectorExtension;
+import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
+import org.eclipse.tm.internal.terminal.view.ITerminalViewConnectionManager.ITerminalViewConnectionFactory;
+import org.eclipse.tm.internal.terminal.view.ITerminalViewConnectionManager.ITerminalViewConnectionListener;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IViewReference;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.ViewPart;
+
+public class TerminalView extends ViewPart implements ITerminalView, ITerminalViewConnectionListener {
+ private static final String PREF_CONNECTORS = "Connectors."; //$NON-NLS-1$
+
+ private static final String STORE_CONNECTION_TYPE = "ConnectionType"; //$NON-NLS-1$
+
+ private static final String STORE_SETTING_SUMMARY = "SettingSummary"; //$NON-NLS-1$
+
+ private static final String STORE_TITLE = "Title"; //$NON-NLS-1$
+
+ public static final String FONT_DEFINITION = ITerminalConstants.FONT_DEFINITION;
+
+ protected ITerminalViewControl fCtlTerminal;
+
+ // TODO (scharf): this decorator is only there to deal wit the common
+ // actions. Find a better solution.
+ TerminalViewControlDecorator fCtlDecorator=new TerminalViewControlDecorator();
+
+ protected TerminalAction fActionTerminalNewTerminal;
+
+ protected TerminalAction fActionTerminalConnect;
+
+ private TerminalAction fActionTerminalScrollLock;
+
+ protected TerminalAction fActionTerminalDisconnect;
+
+ protected TerminalAction fActionTerminalSettings;
+
+ protected TerminalActionCopy fActionEditCopy;
+
+ protected TerminalActionCut fActionEditCut;
+
+ protected TerminalActionPaste fActionEditPaste;
+
+ protected TerminalActionClearAll fActionEditClearAll;
+
+ protected TerminalActionSelectAll fActionEditSelectAll;
+
+ protected TerminalAction fActionToggleCommandInputField;
+
+ protected TerminalPropertyChangeHandler fPropertyChangeHandler;
+
+ protected Action fActionTerminalDropDown;
+ protected Action fActionTerminalRemove;
+
+ protected boolean fMenuAboutToShow;
+
+ private SettingsStore fStore;
+
+ private final ITerminalViewConnectionManager fMultiConnectionManager=new TerminalViewConnectionManager();
+
+ private PageBook fPageBook;
+
+ /**
+ * This listener updates both, the view and the
+ * ITerminalViewConnection.
+ *
+ */
+ class TerminalListener implements ITerminalListener {
+ volatile ITerminalViewConnection fConnection;
+ void setConnection(ITerminalViewConnection connection) {
+ fConnection=connection;
+ }
+ public void setState(final TerminalState state) {
+ runInDisplayThread(new Runnable() {
+ public void run() {
+ fConnection.setState(state);
+ // if the active connection changes, update the view
+ if(fConnection==fMultiConnectionManager.getActiveConnection()) {
+ updateStatus();
+ }
+ }
+ });
+ }
+ public void setTerminalTitle(final String title) {
+ runInDisplayThread(new Runnable() {
+ public void run() {
+ fConnection.setTerminalTitle(title);
+ // if the active connection changes, update the view
+ if(fConnection==fMultiConnectionManager.getActiveConnection()) {
+ updateSummary();
+ }
+ }
+ });
+ }
+ /**
+ * @param runnable run in display thread
+ */
+ private void runInDisplayThread(Runnable runnable) {
+ if(Display.findDisplay(Thread.currentThread())!=null)
+ runnable.run();
+ else if(PlatformUI.isWorkbenchRunning())
+ PlatformUI.getWorkbench().getDisplay().syncExec(runnable);
+ // else should not happen and we ignore it...
+ }
+
+ }
+
+ public TerminalView() {
+ Logger
+ .log("==============================================================="); //$NON-NLS-1$
+ fMultiConnectionManager.addListener(this);
+ }
+
+ /**
+ * @param title
+ * @return a unique part name
+ */
+ String findUniqueTitle(String title) {
+ IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
+ String id= getViewSite().getId();
+ Set names=new HashSet();
+ for (int i = 0; i < pages.length; i++) {
+ IViewReference[] views = pages[i].getViewReferences();
+ for (int j = 0; j < views.length; j++) {
+ IViewReference view = views[j];
+ // only look for views with the same ID
+ if(id.equals(view.getId())) {
+ String name=view.getTitle();
+ if(name!=null)
+ names.add(view.getPartName());
+ }
+ }
+ }
+ // find a unique name
+ int i=1;
+ String uniqueTitle=title;
+ while(true) {
+ if(!names.contains(uniqueTitle))
+ return uniqueTitle;
+ uniqueTitle=title+" "+i++; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Display a new Terminal view. This method is called when the user clicks the New
+ * Terminal button in any Terminal view's toolbar.
+ */
+ public void onTerminalNewTerminal() {
+ Logger.log("creating new Terminal instance."); //$NON-NLS-1$
+ setupControls();
+ if(newConnection(ViewMessages.NEW_TERMINAL_CONNECTION)==null) {
+ fMultiConnectionManager.removeActive();
+ }
+ }
+
+ /**
+ * Programmatically create a new terminal connection within the view. This method
+ * does the same thing as onTerminalNewTerminal, but instead of popping up a settings
+ * dialog to allow the user fill in connection details, a connector is provided as
+ * a parameter. The connector should have all of its details pre-configured so it can
+ * be opened without requiring user input.
+ */
+ public void newTerminal(ITerminalConnector c) {
+ this.setupControls();
+ if(c!=null) {
+ this.setConnector(c);
+ this.onTerminalConnect();
+ }
+ }
+
+ public void onTerminalNewView() {
+ try {
+ // The second argument to showView() is a unique String identifying the
+ // secondary view instance. If it ever matches a previously used secondary
+ // view identifier, then this call will not create a new Terminal view,
+ // which is undesirable. Therefore, we append the active time in
+ // milliseconds to the secondary view identifier to ensure it is always
+ // unique. This code runs only when the user clicks the New Terminal
+ // button, so there is no risk that this code will run twice in a single
+ // millisecond.
+ IViewPart newTerminalView = getSite().getPage().showView(
+ "org.eclipse.tm.terminal.view.TerminalView",//$NON-NLS-1$
+ "SecondaryTerminal" + System.currentTimeMillis(), //$NON-NLS-1$
+ IWorkbenchPage.VIEW_ACTIVATE);
+ if(newTerminalView instanceof ITerminalView) {
+ ITerminalConnector c = ((TerminalView)newTerminalView).newConnection(ViewMessages.NEW_TERMINAL_VIEW);
+ // if there is no connector selected, hide the new view
+ if(c==null) {
+ getSite().getPage().hideView(newTerminalView);
+ }
+ }
+ } catch (PartInitException ex) {
+ Logger.logException(ex);
+ }
+ }
+
+
+ public void onTerminalConnect() {
+ //if (isConnected())
+ if (fCtlTerminal.getState()!=TerminalState.CLOSED)
+ return;
+ if(fCtlTerminal.getTerminalConnector()==null)
+ setConnector(showSettingsDialog(ViewMessages.TERMINALSETTINGS));
+ setEncoding(getActiveConnection().getEncoding());
+ fCtlTerminal.connectTerminal();
+ }
+
+ public void updateStatus() {
+ updateTerminalConnect();
+ updateTerminalDisconnect();
+ updateTerminalSettings();
+ fActionToggleCommandInputField.setChecked(hasCommandInputField());
+ fActionTerminalScrollLock.setChecked(isScrollLock());
+ updateSummary();
+ }
+
+ public void updateTerminalConnect() {
+ //boolean bEnabled = ((!isConnecting()) && (!fCtlTerminal.isConnected()));
+ boolean bEnabled = (fCtlTerminal.getState()==TerminalState.CLOSED);
+
+ fActionTerminalConnect.setEnabled(bEnabled);
+ }
+
+ private boolean isConnecting() {
+ return fCtlTerminal.getState()==TerminalState.CONNECTING;
+ }
+
+ public void onTerminalDisconnect() {
+ fCtlTerminal.disconnectTerminal();
+ }
+
+ public void updateTerminalDisconnect() {
+ boolean bEnabled = ((isConnecting()) || (fCtlTerminal.isConnected()));
+ fActionTerminalDisconnect.setEnabled(bEnabled);
+ }
+
+ public void onTerminalSettings() {
+ newConnection(null);
+ }
+
+ private ITerminalConnector newConnection(String title) {
+ ITerminalConnector c=showSettingsDialog(title);
+ if(c!=null) {
+ setConnector(c);
+ onTerminalConnect();
+ }
+ return c;
+ }
+
+ private ITerminalConnector showSettingsDialog(String title) {
+ // When the settings dialog is opened, load the Terminal settings from the
+ // persistent settings.
+
+ ITerminalConnector[] connectors = fCtlTerminal.getConnectors();
+ if(fCtlTerminal.getState()!=TerminalState.CLOSED)
+ connectors=new ITerminalConnector[0];
+ // load the state from the settings
+ // first load from fStore and then from the preferences.
+ ITerminalConnector c = loadSettings(new LayeredSettingsStore(fStore,getPreferenceSettingsStore()), connectors);
+ // if we have no connector show the one from the settings
+ if(fCtlTerminal.getTerminalConnector()!=null)
+ c=fCtlTerminal.getTerminalConnector();
+ TerminalSettingsDlg dlgTerminalSettings = new TerminalSettingsDlg(getViewSite().getShell(),connectors,c);
+ dlgTerminalSettings.setTerminalTitle(getActiveConnection().getPartName());
+ dlgTerminalSettings.setEncoding(getActiveConnection().getEncoding());
+ if(title!=null)
+ dlgTerminalSettings.setTitle(title);
+ Logger.log("opening Settings dialog."); //$NON-NLS-1$
+
+ if (dlgTerminalSettings.open() == Window.CANCEL) {
+ Logger.log("Settings dialog cancelled."); //$NON-NLS-1$
+ return null;
+ }
+
+ Logger.log("Settings dialog OK'ed."); //$NON-NLS-1$
+
+ // When the settings dialog is closed, we persist the Terminal settings.
+ saveSettings(fStore,dlgTerminalSettings.getConnector());
+ // we also save it in the preferences. This will keep the last change
+ // made to this connector as default...
+ saveSettings(getPreferenceSettingsStore(), dlgTerminalSettings.getConnector());
+
+ setViewTitle(dlgTerminalSettings.getTerminalTitle());
+ setEncoding(dlgTerminalSettings.getEncoding());
+ return dlgTerminalSettings.getConnector();
+ }
+
+ private void setEncoding(String encoding) {
+ getActiveConnection().setEncoding(encoding);
+ updateSummary();
+ }
+
+ private void setConnector(ITerminalConnector connector) {
+ fCtlTerminal.setConnector(connector);
+ }
+
+ public void updateTerminalSettings() {
+// fActionTerminalSettings.setEnabled((fCtlTerminal.getState()==TerminalState.CLOSED));
+ }
+ private void setViewTitle(String title) {
+ setPartName(title);
+ getActiveConnection().setPartName(title);
+ }
+ private void setViewSummary(String summary) {
+ setContentDescription(summary);
+ getViewSite().getActionBars().getStatusLineManager().setMessage(
+ summary);
+ setTitleToolTip(getPartName()+": "+summary); //$NON-NLS-1$
+
+ }
+ public void updateSummary() {
+ setViewSummary(getActiveConnection().getFullSummary());
+ }
+
+ public void onTerminalFontChanged() {
+ // set the font for all - empty hook for extenders
+ }
+
+ // ViewPart interface
+
+ public void createPartControl(Composite wndParent) {
+ // Bind plugin.xml key bindings to this plugin. Overrides global Control-W key
+ // sequence.
+
+ fPageBook=new PageBook(wndParent,SWT.NONE);
+ ISettingsStore s=new SettingStorePrefixDecorator(fStore,"connectionManager"); //$NON-NLS-1$
+ fMultiConnectionManager.loadState(s,new ITerminalViewConnectionFactory() {
+ public ITerminalViewConnection create() {
+ return makeViewConnection();
+ }
+ });
+ // if there is no connection loaded, create at least one
+ // needed to read old states from the old terminal
+ if(fMultiConnectionManager.size()==0) {
+ ITerminalViewConnection conn = makeViewConnection();
+ fMultiConnectionManager.addConnection(conn);
+ fMultiConnectionManager.setActiveConnection(conn);
+ fPageBook.showPage(fCtlTerminal.getRootControl());
+ }
+ setTerminalControl(fMultiConnectionManager.getActiveConnection().getCtlTerminal());
+ setViewTitle(findUniqueTitle(ViewMessages.PROP_TITLE));
+ setupActions();
+ setupLocalToolBars();
+ // setup all context menus
+ ITerminalViewConnection[] conn=fMultiConnectionManager.getConnections();
+ for (int i = 0; i < conn.length; i++) {
+ setupContextMenus(conn[i].getCtlTerminal().getControl());
+ }
+ setupListeners(wndParent);
+
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(wndParent, TerminalViewPlugin.HELPPREFIX + "terminal_page"); //$NON-NLS-1$
+
+ legacyLoadState();
+ legacySetTitle();
+
+ refresh();
+ onTerminalFontChanged();
+
+ }
+
+ public void dispose() {
+ Logger.log("entered."); //$NON-NLS-1$
+
+ JFaceResources.getFontRegistry().removeListener(fPropertyChangeHandler);
+
+ // dispose all connections
+ ITerminalViewConnection[] conn=fMultiConnectionManager.getConnections();
+ for (int i = 0; i < conn.length; i++) {
+ conn[i].getCtlTerminal().disposeTerminal();
+ }
+ super.dispose();
+ }
+ /**
+ * Passing the focus request to the viewer's control.
+ */
+ public void setFocus() {
+ fCtlTerminal.setFocus();
+ }
+
+ /**
+ * This method creates the top-level control for the Terminal view.
+ */
+ protected void setupControls() {
+ ITerminalViewConnection conn = makeViewConnection();
+ fMultiConnectionManager.addConnection(conn);
+ fMultiConnectionManager.setActiveConnection(conn);
+ setupContextMenus(fCtlTerminal.getControl());
+ }
+
+ private ITerminalViewConnection makeViewConnection() {
+ ITerminalConnector[] connectors = makeConnectors();
+ TerminalListener listener=new TerminalListener();
+ ITerminalViewControl ctrl = TerminalViewControlFactory.makeControl(listener, fPageBook, connectors, true);
+ setTerminalControl(ctrl);
+ ITerminalViewConnection conn = new TerminalViewConnection(fCtlTerminal);
+ listener.setConnection(conn);
+ conn.setPartName(getPartName());
+ // load from settings
+ ITerminalConnector connector = loadSettings(fStore,connectors);
+ // set the connector....
+ ctrl.setConnector(connector);
+
+ return conn;
+ }
+
+ /**
+ * @param store contains the data
+ * @param connectors loads the data from store
+ * @return null or the currently selected connector
+ */
+ private ITerminalConnector loadSettings(ISettingsStore store, ITerminalConnector[] connectors) {
+ ITerminalConnector connector=null;
+ String connectionType=store.get(STORE_CONNECTION_TYPE);
+ for (int i = 0; i < connectors.length; i++) {
+ connectors[i].load(getStore(store,connectors[i]));
+ if(connectors[i].getId().equals(connectionType))
+ connector=connectors[i];
+ }
+ return connector;
+ }
+
+ /**
+ * @return a list of connectors this view can use
+ */
+ protected ITerminalConnector[] makeConnectors() {
+ ITerminalConnector[] connectors=TerminalConnectorExtension.makeTerminalConnectors();
+ return connectors;
+ }
+
+ /**
+ * The preference setting store is used to save the settings that are
+ * shared between all views.
+ * @return the settings store for the connection based on the preferences.
+ *
+ */
+ private PreferenceSettingStore getPreferenceSettingsStore() {
+ return new PreferenceSettingStore(TerminalViewPlugin.getDefault().getPluginPreferences(),PREF_CONNECTORS);
+ }
+ /**
+ * @param store the settings will be saved in this store
+ * @param connector the connector that will be saved. Can be null.
+ */
+ private void saveSettings(ISettingsStore store, ITerminalConnector connector) {
+ if(connector!=null) {
+ connector.save(getStore(store, connector));
+ // the last saved connector becomes the default
+ store.put(STORE_CONNECTION_TYPE,connector.getId());
+ }
+
+ }
+ public void init(IViewSite site, IMemento memento) throws PartInitException {
+ super.init(site, memento);
+ fStore=new SettingsStore(memento);
+ }
+ public void saveState(IMemento memento) {
+ super.saveState(memento);
+ fStore.put(STORE_TITLE,getPartName());
+ fMultiConnectionManager.saveState(new SettingStorePrefixDecorator(fStore,"connectionManager")); //$NON-NLS-1$
+ fStore.saveState(memento);
+ }
+ private ISettingsStore getStore(ISettingsStore store, ITerminalConnector connector) {
+ return new SettingStorePrefixDecorator(store,connector.getId()+"."); //$NON-NLS-1$
+ }
+
+ protected void setupActions() {
+ fActionTerminalDropDown = new TerminalActionSelectionDropDown(fMultiConnectionManager);
+ fActionTerminalRemove=new TerminalActionRemove(fMultiConnectionManager);
+ fActionTerminalNewTerminal = new TerminalActionNewTerminal(this);
+ fActionTerminalScrollLock = new TerminalActionScrollLock(this);
+ fActionTerminalConnect = new TerminalActionConnect(this);
+ fActionTerminalDisconnect = new TerminalActionDisconnect(this);
+ fActionTerminalSettings = new TerminalActionSettings(this);
+ fActionEditCopy = new TerminalActionCopy(fCtlDecorator);
+ fActionEditCut = new TerminalActionCut(fCtlDecorator);
+ fActionEditPaste = new TerminalActionPaste(fCtlDecorator);
+ fActionEditClearAll = new TerminalActionClearAll(fCtlDecorator);
+ fActionEditSelectAll = new TerminalActionSelectAll(fCtlDecorator);
+ fActionToggleCommandInputField = new TerminalActionToggleCommandInputField(this);
+ }
+ protected void setupLocalToolBars() {
+ IToolBarManager toolBarMgr = getViewSite().getActionBars().getToolBarManager();
+
+ toolBarMgr.add(fActionTerminalConnect);
+ toolBarMgr.add(fActionTerminalDisconnect);
+ toolBarMgr.add(fActionTerminalSettings);
+ toolBarMgr.add(fActionToggleCommandInputField);
+ toolBarMgr.add(fActionTerminalScrollLock);
+ toolBarMgr.add(new Separator("fixedGroup")); //$NON-NLS-1$
+ toolBarMgr.add(fActionTerminalDropDown);
+ toolBarMgr.add(fActionTerminalNewTerminal);
+ toolBarMgr.add(fActionTerminalRemove);
+ }
+
+ protected void setupContextMenus(Control ctlText) {
+ MenuManager menuMgr;
+ Menu menu;
+ TerminalContextMenuHandler contextMenuHandler;
+
+ menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
+ menu = menuMgr.createContextMenu(ctlText);
+ loadContextMenus(menuMgr);
+ contextMenuHandler = new TerminalContextMenuHandler();
+
+ ctlText.setMenu(menu);
+ menuMgr.addMenuListener(contextMenuHandler);
+ menu.addMenuListener(contextMenuHandler);
+ }
+
+ protected void loadContextMenus(IMenuManager menuMgr) {
+ menuMgr.add(fActionEditCopy);
+ menuMgr.add(fActionEditPaste);
+ menuMgr.add(new Separator());
+ menuMgr.add(fActionEditClearAll);
+ menuMgr.add(fActionEditSelectAll);
+ menuMgr.add(new Separator());
+ menuMgr.add(fActionToggleCommandInputField);
+ menuMgr.add(fActionTerminalScrollLock);
+
+
+ // Other plug-ins can contribute there actions here
+ menuMgr.add(new Separator("Additions")); //$NON-NLS-1$
+ }
+
+ protected void setupListeners(Composite wndParent) {
+ fPropertyChangeHandler = new TerminalPropertyChangeHandler();
+ JFaceResources.getFontRegistry().addListener(fPropertyChangeHandler);
+ }
+
+ protected class TerminalContextMenuHandler implements MenuListener, IMenuListener {
+ public void menuHidden(MenuEvent event) {
+ fMenuAboutToShow = false;
+ fActionEditCopy.updateAction(fMenuAboutToShow);
+ }
+
+ public void menuShown(MenuEvent e) {
+ //
+ }
+ public void menuAboutToShow(IMenuManager menuMgr) {
+ fMenuAboutToShow = true;
+ fActionEditCopy.updateAction(fMenuAboutToShow);
+ fActionEditCut.updateAction(fMenuAboutToShow);
+ fActionEditSelectAll.updateAction(fMenuAboutToShow);
+ fActionEditPaste.updateAction(fMenuAboutToShow);
+ fActionEditClearAll.updateAction(fMenuAboutToShow);
+ }
+ }
+
+ protected class TerminalPropertyChangeHandler implements IPropertyChangeListener {
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(FONT_DEFINITION)) {
+ onTerminalFontChanged();
+ }
+ }
+ }
+
+ public boolean hasCommandInputField() {
+ return getActiveConnection().hasCommandInputField();
+ }
+
+ public void setCommandInputField(boolean on) {
+ getActiveConnection().setCommandInputField(on);
+ }
+
+ public boolean isScrollLock() {
+ return fCtlTerminal.isScrollLock();
+ }
+
+ public void setScrollLock(boolean on) {
+ fCtlTerminal.setScrollLock(on);
+ }
+
+ private ITerminalViewConnection getActiveConnection() {
+ return fMultiConnectionManager.getActiveConnection();
+ }
+ /**
+ * @param ctrl this control becomes the currently used one
+ */
+ private void setTerminalControl(ITerminalViewControl ctrl) {
+ fCtlTerminal=ctrl;
+ fCtlDecorator.setViewContoler(ctrl);
+ }
+ public void connectionsChanged() {
+ if(getActiveConnection()!=null) {
+ // update the active {@link ITerminalViewControl}
+ ITerminalViewControl ctrl = getActiveConnection().getCtlTerminal();
+ if(fCtlTerminal!=ctrl) {
+ setTerminalControl(ctrl);
+ refresh();
+ }
+ }
+ }
+
+ /**
+ * Show the active {@link ITerminalViewControl} in the view
+ */
+ private void refresh() {
+ fPageBook.showPage(fCtlTerminal.getRootControl());
+ updateStatus();
+ setPartName(getActiveConnection().getPartName());
+ }
+ /**
+ * TODO REMOVE This code (added 2008-06-11)
+ * Legacy code to real the old state. Once the state of the
+ * terminal has been saved this method is not needed anymore.
+ * Remove this code with eclipse 3.5.
+ */
+ private void legacyLoadState() {
+ // TODO legacy: load the old title....
+ String summary=fStore.get(STORE_SETTING_SUMMARY);
+ if(summary!=null) {
+ getActiveConnection().setSummary(summary);
+ fStore.put(STORE_SETTING_SUMMARY,null);
+ }
+ }
+ /**
+ * TODO REMOVE This code (added 2008-06-11)
+ * Legacy code to real the old state. Once the state of the
+ * terminal has been saved this method is not needed anymore.
+ * Remove this code with eclipse 3.5.
+ */
+ private void legacySetTitle() {
+ // restore the title of this view
+ String title=fStore.get(STORE_TITLE);
+ if(title!=null && title.length()>0) {
+ setViewTitle(title);
+ fStore.put(STORE_TITLE, null);
+ }
+ }
+
+}
diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalViewConnection.java b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalViewConnection.java
new file mode 100644
index 00000000000..576c281811e
--- /dev/null
+++ b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalViewConnection.java
@@ -0,0 +1,237 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2015 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
+ * Michael Scharf (Wind River) - [240097] Allow paste with the middle mouse button
+ * Michael Scharf (Wind River) - [262996] get rid of TerminalState.OPENED
+ * Anton Leherbauer (Wind River) - [335021] Middle mouse button copy/paste does not work with the terminal
+ * Ahmet Alptekin (Tubitak) - [244405] Add a UI Control for setting the Terminal's encoding
+ *******************************************************************************/
+package org.eclipse.tm.internal.terminal.view;
+
+import java.io.UnsupportedEncodingException;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.tm.internal.terminal.control.CommandInputFieldWithHistory;
+import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
+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.Logger;
+import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
+
+/**
+ * This class represents one connection. The connection might be
+ * closed or open.
+ *
+ */
+class TerminalViewConnection implements ITerminalViewConnection {
+ private static final String STORE_SUMMARY = "Summary"; //$NON-NLS-1$
+ private static final String STORE_PART_NAME = "PartName"; //$NON-NLS-1$
+ private static final String STORE_CONNECTION_TYPE = "ConnectionType"; //$NON-NLS-1$
+ private static final String STORE_HAS_COMMAND_INPUT_FIELD = "HasCommandInputField"; //$NON-NLS-1$
+ private static final String STORE_COMMAND_INPUT_FIELD_HISTORY = "CommandInputFieldHistory"; //$NON-NLS-1$
+ private static final String STORE_ENCODING="Encoding"; //$NON-NLS-1$
+ final private ITerminalViewControl fCtlTerminal;
+ private String fTitle;
+ private String fSummary;
+ private String fHistory;
+ private CommandInputFieldWithHistory fCommandInputField;
+ private String fPartName;
+ private String fEncoding;
+
+ public TerminalViewConnection(ITerminalViewControl ctl) {
+ fCtlTerminal = ctl;
+ fCtlTerminal.getControl().addMouseListener(new MouseAdapter(){
+ public void mouseDown(MouseEvent e) {
+ // paste when the middle button is clicked
+ if (e.button == 2) { // middle button
+ int clipboardType = DND.SELECTION_CLIPBOARD;
+ Clipboard clipboard = fCtlTerminal.getClipboard();
+ if (clipboard.getAvailableTypes(clipboardType).length == 0)
+ // use normal clipboard if selection clipboard is not available
+ clipboardType = DND.CLIPBOARD;
+ String text = (String) clipboard.getContents(TextTransfer.getInstance(), clipboardType);
+ if (text != null && text.length() > 0)
+ fCtlTerminal.pasteString(text);
+ }
+ }
+ });
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tm.internal.terminal.actions.ITerminalViewConnection#getName()
+ */
+ public String getFullSummary() {
+ // if the title is set, then we return the title, else the summary
+ if(fTitle==null)
+ return makeSummary();
+ return fTitle;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tm.internal.terminal.view.ITerminalViewConnection#getImageDescriptor()
+ */
+ public ImageDescriptor getImageDescriptor() {
+ return TerminalViewPlugin.getDefault().getImageRegistry().getDescriptor(ImageConsts.IMAGE_TERMINAL_VIEW);
+ }
+
+ public ITerminalViewControl getCtlTerminal() {
+ return fCtlTerminal;
+ }
+ private ISettingsStore getStore(ISettingsStore store,ITerminalConnector connector) {
+ return new SettingStorePrefixDecorator(store,connector.getId()+"."); //$NON-NLS-1$
+ }
+ public void loadState(ISettingsStore store) {
+ fPartName=store.get(STORE_PART_NAME);
+ fSummary=store.get(STORE_SUMMARY);
+ fHistory=store.get(STORE_COMMAND_INPUT_FIELD_HISTORY);
+ fEncoding=store.get(STORE_ENCODING);
+ // load the state of the connection types
+ ITerminalConnector[] connectors=fCtlTerminal.getConnectors();
+ String connectionType=store.get(STORE_CONNECTION_TYPE);
+ for (int i = 0; i < connectors.length; i++) {
+ connectors[i].load(getStore(store,connectors[i]));
+ // if this is active connection type
+ if(connectors[i].getId().equals(connectionType))
+ fCtlTerminal.setConnector(connectors[i]);
+ }
+
+ if("true".equals(store.get(STORE_HAS_COMMAND_INPUT_FIELD))) //$NON-NLS-1$
+ setCommandInputField(true);
+ }
+
+ public void saveState(ISettingsStore store) {
+ store.put(STORE_PART_NAME, fPartName);
+ store.put(STORE_SUMMARY,fSummary);
+ store.put(STORE_COMMAND_INPUT_FIELD_HISTORY, fHistory);
+ store.put(STORE_ENCODING, fEncoding);
+ if(fCommandInputField!=null)
+ store.put(STORE_COMMAND_INPUT_FIELD_HISTORY, fCommandInputField.getHistory());
+ else
+ store.put(STORE_COMMAND_INPUT_FIELD_HISTORY, fHistory);
+ store.put(STORE_HAS_COMMAND_INPUT_FIELD,hasCommandInputField()?"true":"false"); //$NON-NLS-1$//$NON-NLS-2$
+ ITerminalConnector[] connectors=fCtlTerminal.getConnectors();
+ for (int i = 0; i < connectors.length; i++) {
+ connectors[i].save(getStore(store,connectors[i]));
+ }
+ if(fCtlTerminal.getTerminalConnector()!=null) {
+ store.put(STORE_CONNECTION_TYPE,fCtlTerminal.getTerminalConnector().getId());
+ }
+ }
+ public boolean hasCommandInputField() {
+ return fCommandInputField!=null;
+ }
+ public void setCommandInputField(boolean on) {
+ // save the old history
+ if(fCommandInputField!=null) {
+ fHistory= fCommandInputField.getHistory();
+ fCommandInputField=null;
+ }
+ if(on) {
+ // TODO make history size configurable
+ fCommandInputField=new CommandInputFieldWithHistory(100);
+ fCommandInputField.setHistory(fHistory);
+ }
+ fCtlTerminal.setCommandInputField(fCommandInputField);
+ }
+
+ public void setState(TerminalState state) {
+ // update the title....
+ fTitle=null;
+ }
+
+ public void setTerminalTitle(String title) {
+ // When parameter 'title' is not null, it is a String containing text to
+ // display in the view's content description line. This is used by class
+ // TerminalText when it processes an ANSI OSC escape sequence that commands
+ // the terminal to display text in its title bar.
+ fTitle=title;
+ }
+
+ private String getStateDisplayName(TerminalState state) {
+ if(state==TerminalState.CONNECTED) {
+ return ViewMessages.STATE_CONNECTED;
+ } else if(state==TerminalState.CONNECTING) {
+ return ViewMessages.STATE_CONNECTING;
+ } else if(state==TerminalState.CLOSED) {
+ return ViewMessages.STATE_CLOSED;
+ } else {
+ throw new IllegalStateException(state.toString());
+ }
+ }
+
+ private String makeSummary() {
+ String strTitle = ""; //$NON-NLS-1$
+ if(fCtlTerminal.getTerminalConnector()==null){
+ strTitle=ViewMessages.NO_CONNECTION_SELECTED;
+ } else {
+ // When parameter 'data' is null, we construct a descriptive string to
+ // display in the content description line.
+ String strConnected = getStateDisplayName(fCtlTerminal.getState());
+ String summary = getSettingsSummary();
+ String encoding=getEncoding();
+ //TODO Title should use an NLS String and com.ibm.icu.MessageFormat
+ //In order to make the logic of assembling, and the separators, better adapt to foreign languages
+ if(summary.length()>0)
+ summary=summary+" - "; //$NON-NLS-1$
+ String name=fCtlTerminal.getTerminalConnector().getName();
+ if(name.length()>0) {
+ name+=": "; //$NON-NLS-1$
+ }
+ if (encoding.length()>0) {
+ encoding = NLS.bind(ViewMessages.ENCODING_WITH_PARENTHESES, encoding);
+ //encoding=ViewMessages.ENCODING+" "+"("+encoding+")"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ }
+ strTitle = name + "("+ summary + strConnected + ")"+" - "+encoding; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ return strTitle;
+ }
+ /**
+ * @return the setting summary. If there is no connection, or the connection
+ * has not been initialized, use the last stored state.
+ */
+ private String getSettingsSummary() {
+ if(fCtlTerminal.getTerminalConnector().isInitialized())
+ fSummary=fCtlTerminal.getSettingsSummary();
+ if(fSummary==null)
+ return ""; //$NON-NLS-1$
+ return fSummary;
+ }
+
+ public void setSummary(String summary) {
+ fSummary=summary;
+ }
+
+ public String getPartName() {
+ return fPartName==null?ViewMessages.PROP_TITLE:fPartName;
+ }
+
+ public void setPartName(String name) {
+ fPartName=name;
+
+ }
+ public String getEncoding() {
+ return fEncoding==null?fCtlTerminal.getEncoding():fEncoding;
+ }
+
+ public void setEncoding(String fEncoding) {
+ try {
+ fCtlTerminal.setEncoding(fEncoding);
+ this.fEncoding = fEncoding;
+ } catch (UnsupportedEncodingException uex) {
+ Logger.logException(uex);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalViewConnectionManager.java b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalViewConnectionManager.java
new file mode 100644
index 00000000000..3ba1a308e75
--- /dev/null
+++ b/terminal/deprecated/plugins/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalViewConnectionManager.java
@@ -0,0 +1,181 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2015 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
+ *******************************************************************************/
+package org.eclipse.tm.internal.terminal.view;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
+
+public class TerminalViewConnectionManager implements ITerminalViewConnectionManager {
+ private static final String STORE_CONNECTION_PREFIX = "connection"; //$NON-NLS-1$
+ private static final String STORE_SIZE = "size"; //$NON-NLS-1$
+ private static final String STORE_ACTIVE_CONNECTION = "active"; //$NON-NLS-1$
+ /**
+ * The list of {@link ITerminalViewConnection} in the order they were cerated.
+ * Ordered by creation time
+ */
+ private final List fConnections=new ArrayList();
+ /**
+ * The currently displayed connection
+ */
+ private ITerminalViewConnection fActiveConnection;
+ /**
+ * The list of {@link ITerminalViewConnection} in the order they
+ * were made the active connection. The most recently accessed
+ * connection is at the beginning of the list.
+ */
+ private final List fConnectionHistory=new ArrayList();
+ /**
+ * The {@link ITerminalViewConnectionListener}
+ */
+ private final List fListeners=new ArrayList();
+
+ public ITerminalViewConnection[] getConnections() {
+ return (ITerminalViewConnection[]) fConnections.toArray(new ITerminalViewConnection[fConnections.size()]);
+ }
+
+ public int size() { // TODO Auto-generated method stub
+ return fConnections.size();
+ }
+
+ public ITerminalViewConnection getActiveConnection() {
+ return fActiveConnection;
+ }
+ public void setActiveConnection(ITerminalViewConnection conn) {
+ fActiveConnection=conn;
+ // put the connection at the end of the history list
+ fConnectionHistory.remove(conn);
+ fConnectionHistory.add(0,conn);
+
+ fireListeners();
+ }
+
+ public void swapConnection() {
+ ITerminalViewConnection conn=getPreviousConnection();
+ if(conn!=null)
+ setActiveConnection(conn);
+ }
+
+ /**
+ * @return the connection that was most recently the active connection or null if there is
+ * no previous connection
+ */
+ private ITerminalViewConnection getPreviousConnection() {
+ // find the first connection that is not the active connection in
+ // the list
+ for (Iterator iterator = fConnectionHistory.iterator(); iterator.hasNext();) {
+ ITerminalViewConnection conn = (ITerminalViewConnection) iterator.next();
+ if(conn!=fActiveConnection) {
+ return conn;
+ }
+ }
+ return null;
+ }
+
+ public void addConnection(ITerminalViewConnection conn) {
+ fConnections.add(conn);
+ fireListeners();
+ }
+ public void removeConnection(ITerminalViewConnection conn) {
+ fConnections.remove(conn);
+ fConnectionHistory.remove(conn);
+ fireListeners();
+ }
+
+ public void addListener(ITerminalViewConnectionListener listener) {
+ fListeners.add(listener);
+ }
+
+ public void removeListener(ITerminalViewConnectionListener listener) {
+ fListeners.remove(listener);
+ }
+ protected void fireListeners() {
+ ITerminalViewConnectionListener[] listeners=(ITerminalViewConnectionListener[]) fListeners.toArray(new ITerminalViewConnectionListener[fListeners.size()]);
+ for (int i = 0; i < listeners.length; i++) {
+ listeners[i].connectionsChanged();
+ }
+ }
+
+ public void saveState(ISettingsStore store) {
+ store.put(STORE_SIZE,""+fConnections.size()); //$NON-NLS-1$
+ // save all connections
+ int n=0;
+ for (Iterator iterator = fConnections.iterator(); iterator.hasNext();) {
+ ITerminalViewConnection connection = (ITerminalViewConnection) iterator.next();
+ // the name under which we store the connection
+ String prefix=STORE_CONNECTION_PREFIX+n;
+ n++;
+ // remember the active connection by its prefix
+ if(connection.equals(fActiveConnection))
+ store.put(STORE_ACTIVE_CONNECTION,prefix);
+ connection.saveState(new SettingStorePrefixDecorator(store,prefix));
+ }
+ }
+
+ public void loadState(ISettingsStore store,ITerminalViewConnectionFactory factory) {
+ int size=0;
+ try {
+ size=Integer.parseInt(store.get(STORE_SIZE));
+ } catch(Exception e) {
+ // ignore
+ }
+ if(size>0) {
+ // a slot for the connections
+ String active=store.get(STORE_ACTIVE_CONNECTION);
+ int n=0;
+ for (int i=0;i