1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-13 12:05:21 +02:00

CLOSED - bug 172483: [terminal] Secondary terminals cannot be shown in other perspectives

https://bugs.eclipse.org/bugs/show_bug.cgi?id=172483
This commit is contained in:
Michael Scharf 2008-07-07 20:38:07 +00:00
parent 40f3441b57
commit cc459933cd
19 changed files with 1310 additions and 177 deletions

View file

@ -2,7 +2,7 @@
<feature <feature
id="org.eclipse.tm.terminal.view" id="org.eclipse.tm.terminal.view"
label="%featureName" label="%featureName"
version="2.0.0.qualifier" version="2.0.1.qualifier"
provider-name="%providerName"> provider-name="%providerName">
<description> <description>

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: %pluginName Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.tm.terminal.view;singleton:=true Bundle-SymbolicName: org.eclipse.tm.terminal.view;singleton:=true
Bundle-Version: 2.0.0.qualifier Bundle-Version: 2.0.1.qualifier
Bundle-Activator: org.eclipse.tm.internal.terminal.view.TerminalViewPlugin Bundle-Activator: org.eclipse.tm.internal.terminal.view.TerminalViewPlugin
Bundle-Localization: plugin Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui, Require-Bundle: org.eclipse.ui,

View file

@ -20,6 +20,7 @@ package org.eclipse.tm.internal.terminal.actions;
import org.eclipse.osgi.util.NLS; import org.eclipse.osgi.util.NLS;
public class ActionMessages extends NLS { public class ActionMessages extends NLS {
static { static {
NLS.initializeMessages(ActionMessages.class.getName(), ActionMessages.class); NLS.initializeMessages(ActionMessages.class.getName(), ActionMessages.class);
} }
@ -30,6 +31,11 @@ public class ActionMessages extends NLS {
public static String SETTINGS_ELLIPSE; public static String SETTINGS_ELLIPSE;
public static String SCROLL_LOCK_0; public static String SCROLL_LOCK_0;
public static String SCROLL_LOCK_1; public static String SCROLL_LOCK_1;
public static String REMOVE;
public static String PIN;
public static String ConsoleDropDownAction_0;
public static String ConsoleDropDownAction_1;
public static String SETTINGS; public static String SETTINGS;

View file

@ -14,6 +14,7 @@
# Michael Scharf (Wind River) - split into core, view and connector plugins # Michael Scharf (Wind River) - split into core, view and connector plugins
# Martin Oberhuber (Wind River) - fixed copyright headers and beautified # Martin Oberhuber (Wind River) - fixed copyright headers and beautified
# Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin # Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin
# Michael Scharf (Wind River) - [172483] switch between connections
############################################################################### ###############################################################################
NEW_TERMINAL = New Terminal NEW_TERMINAL = New Terminal
CONNECT = Connect CONNECT = Connect
@ -23,3 +24,9 @@ SCROLL_LOCK_0 = Scroll &Lock
SCROLL_LOCK_1 = Scroll Lock SCROLL_LOCK_1 = Scroll Lock
SETTINGS = Settings SETTINGS = Settings
TOGGLE_COMMAND_INPUT_FIELD= Toggle Command Input Field TOGGLE_COMMAND_INPUT_FIELD= Toggle Command Input Field
REMOVE = Remove Terminal
PIN = Pin Terminal
ConsoleDropDownAction_0=Select Connection
ConsoleDropDownAction_1=Display Selected Connections

View file

@ -0,0 +1,82 @@
/*******************************************************************************
* Copyright (c) 2008 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.actions;
import org.eclipse.jface.action.Action;
import org.eclipse.tm.internal.terminal.view.ITerminalViewConnection;
import org.eclipse.tm.internal.terminal.view.ITerminalViewConnectionManager;
/**
* Shows a specific connection in the terminal view
*/
public class ShowTerminalConnectionAction extends Action {
private final ITerminalViewConnection fConnection;
private final ITerminalViewConnectionManager fConnectionManager;
/**
* Constructs an action to display the given console.
*
* @param manager the console view in which the given console is contained
* @param connection the console
*/
public ShowTerminalConnectionAction(ITerminalViewConnectionManager manager, ITerminalViewConnection connection) {
super(quoteName(buildName(manager,connection)), AS_RADIO_BUTTON);
fConnection = connection;
fConnectionManager = manager;
setImageDescriptor(connection.getImageDescriptor());
}
/**
* the tab at the end quotes '@' chars?!? see
* {@link #setText(String)}
* @param name
* @return a quoted sting
*/
private static String quoteName(String name) {
return name+"\t"; //$NON-NLS-1$
}
/**
* Builds the name. It uses the summary. If the connections have different
* partNames (the names showed in the view title) then this name is prefixed.
* @param m the connection manager
* @param connection the connection for which the name should me extracted
* @return The name to be displayed
*/
private static String buildName(ITerminalViewConnectionManager m,ITerminalViewConnection connection) {
String name = connection.getFullSummary();
if(!checkIfAllPartNamesTheSame(m))
name=connection.getPartName()+" - " +name; //$NON-NLS-1$
return name;
}
/**
* @param m the connection manager
* @return true if the part names of all connections are the same
*/
private static boolean checkIfAllPartNamesTheSame(ITerminalViewConnectionManager m) {
ITerminalViewConnection[] connections = m.getConnections();
if(connections.length>1) {
String partName=connections[0].getPartName();
for (int i = 1; i < connections.length; i++) {
if(!partName.equals(connections[i].getPartName())) {
return false;
}
}
}
return true;
}
/* (non-Javadoc)
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
fConnectionManager.setActiveConnection(fConnection);
}
}

View file

@ -0,0 +1,41 @@
/*******************************************************************************
* Copyright (c) 2008 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) - initial contribution
*******************************************************************************/
package org.eclipse.tm.internal.terminal.actions;
import org.eclipse.jface.action.IAction;
import org.eclipse.tm.internal.terminal.view.ITerminalView;
import org.eclipse.tm.internal.terminal.view.ImageConsts;
public class TerminalActionPin extends TerminalAction
{
public TerminalActionPin(ITerminalView target)
{
super(target,
TerminalActionPin.class.getName(),IAction.AS_RADIO_BUTTON);
setupAction(ActionMessages.PIN,
ActionMessages.PIN,
ImageConsts.IMAGE_CLCL_PIN,
ImageConsts.IMAGE_ELCL_PIN,
ImageConsts.IMAGE_DLCL_PIN,
true);
setChecked(fTarget.isPinned());
}
public void run() {
fTarget.setPinned(!fTarget.isPinned());
setChecked(fTarget.isPinned());
}
}

View file

@ -0,0 +1,45 @@
/*******************************************************************************
* Copyright (c) 2008 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) - initial contribution
*******************************************************************************/
package org.eclipse.tm.internal.terminal.actions;
import org.eclipse.tm.internal.terminal.view.ITerminalViewConnectionManager;
import org.eclipse.tm.internal.terminal.view.ImageConsts;
import org.eclipse.tm.internal.terminal.view.ITerminalViewConnectionManager.ITerminalViewConnectionListener;
public class TerminalActionRemove extends TerminalAction implements ITerminalViewConnectionListener
{
private final ITerminalViewConnectionManager fConnectionManager;
public TerminalActionRemove(ITerminalViewConnectionManager target)
{
super(null,
TerminalActionRemove.class.getName());
fConnectionManager=target;
setupAction(ActionMessages.REMOVE,
ActionMessages.REMOVE,
null,
ImageConsts.IMAGE_ELCL_REMOVE,
ImageConsts.IMAGE_DLCL_REMOVE,
true);
fConnectionManager.addListener(this);
connectionsChanged();
}
public void run() {
fConnectionManager.removeActive();
}
public void connectionsChanged() {
setEnabled(fConnectionManager.size()>1);
}
}

View file

@ -0,0 +1,106 @@
/*******************************************************************************
* Copyright (c) 2000, 2007 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
* Michael Scharf (Wind River) - [172483] switch between connections
* (Adapted from org.eclipse.ui.internal.console.ConsoleDropDownAction)
*******************************************************************************/
package org.eclipse.tm.internal.terminal.actions;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IMenuCreator;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.tm.internal.terminal.view.ITerminalViewConnection;
import org.eclipse.tm.internal.terminal.view.ITerminalViewConnectionManager;
import org.eclipse.tm.internal.terminal.view.ImageConsts;
import org.eclipse.tm.internal.terminal.view.TerminalViewPlugin;
import org.eclipse.tm.internal.terminal.view.ITerminalViewConnectionManager.ITerminalViewConnectionListener;
/**
* Drop down action in the console to select the console to display.
*/
public class TerminalActionSelectionDropDown extends Action implements IMenuCreator, ITerminalViewConnectionListener {
private ITerminalViewConnectionManager fConnections;
private Menu fMenu;
public TerminalActionSelectionDropDown(ITerminalViewConnectionManager view) {
fConnections= view;
setText(ActionMessages.ConsoleDropDownAction_0);
setToolTipText(ActionMessages.ConsoleDropDownAction_1);
setImageDescriptor(TerminalViewPlugin.getDefault().getImageRegistry().getDescriptor(ImageConsts.IMAGE_TERMINAL_VIEW));
// PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IConsoleHelpContextIds.CONSOLE_DISPLAY_CONSOLE_ACTION);
setMenuCreator(this);
fConnections.addListener(this);
connectionsChanged();
}
/* (non-Javadoc)
* @see org.eclipse.jface.action.IMenuCreator#dispose()
*/
public void dispose() {
if (fMenu != null) {
fMenu.dispose();
}
fConnections.removeListener(this);
fConnections= null;
}
/* (non-Javadoc)
* @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Menu)
*/
public Menu getMenu(Menu parent) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Control)
*/
public Menu getMenu(Control parent) {
if (fMenu != null) {
fMenu.dispose();
}
fMenu= new Menu(parent);
ITerminalViewConnection[] consoles= fConnections.getConnections();
ITerminalViewConnection active = fConnections.getActiveConnection();
for (int i = 0; i < consoles.length; i++) {
ITerminalViewConnection console = consoles[i];
Action action = new ShowTerminalConnectionAction(fConnections, console);
action.setChecked(console.equals(active));
addActionToMenu(fMenu, action, i + 1);
}
return fMenu;
}
private void addActionToMenu(Menu parent, Action action, int accelerator) {
if (accelerator < 10) {
StringBuffer label= new StringBuffer();
//add the numerical accelerator
label.append('&');
label.append(accelerator);
label.append(' ');
label.append(action.getText());
action.setText(label.toString());
}
ActionContributionItem item= new ActionContributionItem(action);
item.fill(parent, -1);
}
/* (non-Javadoc)
* @see org.eclipse.jface.action.IAction#run()
*/
public void run() {
fConnections.swapConnection();
}
public void connectionsChanged() {
setEnabled(fConnections.size() > 1);
}
}

View file

@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Michael Scharf (Wind River) - initial API and implementation * Michael Scharf (Wind River) - initial API and implementation
* Martin Oberhuber (Wind River) - [227537] moved actions from terminal.view to terminal plugin * Martin Oberhuber (Wind River) - [227537] moved actions from terminal.view to terminal plugin
* Michael Scharf (Wind River) - [172483] switch between connections
*******************************************************************************/ *******************************************************************************/
package org.eclipse.tm.internal.terminal.view; package org.eclipse.tm.internal.terminal.view;
@ -26,4 +27,6 @@ public interface ITerminalView {
public void setCommandInputField(boolean on); public void setCommandInputField(boolean on);
public boolean isScrollLock(); public boolean isScrollLock();
public void setScrollLock(boolean b); public void setScrollLock(boolean b);
public void setPinned(boolean pin);
public boolean isPinned();
} }

View file

@ -0,0 +1,78 @@
/*******************************************************************************
* Copyright (c) 2008 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 org.eclipse.jface.resource.ImageDescriptor;
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.TerminalState;
/**
* Represents a connection. The connection might be connected
* or not.
*
*/
public interface ITerminalViewConnection {
/**
* @return the summary shown in the status line and
* in the drop down box of the connections
*/
String getFullSummary();
/**
* @param name the name of the view
*/
void setPartName(String name);
/**
* @return the name of the view (never null)
*/
String getPartName();
/**
* @return an image that represents this connection
*/
ImageDescriptor getImageDescriptor();
/**
* @return the control of this connection
*/
ITerminalViewControl getCtlTerminal();
void saveState(ISettingsStore store);
void loadState(ISettingsStore store);
/**
* @return true if the input field is visible
*/
boolean hasCommandInputField();
/**
* @param on turns the input field on
*/
void setCommandInputField(boolean on);
/**
* @param state changes of the state (might change the summary)
*/
void setState(TerminalState state);
/**
* @param title used in the summary. If null the summary
* is created automatically
*/
void setTerminalTitle(String title);
/**
* TODO: legacy (needed to read the old state)
* @param summary
*/
void setSummary(String summary);
}

View file

@ -0,0 +1,83 @@
/*******************************************************************************
* Copyright (c) 2008 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 org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
/**
* Supports multiple connections
*
*/
public interface ITerminalViewConnectionManager {
/**
* Notifies any change in the state of the connections:
* <ul>
* <li> a connection is added or removed
* <li> the active connection has changed
* </ul>
*
*/
interface ITerminalViewConnectionListener {
void connectionsChanged();
}
/**
* Used to create instances of the ITerminalViewConnection
* when the state is read from the {@link ISettingsStore}
*
*/
interface ITerminalViewConnectionFactory {
ITerminalViewConnection create();
}
/**
* @return a list of all connections this view can display
*/
ITerminalViewConnection[] getConnections();
/**
* @return the number of connections
*/
int size();
/**
* @return th connection the view is showing at the moment
*/
ITerminalViewConnection getActiveConnection();
/**
* @param conn make this connection the active connection
*/
void setActiveConnection(ITerminalViewConnection conn);
/**
* If more than two connections are available, remove the active connection
*/
void removeActive();
/**
* @param conn adds a new connection
*/
void addConnection(ITerminalViewConnection conn);
/**
* If there are more than two connections toggle between this and the
* previously shown connection
*/
void swapConnection();
void addListener(ITerminalViewConnectionListener listener);
void removeListener(ITerminalViewConnectionListener listener);
void saveState(ISettingsStore store);
/**
* @param store
* @param factory used to create new {@link ITerminalViewConnection}
*/
void loadState(ISettingsStore store,ITerminalViewConnectionFactory factory);
}

View file

@ -14,37 +14,40 @@
* Michael Scharf (Wind River) - extracted from TerminalConsts * Michael Scharf (Wind River) - extracted from TerminalConsts
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified * Martin Oberhuber (Wind River) - fixed copyright headers and beautified
* Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin
* Michael Scharf (Wind River) - [172483] added some more icons
*******************************************************************************/ *******************************************************************************/
package org.eclipse.tm.internal.terminal.view; package org.eclipse.tm.internal.terminal.view;
public interface ImageConsts public interface ImageConsts
{ {
public final static String IMAGE_DIR_ROOT = "icons/"; //$NON-NLS-1$ public final static String IMAGE_DIR_ROOT = "icons/"; //$NON-NLS-1$
public final static String IMAGE_DIR_CTOOL = "ctool16/"; // basic colors - size 16x16 //$NON-NLS-1$
public final static String IMAGE_DIR_LOCALTOOL = "clcl16/"; // basic colors - size 16x16 //$NON-NLS-1$ public final static String IMAGE_DIR_LOCALTOOL = "clcl16/"; // basic colors - size 16x16 //$NON-NLS-1$
public final static String IMAGE_DIR_DLCL = "dlcl16/"; // disabled - size 16x16 //$NON-NLS-1$ public final static String IMAGE_DIR_DLCL = "dlcl16/"; // disabled - size 16x16 //$NON-NLS-1$
public final static String IMAGE_DIR_ELCL = "elcl16/"; // enabled - size 16x16 //$NON-NLS-1$ public final static String IMAGE_DIR_ELCL = "elcl16/"; // enabled - size 16x16 //$NON-NLS-1$
public final static String IMAGE_DIR_OBJECT = "obj16/"; // basic colors - size 16x16 //$NON-NLS-1$
public final static String IMAGE_DIR_WIZBAN = "wizban/"; // basic colors - size 16x16 //$NON-NLS-1$
public final static String IMAGE_DIR_OVR = "ovr16/"; // basic colors - size 7x8 //$NON-NLS-1$
public final static String IMAGE_DIR_VIEW = "cview16/"; // views //$NON-NLS-1$ public final static String IMAGE_DIR_VIEW = "cview16/"; // views //$NON-NLS-1$
public final static String IMAGE_DIR_EVIEW = "eview16/"; // views //$NON-NLS-1$ public final static String IMAGE_DIR_EVIEW = "eview16/"; // views //$NON-NLS-1$
public static final String IMAGE_NEW_TERMINAL = "TerminalViewNewTerminal"; //$NON-NLS-1$ public static final String IMAGE_NEW_TERMINAL = "TerminalViewNewTerminal"; //$NON-NLS-1$
public static final String IMAGE_TERMINAL_VIEW = "TerminalView"; //$NON-NLS-1$
public static final String IMAGE_CLCL_CONNECT = "ImageClclConnect"; //$NON-NLS-1$ public static final String IMAGE_CLCL_CONNECT = "ImageClclConnect"; //$NON-NLS-1$
public static final String IMAGE_CLCL_DISCONNECT = "ImageClclDisconnect"; //$NON-NLS-1$ public static final String IMAGE_CLCL_DISCONNECT = "ImageClclDisconnect"; //$NON-NLS-1$
public static final String IMAGE_CLCL_SETTINGS = "ImageClclSettings"; //$NON-NLS-1$ public static final String IMAGE_CLCL_SETTINGS = "ImageClclSettings"; //$NON-NLS-1$
public static final String IMAGE_CLCL_SCROLL_LOCK = "ImageClclScrollLock"; //$NON-NLS-1$ public static final String IMAGE_CLCL_SCROLL_LOCK = "ImageClclScrollLock"; //$NON-NLS-1$
public static final String IMAGE_CLCL_PIN = "ImageClclPin"; //$NON-NLS-1$
public static final String IMAGE_DLCL_CONNECT = "ImageDlclConnect"; //$NON-NLS-1$ public static final String IMAGE_DLCL_CONNECT = "ImageDlclConnect"; //$NON-NLS-1$
public static final String IMAGE_DLCL_DISCONNECT = "ImageDlclDisconnect"; //$NON-NLS-1$ public static final String IMAGE_DLCL_DISCONNECT = "ImageDlclDisconnect"; //$NON-NLS-1$
public static final String IMAGE_DLCL_SETTINGS = "ImageDlclSettings"; //$NON-NLS-1$ public static final String IMAGE_DLCL_SETTINGS = "ImageDlclSettings"; //$NON-NLS-1$
public static final String IMAGE_DLCL_SCROLL_LOCK = "ImageDlclScrollLock"; //$NON-NLS-1$ public static final String IMAGE_DLCL_SCROLL_LOCK = "ImageDlclScrollLock"; //$NON-NLS-1$
public static final String IMAGE_DLCL_PIN = "ImageDlclPin"; //$NON-NLS-1$
public static final String IMAGE_DLCL_REMOVE = "ImageDlclRemove"; //$NON-NLS-1$
public static final String IMAGE_ELCL_CONNECT = "ImageElclConnect"; //$NON-NLS-1$ public static final String IMAGE_ELCL_CONNECT = "ImageElclConnect"; //$NON-NLS-1$
public static final String IMAGE_ELCL_DISCONNECT = "ImageElclDisconnect"; //$NON-NLS-1$ public static final String IMAGE_ELCL_DISCONNECT = "ImageElclDisconnect"; //$NON-NLS-1$
public static final String IMAGE_ELCL_SETTINGS = "ImageElclSettings"; //$NON-NLS-1$ public static final String IMAGE_ELCL_SETTINGS = "ImageElclSettings"; //$NON-NLS-1$
public static final String IMAGE_ELCL_SCROLL_LOCK = "ImageElclScrollLock"; //$NON-NLS-1$ public static final String IMAGE_ELCL_SCROLL_LOCK = "ImageElclScrollLock"; //$NON-NLS-1$
public static final String IMAGE_ELCL_PIN = "ImageElclPin"; //$NON-NLS-1$
public static final String IMAGE_ELCL_REMOVE = "ImageElclRemove"; //$NON-NLS-1$
public static final String IMAGE_CLCL_COMMAND_INPUT_FIELD = "ImageClclCommandInputField";//$NON-NLS-1$ public static final String IMAGE_CLCL_COMMAND_INPUT_FIELD = "ImageClclCommandInputField";//$NON-NLS-1$
public static final String IMAGE_ELCL_COMMAND_INPUT_FIELD = "ImageDlclCommandInputField";//$NON-NLS-1$ public static final String IMAGE_ELCL_COMMAND_INPUT_FIELD = "ImageDlclCommandInputField";//$NON-NLS-1$
public static final String IMAGE_DLCL_COMMAND_INPUT_FIELD = "ImageDlclCommandInputField";//$NON-NLS-1$ public static final String IMAGE_DLCL_COMMAND_INPUT_FIELD = "ImageDlclCommandInputField";//$NON-NLS-1$

View file

@ -196,8 +196,10 @@ class TerminalSettingsDlg extends Dialog {
} }
private void setupPanel(Composite wndParent) { private void setupPanel(Composite wndParent) {
setupSettingsTypePanel(wndParent); setupSettingsTypePanel(wndParent);
setupConnTypePanel(wndParent); if(fConnectors.length>0) {
setupSettingsGroup(wndParent); setupConnTypePanel(wndParent);
setupSettingsGroup(wndParent);
}
} }
private void setupSettingsTypePanel(Composite wndParent) { private void setupSettingsTypePanel(Composite wndParent) {
Group wndGroup; Group wndGroup;
@ -246,6 +248,8 @@ class TerminalSettingsDlg extends Dialog {
fPageBook.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fPageBook.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
} }
private void setupListeners() { private void setupListeners() {
if(fCtlConnTypeCombo==null)
return;
fCtlConnTypeCombo.addSelectionListener(new SelectionAdapter() { fCtlConnTypeCombo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) { public void widgetSelected(SelectionEvent event) {
selectPage(fCtlConnTypeCombo.getSelectionIndex()); selectPage(fCtlConnTypeCombo.getSelectionIndex());
@ -275,6 +279,9 @@ class TerminalSettingsDlg extends Dialog {
boolean enable=false; boolean enable=false;
if(getConnector()!=null) if(getConnector()!=null)
enable=getConnector().getInitializationErrorMessage()==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); getButton(IDialogConstants.OK_ID).setEnabled(enable);
} }
} }

View file

@ -19,6 +19,7 @@
* Michael Scharf (Wind River) - [217999] Duplicate context menu entries in Terminal * Michael Scharf (Wind River) - [217999] Duplicate context menu entries in Terminal
* Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin
* Martin Oberhuber (Wind River) - [168186] Add Terminal User Docs * Martin Oberhuber (Wind River) - [168186] Add Terminal User Docs
* Michael Scharf (Wind River) - [172483] switch between connections
*******************************************************************************/ *******************************************************************************/
package org.eclipse.tm.internal.terminal.view; package org.eclipse.tm.internal.terminal.view;
@ -26,6 +27,7 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.Preferences;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.IToolBarManager;
@ -35,8 +37,10 @@ import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.window.Window; import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MenuEvent; import org.eclipse.swt.events.MenuEvent;
import org.eclipse.swt.events.MenuListener; import org.eclipse.swt.events.MenuListener;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
@ -45,9 +49,11 @@ import org.eclipse.tm.internal.terminal.actions.TerminalAction;
import org.eclipse.tm.internal.terminal.actions.TerminalActionConnect; import org.eclipse.tm.internal.terminal.actions.TerminalActionConnect;
import org.eclipse.tm.internal.terminal.actions.TerminalActionDisconnect; import org.eclipse.tm.internal.terminal.actions.TerminalActionDisconnect;
import org.eclipse.tm.internal.terminal.actions.TerminalActionNewTerminal; import org.eclipse.tm.internal.terminal.actions.TerminalActionNewTerminal;
import org.eclipse.tm.internal.terminal.actions.TerminalActionPin;
import org.eclipse.tm.internal.terminal.actions.TerminalActionRemove;
import org.eclipse.tm.internal.terminal.actions.TerminalActionSelectionDropDown;
import org.eclipse.tm.internal.terminal.actions.TerminalActionSettings; import org.eclipse.tm.internal.terminal.actions.TerminalActionSettings;
import org.eclipse.tm.internal.terminal.actions.TerminalActionToggleCommandInputField; import org.eclipse.tm.internal.terminal.actions.TerminalActionToggleCommandInputField;
import org.eclipse.tm.internal.terminal.control.CommandInputFieldWithHistory;
import org.eclipse.tm.internal.terminal.control.ITerminalListener; import org.eclipse.tm.internal.terminal.control.ITerminalListener;
import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
import org.eclipse.tm.internal.terminal.control.TerminalViewControlFactory; import org.eclipse.tm.internal.terminal.control.TerminalViewControlFactory;
@ -61,6 +67,8 @@ 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.Logger;
import org.eclipse.tm.internal.terminal.provisional.api.TerminalConnectorExtension; import org.eclipse.tm.internal.terminal.provisional.api.TerminalConnectorExtension;
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; 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.IMemento;
import org.eclipse.ui.IViewReference; import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IViewSite; import org.eclipse.ui.IViewSite;
@ -69,14 +77,12 @@ import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI; import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart; import org.eclipse.ui.part.ViewPart;
public class TerminalView extends ViewPart implements ITerminalView, ITerminalListener { public class TerminalView extends ViewPart implements ITerminalView, ITerminalViewConnectionListener {
private static final String STORE_CONNECTION_TYPE = "ConnectionType"; //$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_SETTING_SUMMARY = "SettingSummary"; //$NON-NLS-1$
private static final String STORE_HAS_COMMAND_INPUT_FIELD = "HasCommandInputField"; //$NON-NLS-1$ private static final String STORE_PINNED = "Pinned"; //$NON-NLS-1$
private static final String STORE_COMMAND_INPUT_FIELD_HISTORY = "CommandInputFieldHistory"; //$NON-NLS-1$
private static final String STORE_TITLE = "Title"; //$NON-NLS-1$ private static final String STORE_TITLE = "Title"; //$NON-NLS-1$
@ -84,6 +90,10 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
protected ITerminalViewControl fCtlTerminal; 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 fActionTerminalNewTerminal;
protected TerminalAction fActionTerminalConnect; protected TerminalAction fActionTerminalConnect;
@ -108,12 +118,15 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
protected TerminalPropertyChangeHandler fPropertyChangeHandler; protected TerminalPropertyChangeHandler fPropertyChangeHandler;
protected Action fActionTerminalDropDown;
protected Action fActionTerminalPin;
protected Action fActionTerminalRemove;
protected boolean fMenuAboutToShow; protected boolean fMenuAboutToShow;
private SettingsStore fStore; private SettingsStore fStore;
private CommandInputFieldWithHistory fCommandInputField; private final ITerminalViewConnectionManager fMultiConnectionManager=new TerminalViewConnectionManager();
/** /**
* Listens to changes in the preferences * Listens to changes in the preferences
*/ */
@ -126,11 +139,66 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
} }
} }
}; };
private PageBook fPageBook;
private boolean fPinned=true;
/**
* 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() { public TerminalView() {
Logger Logger
.log("==============================================================="); //$NON-NLS-1$ .log("==============================================================="); //$NON-NLS-1$
fMultiConnectionManager.addListener(this);
} }
/**
* @param title
* @return a unique part name
*/
String findUniqueTitle(String title) { String findUniqueTitle(String title) {
IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages(); IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
String id= getViewSite().getId(); String id= getViewSite().getId();
@ -165,58 +233,47 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
// if(!limitOutput) // if(!limitOutput)
// bufferLineLimit=-1; // bufferLineLimit=-1;
int bufferLineLimit = preferences.getInt(TerminalPreferencePage.PREF_BUFFERLINES); int bufferLineLimit = preferences.getInt(TerminalPreferencePage.PREF_BUFFERLINES);
fCtlTerminal.setBufferLineLimit(bufferLineLimit); boolean invert=preferences.getBoolean(TerminalPreferencePage.PREF_INVERT_COLORS);
fCtlTerminal.setInvertedColors(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);
}
} }
// TerminalTarget interface
public void setState(final TerminalState state) {
Runnable runnable=new Runnable() {
public void run() {
updateStatus();
onTerminalStatus();
}
};
runInDisplayThread(runnable);
}
/**
* @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...
}
/** /**
* Display a new Terminal view. This method is called when the user clicks the New * Display a new Terminal view. This method is called when the user clicks the New
* Terminal button in any Terminal view's toolbar. * Terminal button in any Terminal view's toolbar.
*/ */
public void onTerminalNewTerminal() { public void onTerminalNewTerminal() {
Logger.log("creating new Terminal instance."); //$NON-NLS-1$ Logger.log("creating new Terminal instance."); //$NON-NLS-1$
if(isPinned()) {
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.
try { getSite().getPage().showView(
// The second argument to showView() is a unique String identifying the "org.eclipse.tm.terminal.view.TerminalView",//$NON-NLS-1$
// secondary view instance. If it ever matches a previously used secondary "SecondaryTerminal" + System.currentTimeMillis(), //$NON-NLS-1$
// view identifier, then this call will not create a new Terminal view, IWorkbenchPage.VIEW_ACTIVATE);
// which is undesirable. Therefore, we append the current time in } catch (PartInitException ex) {
// milliseconds to the secondary view identifier to ensure it is always Logger.logException(ex);
// 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 } else {
// millisecond. setupControls();
if(newConnection()==null) {
getSite().getPage().showView( fMultiConnectionManager.removeActive();
"org.eclipse.tm.terminal.view.TerminalView",//$NON-NLS-1$ }
"SecondaryTerminal" + System.currentTimeMillis(), //$NON-NLS-1$
IWorkbenchPage.VIEW_ACTIVATE);
} catch (PartInitException ex) {
Logger.logException(ex);
} }
} }
public void onTerminalConnect() { public void onTerminalConnect() {
//if (isConnected()) //if (isConnected())
if (fCtlTerminal.getState()!=TerminalState.CLOSED) if (fCtlTerminal.getState()!=TerminalState.CLOSED)
@ -230,6 +287,8 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
updateTerminalConnect(); updateTerminalConnect();
updateTerminalDisconnect(); updateTerminalDisconnect();
updateTerminalSettings(); updateTerminalSettings();
fActionToggleCommandInputField.setChecked(hasCommandInputField());
updateSummary();
} }
public void updateTerminalConnect() { public void updateTerminalConnect() {
@ -254,20 +313,27 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
} }
public void onTerminalSettings() { public void onTerminalSettings() {
newConnection();
}
private ITerminalConnector newConnection() {
ITerminalConnector c=showSettingsDialog(); ITerminalConnector c=showSettingsDialog();
if(c!=null) { if(c!=null) {
setConnector(c); setConnector(c);
onTerminalConnect(); onTerminalConnect();
} }
return c;
} }
private ITerminalConnector showSettingsDialog() { private ITerminalConnector showSettingsDialog() {
// When the settings dialog is opened, load the Terminal settings from the // When the settings dialog is opened, load the Terminal settings from the
// persistent settings. // persistent settings.
TerminalSettingsDlg dlgTerminalSettings = new TerminalSettingsDlg(getViewSite().getShell(),fCtlTerminal.getConnectors(),fCtlTerminal.getTerminalConnector()); ITerminalConnector[] connectors = fCtlTerminal.getConnectors();
dlgTerminalSettings.setTerminalTitle(getPartName()); if(fCtlTerminal.getState()!=TerminalState.CLOSED)
connectors=new ITerminalConnector[0];
TerminalSettingsDlg dlgTerminalSettings = new TerminalSettingsDlg(getViewSite().getShell(),connectors,fCtlTerminal.getTerminalConnector());
dlgTerminalSettings.setTerminalTitle(getActiveConnection().getPartName());
Logger.log("opening Settings dialog."); //$NON-NLS-1$ Logger.log("opening Settings dialog."); //$NON-NLS-1$
if (dlgTerminalSettings.open() == Window.CANCEL) { if (dlgTerminalSettings.open() == Window.CANCEL) {
@ -280,7 +346,7 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
// When the settings dialog is closed, we persist the Terminal settings. // When the settings dialog is closed, we persist the Terminal settings.
saveSettings(dlgTerminalSettings.getConnector()); saveSettings(dlgTerminalSettings.getConnector());
setPartName(dlgTerminalSettings.getTerminalTitle()); setViewTitle(dlgTerminalSettings.getTerminalTitle());
return dlgTerminalSettings.getConnector(); return dlgTerminalSettings.getConnector();
} }
@ -289,87 +355,30 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
} }
public void updateTerminalSettings() { public void updateTerminalSettings() {
//boolean bEnabled = ((!isConnecting()) && (!fCtlTerminal.isConnected())); // fActionTerminalSettings.setEnabled((fCtlTerminal.getState()==TerminalState.CLOSED));
boolean bEnabled = (fCtlTerminal.getState()==TerminalState.CLOSED);
fActionTerminalSettings.setEnabled(bEnabled);
} }
private void setViewTitle(String title) {
public void setTerminalTitle(final String strTitle) { setPartName(title);
runInDisplayThread(new Runnable() { getActiveConnection().setPartName(title);
public void run() {
runSetTitle(strTitle);
}});
} }
private void setViewSummary(String summary) {
private void runSetTitle(String strTitle) { setContentDescription(summary);
if (fCtlTerminal.isDisposed())
return;
if (strTitle != null) {
// When parameter 'data' 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.
} else 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();
//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$
}
strTitle = name + "("+ summary + strConnected + ")"; //$NON-NLS-1$ //$NON-NLS-2$
}
setContentDescription(strTitle);
getViewSite().getActionBars().getStatusLineManager().setMessage( getViewSite().getActionBars().getStatusLineManager().setMessage(
strTitle); summary);
setTitleToolTip(getPartName()+": "+strTitle); //$NON-NLS-1$ setTitleToolTip(getPartName()+": "+summary); //$NON-NLS-1$
} }
/** public void updateSummary() {
* @return the setting summary. If there is no connection, or the connection setViewSummary(getActiveConnection().getFullSummary());
* has not been initialized, use the last stored state.
*/
private String getSettingsSummary() {
// TODO: use another mechanism than "?" for the magic non initialized state
// see TerminalConnectorProxy.getSettingsSummary
String summary="?"; //$NON-NLS-1$
if(fCtlTerminal.getTerminalConnector()!=null)
summary=fCtlTerminal.getSettingsSummary();
if("?".equals(summary)) { //$NON-NLS-1$
summary=fStore.get(STORE_SETTING_SUMMARY, ""); //$NON-NLS-1$
}
return summary;
}
public void onTerminalStatus() {
setTerminalTitle(null);
}
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.OPENED) {
return ViewMessages.STATE_OPENED;
} else if(state==TerminalState.CLOSED) {
return ViewMessages.STATE_CLOSED;
} else {
throw new IllegalStateException(state.toString());
}
} }
public void onTerminalFontChanged() { public void onTerminalFontChanged() {
fCtlTerminal.setFont(JFaceResources.getFont(FONT_DEFINITION)); // 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);
}
} }
// ViewPart interface // ViewPart interface
@ -378,25 +387,54 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
// Bind plugin.xml key bindings to this plugin. Overrides global Control-W key // Bind plugin.xml key bindings to this plugin. Overrides global Control-W key
// sequence. // sequence.
setPartName(findUniqueTitle(ViewMessages.PROP_TITLE)); fPageBook=new PageBook(wndParent,SWT.NONE);
setupControls(wndParent); 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(); setupActions();
setupLocalToolBars(); setupLocalToolBars();
setupContextMenus(); // setup all context menus
ITerminalViewConnection[] conn=fMultiConnectionManager.getConnections();
for (int i = 0; i < conn.length; i++) {
setupContextMenus(conn[i].getCtlTerminal().getControl());
}
setupListeners(wndParent); setupListeners(wndParent);
PlatformUI.getWorkbench().getHelpSystem().setHelp(wndParent, TerminalViewPlugin.HELPPREFIX + "terminal_page"); //$NON-NLS-1$ PlatformUI.getWorkbench().getHelpSystem().setHelp(wndParent, TerminalViewPlugin.HELPPREFIX + "terminal_page"); //$NON-NLS-1$
onTerminalStatus(); legacyLoadState();
legacySetTitle();
refresh();
onTerminalFontChanged(); onTerminalFontChanged();
} }
public void dispose() { public void dispose() {
Logger.log("entered."); //$NON-NLS-1$ Logger.log("entered."); //$NON-NLS-1$
TerminalViewPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPreferenceListener); TerminalViewPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPreferenceListener);
JFaceResources.getFontRegistry().removeListener(fPropertyChangeHandler); JFaceResources.getFontRegistry().removeListener(fPropertyChangeHandler);
fCtlTerminal.disposeTerminal();
// dispose all connections
ITerminalViewConnection[] conn=fMultiConnectionManager.getConnections();
for (int i = 0; i < conn.length; i++) {
conn[i].getCtlTerminal().disposeTerminal();
}
super.dispose(); super.dispose();
} }
/** /**
@ -409,24 +447,31 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
/** /**
* This method creates the top-level control for the Terminal view. * This method creates the top-level control for the Terminal view.
*/ */
protected void setupControls(Composite wndParent) { protected void setupControls() {
ITerminalConnector[] connectors = makeConnectors(); ITerminalViewConnection conn = makeViewConnection();
fCtlTerminal = TerminalViewControlFactory.makeControl(this, wndParent, connectors); 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);
setTerminalControl(ctrl);
ITerminalViewConnection conn = new TerminalViewConnection(fCtlTerminal);
listener.setConnection(conn);
conn.setPartName(getPartName());
String connectionType=fStore.get(STORE_CONNECTION_TYPE); String connectionType=fStore.get(STORE_CONNECTION_TYPE);
for (int i = 0; i < connectors.length; i++) { for (int i = 0; i < connectors.length; i++) {
connectors[i].load(getStore(connectors[i])); connectors[i].load(getStore(connectors[i]));
if(connectors[i].getId().equals(connectionType)) if(connectors[i].getId().equals(connectionType))
fCtlTerminal.setConnector(connectors[i]); ctrl.setConnector(connectors[i]);
} }
setCommandInputField("true".equals(fStore.get(STORE_HAS_COMMAND_INPUT_FIELD))); //$NON-NLS-1$
updatePreferences(); updatePreferences();
TerminalViewPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPreferenceListener); TerminalViewPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPreferenceListener);
// restore the title of this view return conn;
String title=fStore.get(STORE_TITLE);
if(title!=null && title.length()>0)
setPartName(title);
} }
/** /**
@ -450,15 +495,15 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
public void init(IViewSite site, IMemento memento) throws PartInitException { public void init(IViewSite site, IMemento memento) throws PartInitException {
super.init(site, memento); super.init(site, memento);
fStore=new SettingsStore(memento); fStore=new SettingsStore(memento);
// have we stored the pinned status?
if(fStore.get(STORE_PINNED)!=null)
setPinned("true".equals(fStore.get(STORE_PINNED))); //$NON-NLS-1$
} }
public void saveState(IMemento memento) { public void saveState(IMemento memento) {
super.saveState(memento); super.saveState(memento);
if(fCommandInputField!=null) fStore.put(STORE_PINNED, isPinned()?"true":"false"); //$NON-NLS-1$ //$NON-NLS-2$
fStore.put(STORE_COMMAND_INPUT_FIELD_HISTORY, fCommandInputField.getHistory());
fStore.put(STORE_HAS_COMMAND_INPUT_FIELD,hasCommandInputField()?"true":"false"); //$NON-NLS-1$//$NON-NLS-2$
fStore.put(STORE_SETTING_SUMMARY, getSettingsSummary());
fStore.put(STORE_TITLE,getPartName()); fStore.put(STORE_TITLE,getPartName());
fMultiConnectionManager.saveState(new SettingStorePrefixDecorator(fStore,"connectionManager")); //$NON-NLS-1$
fStore.saveState(memento); fStore.saveState(memento);
} }
private ISettingsStore getStore(ITerminalConnector connector) { private ISettingsStore getStore(ITerminalConnector connector) {
@ -466,36 +511,42 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
} }
protected void setupActions() { protected void setupActions() {
fActionTerminalDropDown = new TerminalActionSelectionDropDown(fMultiConnectionManager);
fActionTerminalPin=new TerminalActionPin(this);
fActionTerminalPin.setChecked(isPinned());
fActionTerminalRemove=new TerminalActionRemove(fMultiConnectionManager);
fActionTerminalNewTerminal = new TerminalActionNewTerminal(this); fActionTerminalNewTerminal = new TerminalActionNewTerminal(this);
// fActionTerminalScrollLock = new TerminalActionScrollLock(this); // fActionTerminalScrollLock = new TerminalActionScrollLock(this);
fActionTerminalConnect = new TerminalActionConnect(this); fActionTerminalConnect = new TerminalActionConnect(this);
fActionTerminalDisconnect = new TerminalActionDisconnect(this); fActionTerminalDisconnect = new TerminalActionDisconnect(this);
fActionTerminalSettings = new TerminalActionSettings(this); fActionTerminalSettings = new TerminalActionSettings(this);
fActionEditCopy = new TerminalActionCopy(fCtlTerminal); fActionEditCopy = new TerminalActionCopy(fCtlDecorator);
fActionEditCut = new TerminalActionCut(fCtlTerminal); fActionEditCut = new TerminalActionCut(fCtlDecorator);
fActionEditPaste = new TerminalActionPaste(fCtlTerminal); fActionEditPaste = new TerminalActionPaste(fCtlDecorator);
fActionEditClearAll = new TerminalActionClearAll(fCtlTerminal); fActionEditClearAll = new TerminalActionClearAll(fCtlDecorator);
fActionEditSelectAll = new TerminalActionSelectAll(fCtlTerminal); fActionEditSelectAll = new TerminalActionSelectAll(fCtlDecorator);
fActionToggleCommandInputField = new TerminalActionToggleCommandInputField(this); fActionToggleCommandInputField = new TerminalActionToggleCommandInputField(this);
} }
protected void setupLocalToolBars() { protected void setupLocalToolBars() {
IToolBarManager toolBarMgr = getViewSite().getActionBars().getToolBarManager(); IToolBarManager toolBarMgr = getViewSite().getActionBars().getToolBarManager();
toolBarMgr.add(fActionTerminalNewTerminal);
// toolBarMgr.add(fActionTerminalScrollLock); // toolBarMgr.add(fActionTerminalScrollLock);
toolBarMgr.add(fActionTerminalConnect); toolBarMgr.add(fActionTerminalConnect);
toolBarMgr.add(fActionTerminalDisconnect); toolBarMgr.add(fActionTerminalDisconnect);
toolBarMgr.add(fActionTerminalSettings); toolBarMgr.add(fActionTerminalSettings);
toolBarMgr.add(fActionToggleCommandInputField); toolBarMgr.add(fActionToggleCommandInputField);
toolBarMgr.add(new Separator("fixedGroup")); //$NON-NLS-1$
toolBarMgr.add(fActionTerminalPin);
toolBarMgr.add(fActionTerminalDropDown);
toolBarMgr.add(fActionTerminalNewTerminal);
toolBarMgr.add(fActionTerminalRemove);
} }
protected void setupContextMenus() { protected void setupContextMenus(Control ctlText) {
Control ctlText;
MenuManager menuMgr; MenuManager menuMgr;
Menu menu; Menu menu;
TerminalContextMenuHandler contextMenuHandler; TerminalContextMenuHandler contextMenuHandler;
ctlText = fCtlTerminal.getControl();
menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$ menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
menu = menuMgr.createContextMenu(ctlText); menu = menuMgr.createContextMenu(ctlText);
loadContextMenus(menuMgr); loadContextMenus(menuMgr);
@ -554,20 +605,11 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
} }
public boolean hasCommandInputField() { public boolean hasCommandInputField() {
return fCommandInputField!=null; return getActiveConnection().hasCommandInputField();
} }
public void setCommandInputField(boolean on) { public void setCommandInputField(boolean on) {
// save the old history getActiveConnection().setCommandInputField(on);
if(fCommandInputField!=null) {
fStore.put(STORE_COMMAND_INPUT_FIELD_HISTORY, fCommandInputField.getHistory());
fCommandInputField=null;
}
if(on) {
// TODO make history size configurable
fCommandInputField=new CommandInputFieldWithHistory(100);
fCommandInputField.setHistory(fStore.get(STORE_COMMAND_INPUT_FIELD_HISTORY));
}
fCtlTerminal.setCommandInputField(fCommandInputField);
} }
public boolean isScrollLock() { public boolean isScrollLock() {
@ -577,4 +619,71 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
public void setScrollLock(boolean on) { public void setScrollLock(boolean on) {
fCtlTerminal.setScrollLock(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());
}
public void setPinned(boolean pinned) {
fPinned=pinned;
}
public boolean isPinned() {
return fPinned;
}
/**
* 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);
}
}
} }

View file

@ -0,0 +1,195 @@
/*******************************************************************************
* Copyright (c) 20078 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 org.eclipse.jface.resource.ImageDescriptor;
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.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$
final private ITerminalViewControl fCtlTerminal;
private String fTitle;
private String fSummary;
private String fHistory;
private CommandInputFieldWithHistory fCommandInputField;
private String fPartName;
public TerminalViewConnection(ITerminalViewControl ctl) {
fCtlTerminal = ctl;
}
/* (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);
// 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);
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.OPENED) {
return ViewMessages.STATE_OPENED;
} 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();
//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$
}
strTitle = name + "("+ summary + strConnected + ")"; //$NON-NLS-1$ //$NON-NLS-2$
}
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;
}
}

View file

@ -0,0 +1,181 @@
/*******************************************************************************
* Copyright (c) 2008 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<size;i++) {
// the name under which we stored the connection
String prefix=STORE_CONNECTION_PREFIX+n;
n++;
try {
ITerminalViewConnection connection = factory.create();
fConnections.add(connection);
fConnectionHistory.add(connection);
if(prefix.equals(active))
fActiveConnection=connection;
connection.loadState(new SettingStorePrefixDecorator(store,prefix));
} catch(RuntimeException e) {
// in case something goes wrong, make sure we can read the other
// connections....
TerminalViewPlugin.getDefault().getLog().log(
new Status(
IStatus.WARNING,
TerminalViewPlugin.getDefault().getBundle().getSymbolicName(),
0,
e.getLocalizedMessage(),
e
));
}
}
}
}
public void removeActive() {
// don't remove the last connection -- we need at least one!
if(fConnections.size()>1) {
fConnections.remove(fActiveConnection);
fConnectionHistory.remove(fActiveConnection);
// make sure connection is not null....
fActiveConnection=getPreviousConnection();
// if there is no previous connection then make
// the first connection the list the active connection
if(fActiveConnection==null)
fActiveConnection=(ITerminalViewConnection) fConnections.get(0);
fireListeners();
}
}
}

View file

@ -0,0 +1,167 @@
/*******************************************************************************
* Copyright (c) 2007 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.io.UnsupportedEncodingException;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Control;
import org.eclipse.tm.internal.terminal.control.ICommandInputField;
import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
// TODO (scharf): this decorator is only there to deal with the common
// actions. Find a better solution.
public class TerminalViewControlDecorator implements ITerminalViewControl {
ITerminalViewControl fViewContoler;
public void clearTerminal() {
fViewContoler.clearTerminal();
}
public void connectTerminal() {
fViewContoler.connectTerminal();
}
public void copy() {
fViewContoler.copy();
}
public void disconnectTerminal() {
fViewContoler.disconnectTerminal();
}
public void disposeTerminal() {
fViewContoler.disposeTerminal();
}
public int getBufferLineLimit() {
return fViewContoler.getBufferLineLimit();
}
public Clipboard getClipboard() {
return fViewContoler.getClipboard();
}
public ICommandInputField getCommandInputField() {
return fViewContoler.getCommandInputField();
}
public ITerminalConnector[] getConnectors() {
return fViewContoler.getConnectors();
}
public Control getControl() {
return fViewContoler.getControl();
}
public String getEncoding() {
return fViewContoler.getEncoding();
}
public Font getFont() {
return fViewContoler.getFont();
}
public Control getRootControl() {
return fViewContoler.getRootControl();
}
public String getSelection() {
return fViewContoler.getSelection();
}
public String getSettingsSummary() {
return fViewContoler.getSettingsSummary();
}
public TerminalState getState() {
return fViewContoler.getState();
}
public ITerminalConnector getTerminalConnector() {
return fViewContoler.getTerminalConnector();
}
public boolean isConnected() {
return fViewContoler.isConnected();
}
public boolean isDisposed() {
return fViewContoler.isDisposed();
}
public boolean isEmpty() {
return fViewContoler.isEmpty();
}
public boolean isScrollLock() {
return fViewContoler.isScrollLock();
}
public void paste() {
fViewContoler.paste();
}
public boolean pasteString(String string) {
return fViewContoler.pasteString(string);
}
public void selectAll() {
fViewContoler.selectAll();
}
public void sendKey(char arg0) {
fViewContoler.sendKey(arg0);
}
public void setBufferLineLimit(int bufferLineLimit) {
fViewContoler.setBufferLineLimit(bufferLineLimit);
}
public void setCommandInputField(ICommandInputField inputField) {
fViewContoler.setCommandInputField(inputField);
}
public void setConnector(ITerminalConnector connector) {
fViewContoler.setConnector(connector);
}
public void setEncoding(String encoding) throws UnsupportedEncodingException {
fViewContoler.setEncoding(encoding);
}
public void setFocus() {
fViewContoler.setFocus();
}
public void setFont(Font font) {
fViewContoler.setFont(font);
}
public void setInvertedColors(boolean invert) {
fViewContoler.setInvertedColors(invert);
}
public void setScrollLock(boolean on) {
fViewContoler.setScrollLock(on);
}
public ITerminalViewControl getViewContoler() {
return fViewContoler;
}
public void setViewContoler(ITerminalViewControl viewContoler) {
fViewContoler = viewContoler;
}
}

View file

@ -15,6 +15,7 @@
* Martin Oberhuber (Wind River) - fixed copyright headers and beautified * Martin Oberhuber (Wind River) - fixed copyright headers and beautified
* Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin
* Martin Oberhuber (Wind River) - [168186] Add Terminal User Docs * Martin Oberhuber (Wind River) - [168186] Add Terminal User Docs
* Michael Scharf (Wind River) - [172483] switch between connections
*******************************************************************************/ *******************************************************************************/
package org.eclipse.tm.internal.terminal.view; package org.eclipse.tm.internal.terminal.view;
@ -53,6 +54,7 @@ public class TerminalViewPlugin extends AbstractUIPlugin {
map.put(ImageConsts.IMAGE_CLCL_SETTINGS, "properties_tsk.gif"); //$NON-NLS-1$ map.put(ImageConsts.IMAGE_CLCL_SETTINGS, "properties_tsk.gif"); //$NON-NLS-1$
map.put(ImageConsts.IMAGE_CLCL_COMMAND_INPUT_FIELD, "command_input_field.gif"); //$NON-NLS-1$ map.put(ImageConsts.IMAGE_CLCL_COMMAND_INPUT_FIELD, "command_input_field.gif"); //$NON-NLS-1$
map.put(ImageConsts.IMAGE_CLCL_SCROLL_LOCK, "lock_co.gif"); //$NON-NLS-1$ map.put(ImageConsts.IMAGE_CLCL_SCROLL_LOCK, "lock_co.gif"); //$NON-NLS-1$
map.put(ImageConsts.IMAGE_CLCL_PIN, "pin.gif"); //$NON-NLS-1$
loadImageRegistry(imageRegistry, ImageConsts.IMAGE_DIR_LOCALTOOL, map); loadImageRegistry(imageRegistry, ImageConsts.IMAGE_DIR_LOCALTOOL, map);
@ -65,7 +67,9 @@ public class TerminalViewPlugin extends AbstractUIPlugin {
map.put(ImageConsts.IMAGE_ELCL_SETTINGS, "properties_tsk.gif"); //$NON-NLS-1$ map.put(ImageConsts.IMAGE_ELCL_SETTINGS, "properties_tsk.gif"); //$NON-NLS-1$
map.put(ImageConsts.IMAGE_ELCL_COMMAND_INPUT_FIELD, "command_input_field.gif"); //$NON-NLS-1$ map.put(ImageConsts.IMAGE_ELCL_COMMAND_INPUT_FIELD, "command_input_field.gif"); //$NON-NLS-1$
map.put(ImageConsts.IMAGE_ELCL_SCROLL_LOCK, "lock_co.gif"); //$NON-NLS-1$ map.put(ImageConsts.IMAGE_ELCL_SCROLL_LOCK, "lock_co.gif"); //$NON-NLS-1$
map.put(ImageConsts.IMAGE_ELCL_PIN, "pin.gif"); //$NON-NLS-1$
map.put(ImageConsts.IMAGE_ELCL_REMOVE, "rem_co.gif"); //$NON-NLS-1$
loadImageRegistry(imageRegistry, ImageConsts.IMAGE_DIR_ELCL, map); loadImageRegistry(imageRegistry, ImageConsts.IMAGE_DIR_ELCL, map);
map.clear(); map.clear();
@ -77,10 +81,19 @@ public class TerminalViewPlugin extends AbstractUIPlugin {
map.put(ImageConsts.IMAGE_DLCL_SETTINGS, "properties_tsk.gif"); //$NON-NLS-1$ map.put(ImageConsts.IMAGE_DLCL_SETTINGS, "properties_tsk.gif"); //$NON-NLS-1$
map.put(ImageConsts.IMAGE_DLCL_COMMAND_INPUT_FIELD, "command_input_field.gif"); //$NON-NLS-1$ map.put(ImageConsts.IMAGE_DLCL_COMMAND_INPUT_FIELD, "command_input_field.gif"); //$NON-NLS-1$
map.put(ImageConsts.IMAGE_DLCL_SCROLL_LOCK, "lock_co.gif"); //$NON-NLS-1$ map.put(ImageConsts.IMAGE_DLCL_SCROLL_LOCK, "lock_co.gif"); //$NON-NLS-1$
map.put(ImageConsts.IMAGE_DLCL_PIN, "pin.gif"); //$NON-NLS-1$
map.put(ImageConsts.IMAGE_DLCL_REMOVE, "rem_co.gif"); //$NON-NLS-1$
loadImageRegistry(imageRegistry, ImageConsts.IMAGE_DIR_DLCL, map); loadImageRegistry(imageRegistry, ImageConsts.IMAGE_DIR_DLCL, map);
map.clear(); map.clear();
map.put(ImageConsts.IMAGE_TERMINAL_VIEW, "terminal_view.gif"); //$NON-NLS-1$
loadImageRegistry(imageRegistry, ImageConsts.IMAGE_DIR_EVIEW, map);
map.clear();
} catch (MalformedURLException malformedURLException) { } catch (MalformedURLException malformedURLException) {
malformedURLException.printStackTrace(); malformedURLException.printStackTrace();
} }

View file

@ -48,7 +48,14 @@ public interface ITerminalViewControl {
void setFont(Font font); void setFont(Font font);
void setInvertedColors(boolean invert); void setInvertedColors(boolean invert);
Font getFont(); Font getFont();
/**
* @return the text control
*/
Control getControl(); Control getControl();
/**
* @return the root of all controls
*/
Control getRootControl();
boolean isDisposed(); boolean isDisposed();
void selectAll(); void selectAll();
void clearTerminal(); void clearTerminal();