Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 104859 Details for
Bug 172483
[terminal] Secondary terminals cannot be shown in other perspectives
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
A few cosmetic changes after review with Uwe
clipboard.txt (text/plain), 74.75 KB, created by
Michael Scharf
on 2008-06-13 10:00:27 EDT
(
hide
)
Description:
A few cosmetic changes after review with Uwe
Filename:
MIME Type:
Creator:
Michael Scharf
Created:
2008-06-13 10:00:27 EDT
Size:
74.75 KB
patch
obsolete
>### 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 13:56:51 -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 13:56:50 -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 13:56:58 -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.ITerminalViewConnectionListener; > 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, ITerminalViewConnectionListener { > 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,66 @@ > } > } > }; >+ >+ 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() { > 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 +233,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 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. >+ >+ 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.removeActive(); >+ } > } > } > >+ > public void onTerminalConnect() { > //if (isConnected()) > if (fCtlTerminal.getState()!=TerminalState.CLOSED) >@@ -222,6 +287,8 @@ > updateTerminalConnect(); > updateTerminalDisconnect(); > updateTerminalSettings(); >+ fActionToggleCommandInputField.setChecked(hasCommandInputField()); >+ updateSummary(); > } > > public void updateTerminalConnect() { >@@ -246,12 +313,16 @@ > } > > public void onTerminalSettings() { >+ newConnection(); >+ } >+ >+ private ITerminalConnector newConnection() { > ITerminalConnector c=showSettingsDialog(); > if(c!=null) { > setConnector(c); >- > onTerminalConnect(); > } >+ return c; > } > > private ITerminalConnector showSettingsDialog() { >@@ -259,7 +330,7 @@ > // persistent settings. > > TerminalSettingsDlg dlgTerminalSettings = new TerminalSettingsDlg(getViewSite().getShell(),fCtlTerminal.getConnectors(),fCtlTerminal.getTerminalConnector()); >- dlgTerminalSettings.setTerminalTitle(getPartName()); >+ dlgTerminalSettings.setTerminalTitle(getActiveConnection().getPartName()); > Logger.log("opening Settings dialog."); //$NON-NLS-1$ > > if (dlgTerminalSettings.open() == Window.CANCEL) { >@@ -272,7 +343,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 +357,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); >+ getActiveConnection().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(getActiveConnection().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 +387,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.setActiveConnection(conn); >+ fPageBook.showPage(fCtlTerminal.getRootControl()); >+ } >+ setTerminalControl(fMultiConnectionManager.getActiveConnection().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 +447,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.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); > 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 +495,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 +511,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 +605,11 @@ > } > > public boolean hasCommandInputField() { >- return fCommandInputField!=null; >+ return getActiveConnection().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); >+ getActiveConnection().setCommandInputField(on); > } > > public boolean isScrollLock() { >@@ -561,4 +619,71 @@ > public void setScrollLock(boolean on) { > fCtlTerminal.setScrollLock(on); > } >+ >+ private ITerminalViewConnection getActiveConnection() { >+ return fMultiConnectionManager.getActiveConnection(); >+ } >+ /** >+ * @param ctrl this control becomes the currently used one >+ */ >+ private void setTerminalControl(ITerminalViewControl ctrl) { >+ fCtlTerminal=ctrl; >+ fCtlDecorator.setViewContoler(ctrl); >+ } >+ public void connectionsChanged() { >+ if(getActiveConnection()!=null) { >+ // update the active {@link ITerminalViewControl} >+ ITerminalViewControl ctrl = getActiveConnection().getCtlTerminal(); >+ if(fCtlTerminal!=ctrl) { >+ setTerminalControl(ctrl); >+ refresh(); >+ } >+ } >+ } >+ >+ /** >+ * Show the active {@link ITerminalViewControl} in the view >+ */ >+ private void refresh() { >+ fPageBook.showPage(fCtlTerminal.getRootControl()); >+ updateStatus(); >+ setPartName(getActiveConnection().getPartName()); >+ } >+ >+ 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); >+ } >+ } >+ > } >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 13:56:57 -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 13:56:57 -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 13:56:58 -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 13:56:57 -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 13:56:57 -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/ShowTerminalConnectionAction.java >=================================================================== >RCS file: src/org/eclipse/tm/internal/terminal/actions/ShowTerminalConnectionAction.java >diff -N src/org/eclipse/tm/internal/terminal/actions/ShowTerminalConnectionAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tm/internal/terminal/actions/ShowTerminalConnectionAction.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 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); >+ } >+} >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,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); >+ >+} >Index: src/org/eclipse/tm/internal/terminal/view/ITerminalViewConnection.java >=================================================================== >RCS file: src/org/eclipse/tm/internal/terminal/view/ITerminalViewConnection.java >diff -N src/org/eclipse/tm/internal/terminal/view/ITerminalViewConnection.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tm/internal/terminal/view/ITerminalViewConnection.java 1 Jan 1970 00:00:00 -0000 >@@ -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); >+} >Index: src/org/eclipse/tm/internal/terminal/view/TerminalViewConnectionManager.java >=================================================================== >RCS file: src/org/eclipse/tm/internal/terminal/view/TerminalViewConnectionManager.java >diff -N src/org/eclipse/tm/internal/terminal/view/TerminalViewConnectionManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tm/internal/terminal/view/TerminalViewConnectionManager.java 1 Jan 1970 00:00:00 -0000 >@@ -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(); >+ } >+ } >+} >Index: src/org/eclipse/tm/internal/terminal/view/TerminalViewConnection.java >=================================================================== >RCS file: src/org/eclipse/tm/internal/terminal/view/TerminalViewConnection.java >diff -N src/org/eclipse/tm/internal/terminal/view/TerminalViewConnection.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tm/internal/terminal/view/TerminalViewConnection.java 1 Jan 1970 00:00:00 -0000 >@@ -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; >+ >+ } >+ >+} >Index: src/org/eclipse/tm/internal/terminal/actions/TerminalActionRemove.java >=================================================================== >RCS file: src/org/eclipse/tm/internal/terminal/actions/TerminalActionRemove.java >diff -N src/org/eclipse/tm/internal/terminal/actions/TerminalActionRemove.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tm/internal/terminal/actions/TerminalActionRemove.java 1 Jan 1970 00:00:00 -0000 >@@ -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); >+ } >+} >Index: src/org/eclipse/tm/internal/terminal/actions/TerminalActionSelectionDropDown.java >=================================================================== >RCS file: src/org/eclipse/tm/internal/terminal/actions/TerminalActionSelectionDropDown.java >diff -N src/org/eclipse/tm/internal/terminal/actions/TerminalActionSelectionDropDown.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tm/internal/terminal/actions/TerminalActionSelectionDropDown.java 1 Jan 1970 00:00:00 -0000 >@@ -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); >+ } >+} >Index: src/org/eclipse/tm/internal/terminal/view/TerminalViewControlDecorator.java >=================================================================== >RCS file: src/org/eclipse/tm/internal/terminal/view/TerminalViewControlDecorator.java >diff -N src/org/eclipse/tm/internal/terminal/view/TerminalViewControlDecorator.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tm/internal/terminal/view/TerminalViewControlDecorator.java 1 Jan 1970 00:00:00 -0000 >@@ -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; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 172483
:
104263
|
104271
|
104276
|
104344
|
104426
|
104558
|
104560
|
104803
|
104804
|
104859
|
105775
|
105940
|
107547