View | Details | Raw Unified | Return to bug 172483 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/tm/internal/terminal/emulator/VT100TerminalControl.java (+3 lines)
Lines 549-554 Link Here
549
	public Control getControl() {
549
	public Control getControl() {
550
		return fCtlText;
550
		return fCtlText;
551
	}
551
	}
552
	public Control getRootControl() {
553
		return fWndParent;
554
	}
552
	protected void setupControls(Composite parent) {
555
	protected void setupControls(Composite parent) {
553
		// The Terminal view now aims to be an ANSI-conforming terminal emulator, so it
556
		// The Terminal view now aims to be an ANSI-conforming terminal emulator, so it
554
		// can't have a horizontal scroll bar (but a vertical one is ok).  Also, do
557
		// can't have a horizontal scroll bar (but a vertical one is ok).  Also, do
(-)src/org/eclipse/tm/internal/terminal/control/ITerminalViewControl.java (+7 lines)
Lines 48-54 Link Here
48
	void setFont(Font font);
48
	void setFont(Font font);
49
	void setInvertedColors(boolean invert);
49
	void setInvertedColors(boolean invert);
50
	Font getFont();
50
	Font getFont();
51
	/**
52
	 * @return the text control
53
	 */
51
	Control getControl();
54
	Control getControl();
55
	/**
56
	 * @return the root of all controls
57
	 */
58
	Control getRootControl();
52
    boolean isDisposed();
59
    boolean isDisposed();
53
    void selectAll();
60
    void selectAll();
54
    void clearTerminal();
61
    void clearTerminal();
(-)src/org/eclipse/tm/internal/terminal/view/TerminalView.java (-149 / +273 lines)
Lines 19-24 Link Here
19
 * Michael Scharf (Wind River) - [217999] Duplicate context menu entries in Terminal
19
 * Michael Scharf (Wind River) - [217999] Duplicate context menu entries in Terminal
20
 * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin
20
 * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin
21
 * Martin Oberhuber (Wind River) - [168186] Add Terminal User Docs
21
 * Martin Oberhuber (Wind River) - [168186] Add Terminal User Docs
22
 * Michael Scharf (Wind River) - [172483] switch between connections
22
 *******************************************************************************/
23
 *******************************************************************************/
23
package org.eclipse.tm.internal.terminal.view;
24
package org.eclipse.tm.internal.terminal.view;
24
25
Lines 26-31 Link Here
26
import java.util.Set;
27
import java.util.Set;
27
28
28
import org.eclipse.core.runtime.Preferences;
29
import org.eclipse.core.runtime.Preferences;
30
import org.eclipse.jface.action.Action;
29
import org.eclipse.jface.action.IMenuListener;
31
import org.eclipse.jface.action.IMenuListener;
30
import org.eclipse.jface.action.IMenuManager;
32
import org.eclipse.jface.action.IMenuManager;
31
import org.eclipse.jface.action.IToolBarManager;
33
import org.eclipse.jface.action.IToolBarManager;
Lines 35-42 Link Here
35
import org.eclipse.jface.util.IPropertyChangeListener;
37
import org.eclipse.jface.util.IPropertyChangeListener;
36
import org.eclipse.jface.util.PropertyChangeEvent;
38
import org.eclipse.jface.util.PropertyChangeEvent;
37
import org.eclipse.jface.window.Window;
39
import org.eclipse.jface.window.Window;
40
import org.eclipse.swt.SWT;
38
import org.eclipse.swt.events.MenuEvent;
41
import org.eclipse.swt.events.MenuEvent;
39
import org.eclipse.swt.events.MenuListener;
42
import org.eclipse.swt.events.MenuListener;
43
import org.eclipse.swt.graphics.Font;
40
import org.eclipse.swt.widgets.Composite;
44
import org.eclipse.swt.widgets.Composite;
41
import org.eclipse.swt.widgets.Control;
45
import org.eclipse.swt.widgets.Control;
42
import org.eclipse.swt.widgets.Display;
46
import org.eclipse.swt.widgets.Display;
Lines 45-53 Link Here
45
import org.eclipse.tm.internal.terminal.actions.TerminalActionConnect;
49
import org.eclipse.tm.internal.terminal.actions.TerminalActionConnect;
46
import org.eclipse.tm.internal.terminal.actions.TerminalActionDisconnect;
50
import org.eclipse.tm.internal.terminal.actions.TerminalActionDisconnect;
47
import org.eclipse.tm.internal.terminal.actions.TerminalActionNewTerminal;
51
import org.eclipse.tm.internal.terminal.actions.TerminalActionNewTerminal;
52
import org.eclipse.tm.internal.terminal.actions.TerminalActionPin;
53
import org.eclipse.tm.internal.terminal.actions.TerminalActionRemove;
54
import org.eclipse.tm.internal.terminal.actions.TerminalActionSelectionDropDown;
48
import org.eclipse.tm.internal.terminal.actions.TerminalActionSettings;
55
import org.eclipse.tm.internal.terminal.actions.TerminalActionSettings;
49
import org.eclipse.tm.internal.terminal.actions.TerminalActionToggleCommandInputField;
56
import org.eclipse.tm.internal.terminal.actions.TerminalActionToggleCommandInputField;
50
import org.eclipse.tm.internal.terminal.control.CommandInputFieldWithHistory;
51
import org.eclipse.tm.internal.terminal.control.ITerminalListener;
57
import org.eclipse.tm.internal.terminal.control.ITerminalListener;
52
import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
58
import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
53
import org.eclipse.tm.internal.terminal.control.TerminalViewControlFactory;
59
import org.eclipse.tm.internal.terminal.control.TerminalViewControlFactory;
Lines 61-66 Link Here
61
import org.eclipse.tm.internal.terminal.provisional.api.Logger;
67
import org.eclipse.tm.internal.terminal.provisional.api.Logger;
62
import org.eclipse.tm.internal.terminal.provisional.api.TerminalConnectorExtension;
68
import org.eclipse.tm.internal.terminal.provisional.api.TerminalConnectorExtension;
63
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
69
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
70
import org.eclipse.tm.internal.terminal.view.ITerminalViewConnectionManager.ITerminalViewConnectionFactory;
71
import org.eclipse.tm.internal.terminal.view.ITerminalViewConnectionManager.TerminalViewConnectionListener;
64
import org.eclipse.ui.IMemento;
72
import org.eclipse.ui.IMemento;
65
import org.eclipse.ui.IViewReference;
73
import org.eclipse.ui.IViewReference;
66
import org.eclipse.ui.IViewSite;
74
import org.eclipse.ui.IViewSite;
Lines 69-82 Link Here
69
import org.eclipse.ui.PlatformUI;
77
import org.eclipse.ui.PlatformUI;
70
import org.eclipse.ui.part.ViewPart;
78
import org.eclipse.ui.part.ViewPart;
71
79
72
public class TerminalView extends ViewPart implements ITerminalView, ITerminalListener {
80
public class TerminalView extends ViewPart implements ITerminalView, TerminalViewConnectionListener {
73
    private static final String STORE_CONNECTION_TYPE = "ConnectionType"; //$NON-NLS-1$
81
    private static final String STORE_CONNECTION_TYPE = "ConnectionType"; //$NON-NLS-1$
74
82
75
    private static final String STORE_SETTING_SUMMARY = "SettingSummary"; //$NON-NLS-1$
83
    private static final String STORE_SETTING_SUMMARY = "SettingSummary"; //$NON-NLS-1$
76
84
    
77
    private static final String STORE_HAS_COMMAND_INPUT_FIELD = "HasCommandInputField"; //$NON-NLS-1$
85
    private static final String STORE_PINNED = "Pinned"; //$NON-NLS-1$
78
79
	private static final String STORE_COMMAND_INPUT_FIELD_HISTORY = "CommandInputFieldHistory"; //$NON-NLS-1$
80
86
81
	private static final String STORE_TITLE = "Title"; //$NON-NLS-1$
87
	private static final String STORE_TITLE = "Title"; //$NON-NLS-1$
82
88
Lines 84-89 Link Here
84
90
85
	protected ITerminalViewControl fCtlTerminal;
91
	protected ITerminalViewControl fCtlTerminal;
86
92
93
	// TODO (scharf): this decorator is only there to deal wit the common
94
	// actions. Find a better solution.
95
	TerminalViewControlDecorator fCtlDecorator=new TerminalViewControlDecorator();
96
	
87
	protected TerminalAction fActionTerminalNewTerminal;
97
	protected TerminalAction fActionTerminalNewTerminal;
88
98
89
	protected TerminalAction fActionTerminalConnect;
99
	protected TerminalAction fActionTerminalConnect;
Lines 108-119 Link Here
108
118
109
	protected TerminalPropertyChangeHandler fPropertyChangeHandler;
119
	protected TerminalPropertyChangeHandler fPropertyChangeHandler;
110
120
121
	protected Action fActionTerminalDropDown;
122
	protected Action fActionTerminalPin;
123
	protected Action fActionTerminalRemove;
124
111
	protected boolean fMenuAboutToShow;
125
	protected boolean fMenuAboutToShow;
112
126
113
	private SettingsStore fStore;
127
	private SettingsStore fStore;
114
128
115
	private CommandInputFieldWithHistory fCommandInputField;
129
	private final ITerminalViewConnectionManager fMultiConnectionManager=new TerminalViewConnectionManager();
116
117
	/**
130
	/**
118
	 * Listens to changes in the preferences
131
	 * Listens to changes in the preferences
119
	 */
132
	 */
Lines 126-136 Link Here
126
			}
139
			}
127
		}
140
		}
128
	};
141
	};
142
143
	private PageBook fPageBook;
144
145
	private boolean fPinned=true;
146
147
	/**
148
	 * This listener updates both, the view and the 
149
	 * ITerminalViewConnection.
150
	 *
151
	 */
152
	class TerminalListener implements ITerminalListener {
153
		volatile ITerminalViewConnection fConnection;
154
		void setConnection(ITerminalViewConnection connection) {
155
			fConnection=connection;
156
		}
157
		public void setState(final TerminalState state) {
158
			runInDisplayThread(new Runnable() {
159
				public void run() {
160
					fConnection.setState(state);
161
					// if the current connection changes, update the view
162
					if(fConnection==fMultiConnectionManager.getCurrentConnection()) {
163
						updateStatus();
164
					}
165
				}
166
			});
167
		}
168
		public void setTerminalTitle(final String title) {
169
			runInDisplayThread(new Runnable() {
170
				public void run() {
171
					fConnection.setTerminalTitle(title);
172
					// if the current connection changes, update the view
173
					if(fConnection==fMultiConnectionManager.getCurrentConnection()) {
174
						updateSummary();
175
					}
176
				}
177
			});
178
		}
179
		/**
180
		 * @param runnable run in display thread
181
		 */
182
		private void runInDisplayThread(Runnable runnable) {
183
			if(Thread.currentThread()==Display.getDefault().getThread())
184
				runnable.run();
185
			else
186
				Display.getDefault().syncExec(runnable);
187
		}
188
		
189
	}
190
	
129
	public TerminalView() {
191
	public TerminalView() {
130
		Logger
192
		Logger
131
				.log("==============================================================="); //$NON-NLS-1$
193
				.log("==============================================================="); //$NON-NLS-1$
194
		fMultiConnectionManager.addListener(this);
132
	}
195
	}
133
196
197
	/**
198
	 * @param title
199
	 * @return a unique part name
200
	 */
134
	String findUniqueTitle(String title) {
201
	String findUniqueTitle(String title) {
135
		IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
202
		IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
136
		String id=	getViewSite().getId();
203
		String id=	getViewSite().getId();
Lines 165-214 Link Here
165
//		if(!limitOutput)
232
//		if(!limitOutput)
166
//			bufferLineLimit=-1;
233
//			bufferLineLimit=-1;
167
		int bufferLineLimit = preferences.getInt(TerminalPreferencePage.PREF_BUFFERLINES);
234
		int bufferLineLimit = preferences.getInt(TerminalPreferencePage.PREF_BUFFERLINES);
168
		fCtlTerminal.setBufferLineLimit(bufferLineLimit);
235
		boolean invert=preferences.getBoolean(TerminalPreferencePage.PREF_INVERT_COLORS);
169
		fCtlTerminal.setInvertedColors(preferences.getBoolean(TerminalPreferencePage.PREF_INVERT_COLORS));
236
		// update the preferences for all controls
170
	}
237
		ITerminalViewConnection[] conn=fMultiConnectionManager.getConnections();
171
	// TerminalTarget interface
238
		for (int i = 0; i < conn.length; i++) {
172
	public void setState(final TerminalState state) {
239
			conn[i].getCtlTerminal().setBufferLineLimit(bufferLineLimit);
173
		Runnable runnable=new Runnable() {
240
			conn[i].getCtlTerminal().setInvertedColors(invert);
174
			public void run() {
241
		}
175
				updateStatus();
176
				onTerminalStatus();
177
			}
178
		};
179
		if(Thread.currentThread()==Display.getDefault().getThread())
180
			runnable.run();
181
		else
182
			Display.getDefault().syncExec(runnable);
183
	}
242
	}
184
185
186
	/**
243
	/**
187
	 * Display a new Terminal view.  This method is called when the user clicks the New
244
	 * Display a new Terminal view.  This method is called when the user clicks the New
188
	 * Terminal button in any Terminal view's toolbar.
245
	 * Terminal button in any Terminal view's toolbar.
189
	 */
246
	 */
190
	public void onTerminalNewTerminal() {
247
	public void onTerminalNewTerminal() {
191
		Logger.log("creating new Terminal instance."); //$NON-NLS-1$
248
		Logger.log("creating new Terminal instance."); //$NON-NLS-1$
192
249
		if(isPinned()) {
193
		try {
250
			try {
194
			// The second argument to showView() is a unique String identifying the
251
				// The second argument to showView() is a unique String identifying the
195
			// secondary view instance.  If it ever matches a previously used secondary
252
				// secondary view instance.  If it ever matches a previously used secondary
196
			// view identifier, then this call will not create a new Terminal view,
253
				// view identifier, then this call will not create a new Terminal view,
197
			// which is undesirable.  Therefore, we append the current time in
254
				// which is undesirable.  Therefore, we append the current time in
198
			// milliseconds to the secondary view identifier to ensure it is always
255
				// milliseconds to the secondary view identifier to ensure it is always
199
			// unique.  This code runs only when the user clicks the New Terminal
256
				// unique.  This code runs only when the user clicks the New Terminal
200
			// button, so there is no risk that this code will run twice in a single
257
				// button, so there is no risk that this code will run twice in a single
201
			// millisecond.
258
				// millisecond.
202
259
203
			getSite().getPage().showView(
260
				getSite().getPage().showView(
204
					"org.eclipse.tm.terminal.view.TerminalView",//$NON-NLS-1$
261
						"org.eclipse.tm.terminal.view.TerminalView",//$NON-NLS-1$
205
					"SecondaryTerminal" + System.currentTimeMillis(), //$NON-NLS-1$
262
						"SecondaryTerminal" + System.currentTimeMillis(), //$NON-NLS-1$
206
					IWorkbenchPage.VIEW_ACTIVATE);
263
						IWorkbenchPage.VIEW_ACTIVATE);
207
		} catch (PartInitException ex) {
264
			} catch (PartInitException ex) {
208
			Logger.logException(ex);
265
				Logger.logException(ex);
266
			}
267
		} else {
268
			setupControls();
269
			if(newConnection()==null) {
270
				fMultiConnectionManager.removeCurrent();
271
			}
209
		}
272
		}
210
	}
273
	}
211
274
275
	
212
	public void onTerminalConnect() {
276
	public void onTerminalConnect() {
213
		//if (isConnected())
277
		//if (isConnected())
214
		if (fCtlTerminal.getState()!=TerminalState.CLOSED)
278
		if (fCtlTerminal.getState()!=TerminalState.CLOSED)
Lines 222-227 Link Here
222
		updateTerminalConnect();
286
		updateTerminalConnect();
223
		updateTerminalDisconnect();
287
		updateTerminalDisconnect();
224
		updateTerminalSettings();
288
		updateTerminalSettings();
289
		fActionToggleCommandInputField.setChecked(hasCommandInputField());
290
		updateSummary();
225
	}
291
	}
226
292
227
	public void updateTerminalConnect() {
293
	public void updateTerminalConnect() {
Lines 246-257 Link Here
246
	}
312
	}
247
313
248
	public void onTerminalSettings() {
314
	public void onTerminalSettings() {
315
		newConnection();
316
	}
317
318
	private ITerminalConnector newConnection() {
249
		ITerminalConnector c=showSettingsDialog();
319
		ITerminalConnector c=showSettingsDialog();
250
		if(c!=null) {
320
		if(c!=null) {
251
			setConnector(c);
321
			setConnector(c);
252
253
			onTerminalConnect();
322
			onTerminalConnect();
254
		}
323
		}
324
		return c;
255
	}
325
	}
256
326
257
	private ITerminalConnector showSettingsDialog() {
327
	private ITerminalConnector showSettingsDialog() {
Lines 259-265 Link Here
259
		// persistent settings.
329
		// persistent settings.
260
330
261
		TerminalSettingsDlg dlgTerminalSettings = new TerminalSettingsDlg(getViewSite().getShell(),fCtlTerminal.getConnectors(),fCtlTerminal.getTerminalConnector());
331
		TerminalSettingsDlg dlgTerminalSettings = new TerminalSettingsDlg(getViewSite().getShell(),fCtlTerminal.getConnectors(),fCtlTerminal.getTerminalConnector());
262
		dlgTerminalSettings.setTerminalTitle(getPartName());
332
		dlgTerminalSettings.setTerminalTitle(getCurrentConnection().getPartName());
263
		Logger.log("opening Settings dialog."); //$NON-NLS-1$
333
		Logger.log("opening Settings dialog."); //$NON-NLS-1$
264
334
265
		if (dlgTerminalSettings.open() == Window.CANCEL) {
335
		if (dlgTerminalSettings.open() == Window.CANCEL) {
Lines 272-278 Link Here
272
		// When the settings dialog is closed, we persist the Terminal settings.
342
		// When the settings dialog is closed, we persist the Terminal settings.
273
343
274
		saveSettings(dlgTerminalSettings.getConnector());
344
		saveSettings(dlgTerminalSettings.getConnector());
275
		setPartName(dlgTerminalSettings.getTerminalTitle());
345
		setViewTitle(dlgTerminalSettings.getTerminalTitle());
276
		return dlgTerminalSettings.getConnector();
346
		return dlgTerminalSettings.getConnector();
277
	}
347
	}
278
348
Lines 286-359 Link Here
286
356
287
		fActionTerminalSettings.setEnabled(bEnabled);
357
		fActionTerminalSettings.setEnabled(bEnabled);
288
	}
358
	}
289
359
	private void setViewTitle(String title) {
290
	public void setTerminalTitle(String strTitle) {
360
		setPartName(title);
291
		if (fCtlTerminal.isDisposed())
361
		getCurrentConnection().setPartName(title);
292
			return;
362
	}
293
363
	private void setViewSummary(String summary) {
294
		if (strTitle != null) {
364
		setContentDescription(summary);
295
			// When parameter 'data' is not null, it is a String containing text to
296
			// display in the view's content description line.  This is used by class
297
			// TerminalText when it processes an ANSI OSC escape sequence that commands
298
			// the terminal to display text in its title bar.
299
		} else if(fCtlTerminal.getTerminalConnector()==null){
300
			strTitle=ViewMessages.NO_CONNECTION_SELECTED;
301
		} else {
302
			// When parameter 'data' is null, we construct a descriptive string to
303
			// display in the content description line.
304
			String strConnected = getStateDisplayName(fCtlTerminal.getState());
305
			String summary = getSettingsSummary();
306
			//TODO Title should use an NLS String and com.ibm.icu.MessageFormat
307
			//In order to make the logic of assembling, and the separators, better adapt to foreign languages
308
			if(summary.length()>0)
309
				summary=summary+" - ";  //$NON-NLS-1$
310
			String name=fCtlTerminal.getTerminalConnector().getName();
311
			if(name.length()>0) {
312
				name+=": "; //$NON-NLS-1$
313
			}
314
			strTitle = name + "("+ summary + strConnected + ")"; //$NON-NLS-1$ //$NON-NLS-2$
315
		}
316
317
		setContentDescription(strTitle);
318
		getViewSite().getActionBars().getStatusLineManager().setMessage(
365
		getViewSite().getActionBars().getStatusLineManager().setMessage(
319
				strTitle);
366
				summary);
320
		setTitleToolTip(getPartName()+": "+strTitle); //$NON-NLS-1$
367
		setTitleToolTip(getPartName()+": "+summary); //$NON-NLS-1$
368
		
321
	}
369
	}
322
	/**
370
	public void updateSummary() {
323
	 * @return the setting summary. If there is no connection, or the connection
371
		setViewSummary(getCurrentConnection().getFullSummary());
324
	 * has not been initialized, use the last stored state.
325
	 */
326
	private String getSettingsSummary() {
327
		// TODO: use another mechanism than "?" for the magic non initialized state
328
		// see TerminalConnectorProxy.getSettingsSummary
329
		String summary="?"; //$NON-NLS-1$
330
		if(fCtlTerminal.getTerminalConnector()!=null)
331
			summary=fCtlTerminal.getSettingsSummary();
332
		if("?".equals(summary)) { //$NON-NLS-1$
333
			summary=fStore.get(STORE_SETTING_SUMMARY, ""); //$NON-NLS-1$
334
		}
335
		return summary;
336
	}
337
	public void onTerminalStatus() {
338
		setTerminalTitle(null);
339
	}
340
341
	private String getStateDisplayName(TerminalState state) {
342
		if(state==TerminalState.CONNECTED) {
343
			return ViewMessages.STATE_CONNECTED;
344
		} else if(state==TerminalState.CONNECTING) {
345
			return ViewMessages.STATE_CONNECTING;
346
		} else if(state==TerminalState.OPENED) {
347
			return ViewMessages.STATE_OPENED;
348
		} else if(state==TerminalState.CLOSED) {
349
			return ViewMessages.STATE_CLOSED;
350
		} else {
351
			throw new IllegalStateException(state.toString());
352
		}
353
	}
372
	}
354
373
355
	public void onTerminalFontChanged() {
374
	public void onTerminalFontChanged() {
356
		fCtlTerminal.setFont(JFaceResources.getFont(FONT_DEFINITION));
375
		// set the font for all 
376
		Font font=JFaceResources.getFont(FONT_DEFINITION);
377
		ITerminalViewConnection[] conn=fMultiConnectionManager.getConnections();
378
		for (int i = 0; i < conn.length; i++) {
379
			conn[i].getCtlTerminal().setFont(font);
380
		}
357
	}
381
	}
358
382
359
	// ViewPart interface
383
	// ViewPart interface
Lines 362-386 Link Here
362
		// Bind plugin.xml key bindings to this plugin.  Overrides global Control-W key
386
		// Bind plugin.xml key bindings to this plugin.  Overrides global Control-W key
363
		// sequence.
387
		// sequence.
364
388
365
		setPartName(findUniqueTitle(ViewMessages.PROP_TITLE));
389
		fPageBook=new PageBook(wndParent,SWT.NONE);
366
		setupControls(wndParent);
390
		ISettingsStore s=new SettingStorePrefixDecorator(fStore,"connectionManager"); //$NON-NLS-1$
391
		fMultiConnectionManager.loadState(s,new ITerminalViewConnectionFactory() {
392
			public ITerminalViewConnection create() {
393
				return makeViewConnection();
394
			}
395
		});
396
		// if there is no connection loaded, create at least one
397
		// needed to read old states from the old terminal
398
		if(fMultiConnectionManager.size()==0) {
399
			ITerminalViewConnection conn = makeViewConnection();
400
			fMultiConnectionManager.addConnection(conn);
401
			fMultiConnectionManager.setConnection(conn);
402
			fPageBook.showPage(fCtlTerminal.getRootControl());
403
		}
404
		setTerminalControl(fMultiConnectionManager.getCurrentConnection().getCtlTerminal());
405
		setViewTitle(findUniqueTitle(ViewMessages.PROP_TITLE));
367
		setupActions();
406
		setupActions();
368
		setupLocalToolBars();
407
		setupLocalToolBars();
369
		setupContextMenus();
408
		// setup all context menus
409
		ITerminalViewConnection[] conn=fMultiConnectionManager.getConnections();
410
		for (int i = 0; i < conn.length; i++) {
411
			setupContextMenus(conn[i].getCtlTerminal().getControl());
412
		}
370
		setupListeners(wndParent);
413
		setupListeners(wndParent);
371
414
372
		PlatformUI.getWorkbench().getHelpSystem().setHelp(wndParent, TerminalViewPlugin.HELPPREFIX + "terminal_page"); //$NON-NLS-1$
415
		PlatformUI.getWorkbench().getHelpSystem().setHelp(wndParent, TerminalViewPlugin.HELPPREFIX + "terminal_page"); //$NON-NLS-1$
373
416
374
		onTerminalStatus();
417
		legacyLoadState();
418
		legacySetTitle();
419
420
		refresh();
375
		onTerminalFontChanged();
421
		onTerminalFontChanged();
422
376
	}
423
	}
424
377
	public void dispose() {
425
	public void dispose() {
378
		Logger.log("entered."); //$NON-NLS-1$
426
		Logger.log("entered."); //$NON-NLS-1$
379
427
380
		TerminalViewPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPreferenceListener);
428
		TerminalViewPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPreferenceListener);
381
429
382
		JFaceResources.getFontRegistry().removeListener(fPropertyChangeHandler);
430
		JFaceResources.getFontRegistry().removeListener(fPropertyChangeHandler);
383
		fCtlTerminal.disposeTerminal();
431
		
432
		// dispose all connections
433
		ITerminalViewConnection[] conn=fMultiConnectionManager.getConnections();
434
		for (int i = 0; i < conn.length; i++) {
435
			conn[i].getCtlTerminal().disposeTerminal();
436
		}
384
		super.dispose();
437
		super.dispose();
385
	}
438
	}
386
	/**
439
	/**
Lines 393-416 Link Here
393
	/**
446
	/**
394
	 * This method creates the top-level control for the Terminal view.
447
	 * This method creates the top-level control for the Terminal view.
395
	 */
448
	 */
396
	protected void setupControls(Composite wndParent) {
449
	protected void setupControls() {
397
		ITerminalConnector[] connectors = makeConnectors();
450
		ITerminalViewConnection conn = makeViewConnection();
398
		fCtlTerminal = TerminalViewControlFactory.makeControl(this, wndParent, connectors);
451
		fMultiConnectionManager.addConnection(conn);
452
		fMultiConnectionManager.setConnection(conn);
453
		setupContextMenus(fCtlTerminal.getControl());
454
	}
399
455
456
	private ITerminalViewConnection makeViewConnection() {
457
		ITerminalConnector[] connectors = makeConnectors();
458
		TerminalListener listener=new TerminalListener();
459
		ITerminalViewControl ctrl = TerminalViewControlFactory.makeControl(listener, fPageBook, connectors);
460
		setTerminalControl(ctrl);
461
		ITerminalViewConnection conn = new TerminalViewConnection(fCtlTerminal);
462
		listener.setConnection(conn);
463
		conn.setPartName(getPartName());
400
		String connectionType=fStore.get(STORE_CONNECTION_TYPE);
464
		String connectionType=fStore.get(STORE_CONNECTION_TYPE);
401
		for (int i = 0; i < connectors.length; i++) {
465
		for (int i = 0; i < connectors.length; i++) {
402
			connectors[i].load(getStore(connectors[i]));
466
			connectors[i].load(getStore(connectors[i]));
403
			if(connectors[i].getId().equals(connectionType))
467
			if(connectors[i].getId().equals(connectionType))
404
				fCtlTerminal.setConnector(connectors[i]);
468
				ctrl.setConnector(connectors[i]);
405
		}
469
		}
406
		setCommandInputField("true".equals(fStore.get(STORE_HAS_COMMAND_INPUT_FIELD))); //$NON-NLS-1$
407
		updatePreferences();
470
		updatePreferences();
408
		TerminalViewPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPreferenceListener);
471
		TerminalViewPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPreferenceListener);
409
472
		
410
		// restore the title of this view
473
		return conn;
411
		String title=fStore.get(STORE_TITLE);
412
		if(title!=null && title.length()>0)
413
			setPartName(title);
414
	}
474
	}
415
475
416
	/**
476
	/**
Lines 434-448 Link Here
434
	public void init(IViewSite site, IMemento memento) throws PartInitException {
494
	public void init(IViewSite site, IMemento memento) throws PartInitException {
435
		super.init(site, memento);
495
		super.init(site, memento);
436
		fStore=new SettingsStore(memento);
496
		fStore=new SettingsStore(memento);
497
		// have we stored the pinned status?
498
		if(fStore.get(STORE_PINNED)!=null)
499
			setPinned("true".equals(fStore.get(STORE_PINNED))); //$NON-NLS-1$
437
	}
500
	}
438
439
	public void saveState(IMemento memento) {
501
	public void saveState(IMemento memento) {
440
		super.saveState(memento);
502
		super.saveState(memento);
441
		if(fCommandInputField!=null)
503
		fStore.put(STORE_PINNED, isPinned()?"true":"false"); //$NON-NLS-1$ //$NON-NLS-2$
442
			fStore.put(STORE_COMMAND_INPUT_FIELD_HISTORY, fCommandInputField.getHistory());
443
		fStore.put(STORE_HAS_COMMAND_INPUT_FIELD,hasCommandInputField()?"true":"false");   //$NON-NLS-1$//$NON-NLS-2$
444
		fStore.put(STORE_SETTING_SUMMARY, getSettingsSummary());
445
		fStore.put(STORE_TITLE,getPartName());
504
		fStore.put(STORE_TITLE,getPartName());
505
		fMultiConnectionManager.saveState(new SettingStorePrefixDecorator(fStore,"connectionManager")); //$NON-NLS-1$
446
		fStore.saveState(memento);
506
		fStore.saveState(memento);
447
	}
507
	}
448
	private ISettingsStore getStore(ITerminalConnector connector) {
508
	private ISettingsStore getStore(ITerminalConnector connector) {
Lines 450-485 Link Here
450
	}
510
	}
451
511
452
	protected void setupActions() {
512
	protected void setupActions() {
513
		fActionTerminalDropDown = new TerminalActionSelectionDropDown(fMultiConnectionManager);
514
		fActionTerminalPin=new TerminalActionPin(this);
515
		fActionTerminalPin.setChecked(isPinned());
516
		fActionTerminalRemove=new TerminalActionRemove(fMultiConnectionManager);
453
		fActionTerminalNewTerminal = new TerminalActionNewTerminal(this);
517
		fActionTerminalNewTerminal = new TerminalActionNewTerminal(this);
454
//		fActionTerminalScrollLock = new TerminalActionScrollLock(this);
518
//		fActionTerminalScrollLock = new TerminalActionScrollLock(this);
455
		fActionTerminalConnect = new TerminalActionConnect(this);
519
		fActionTerminalConnect = new TerminalActionConnect(this);
456
		fActionTerminalDisconnect = new TerminalActionDisconnect(this);
520
		fActionTerminalDisconnect = new TerminalActionDisconnect(this);
457
		fActionTerminalSettings = new TerminalActionSettings(this);
521
		fActionTerminalSettings = new TerminalActionSettings(this);
458
		fActionEditCopy = new TerminalActionCopy(fCtlTerminal);
522
		fActionEditCopy = new TerminalActionCopy(fCtlDecorator);
459
		fActionEditCut = new TerminalActionCut(fCtlTerminal);
523
		fActionEditCut = new TerminalActionCut(fCtlDecorator);
460
		fActionEditPaste = new TerminalActionPaste(fCtlTerminal);
524
		fActionEditPaste = new TerminalActionPaste(fCtlDecorator);
461
		fActionEditClearAll = new TerminalActionClearAll(fCtlTerminal);
525
		fActionEditClearAll = new TerminalActionClearAll(fCtlDecorator);
462
		fActionEditSelectAll = new TerminalActionSelectAll(fCtlTerminal);
526
		fActionEditSelectAll = new TerminalActionSelectAll(fCtlDecorator);
463
		fActionToggleCommandInputField = new TerminalActionToggleCommandInputField(this);
527
		fActionToggleCommandInputField = new TerminalActionToggleCommandInputField(this);
464
	}
528
	}
465
	protected void setupLocalToolBars() {
529
	protected void setupLocalToolBars() {
466
		IToolBarManager toolBarMgr = getViewSite().getActionBars().getToolBarManager();
530
		IToolBarManager toolBarMgr = getViewSite().getActionBars().getToolBarManager();
467
531
468
		toolBarMgr.add(fActionTerminalNewTerminal);
469
//		toolBarMgr.add(fActionTerminalScrollLock);
532
//		toolBarMgr.add(fActionTerminalScrollLock);
470
		toolBarMgr.add(fActionTerminalConnect);
533
		toolBarMgr.add(fActionTerminalConnect);
471
		toolBarMgr.add(fActionTerminalDisconnect);
534
		toolBarMgr.add(fActionTerminalDisconnect);
472
		toolBarMgr.add(fActionTerminalSettings);
535
		toolBarMgr.add(fActionTerminalSettings);
473
		toolBarMgr.add(fActionToggleCommandInputField);
536
		toolBarMgr.add(fActionToggleCommandInputField);
537
		toolBarMgr.add(new Separator("fixedGroup")); //$NON-NLS-1$
538
		toolBarMgr.add(fActionTerminalPin);
539
		toolBarMgr.add(fActionTerminalDropDown);
540
		toolBarMgr.add(fActionTerminalNewTerminal);
541
		toolBarMgr.add(fActionTerminalRemove);
474
	}
542
	}
475
543
476
	protected void setupContextMenus() {
544
	protected void setupContextMenus(Control ctlText) {
477
		Control ctlText;
478
		MenuManager menuMgr;
545
		MenuManager menuMgr;
479
		Menu menu;
546
		Menu menu;
480
		TerminalContextMenuHandler contextMenuHandler;
547
		TerminalContextMenuHandler contextMenuHandler;
481
548
482
		ctlText = fCtlTerminal.getControl();
483
		menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
549
		menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
484
		menu = menuMgr.createContextMenu(ctlText);
550
		menu = menuMgr.createContextMenu(ctlText);
485
		loadContextMenus(menuMgr);
551
		loadContextMenus(menuMgr);
Lines 538-557 Link Here
538
	}
604
	}
539
605
540
	public boolean hasCommandInputField() {
606
	public boolean hasCommandInputField() {
541
		return fCommandInputField!=null;
607
		return getCurrentConnection().hasCommandInputField();
542
	}
608
	}
609
543
	public void setCommandInputField(boolean on) {
610
	public void setCommandInputField(boolean on) {
544
		// save the old history
611
		getCurrentConnection().setCommandInputField(on);
545
		if(fCommandInputField!=null) {
546
			fStore.put(STORE_COMMAND_INPUT_FIELD_HISTORY, fCommandInputField.getHistory());
547
			fCommandInputField=null;
548
		}
549
		if(on) {
550
			// TODO make history size configurable
551
			fCommandInputField=new CommandInputFieldWithHistory(100);
552
			fCommandInputField.setHistory(fStore.get(STORE_COMMAND_INPUT_FIELD_HISTORY));
553
		}
554
		fCtlTerminal.setCommandInputField(fCommandInputField);
555
	}
612
	}
556
613
557
	public boolean isScrollLock() {
614
	public boolean isScrollLock() {
Lines 561-564 Link Here
561
	public void setScrollLock(boolean on) {
618
	public void setScrollLock(boolean on) {
562
		fCtlTerminal.setScrollLock(on);
619
		fCtlTerminal.setScrollLock(on);
563
	}
620
	}
621
622
	private ITerminalViewConnection getCurrentConnection() {
623
		return fMultiConnectionManager.getCurrentConnection();
624
	}
625
	/**
626
	 * @param ctrl this control becomes the currently used one
627
	 */
628
	private void setTerminalControl(ITerminalViewControl ctrl) {
629
		fCtlTerminal=ctrl;
630
		fCtlDecorator.setViewContoler(ctrl);
631
	}
632
	public void connectionsChanged() {
633
		if(getCurrentConnection()!=null) {
634
			// update the current {@link ITerminalViewControl}
635
			ITerminalViewControl ctrl = getCurrentConnection().getCtlTerminal();
636
			if(fCtlTerminal!=ctrl) {
637
				setTerminalControl(ctrl);
638
				refresh();
639
			}
640
		}	
641
	}
642
643
	/**
644
	 * Show the current {@link ITerminalViewControl} in the view
645
	 */
646
	private void refresh() {
647
		fPageBook.showPage(fCtlTerminal.getRootControl());
648
		updateStatus();
649
		setPartName(getCurrentConnection().getPartName());
650
	}
651
652
	public void setPinned(boolean pinned) {
653
		fPinned=pinned;
654
	}
655
	public boolean isPinned() {
656
		return fPinned;
657
	}
658
659
	/**
660
	 * TODO REMOVE This code (added 2008-06-11)
661
	 * Legacy code to real the old state. Once the state of the
662
	 * terminal has been saved this method is not needed anymore.
663
	 * Remove this code with eclipse 3.5.
664
	 */
665
	private void legacyLoadState() {
666
		// TODO legacy: load the old title....
667
		String summary=fStore.get(STORE_SETTING_SUMMARY);
668
		if(summary!=null) {
669
			getCurrentConnection().setSummary(summary);
670
			fStore.put(STORE_SETTING_SUMMARY,null);
671
		}
672
	}
673
	/**
674
	 * TODO REMOVE This code (added 2008-06-11)
675
	 * Legacy code to real the old state. Once the state of the
676
	 * terminal has been saved this method is not needed anymore.
677
	 * Remove this code with eclipse 3.5.
678
	 */
679
	private void legacySetTitle() {
680
		// restore the title of this view
681
		String title=fStore.get(STORE_TITLE);
682
		if(title!=null && title.length()>0) {
683
			setViewTitle(title);
684
			fStore.put(STORE_TITLE, null);
685
		}
686
	}
687
564
}
688
}
(-)src/org/eclipse/tm/internal/terminal/view/ITerminalView.java (+3 lines)
Lines 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 * Michael Scharf (Wind River) - initial API and implementation
9
 * Michael Scharf (Wind River) - initial API and implementation
10
 * Martin Oberhuber (Wind River) - [227537] moved actions from terminal.view to terminal plugin
10
 * Martin Oberhuber (Wind River) - [227537] moved actions from terminal.view to terminal plugin
11
 * Michael Scharf (Wind River) - [172483] switch between connections
11
 *******************************************************************************/
12
 *******************************************************************************/
12
package org.eclipse.tm.internal.terminal.view;
13
package org.eclipse.tm.internal.terminal.view;
13
14
Lines 26-29 Link Here
26
	public void setCommandInputField(boolean on);
27
	public void setCommandInputField(boolean on);
27
	public boolean isScrollLock();
28
	public boolean isScrollLock();
28
	public void setScrollLock(boolean b);
29
	public void setScrollLock(boolean b);
30
	public void setPinned(boolean pin);
31
	public boolean isPinned();
29
}
32
}
(-)src/org/eclipse/tm/internal/terminal/view/ImageConsts.java (-4 / +7 lines)
Lines 14-50 Link Here
14
 * Michael Scharf (Wind River) - extracted from TerminalConsts
14
 * Michael Scharf (Wind River) - extracted from TerminalConsts
15
 * Martin Oberhuber (Wind River) - fixed copyright headers and beautified
15
 * Martin Oberhuber (Wind River) - fixed copyright headers and beautified
16
 * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin
16
 * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin
17
 * Michael Scharf (Wind River) - [172483] added some more icons
17
 *******************************************************************************/
18
 *******************************************************************************/
18
package org.eclipse.tm.internal.terminal.view;
19
package org.eclipse.tm.internal.terminal.view;
19
20
20
public interface ImageConsts
21
public interface ImageConsts
21
{
22
{
22
    public final static String  IMAGE_DIR_ROOT                 = "icons/"; //$NON-NLS-1$
23
    public final static String  IMAGE_DIR_ROOT                 = "icons/"; //$NON-NLS-1$
23
    public final static String  IMAGE_DIR_CTOOL                = "ctool16/";   // basic colors - size 16x16 //$NON-NLS-1$
24
    public final static String  IMAGE_DIR_LOCALTOOL            = "clcl16/";    // basic colors - size 16x16 //$NON-NLS-1$
24
    public final static String  IMAGE_DIR_LOCALTOOL            = "clcl16/";    // basic colors - size 16x16 //$NON-NLS-1$
25
    public final static String  IMAGE_DIR_DLCL                 = "dlcl16/";    // disabled - size 16x16 //$NON-NLS-1$
25
    public final static String  IMAGE_DIR_DLCL                 = "dlcl16/";    // disabled - size 16x16 //$NON-NLS-1$
26
    public final static String  IMAGE_DIR_ELCL                 = "elcl16/";    // enabled - size 16x16 //$NON-NLS-1$
26
    public final static String  IMAGE_DIR_ELCL                 = "elcl16/";    // enabled - size 16x16 //$NON-NLS-1$
27
    public final static String  IMAGE_DIR_OBJECT               = "obj16/";     // basic colors - size 16x16 //$NON-NLS-1$
28
    public final static String  IMAGE_DIR_WIZBAN               = "wizban/";    // basic colors - size 16x16 //$NON-NLS-1$
29
    public final static String  IMAGE_DIR_OVR                  = "ovr16/";     // basic colors - size 7x8 //$NON-NLS-1$
30
    public final static String  IMAGE_DIR_VIEW                 = "cview16/";   // views //$NON-NLS-1$
27
    public final static String  IMAGE_DIR_VIEW                 = "cview16/";   // views //$NON-NLS-1$
31
    public final static String  IMAGE_DIR_EVIEW                = "eview16/";   // views //$NON-NLS-1$
28
    public final static String  IMAGE_DIR_EVIEW                = "eview16/";   // views //$NON-NLS-1$
32
29
33
    public static final String  IMAGE_NEW_TERMINAL             = "TerminalViewNewTerminal"; //$NON-NLS-1$
30
    public static final String  IMAGE_NEW_TERMINAL             = "TerminalViewNewTerminal"; //$NON-NLS-1$
31
    public static final String  IMAGE_TERMINAL_VIEW            = "TerminalView"; //$NON-NLS-1$
34
    public static final String  IMAGE_CLCL_CONNECT             = "ImageClclConnect"; //$NON-NLS-1$
32
    public static final String  IMAGE_CLCL_CONNECT             = "ImageClclConnect"; //$NON-NLS-1$
35
    public static final String  IMAGE_CLCL_DISCONNECT          = "ImageClclDisconnect"; //$NON-NLS-1$
33
    public static final String  IMAGE_CLCL_DISCONNECT          = "ImageClclDisconnect"; //$NON-NLS-1$
36
    public static final String  IMAGE_CLCL_SETTINGS            = "ImageClclSettings"; //$NON-NLS-1$
34
    public static final String  IMAGE_CLCL_SETTINGS            = "ImageClclSettings"; //$NON-NLS-1$
37
    public static final String  IMAGE_CLCL_SCROLL_LOCK         = "ImageClclScrollLock"; //$NON-NLS-1$
35
    public static final String  IMAGE_CLCL_SCROLL_LOCK         = "ImageClclScrollLock"; //$NON-NLS-1$
36
    public static final String  IMAGE_CLCL_PIN         	       = "ImageClclPin"; //$NON-NLS-1$
38
37
39
    public static final String  IMAGE_DLCL_CONNECT             = "ImageDlclConnect"; //$NON-NLS-1$
38
    public static final String  IMAGE_DLCL_CONNECT             = "ImageDlclConnect"; //$NON-NLS-1$
40
    public static final String  IMAGE_DLCL_DISCONNECT          = "ImageDlclDisconnect"; //$NON-NLS-1$
39
    public static final String  IMAGE_DLCL_DISCONNECT          = "ImageDlclDisconnect"; //$NON-NLS-1$
41
    public static final String  IMAGE_DLCL_SETTINGS            = "ImageDlclSettings"; //$NON-NLS-1$
40
    public static final String  IMAGE_DLCL_SETTINGS            = "ImageDlclSettings"; //$NON-NLS-1$
42
    public static final String  IMAGE_DLCL_SCROLL_LOCK         = "ImageDlclScrollLock"; //$NON-NLS-1$
41
    public static final String  IMAGE_DLCL_SCROLL_LOCK         = "ImageDlclScrollLock"; //$NON-NLS-1$
42
    public static final String  IMAGE_DLCL_PIN         	       = "ImageDlclPin"; //$NON-NLS-1$
43
    public static final String  IMAGE_DLCL_REMOVE         	   = "ImageDlclRemove"; //$NON-NLS-1$
43
44
44
    public static final String  IMAGE_ELCL_CONNECT             = "ImageElclConnect"; //$NON-NLS-1$
45
    public static final String  IMAGE_ELCL_CONNECT             = "ImageElclConnect"; //$NON-NLS-1$
45
    public static final String  IMAGE_ELCL_DISCONNECT          = "ImageElclDisconnect"; //$NON-NLS-1$
46
    public static final String  IMAGE_ELCL_DISCONNECT          = "ImageElclDisconnect"; //$NON-NLS-1$
46
    public static final String  IMAGE_ELCL_SETTINGS            = "ImageElclSettings"; //$NON-NLS-1$
47
    public static final String  IMAGE_ELCL_SETTINGS            = "ImageElclSettings"; //$NON-NLS-1$
47
    public static final String  IMAGE_ELCL_SCROLL_LOCK         = "ImageElclScrollLock"; //$NON-NLS-1$
48
    public static final String  IMAGE_ELCL_SCROLL_LOCK         = "ImageElclScrollLock"; //$NON-NLS-1$
49
    public static final String  IMAGE_ELCL_PIN         	       = "ImageElclPin"; //$NON-NLS-1$
50
    public static final String  IMAGE_ELCL_REMOVE         	   = "ImageElclRemove"; //$NON-NLS-1$
48
	public static final String  IMAGE_CLCL_COMMAND_INPUT_FIELD        = "ImageClclCommandInputField";//$NON-NLS-1$
51
	public static final String  IMAGE_CLCL_COMMAND_INPUT_FIELD        = "ImageClclCommandInputField";//$NON-NLS-1$
49
	public static final String  IMAGE_ELCL_COMMAND_INPUT_FIELD        = "ImageDlclCommandInputField";//$NON-NLS-1$
52
	public static final String  IMAGE_ELCL_COMMAND_INPUT_FIELD        = "ImageDlclCommandInputField";//$NON-NLS-1$
50
	public static final String  IMAGE_DLCL_COMMAND_INPUT_FIELD        = "ImageDlclCommandInputField";//$NON-NLS-1$
53
	public static final String  IMAGE_DLCL_COMMAND_INPUT_FIELD        = "ImageDlclCommandInputField";//$NON-NLS-1$
(-)src/org/eclipse/tm/internal/terminal/view/TerminalViewPlugin.java (-1 / +14 lines)
Lines 15-20 Link Here
15
 * Martin Oberhuber (Wind River) - fixed copyright headers and beautified
15
 * Martin Oberhuber (Wind River) - fixed copyright headers and beautified
16
 * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin
16
 * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin
17
 * Martin Oberhuber (Wind River) - [168186] Add Terminal User Docs
17
 * Martin Oberhuber (Wind River) - [168186] Add Terminal User Docs
18
 * Michael Scharf (Wind River) - [172483] switch between connections
18
 *******************************************************************************/
19
 *******************************************************************************/
19
package org.eclipse.tm.internal.terminal.view;
20
package org.eclipse.tm.internal.terminal.view;
20
21
Lines 53-58 Link Here
53
			map.put(ImageConsts.IMAGE_CLCL_SETTINGS, "properties_tsk.gif"); //$NON-NLS-1$
54
			map.put(ImageConsts.IMAGE_CLCL_SETTINGS, "properties_tsk.gif"); //$NON-NLS-1$
54
			map.put(ImageConsts.IMAGE_CLCL_COMMAND_INPUT_FIELD, "command_input_field.gif"); //$NON-NLS-1$
55
			map.put(ImageConsts.IMAGE_CLCL_COMMAND_INPUT_FIELD, "command_input_field.gif"); //$NON-NLS-1$
55
			map.put(ImageConsts.IMAGE_CLCL_SCROLL_LOCK, "lock_co.gif"); //$NON-NLS-1$
56
			map.put(ImageConsts.IMAGE_CLCL_SCROLL_LOCK, "lock_co.gif"); //$NON-NLS-1$
57
			map.put(ImageConsts.IMAGE_CLCL_PIN, "pin.gif"); //$NON-NLS-1$
56
58
57
			loadImageRegistry(imageRegistry, ImageConsts.IMAGE_DIR_LOCALTOOL, map);
59
			loadImageRegistry(imageRegistry, ImageConsts.IMAGE_DIR_LOCALTOOL, map);
58
60
Lines 65-71 Link Here
65
			map.put(ImageConsts.IMAGE_ELCL_SETTINGS, "properties_tsk.gif"); //$NON-NLS-1$
67
			map.put(ImageConsts.IMAGE_ELCL_SETTINGS, "properties_tsk.gif"); //$NON-NLS-1$
66
			map.put(ImageConsts.IMAGE_ELCL_COMMAND_INPUT_FIELD, "command_input_field.gif"); //$NON-NLS-1$
68
			map.put(ImageConsts.IMAGE_ELCL_COMMAND_INPUT_FIELD, "command_input_field.gif"); //$NON-NLS-1$
67
			map.put(ImageConsts.IMAGE_ELCL_SCROLL_LOCK, "lock_co.gif"); //$NON-NLS-1$
69
			map.put(ImageConsts.IMAGE_ELCL_SCROLL_LOCK, "lock_co.gif"); //$NON-NLS-1$
68
70
			map.put(ImageConsts.IMAGE_ELCL_PIN, "pin.gif"); //$NON-NLS-1$
71
			map.put(ImageConsts.IMAGE_ELCL_REMOVE, "rem_co.gif"); //$NON-NLS-1$
72
			
69
			loadImageRegistry(imageRegistry, ImageConsts.IMAGE_DIR_ELCL, map);
73
			loadImageRegistry(imageRegistry, ImageConsts.IMAGE_DIR_ELCL, map);
70
74
71
			map.clear();
75
			map.clear();
Lines 77-86 Link Here
77
			map.put(ImageConsts.IMAGE_DLCL_SETTINGS, "properties_tsk.gif"); //$NON-NLS-1$
81
			map.put(ImageConsts.IMAGE_DLCL_SETTINGS, "properties_tsk.gif"); //$NON-NLS-1$
78
			map.put(ImageConsts.IMAGE_DLCL_COMMAND_INPUT_FIELD, "command_input_field.gif"); //$NON-NLS-1$
82
			map.put(ImageConsts.IMAGE_DLCL_COMMAND_INPUT_FIELD, "command_input_field.gif"); //$NON-NLS-1$
79
			map.put(ImageConsts.IMAGE_DLCL_SCROLL_LOCK, "lock_co.gif"); //$NON-NLS-1$
83
			map.put(ImageConsts.IMAGE_DLCL_SCROLL_LOCK, "lock_co.gif"); //$NON-NLS-1$
84
			map.put(ImageConsts.IMAGE_DLCL_PIN, "pin.gif"); //$NON-NLS-1$
85
			map.put(ImageConsts.IMAGE_DLCL_REMOVE, "rem_co.gif"); //$NON-NLS-1$
80
86
81
			loadImageRegistry(imageRegistry, ImageConsts.IMAGE_DIR_DLCL, map);
87
			loadImageRegistry(imageRegistry, ImageConsts.IMAGE_DIR_DLCL, map);
82
88
83
			map.clear();
89
			map.clear();
90
91
			map.put(ImageConsts.IMAGE_TERMINAL_VIEW, "terminal_view.gif"); //$NON-NLS-1$
92
93
			loadImageRegistry(imageRegistry, ImageConsts.IMAGE_DIR_EVIEW, map);
94
95
			map.clear();
96
		
84
		} catch (MalformedURLException malformedURLException) {
97
		} catch (MalformedURLException malformedURLException) {
85
			malformedURLException.printStackTrace();
98
			malformedURLException.printStackTrace();
86
		}
99
		}
(-)src/org/eclipse/tm/internal/terminal/actions/ActionMessages.properties (+7 lines)
Lines 14-19 Link Here
14
# Michael Scharf (Wind River) - split into core, view and connector plugins 
14
# Michael Scharf (Wind River) - split into core, view and connector plugins 
15
# Martin Oberhuber (Wind River) - fixed copyright headers and beautified
15
# Martin Oberhuber (Wind River) - fixed copyright headers and beautified
16
# Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin
16
# Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin
17
# Michael Scharf (Wind River) - [172483] switch between connections
17
###############################################################################
18
###############################################################################
18
NEW_TERMINAL              = New Terminal
19
NEW_TERMINAL              = New Terminal
19
CONNECT                   = Connect
20
CONNECT                   = Connect
Lines 23-25 Link Here
23
SCROLL_LOCK_1			  = Scroll Lock
24
SCROLL_LOCK_1			  = Scroll Lock
24
SETTINGS                  = Settings
25
SETTINGS                  = Settings
25
TOGGLE_COMMAND_INPUT_FIELD= Toggle Command Input Field
26
TOGGLE_COMMAND_INPUT_FIELD= Toggle Command Input Field
27
REMOVE					  = Remove Terminal
28
PIN					      = Pin Terminal
29
30
ConsoleDropDownAction_0=Select Connection
31
ConsoleDropDownAction_1=Display Selected Connections
32
(-)src/org/eclipse/tm/internal/terminal/actions/ActionMessages.java (+6 lines)
Lines 20-25 Link Here
20
import org.eclipse.osgi.util.NLS;
20
import org.eclipse.osgi.util.NLS;
21
21
22
public class ActionMessages extends NLS {
22
public class ActionMessages extends NLS {
23
23
	static {
24
	static {
24
		NLS.initializeMessages(ActionMessages.class.getName(), ActionMessages.class);
25
		NLS.initializeMessages(ActionMessages.class.getName(), ActionMessages.class);
25
	}
26
	}
Lines 30-35 Link Here
30
    public static String  SETTINGS_ELLIPSE;
31
    public static String  SETTINGS_ELLIPSE;
31
    public static String  SCROLL_LOCK_0;
32
    public static String  SCROLL_LOCK_0;
32
    public static String  SCROLL_LOCK_1;
33
    public static String  SCROLL_LOCK_1;
34
	public static String  REMOVE;
35
	public static String  PIN;
36
37
    public static String ConsoleDropDownAction_0;
38
    public static String ConsoleDropDownAction_1;
33
39
34
    public static String  SETTINGS;
40
    public static String  SETTINGS;
35
41
(-)src/org/eclipse/tm/internal/terminal/actions/TerminalActionPin.java (+41 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Initial Contributors:
9
 * The following Wind River employees contributed to the Terminal component
10
 * that contains this file: Chris Thew, Fran Litterio, Stephen Lamb,
11
 * Helmut Haigermoser and Ted Williams.
12
 *
13
 * Contributors:
14
 * Michael Scharf (Wind River) - initial contribution
15
 *******************************************************************************/
16
package org.eclipse.tm.internal.terminal.actions;
17
18
import org.eclipse.jface.action.IAction;
19
import org.eclipse.tm.internal.terminal.view.ITerminalView;
20
import org.eclipse.tm.internal.terminal.view.ImageConsts;
21
22
public class TerminalActionPin extends TerminalAction
23
{
24
    public TerminalActionPin(ITerminalView target)
25
    {
26
        super(target,
27
              TerminalActionPin.class.getName(),IAction.AS_RADIO_BUTTON);
28
29
        setupAction(ActionMessages.PIN,
30
                    ActionMessages.PIN,
31
                    ImageConsts.IMAGE_CLCL_PIN,
32
                    ImageConsts.IMAGE_ELCL_PIN,
33
                    ImageConsts.IMAGE_DLCL_PIN,
34
                    true);
35
		setChecked(fTarget.isPinned());
36
   }
37
	public void run() {
38
		fTarget.setPinned(!fTarget.isPinned());
39
		setChecked(fTarget.isPinned());
40
	}
41
}
(-)src/org/eclipse/tm/internal/terminal/actions/ShowConsoleAction.java (+82 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * 
8
 * Contributors: 
9
 * Michael Scharf (Wind River) - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.tm.internal.terminal.actions;
12
13
import org.eclipse.jface.action.Action;
14
import org.eclipse.tm.internal.terminal.view.ITerminalViewConnection;
15
import org.eclipse.tm.internal.terminal.view.ITerminalViewConnectionManager;
16
17
/**
18
 * Shows a specific console in the console view
19
 */
20
public class ShowConsoleAction extends Action {
21
	
22
	private final ITerminalViewConnection fConnection;
23
	private final ITerminalViewConnectionManager fConnectionManager;
24
25
	/**
26
	 * Constructs an action to display the given console.
27
	 * 
28
	 * @param manager the console view in which the given console is contained
29
	 * @param console the console
30
	 */
31
	public ShowConsoleAction(ITerminalViewConnectionManager manager, ITerminalViewConnection console) {
32
		super(quoteName(buildName(manager,console)), AS_RADIO_BUTTON);
33
		fConnection = console;
34
		fConnectionManager = manager;
35
		setImageDescriptor(console.getImageDescriptor());
36
	}
37
	/**
38
	 * the tab at the end quotes '@' chars?!? see 
39
	 * {@link #setText(String)}
40
	 * @param name
41
	 * @return a quoted sting
42
	 */
43
	private static String quoteName(String name) {
44
		return name+"\t"; //$NON-NLS-1$
45
	}
46
	/**
47
	 * Builds the name. It uses the summary. If the connections have different
48
	 * partNames (the names showed in the view title) then this name is perfixed.
49
	 * @param m the connection manager
50
	 * @param console the console for which the name should me extracted
51
	 * @return The name to be displayed
52
	 */
53
	private static String buildName(ITerminalViewConnectionManager m,ITerminalViewConnection console) {
54
		String name = console.getFullSummary();
55
		if(!checkIfAllPartNamesTheSame(m))
56
			name=console.getPartName()+" - " +name; //$NON-NLS-1$
57
		return name;
58
	}
59
	/**
60
	 * @param m the connection manager
61
	 * @return true if the part names of all connections are the same
62
	 */
63
	private static boolean checkIfAllPartNamesTheSame(ITerminalViewConnectionManager m) {
64
		ITerminalViewConnection[] connections = m.getConnections();
65
		if(connections.length>1) {
66
			String partName=connections[0].getPartName();
67
			for (int i = 1; i < connections.length; i++) {
68
				if(!partName.equals(connections[i].getPartName())) {
69
					return false;
70
				}			
71
			}
72
			
73
		}
74
		return true;
75
	}
76
	/* (non-Javadoc)
77
	 * @see org.eclipse.jface.action.IAction#run()
78
	 */
79
	public void run() {
80
		fConnectionManager.setConnection(fConnection);
81
	}
82
}
(-)src/org/eclipse/tm/internal/terminal/view/ITerminalViewConnectionManager.java (+82 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * 
8
 * Contributors: 
9
 * Michael Scharf (Wind River) - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.tm.internal.terminal.view;
12
13
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
14
15
16
/**
17
 * Supports multiple connections
18
 *
19
 */
20
public interface ITerminalViewConnectionManager {
21
	/**
22
	 * Notifies any change in the state of the connections:
23
	 * <ul>
24
	 * <li> a connection is added or removed
25
	 * <li> the current connection has changed
26
	 * </ul>
27
	 *
28
	 */
29
	interface TerminalViewConnectionListener {
30
		void connectionsChanged();
31
	}
32
	/**
33
	 * Used to create instances of the ITerminalViewConnection 
34
	 * when the state is read from the {@link ISettingsStore}
35
	 *
36
	 */
37
	interface ITerminalViewConnectionFactory {
38
		ITerminalViewConnection create();
39
	}
40
	/**
41
	 * @return a list of all connections this view can display
42
	 */
43
	ITerminalViewConnection[] getConnections();
44
	/**
45
	 * If more than two connections are available, remove the current connection
46
	 */
47
	void removeCurrent();
48
49
	/**
50
	 * @param conn adds a new connection
51
	 */
52
	void addConnection(ITerminalViewConnection conn);
53
	/**
54
	 * @return the number of connections
55
	 */
56
	int size();
57
	/**
58
	 * @return th connection the view is showing at the moment
59
	 */
60
	ITerminalViewConnection getCurrentConnection();
61
62
	/**
63
	 * @param conn make this connection the current connection
64
	 */
65
	void setConnection(ITerminalViewConnection conn);
66
67
	/**
68
	 * If there are more than two connections toggle between this and the
69
	 * previously shown connection
70
	 */
71
	void swapConnection();
72
73
	void addListener(TerminalViewConnectionListener listener);
74
	void removeListener(TerminalViewConnectionListener listener);
75
	
76
	void saveState(ISettingsStore store);
77
	/**
78
	 * @param store
79
	 */
80
	void loadState(ISettingsStore store,ITerminalViewConnectionFactory factory);
81
	
82
}
(-)src/org/eclipse/tm/internal/terminal/view/ITerminalViewConnection.java (+78 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * 
8
 * Contributors: 
9
 * Michael Scharf (Wind River) - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.tm.internal.terminal.view;
12
13
import org.eclipse.jface.resource.ImageDescriptor;
14
import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
15
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
16
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
17
18
/**
19
 * Represents a connection. The connection might be connected
20
 * or not.
21
 *
22
 */
23
public interface ITerminalViewConnection {
24
25
	/**
26
	 * @return the summary shown in the status line and
27
	 * in the drop down box of the connections
28
	 */
29
	String getFullSummary();
30
31
	/**
32
	 * @param name the name of the view
33
	 */
34
	void setPartName(String name);
35
	/**
36
	 * @return the name of the view (never null)
37
	 */
38
	String getPartName();
39
	
40
	/**
41
	 * @return an image that represents this connection
42
	 */
43
	ImageDescriptor getImageDescriptor();
44
	/**
45
	 * @return the control of this connection
46
	 */
47
	ITerminalViewControl getCtlTerminal();
48
49
	void saveState(ISettingsStore store);
50
51
	void loadState(ISettingsStore store);
52
	
53
	/**
54
	 * @return true if the input field is visible 
55
	 */
56
	boolean hasCommandInputField();
57
	/**
58
	 * @param on turns the input field on
59
	 */
60
	void setCommandInputField(boolean on);
61
62
	/**
63
	 * @param state changes of the state (might change the summary)
64
	 */
65
	void setState(TerminalState state);
66
67
	/**
68
	 * @param title used in the summary. If null the summary
69
	 * is created automatically
70
	 */
71
	void setTerminalTitle(String title);
72
73
	/**
74
	 * TODO: legacy (needed to read the old state)
75
	 * @param summary
76
	 */
77
	void setSummary(String summary);
78
}
(-)src/org/eclipse/tm/internal/terminal/view/TerminalViewConnectionManager.java (+180 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * 
8
 * Contributors: 
9
 * Michael Scharf (Wind River) - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.tm.internal.terminal.view;
12
13
import java.util.ArrayList;
14
import java.util.Iterator;
15
import java.util.List;
16
17
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.Status;
19
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
20
21
public class TerminalViewConnectionManager implements ITerminalViewConnectionManager {
22
	private static final String STORE_CONNECTION_PREFIX = "c"; //$NON-NLS-1$
23
	private static final String STORE_SIZE = "size"; //$NON-NLS-1$
24
	private static final String STORE_CURRENT_CONNECTION = "current"; //$NON-NLS-1$
25
	/**
26
	 * The list of {@link ITerminalViewConnection} in the order they were cerated.
27
	 * Ordered by creation time
28
	 */
29
	private final List fConnections=new ArrayList();
30
	/**
31
	 * The currently displayed connection
32
	 */
33
	private ITerminalViewConnection fCurrentConnection;
34
	/**
35
	 * The list of {@link ITerminalViewConnection} in the order they
36
	 * were made the current connection. The most recently accessed
37
	 * connection is at the beginning of the list.
38
	 */
39
	private final List fConnectionHistory=new ArrayList();
40
	/**
41
	 * The {@link TerminalViewConnectionListener}
42
	 */
43
	private final List fListeners=new ArrayList();
44
45
	public ITerminalViewConnection[] getConnections() {
46
		return (ITerminalViewConnection[]) fConnections.toArray(new ITerminalViewConnection[fConnections.size()]);
47
	}
48
49
	public int size() {		// TODO Auto-generated method stub
50
		return fConnections.size();
51
	}
52
	
53
	public ITerminalViewConnection getCurrentConnection() {
54
		return fCurrentConnection;
55
	}
56
	public void setConnection(ITerminalViewConnection conn) {
57
		fCurrentConnection=conn;
58
		// put the connection at the end of the history list
59
		fConnectionHistory.remove(conn);
60
		fConnectionHistory.add(0,conn);
61
62
		fireListeners();
63
	}
64
65
	public void swapConnection() {
66
		ITerminalViewConnection conn=getPreviousConnection();
67
		if(conn!=null)
68
			setConnection(conn);
69
	}
70
71
	/**
72
	 * @return the connection that was most recently the current connection or null if there is
73
	 * no previous connection
74
	 */
75
	private ITerminalViewConnection getPreviousConnection() {
76
		// find the first connection that is not the current connection in
77
		// the list
78
		for (Iterator iterator = fConnectionHistory.iterator(); iterator.hasNext();) {
79
			ITerminalViewConnection conn = (ITerminalViewConnection) iterator.next();
80
			if(conn!=fCurrentConnection) {
81
				return conn;
82
			}
83
		}
84
		return null;
85
	}
86
87
	public void addConnection(ITerminalViewConnection conn) {
88
		fConnections.add(conn);
89
		fireListeners();
90
	}
91
	public void removeConnection(ITerminalViewConnection conn) {
92
		fConnections.remove(conn);
93
		fConnectionHistory.remove(conn);
94
		fireListeners();
95
	}
96
97
	public void addListener(TerminalViewConnectionListener listener) {
98
		fListeners.add(listener);
99
	}
100
101
	public void removeListener(TerminalViewConnectionListener listener) {
102
		fListeners.remove(listener);
103
	}
104
	protected void fireListeners() {
105
		TerminalViewConnectionListener[] listeners=(TerminalViewConnectionListener[]) fListeners.toArray(new TerminalViewConnectionListener[fListeners.size()]);
106
		for (int i = 0; i < listeners.length; i++) {
107
			listeners[i].connectionsChanged();
108
		}
109
	}
110
111
	public void saveState(ISettingsStore store) {
112
		store.put(STORE_SIZE,""+fConnections.size()); //$NON-NLS-1$
113
		// save all connections
114
		int n=0;
115
		for (Iterator iterator = fConnections.iterator(); iterator.hasNext();) {
116
			// the name under which we store the connection
117
			String prefix=STORE_CONNECTION_PREFIX+n;
118
			n++;
119
			ITerminalViewConnection connection = (ITerminalViewConnection) iterator.next();
120
			// remember the current connection by its prefix
121
			if(connection.equals(fCurrentConnection))
122
				store.put(STORE_CURRENT_CONNECTION,prefix);
123
			connection.saveState(new SettingStorePrefixDecorator(store,prefix)); 
124
		}
125
	}
126
127
	public void loadState(ISettingsStore store,ITerminalViewConnectionFactory factory) {
128
		int size=0;
129
		try {
130
			size=Integer.parseInt(store.get(STORE_SIZE));
131
		} catch(Exception e) {
132
			// ignore
133
		}
134
		if(size>0) {
135
			// a slot for the connections
136
			String current=store.get(STORE_CURRENT_CONNECTION);
137
			int n=0;
138
			for (int i=0;i<size;i++) {
139
				// the name under which we stored the connection
140
				String prefix=STORE_CONNECTION_PREFIX+n;
141
				n++;
142
				try {
143
					ITerminalViewConnection connection = factory.create();
144
					fConnections.add(connection);
145
					fConnectionHistory.add(connection);
146
					if(prefix.equals(current))
147
						fCurrentConnection=connection;
148
					connection.loadState(new SettingStorePrefixDecorator(store,prefix));
149
				} catch(RuntimeException e) {
150
					// in case something goes wrong, make sure we can read the other
151
					// connections....
152
					TerminalViewPlugin.getDefault().getLog().log(
153
							new Status(
154
									IStatus.WARNING, 
155
									TerminalViewPlugin.getDefault().getBundle().getSymbolicName(), 
156
									0, 
157
									e.getLocalizedMessage(), 
158
									e
159
					));
160
				}
161
			}
162
		}
163
	}
164
165
	public void removeCurrent() {
166
		if(fConnections.size()>1) {
167
			fConnections.remove(fCurrentConnection);
168
			fConnectionHistory.remove(fCurrentConnection);
169
			
170
			// make sure connection is not null....
171
			fCurrentConnection=getPreviousConnection();
172
			// if there is no previous connection then make
173
			// the first connection the list the current connection
174
			if(fCurrentConnection==null)
175
				fCurrentConnection=(ITerminalViewConnection) fConnections.get(0);
176
				
177
			fireListeners();			
178
		}
179
	}
180
}
(-)src/org/eclipse/tm/internal/terminal/view/TerminalViewConnection.java (+190 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 20078 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * 
8
 * Contributors: 
9
 * Michael Scharf (Wind River) - initial API and implementation
10
 *******************************************************************************/
11
/**
12
 * 
13
 */
14
package org.eclipse.tm.internal.terminal.view;
15
16
import org.eclipse.jface.resource.ImageDescriptor;
17
import org.eclipse.tm.internal.terminal.control.CommandInputFieldWithHistory;
18
import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
19
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
20
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
21
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
22
23
/**
24
 * This class represents one connection. The connection might be
25
 * closed or open. 
26
 *
27
 */
28
class TerminalViewConnection implements ITerminalViewConnection {
29
	private static final String STORE_SUMMARY = "Summary"; //$NON-NLS-1$
30
	private static final String STORE_PART_NAME = "PartName"; //$NON-NLS-1$
31
	private static final String STORE_CONNECTION_TYPE = "ConnectionType"; //$NON-NLS-1$
32
    private static final String STORE_HAS_COMMAND_INPUT_FIELD = "HasCommandInputField"; //$NON-NLS-1$
33
	private static final String STORE_COMMAND_INPUT_FIELD_HISTORY = "CommandInputFieldHistory"; //$NON-NLS-1$
34
35
	final private ITerminalViewControl fCtlTerminal;
36
	private String fTitle;
37
	private String fSummary;
38
	private String fHistory;
39
	private CommandInputFieldWithHistory fCommandInputField;
40
	private String fPartName;
41
	
42
	public TerminalViewConnection(ITerminalViewControl ctl) {
43
		fCtlTerminal = ctl;
44
	}
45
46
	/* (non-Javadoc)
47
	 * @see org.eclipse.tm.internal.terminal.actions.ITerminalViewConnection#getName()
48
	 */
49
	public String getFullSummary() {
50
		if(fTitle==null)
51
			return makeTitle();
52
		return fTitle;
53
	}
54
55
	/* (non-Javadoc)
56
	 * @see org.eclipse.tm.internal.terminal.view.ITerminalViewConnection#getImageDescriptor()
57
	 */
58
	public ImageDescriptor getImageDescriptor() {
59
		return TerminalViewPlugin.getDefault().getImageRegistry().getDescriptor(ImageConsts.IMAGE_TERMINAL_VIEW);
60
	}
61
62
	public ITerminalViewControl getCtlTerminal() {
63
		return fCtlTerminal;
64
	}
65
	private ISettingsStore getStore(ISettingsStore store,ITerminalConnector connector) {
66
		return new SettingStorePrefixDecorator(store,connector.getId()+"."); //$NON-NLS-1$
67
	}
68
	public void loadState(ISettingsStore store) {
69
		fPartName=store.get(STORE_PART_NAME);
70
		fSummary=store.get(STORE_SUMMARY);
71
		fHistory=store.get(STORE_COMMAND_INPUT_FIELD_HISTORY);
72
		ITerminalConnector[] connectors=fCtlTerminal.getConnectors();
73
		String connectionType=store.get(STORE_CONNECTION_TYPE);
74
		for (int i = 0; i < connectors.length; i++) {
75
			connectors[i].load(getStore(store,connectors[i]));
76
			if(connectors[i].getId().equals(connectionType))
77
				fCtlTerminal.setConnector(connectors[i]);
78
		}
79
		if("true".equals(store.get(STORE_HAS_COMMAND_INPUT_FIELD))) //$NON-NLS-1$
80
			setCommandInputField(true);
81
	}
82
83
	public void saveState(ISettingsStore store) {
84
		store.put(STORE_PART_NAME, fPartName);
85
		store.put(STORE_SUMMARY,fSummary);
86
		store.put(STORE_COMMAND_INPUT_FIELD_HISTORY, fHistory);
87
		if(fCommandInputField!=null)
88
			store.put(STORE_COMMAND_INPUT_FIELD_HISTORY, fCommandInputField.getHistory());
89
		else
90
			store.put(STORE_COMMAND_INPUT_FIELD_HISTORY, fHistory);
91
		store.put(STORE_HAS_COMMAND_INPUT_FIELD,hasCommandInputField()?"true":"false");   //$NON-NLS-1$//$NON-NLS-2$
92
		ITerminalConnector[] connectors=fCtlTerminal.getConnectors();
93
		for (int i = 0; i < connectors.length; i++) {
94
			connectors[i].save(getStore(store,connectors[i]));
95
		}
96
		if(fCtlTerminal.getTerminalConnector()!=null) {
97
			store.put(STORE_CONNECTION_TYPE,fCtlTerminal.getTerminalConnector().getId());
98
		}
99
	}
100
	public boolean hasCommandInputField() {
101
		return fCommandInputField!=null;
102
	}
103
	public void setCommandInputField(boolean on) {
104
		// save the old history
105
		if(fCommandInputField!=null) {
106
			fHistory= fCommandInputField.getHistory();
107
			fCommandInputField=null;
108
		}
109
		if(on) {
110
			// TODO make history size configurable
111
			fCommandInputField=new CommandInputFieldWithHistory(100);
112
			fCommandInputField.setHistory(fHistory);
113
		}
114
		fCtlTerminal.setCommandInputField(fCommandInputField);
115
	}
116
117
	public void setState(TerminalState state) {
118
		// update the title....
119
		fTitle=null;		
120
	}
121
122
	public void setTerminalTitle(String title) {
123
		// When parameter 'title' is not null, it is a String containing text to
124
		// display in the view's content description line.  This is used by class
125
		// TerminalText when it processes an ANSI OSC escape sequence that commands
126
		// the terminal to display text in its title bar.
127
		fTitle=title;
128
	}
129
130
	private String getStateDisplayName(TerminalState state) {
131
		if(state==TerminalState.CONNECTED) {
132
			return ViewMessages.STATE_CONNECTED;
133
		} else if(state==TerminalState.CONNECTING) {
134
			return ViewMessages.STATE_CONNECTING;
135
		} else if(state==TerminalState.OPENED) {
136
			return ViewMessages.STATE_OPENED;
137
		} else if(state==TerminalState.CLOSED) {
138
			return ViewMessages.STATE_CLOSED;
139
		} else {
140
			throw new IllegalStateException(state.toString());
141
		}
142
	}
143
144
	private String makeTitle() {
145
		String strTitle = ""; //$NON-NLS-1$
146
		if(fCtlTerminal.getTerminalConnector()==null){
147
			strTitle=ViewMessages.NO_CONNECTION_SELECTED;
148
		} else {
149
			// When parameter 'data' is null, we construct a descriptive string to
150
			// display in the content description line.
151
			String strConnected = getStateDisplayName(fCtlTerminal.getState());
152
			String summary = getSettingsSummary();
153
			//TODO Title should use an NLS String and com.ibm.icu.MessageFormat
154
			//In order to make the logic of assembling, and the separators, better adapt to foreign languages
155
			if(summary.length()>0)
156
				summary=summary+" - ";  //$NON-NLS-1$
157
			String name=fCtlTerminal.getTerminalConnector().getName();
158
			if(name.length()>0) {
159
				name+=": "; //$NON-NLS-1$
160
			}
161
			strTitle = name + "("+ summary + strConnected + ")"; //$NON-NLS-1$ //$NON-NLS-2$
162
		}
163
		return strTitle;
164
	}
165
	/**
166
	 * @return the setting summary. If there is no connection, or the connection
167
	 * has not been initialized, use the last stored state.
168
	 */
169
	private String getSettingsSummary() {
170
		if(fCtlTerminal.getTerminalConnector().isInitialized())
171
			fSummary=fCtlTerminal.getSettingsSummary();
172
		if(fSummary==null)
173
			return ""; //$NON-NLS-1$
174
		return fSummary;
175
	}
176
177
	public void setSummary(String summary) {
178
		fSummary=summary;
179
	}
180
181
	public String getPartName() {
182
		return fPartName==null?ViewMessages.PROP_TITLE:fPartName;
183
	}
184
185
	public void setPartName(String name) {
186
		fPartName=name;
187
		
188
	}
189
190
}
(-)src/org/eclipse/tm/internal/terminal/actions/TerminalActionRemove.java (+45 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Initial Contributors:
9
 * The following Wind River employees contributed to the Terminal component
10
 * that contains this file: Chris Thew, Fran Litterio, Stephen Lamb,
11
 * Helmut Haigermoser and Ted Williams.
12
 *
13
 * Contributors:
14
 * Michael Scharf (Wind River) - initial contribution
15
 *******************************************************************************/
16
package org.eclipse.tm.internal.terminal.actions;
17
18
import org.eclipse.tm.internal.terminal.view.ITerminalViewConnectionManager;
19
import org.eclipse.tm.internal.terminal.view.ImageConsts;
20
import org.eclipse.tm.internal.terminal.view.ITerminalViewConnectionManager.TerminalViewConnectionListener;
21
22
public class TerminalActionRemove extends TerminalAction implements TerminalViewConnectionListener 
23
{
24
	private final ITerminalViewConnectionManager fConnectionManager;
25
    public TerminalActionRemove(ITerminalViewConnectionManager target)
26
    {
27
        super(null,
28
              TerminalActionRemove.class.getName());
29
        fConnectionManager=target;
30
        setupAction(ActionMessages.REMOVE,
31
                    ActionMessages.REMOVE,
32
                    null,
33
                    ImageConsts.IMAGE_ELCL_REMOVE,
34
                    ImageConsts.IMAGE_DLCL_REMOVE,
35
                    true);
36
		fConnectionManager.addListener(this);
37
		connectionsChanged();
38
    }
39
	public void run() {
40
		fConnectionManager.removeCurrent();
41
	}
42
	public void connectionsChanged() {
43
		setEnabled(fConnectionManager.size()>1);
44
	}
45
}
(-)src/org/eclipse/tm/internal/terminal/actions/TerminalActionSelectionDropDown.java (+107 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 * IBM Corporation - initial API and implementation
10
 * Michael Scharf (Wind River) - [172483] switch between connections
11
 *                               (Adapted from org.eclipse.ui.internal.console.ConsoleDropDownAction)
12
 *******************************************************************************/
13
package org.eclipse.tm.internal.terminal.actions;
14
15
16
import org.eclipse.jface.action.Action;
17
import org.eclipse.jface.action.ActionContributionItem;
18
import org.eclipse.jface.action.IMenuCreator;
19
import org.eclipse.swt.widgets.Control;
20
import org.eclipse.swt.widgets.Menu;
21
import org.eclipse.tm.internal.terminal.view.ITerminalViewConnection;
22
import org.eclipse.tm.internal.terminal.view.ITerminalViewConnectionManager;
23
import org.eclipse.tm.internal.terminal.view.ImageConsts;
24
import org.eclipse.tm.internal.terminal.view.TerminalViewPlugin;
25
import org.eclipse.tm.internal.terminal.view.ITerminalViewConnectionManager.TerminalViewConnectionListener;
26
27
/**
28
 * Drop down action in the console to select the console to display.
29
 */
30
public class TerminalActionSelectionDropDown extends Action implements IMenuCreator, TerminalViewConnectionListener {
31
	private ITerminalViewConnectionManager fConnections;
32
	private Menu fMenu;
33
	public TerminalActionSelectionDropDown(ITerminalViewConnectionManager view) {
34
		fConnections= view;
35
		setText(ActionMessages.ConsoleDropDownAction_0); 
36
		setToolTipText(ActionMessages.ConsoleDropDownAction_1); 
37
		setImageDescriptor(TerminalViewPlugin.getDefault().getImageRegistry().getDescriptor(ImageConsts.IMAGE_TERMINAL_VIEW));
38
//		PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IConsoleHelpContextIds.CONSOLE_DISPLAY_CONSOLE_ACTION);
39
		setMenuCreator(this);
40
		fConnections.addListener(this);
41
		connectionsChanged();
42
	}
43
44
	/* (non-Javadoc)
45
	 * @see org.eclipse.jface.action.IMenuCreator#dispose()
46
	 */
47
	public void dispose() {
48
		if (fMenu != null) {
49
			fMenu.dispose();
50
		}
51
		fConnections.removeListener(this);
52
		fConnections= null;
53
	}
54
55
	/* (non-Javadoc)
56
	 * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Menu)
57
	 */
58
	public Menu getMenu(Menu parent) {
59
		return null;
60
	}
61
62
	/* (non-Javadoc)
63
	 * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Control)
64
	 */
65
	public Menu getMenu(Control parent) {
66
		if (fMenu != null) {
67
			fMenu.dispose();
68
		}
69
		
70
		fMenu= new Menu(parent);
71
		ITerminalViewConnection[] consoles= fConnections.getConnections();
72
		ITerminalViewConnection current = fConnections.getCurrentConnection();
73
		for (int i = 0; i < consoles.length; i++) {
74
			ITerminalViewConnection console = consoles[i];
75
			Action action = new ShowConsoleAction(fConnections, console);
76
			action.setChecked(console.equals(current));
77
			addActionToMenu(fMenu, action, i + 1);
78
		}
79
		return fMenu;
80
	}
81
	
82
	private void addActionToMenu(Menu parent, Action action, int accelerator) {
83
	    if (accelerator < 10) {
84
		    StringBuffer label= new StringBuffer();
85
			//add the numerical accelerator
86
			label.append('&');
87
			label.append(accelerator);
88
			label.append(' ');
89
			label.append(action.getText());
90
			action.setText(label.toString());
91
		}
92
		ActionContributionItem item= new ActionContributionItem(action);
93
		item.fill(parent, -1);
94
	}
95
96
	/* (non-Javadoc)
97
	 * @see org.eclipse.jface.action.IAction#run()
98
	 */
99
	public void run() {
100
		fConnections.swapConnection();
101
	}
102
103
	public void connectionsChanged() {
104
		ITerminalViewConnection[] consoles= fConnections.getConnections();
105
		setEnabled(consoles.length > 1);
106
	}
107
}
(-)src/org/eclipse/tm/internal/terminal/view/TerminalViewControlDecorator.java (+167 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 Wind River Systems, Inc. and others.
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * 
8
 * Contributors: 
9
 * Michael Scharf (Wind River) - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.tm.internal.terminal.view;
12
13
import java.io.UnsupportedEncodingException;
14
15
import org.eclipse.swt.dnd.Clipboard;
16
import org.eclipse.swt.graphics.Font;
17
import org.eclipse.swt.widgets.Control;
18
import org.eclipse.tm.internal.terminal.control.ICommandInputField;
19
import org.eclipse.tm.internal.terminal.control.ITerminalViewControl;
20
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector;
21
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
22
23
// TODO (scharf): this decorator is only there to deal wit the common
24
// actions. Find a better solution.
25
public class TerminalViewControlDecorator implements ITerminalViewControl {
26
	ITerminalViewControl fViewContoler;
27
28
	public void clearTerminal() {
29
		fViewContoler.clearTerminal();
30
	}
31
32
	public void connectTerminal() {
33
		fViewContoler.connectTerminal();
34
	}
35
36
	public void copy() {
37
		fViewContoler.copy();
38
	}
39
40
	public void disconnectTerminal() {
41
		fViewContoler.disconnectTerminal();
42
	}
43
44
	public void disposeTerminal() {
45
		fViewContoler.disposeTerminal();
46
	}
47
48
	public int getBufferLineLimit() {
49
		return fViewContoler.getBufferLineLimit();
50
	}
51
52
	public Clipboard getClipboard() {
53
		return fViewContoler.getClipboard();
54
	}
55
56
	public ICommandInputField getCommandInputField() {
57
		return fViewContoler.getCommandInputField();
58
	}
59
60
	public ITerminalConnector[] getConnectors() {
61
		return fViewContoler.getConnectors();
62
	}
63
64
	public Control getControl() {
65
		return fViewContoler.getControl();
66
	}
67
68
	public String getEncoding() {
69
		return fViewContoler.getEncoding();
70
	}
71
72
	public Font getFont() {
73
		return fViewContoler.getFont();
74
	}
75
76
	public Control getRootControl() {
77
		return fViewContoler.getRootControl();
78
	}
79
80
	public String getSelection() {
81
		return fViewContoler.getSelection();
82
	}
83
84
	public String getSettingsSummary() {
85
		return fViewContoler.getSettingsSummary();
86
	}
87
88
	public TerminalState getState() {
89
		return fViewContoler.getState();
90
	}
91
92
	public ITerminalConnector getTerminalConnector() {
93
		return fViewContoler.getTerminalConnector();
94
	}
95
96
	public boolean isConnected() {
97
		return fViewContoler.isConnected();
98
	}
99
100
	public boolean isDisposed() {
101
		return fViewContoler.isDisposed();
102
	}
103
104
	public boolean isEmpty() {
105
		return fViewContoler.isEmpty();
106
	}
107
108
	public boolean isScrollLock() {
109
		return fViewContoler.isScrollLock();
110
	}
111
112
	public void paste() {
113
		fViewContoler.paste();
114
	}
115
116
	public boolean pasteString(String string) {
117
		return fViewContoler.pasteString(string);
118
	}
119
120
	public void selectAll() {
121
		fViewContoler.selectAll();
122
	}
123
124
	public void sendKey(char arg0) {
125
		fViewContoler.sendKey(arg0);
126
	}
127
128
	public void setBufferLineLimit(int bufferLineLimit) {
129
		fViewContoler.setBufferLineLimit(bufferLineLimit);
130
	}
131
132
	public void setCommandInputField(ICommandInputField inputField) {
133
		fViewContoler.setCommandInputField(inputField);
134
	}
135
136
	public void setConnector(ITerminalConnector connector) {
137
		fViewContoler.setConnector(connector);
138
	}
139
140
	public void setEncoding(String encoding) throws UnsupportedEncodingException {
141
		fViewContoler.setEncoding(encoding);
142
	}
143
144
	public void setFocus() {
145
		fViewContoler.setFocus();
146
	}
147
148
	public void setFont(Font font) {
149
		fViewContoler.setFont(font);
150
	}
151
152
	public void setInvertedColors(boolean invert) {
153
		fViewContoler.setInvertedColors(invert);
154
	}
155
156
	public void setScrollLock(boolean on) {
157
		fViewContoler.setScrollLock(on);
158
	}
159
160
	public ITerminalViewControl getViewContoler() {
161
		return fViewContoler;
162
	}
163
164
	public void setViewContoler(ITerminalViewControl viewContoler) {
165
		fViewContoler = viewContoler;
166
	}
167
}

Return to bug 172483