### Eclipse Workspace Patch 1.0 #P org.eclipse.tm.terminal Index: src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java,v retrieving revision 1.22 diff -u -r1.22 VT100TerminalControl.java --- src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java 10 Jun 2008 00:46:10 -0000 1.22 +++ src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java 13 Jun 2008 03:46:20 -0000 @@ -549,6 +549,9 @@ public Control getControl() { return fCtlText; } + public Control getRootControl() { + return fWndParent; + } protected void setupControls(Composite parent) { // The Terminal view now aims to be an ANSI-conforming terminal emulator, so it // can't have a horizontal scroll bar (but a vertical one is ok). Also, do Index: src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java,v retrieving revision 1.13 diff -u -r1.13 ITerminalViewControl.java --- src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java 9 Jun 2008 23:38:52 -0000 1.13 +++ src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java 13 Jun 2008 03:46:20 -0000 @@ -48,7 +48,14 @@ void setFont(Font font); void setInvertedColors(boolean invert); Font getFont(); + /** + * @return the text control + */ Control getControl(); + /** + * @return the root of all controls + */ + Control getRootControl(); boolean isDisposed(); void selectAll(); void clearTerminal(); #P org.eclipse.tm.terminal.view Index: src/org/eclipse/tm/internal/terminal/view/TerminalView.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalView.java,v retrieving revision 1.27 diff -u -r1.27 TerminalView.java --- src/org/eclipse/tm/internal/terminal/view/TerminalView.java 7 May 2008 14:48:03 -0000 1.27 +++ src/org/eclipse/tm/internal/terminal/view/TerminalView.java 13 Jun 2008 03:46:30 -0000 @@ -19,6 +19,7 @@ * 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 *******************************************************************************/ package org.eclipse.tm.internal.terminal.view; @@ -26,6 +27,7 @@ import java.util.Set; import org.eclipse.core.runtime.Preferences; +import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; @@ -35,8 +37,10 @@ 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.graphics.Font; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; @@ -45,9 +49,11 @@ 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.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.TerminalActionToggleCommandInputField; -import org.eclipse.tm.internal.terminal.control.CommandInputFieldWithHistory; import org.eclipse.tm.internal.terminal.control.ITerminalListener; import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; import org.eclipse.tm.internal.terminal.control.TerminalViewControlFactory; @@ -61,6 +67,8 @@ 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.TerminalState; +import org.eclipse.tm.internal.terminal.view.ITerminalViewConnectionManager.ITerminalViewConnectionFactory; +import org.eclipse.tm.internal.terminal.view.ITerminalViewConnectionManager.TerminalViewConnectionListener; import org.eclipse.ui.IMemento; import org.eclipse.ui.IViewReference; import org.eclipse.ui.IViewSite; @@ -69,14 +77,12 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.ViewPart; -public class TerminalView extends ViewPart implements ITerminalView, ITerminalListener { +public class TerminalView extends ViewPart implements ITerminalView, TerminalViewConnectionListener { 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_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_PINNED = "Pinned"; //$NON-NLS-1$ private static final String STORE_TITLE = "Title"; //$NON-NLS-1$ @@ -84,6 +90,10 @@ 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; @@ -108,12 +118,15 @@ protected TerminalPropertyChangeHandler fPropertyChangeHandler; + protected Action fActionTerminalDropDown; + protected Action fActionTerminalPin; + protected Action fActionTerminalRemove; + protected boolean fMenuAboutToShow; private SettingsStore fStore; - private CommandInputFieldWithHistory fCommandInputField; - + private final ITerminalViewConnectionManager fMultiConnectionManager=new TerminalViewConnectionManager(); /** * Listens to changes in the preferences */ @@ -126,11 +139,65 @@ } } }; + + 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 current connection changes, update the view + if(fConnection==fMultiConnectionManager.getCurrentConnection()) { + updateStatus(); + } + } + }); + } + public void setTerminalTitle(final String title) { + runInDisplayThread(new Runnable() { + public void run() { + fConnection.setTerminalTitle(title); + // if the current connection changes, update the view + if(fConnection==fMultiConnectionManager.getCurrentConnection()) { + updateSummary(); + } + } + }); + } + /** + * @param runnable run in display thread + */ + private void runInDisplayThread(Runnable runnable) { + if(Thread.currentThread()==Display.getDefault().getThread()) + runnable.run(); + else + Display.getDefault().syncExec(runnable); + } + + } + 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(); @@ -165,50 +232,47 @@ // if(!limitOutput) // bufferLineLimit=-1; int bufferLineLimit = preferences.getInt(TerminalPreferencePage.PREF_BUFFERLINES); - fCtlTerminal.setBufferLineLimit(bufferLineLimit); - fCtlTerminal.setInvertedColors(preferences.getBoolean(TerminalPreferencePage.PREF_INVERT_COLORS)); - } - // TerminalTarget interface - public void setState(final TerminalState state) { - Runnable runnable=new Runnable() { - public void run() { - updateStatus(); - onTerminalStatus(); - } - }; - if(Thread.currentThread()==Display.getDefault().getThread()) - runnable.run(); - else - Display.getDefault().syncExec(runnable); + boolean invert=preferences.getBoolean(TerminalPreferencePage.PREF_INVERT_COLORS); + // update the preferences for all controls + ITerminalViewConnection[] conn=fMultiConnectionManager.getConnections(); + for (int i = 0; i < conn.length; i++) { + conn[i].getCtlTerminal().setBufferLineLimit(bufferLineLimit); + conn[i].getCtlTerminal().setInvertedColors(invert); + } } - - /** * Display a new Terminal view. This method is called when the user clicks the New * Terminal button in any Terminal view's toolbar. */ public void onTerminalNewTerminal() { Logger.log("creating new Terminal instance."); //$NON-NLS-1$ - - 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 current 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. - - getSite().getPage().showView( - "org.eclipse.tm.terminal.view.TerminalView",//$NON-NLS-1$ - "SecondaryTerminal" + System.currentTimeMillis(), //$NON-NLS-1$ - IWorkbenchPage.VIEW_ACTIVATE); - } catch (PartInitException ex) { - Logger.logException(ex); + 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 current 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. + + getSite().getPage().showView( + "org.eclipse.tm.terminal.view.TerminalView",//$NON-NLS-1$ + "SecondaryTerminal" + System.currentTimeMillis(), //$NON-NLS-1$ + IWorkbenchPage.VIEW_ACTIVATE); + } catch (PartInitException ex) { + Logger.logException(ex); + } + } else { + setupControls(); + if(newConnection()==null) { + fMultiConnectionManager.removeCurrent(); + } } } + public void onTerminalConnect() { //if (isConnected()) if (fCtlTerminal.getState()!=TerminalState.CLOSED) @@ -222,6 +286,8 @@ updateTerminalConnect(); updateTerminalDisconnect(); updateTerminalSettings(); + fActionToggleCommandInputField.setChecked(hasCommandInputField()); + updateSummary(); } public void updateTerminalConnect() { @@ -246,12 +312,16 @@ } public void onTerminalSettings() { + newConnection(); + } + + private ITerminalConnector newConnection() { ITerminalConnector c=showSettingsDialog(); if(c!=null) { setConnector(c); - onTerminalConnect(); } + return c; } private ITerminalConnector showSettingsDialog() { @@ -259,7 +329,7 @@ // persistent settings. TerminalSettingsDlg dlgTerminalSettings = new TerminalSettingsDlg(getViewSite().getShell(),fCtlTerminal.getConnectors(),fCtlTerminal.getTerminalConnector()); - dlgTerminalSettings.setTerminalTitle(getPartName()); + dlgTerminalSettings.setTerminalTitle(getCurrentConnection().getPartName()); Logger.log("opening Settings dialog."); //$NON-NLS-1$ if (dlgTerminalSettings.open() == Window.CANCEL) { @@ -272,7 +342,7 @@ // When the settings dialog is closed, we persist the Terminal settings. saveSettings(dlgTerminalSettings.getConnector()); - setPartName(dlgTerminalSettings.getTerminalTitle()); + setViewTitle(dlgTerminalSettings.getTerminalTitle()); return dlgTerminalSettings.getConnector(); } @@ -286,74 +356,28 @@ fActionTerminalSettings.setEnabled(bEnabled); } - - public void setTerminalTitle(String strTitle) { - 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); + private void setViewTitle(String title) { + setPartName(title); + getCurrentConnection().setPartName(title); + } + private void setViewSummary(String summary) { + setContentDescription(summary); getViewSite().getActionBars().getStatusLineManager().setMessage( - strTitle); - setTitleToolTip(getPartName()+": "+strTitle); //$NON-NLS-1$ + summary); + setTitleToolTip(getPartName()+": "+summary); //$NON-NLS-1$ + } - /** - * @return the setting summary. If there is no connection, or the connection - * 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 updateSummary() { + setViewSummary(getCurrentConnection().getFullSummary()); } 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 @@ -362,25 +386,54 @@ // Bind plugin.xml key bindings to this plugin. Overrides global Control-W key // sequence. - setPartName(findUniqueTitle(ViewMessages.PROP_TITLE)); - setupControls(wndParent); + 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.setConnection(conn); + fPageBook.showPage(fCtlTerminal.getRootControl()); + } + setTerminalControl(fMultiConnectionManager.getCurrentConnection().getCtlTerminal()); + setViewTitle(findUniqueTitle(ViewMessages.PROP_TITLE)); setupActions(); 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); PlatformUI.getWorkbench().getHelpSystem().setHelp(wndParent, TerminalViewPlugin.HELPPREFIX + "terminal_page"); //$NON-NLS-1$ - onTerminalStatus(); + legacyLoadState(); + legacySetTitle(); + + refresh(); onTerminalFontChanged(); + } + public void dispose() { Logger.log("entered."); //$NON-NLS-1$ TerminalViewPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPreferenceListener); 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(); } /** @@ -393,24 +446,31 @@ /** * This method creates the top-level control for the Terminal view. */ - protected void setupControls(Composite wndParent) { - ITerminalConnector[] connectors = makeConnectors(); - fCtlTerminal = TerminalViewControlFactory.makeControl(this, wndParent, connectors); + protected void setupControls() { + ITerminalViewConnection conn = makeViewConnection(); + fMultiConnectionManager.addConnection(conn); + fMultiConnectionManager.setConnection(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); for (int i = 0; i < connectors.length; i++) { connectors[i].load(getStore(connectors[i])); 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(); TerminalViewPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPreferenceListener); - - // restore the title of this view - String title=fStore.get(STORE_TITLE); - if(title!=null && title.length()>0) - setPartName(title); + + return conn; } /** @@ -434,15 +494,15 @@ public void init(IViewSite site, IMemento memento) throws PartInitException { super.init(site, 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) { super.saveState(memento); - if(fCommandInputField!=null) - 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_PINNED, isPinned()?"true":"false"); //$NON-NLS-1$ //$NON-NLS-2$ fStore.put(STORE_TITLE,getPartName()); + fMultiConnectionManager.saveState(new SettingStorePrefixDecorator(fStore,"connectionManager")); //$NON-NLS-1$ fStore.saveState(memento); } private ISettingsStore getStore(ITerminalConnector connector) { @@ -450,36 +510,42 @@ } protected void setupActions() { + fActionTerminalDropDown = new TerminalActionSelectionDropDown(fMultiConnectionManager); + fActionTerminalPin=new TerminalActionPin(this); + fActionTerminalPin.setChecked(isPinned()); + 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(fCtlTerminal); - fActionEditCut = new TerminalActionCut(fCtlTerminal); - fActionEditPaste = new TerminalActionPaste(fCtlTerminal); - fActionEditClearAll = new TerminalActionClearAll(fCtlTerminal); - fActionEditSelectAll = new TerminalActionSelectAll(fCtlTerminal); + 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(fActionTerminalNewTerminal); // toolBarMgr.add(fActionTerminalScrollLock); toolBarMgr.add(fActionTerminalConnect); toolBarMgr.add(fActionTerminalDisconnect); toolBarMgr.add(fActionTerminalSettings); 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() { - Control ctlText; + protected void setupContextMenus(Control ctlText) { MenuManager menuMgr; Menu menu; TerminalContextMenuHandler contextMenuHandler; - ctlText = fCtlTerminal.getControl(); menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$ menu = menuMgr.createContextMenu(ctlText); loadContextMenus(menuMgr); @@ -538,20 +604,11 @@ } public boolean hasCommandInputField() { - return fCommandInputField!=null; + return getCurrentConnection().hasCommandInputField(); } + public void setCommandInputField(boolean on) { - // save the old history - 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); + getCurrentConnection().setCommandInputField(on); } public boolean isScrollLock() { @@ -561,4 +618,71 @@ public void setScrollLock(boolean on) { fCtlTerminal.setScrollLock(on); } + + private ITerminalViewConnection getCurrentConnection() { + return fMultiConnectionManager.getCurrentConnection(); + } + /** + * @param ctrl this control becomes the currently used one + */ + private void setTerminalControl(ITerminalViewControl ctrl) { + fCtlTerminal=ctrl; + fCtlDecorator.setViewContoler(ctrl); + } + public void connectionsChanged() { + if(getCurrentConnection()!=null) { + // update the current {@link ITerminalViewControl} + ITerminalViewControl ctrl = getCurrentConnection().getCtlTerminal(); + if(fCtlTerminal!=ctrl) { + setTerminalControl(ctrl); + refresh(); + } + } + } + + /** + * Show the current {@link ITerminalViewControl} in the view + */ + private void refresh() { + fPageBook.showPage(fCtlTerminal.getRootControl()); + updateStatus(); + setPartName(getCurrentConnection().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) { + getCurrentConnection().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); + } + } + } Index: src/org/eclipse/tm/internal/terminal/view/ITerminalView.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ITerminalView.java,v retrieving revision 1.5 diff -u -r1.5 ITerminalView.java --- src/org/eclipse/tm/internal/terminal/view/ITerminalView.java 25 Apr 2008 20:14:49 -0000 1.5 +++ src/org/eclipse/tm/internal/terminal/view/ITerminalView.java 13 Jun 2008 03:46:30 -0000 @@ -8,6 +8,7 @@ * Contributors: * Michael Scharf (Wind River) - initial API and implementation * 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; @@ -26,4 +27,6 @@ public void setCommandInputField(boolean on); public boolean isScrollLock(); public void setScrollLock(boolean b); + public void setPinned(boolean pin); + public boolean isPinned(); } Index: src/org/eclipse/tm/internal/terminal/view/ImageConsts.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ImageConsts.java,v retrieving revision 1.5 diff -u -r1.5 ImageConsts.java --- src/org/eclipse/tm/internal/terminal/view/ImageConsts.java 25 Apr 2008 20:14:49 -0000 1.5 +++ src/org/eclipse/tm/internal/terminal/view/ImageConsts.java 13 Jun 2008 03:46:30 -0000 @@ -14,37 +14,40 @@ * Michael Scharf (Wind River) - extracted from TerminalConsts * Martin Oberhuber (Wind River) - fixed copyright headers and beautified * 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; public interface ImageConsts { 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_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_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_EVIEW = "eview16/"; // views //$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_DISCONNECT = "ImageClclDisconnect"; //$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_PIN = "ImageClclPin"; //$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_SETTINGS = "ImageDlclSettings"; //$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_DISCONNECT = "ImageElclDisconnect"; //$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_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_ELCL_COMMAND_INPUT_FIELD = "ImageDlclCommandInputField";//$NON-NLS-1$ public static final String IMAGE_DLCL_COMMAND_INPUT_FIELD = "ImageDlclCommandInputField";//$NON-NLS-1$ Index: src/org/eclipse/tm/internal/terminal/view/TerminalViewPlugin.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalViewPlugin.java,v retrieving revision 1.8 diff -u -r1.8 TerminalViewPlugin.java --- src/org/eclipse/tm/internal/terminal/view/TerminalViewPlugin.java 7 May 2008 14:48:03 -0000 1.8 +++ src/org/eclipse/tm/internal/terminal/view/TerminalViewPlugin.java 13 Jun 2008 03:46:30 -0000 @@ -15,6 +15,7 @@ * Martin Oberhuber (Wind River) - fixed copyright headers and beautified * 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 *******************************************************************************/ package org.eclipse.tm.internal.terminal.view; @@ -53,6 +54,7 @@ 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_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); @@ -65,7 +67,9 @@ 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_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); map.clear(); @@ -77,10 +81,19 @@ 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_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); 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) { malformedURLException.printStackTrace(); } Index: src/org/eclipse/tm/internal/terminal/actions/ActionMessages.properties =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/ActionMessages.properties,v retrieving revision 1.5 diff -u -r1.5 ActionMessages.properties --- src/org/eclipse/tm/internal/terminal/actions/ActionMessages.properties 25 Apr 2008 20:14:49 -0000 1.5 +++ src/org/eclipse/tm/internal/terminal/actions/ActionMessages.properties 13 Jun 2008 03:46:30 -0000 @@ -14,6 +14,7 @@ # Michael Scharf (Wind River) - split into core, view and connector plugins # Martin Oberhuber (Wind River) - fixed copyright headers and beautified # Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin +# Michael Scharf (Wind River) - [172483] switch between connections ############################################################################### NEW_TERMINAL = New Terminal CONNECT = Connect @@ -23,3 +24,9 @@ SCROLL_LOCK_1 = Scroll Lock SETTINGS = Settings TOGGLE_COMMAND_INPUT_FIELD= Toggle Command Input Field +REMOVE = Remove Terminal +PIN = Pin Terminal + +ConsoleDropDownAction_0=Select Connection +ConsoleDropDownAction_1=Display Selected Connections + Index: src/org/eclipse/tm/internal/terminal/actions/ActionMessages.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.core/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/ActionMessages.java,v retrieving revision 1.5 diff -u -r1.5 ActionMessages.java --- src/org/eclipse/tm/internal/terminal/actions/ActionMessages.java 25 Apr 2008 20:14:48 -0000 1.5 +++ src/org/eclipse/tm/internal/terminal/actions/ActionMessages.java 13 Jun 2008 03:46:30 -0000 @@ -20,6 +20,7 @@ import org.eclipse.osgi.util.NLS; public class ActionMessages extends NLS { + static { NLS.initializeMessages(ActionMessages.class.getName(), ActionMessages.class); } @@ -30,6 +31,11 @@ public static String SETTINGS_ELLIPSE; public static String SCROLL_LOCK_0; 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; Index: src/org/eclipse/tm/internal/terminal/actions/TerminalActionPin.java =================================================================== RCS file: src/org/eclipse/tm/internal/terminal/actions/TerminalActionPin.java diff -N src/org/eclipse/tm/internal/terminal/actions/TerminalActionPin.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/tm/internal/terminal/actions/TerminalActionPin.java 1 Jan 1970 00:00:00 -0000 @@ -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()); + } +} Index: src/org/eclipse/tm/internal/terminal/actions/ShowConsoleAction.java =================================================================== RCS file: src/org/eclipse/tm/internal/terminal/actions/ShowConsoleAction.java diff -N src/org/eclipse/tm/internal/terminal/actions/ShowConsoleAction.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/tm/internal/terminal/actions/ShowConsoleAction.java 1 Jan 1970 00:00:00 -0000 @@ -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 console in the console view + */ +public class ShowConsoleAction 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 console the console + */ + public ShowConsoleAction(ITerminalViewConnectionManager manager, ITerminalViewConnection console) { + super(quoteName(buildName(manager,console)), AS_RADIO_BUTTON); + fConnection = console; + fConnectionManager = manager; + setImageDescriptor(console.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 perfixed. + * @param m the connection manager + * @param console the console for which the name should me extracted + * @return The name to be displayed + */ + private static String buildName(ITerminalViewConnectionManager m,ITerminalViewConnection console) { + String name = console.getFullSummary(); + if(!checkIfAllPartNamesTheSame(m)) + name=console.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.setConnection(fConnection); + } +} Index: src/org/eclipse/tm/internal/terminal/view/ITerminalViewConnectionManager.java =================================================================== RCS file: src/org/eclipse/tm/internal/terminal/view/ITerminalViewConnectionManager.java diff -N src/org/eclipse/tm/internal/terminal/view/ITerminalViewConnectionManager.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/tm/internal/terminal/view/ITerminalViewConnectionManager.java 1 Jan 1970 00:00:00 -0000 @@ -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.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: + *