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

Collapse All | Expand All

(-)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 (-166 / +278 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.ITerminalViewConnectionListener;
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, ITerminalViewConnectionListener {
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 active connection changes, update the view
162
					if(fConnection==fMultiConnectionManager.getActiveConnection()) {
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 active connection changes, update the view
173
					if(fConnection==fMultiConnectionManager.getActiveConnection()) {
174
						updateSummary();
175
					}
176
				}
177
			});
178
		}
179
		/**
180
		 * @param runnable run in display thread
181
		 */
182
		private void runInDisplayThread(Runnable runnable) {
183
			if(Display.findDisplay(Thread.currentThread())!=null)
184
				runnable.run();
185
			else if(PlatformUI.isWorkbenchRunning())
186
				PlatformUI.getWorkbench().getDisplay().syncExec(runnable);
187
			// else should not happen and we ignore it...
188
		}
189
		
190
	}
191
	
129
	public TerminalView() {
192
	public TerminalView() {
130
		Logger
193
		Logger
131
				.log("==============================================================="); //$NON-NLS-1$
194
				.log("==============================================================="); //$NON-NLS-1$
195
		fMultiConnectionManager.addListener(this);
132
	}
196
	}
133
197
198
	/**
199
	 * @param title
200
	 * @return a unique part name
201
	 */
134
	String findUniqueTitle(String title) {
202
	String findUniqueTitle(String title) {
135
		IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
203
		IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
136
		String id=	getViewSite().getId();
204
		String id=	getViewSite().getId();
Lines 165-222 Link Here
165
//		if(!limitOutput)
233
//		if(!limitOutput)
166
//			bufferLineLimit=-1;
234
//			bufferLineLimit=-1;
167
		int bufferLineLimit = preferences.getInt(TerminalPreferencePage.PREF_BUFFERLINES);
235
		int bufferLineLimit = preferences.getInt(TerminalPreferencePage.PREF_BUFFERLINES);
168
		fCtlTerminal.setBufferLineLimit(bufferLineLimit);
236
		boolean invert=preferences.getBoolean(TerminalPreferencePage.PREF_INVERT_COLORS);
169
		fCtlTerminal.setInvertedColors(preferences.getBoolean(TerminalPreferencePage.PREF_INVERT_COLORS));
237
		// update the preferences for all controls
170
	}
238
		ITerminalViewConnection[] conn=fMultiConnectionManager.getConnections();
171
	// TerminalTarget interface
239
		for (int i = 0; i < conn.length; i++) {
172
	public void setState(final TerminalState state) {
240
			conn[i].getCtlTerminal().setBufferLineLimit(bufferLineLimit);
173
		Runnable runnable=new Runnable() {
241
			conn[i].getCtlTerminal().setInvertedColors(invert);
174
			public void run() {
242
		}
175
				updateStatus();
176
				onTerminalStatus();
177
			}
178
		};
179
		runInDisplayThread(runnable);
180
	}
181
182
	/**
183
	 * @param runnable run in display thread
184
	 */
185
	private void runInDisplayThread(Runnable runnable) {
186
		if(Display.findDisplay(Thread.currentThread())!=null)
187
			runnable.run();
188
		else if(PlatformUI.isWorkbenchRunning())
189
			PlatformUI.getWorkbench().getDisplay().syncExec(runnable);
190
		// else should not happen and we ignore it...
191
	}
243
	}
192
193
194
	/**
244
	/**
195
	 * Display a new Terminal view.  This method is called when the user clicks the New
245
	 * Display a new Terminal view.  This method is called when the user clicks the New
196
	 * Terminal button in any Terminal view's toolbar.
246
	 * Terminal button in any Terminal view's toolbar.
197
	 */
247
	 */
198
	public void onTerminalNewTerminal() {
248
	public void onTerminalNewTerminal() {
199
		Logger.log("creating new Terminal instance."); //$NON-NLS-1$
249
		Logger.log("creating new Terminal instance."); //$NON-NLS-1$
200
250
		if(isPinned()) {
201
		try {
251
			try {
202
			// The second argument to showView() is a unique String identifying the
252
				// The second argument to showView() is a unique String identifying the
203
			// secondary view instance.  If it ever matches a previously used secondary
253
				// secondary view instance.  If it ever matches a previously used secondary
204
			// view identifier, then this call will not create a new Terminal view,
254
				// view identifier, then this call will not create a new Terminal view,
205
			// which is undesirable.  Therefore, we append the current time in
255
				// which is undesirable.  Therefore, we append the active time in
206
			// milliseconds to the secondary view identifier to ensure it is always
256
				// milliseconds to the secondary view identifier to ensure it is always
207
			// unique.  This code runs only when the user clicks the New Terminal
257
				// unique.  This code runs only when the user clicks the New Terminal
208
			// button, so there is no risk that this code will run twice in a single
258
				// button, so there is no risk that this code will run twice in a single
209
			// millisecond.
259
				// millisecond.
210
260
211
			getSite().getPage().showView(
261
				getSite().getPage().showView(
212
					"org.eclipse.tm.terminal.view.TerminalView",//$NON-NLS-1$
262
						"org.eclipse.tm.terminal.view.TerminalView",//$NON-NLS-1$
213
					"SecondaryTerminal" + System.currentTimeMillis(), //$NON-NLS-1$
263
						"SecondaryTerminal" + System.currentTimeMillis(), //$NON-NLS-1$
214
					IWorkbenchPage.VIEW_ACTIVATE);
264
						IWorkbenchPage.VIEW_ACTIVATE);
215
		} catch (PartInitException ex) {
265
			} catch (PartInitException ex) {
216
			Logger.logException(ex);
266
				Logger.logException(ex);
267
			}
268
		} else {
269
			setupControls();
270
			if(newConnection()==null) {
271
				fMultiConnectionManager.removeActive();
272
			}
217
		}
273
		}
218
	}
274
	}
219
275
276
	
220
	public void onTerminalConnect() {
277
	public void onTerminalConnect() {
221
		//if (isConnected())
278
		//if (isConnected())
222
		if (fCtlTerminal.getState()!=TerminalState.CLOSED)
279
		if (fCtlTerminal.getState()!=TerminalState.CLOSED)
Lines 230-235 Link Here
230
		updateTerminalConnect();
287
		updateTerminalConnect();
231
		updateTerminalDisconnect();
288
		updateTerminalDisconnect();
232
		updateTerminalSettings();
289
		updateTerminalSettings();
290
		fActionToggleCommandInputField.setChecked(hasCommandInputField());
291
		updateSummary();
233
	}
292
	}
234
293
235
	public void updateTerminalConnect() {
294
	public void updateTerminalConnect() {
Lines 254-273 Link Here
254
	}
313
	}
255
314
256
	public void onTerminalSettings() {
315
	public void onTerminalSettings() {
316
		newConnection();
317
	}
318
319
	private ITerminalConnector newConnection() {
257
		ITerminalConnector c=showSettingsDialog();
320
		ITerminalConnector c=showSettingsDialog();
258
		if(c!=null) {
321
		if(c!=null) {
259
			setConnector(c);
322
			setConnector(c);
260
261
			onTerminalConnect();
323
			onTerminalConnect();
262
		}
324
		}
325
		return c;
263
	}
326
	}
264
327
265
	private ITerminalConnector showSettingsDialog() {
328
	private ITerminalConnector showSettingsDialog() {
266
		// When the settings dialog is opened, load the Terminal settings from the
329
		// When the settings dialog is opened, load the Terminal settings from the
267
		// persistent settings.
330
		// persistent settings.
268
331
269
		TerminalSettingsDlg dlgTerminalSettings = new TerminalSettingsDlg(getViewSite().getShell(),fCtlTerminal.getConnectors(),fCtlTerminal.getTerminalConnector());
332
		ITerminalConnector[] connectors = fCtlTerminal.getConnectors();
270
		dlgTerminalSettings.setTerminalTitle(getPartName());
333
		if(fCtlTerminal.getState()!=TerminalState.CLOSED)
334
			connectors=new ITerminalConnector[0];
335
		TerminalSettingsDlg dlgTerminalSettings = new TerminalSettingsDlg(getViewSite().getShell(),connectors,fCtlTerminal.getTerminalConnector());
336
		dlgTerminalSettings.setTerminalTitle(getActiveConnection().getPartName());
271
		Logger.log("opening Settings dialog."); //$NON-NLS-1$
337
		Logger.log("opening Settings dialog."); //$NON-NLS-1$
272
338
273
		if (dlgTerminalSettings.open() == Window.CANCEL) {
339
		if (dlgTerminalSettings.open() == Window.CANCEL) {
Lines 280-286 Link Here
280
		// When the settings dialog is closed, we persist the Terminal settings.
346
		// When the settings dialog is closed, we persist the Terminal settings.
281
347
282
		saveSettings(dlgTerminalSettings.getConnector());
348
		saveSettings(dlgTerminalSettings.getConnector());
283
		setPartName(dlgTerminalSettings.getTerminalTitle());
349
		setViewTitle(dlgTerminalSettings.getTerminalTitle());
284
		return dlgTerminalSettings.getConnector();
350
		return dlgTerminalSettings.getConnector();
285
	}
351
	}
286
352
Lines 292-375 Link Here
292
		//boolean bEnabled = ((!isConnecting()) && (!fCtlTerminal.isConnected()));
358
		//boolean bEnabled = ((!isConnecting()) && (!fCtlTerminal.isConnected()));
293
		boolean bEnabled = (fCtlTerminal.getState()==TerminalState.CLOSED);
359
		boolean bEnabled = (fCtlTerminal.getState()==TerminalState.CLOSED);
294
360
295
		fActionTerminalSettings.setEnabled(bEnabled);
361
//		fActionTerminalSettings.setEnabled(bEnabled);
296
	}
362
	}
297
363
	private void setViewTitle(String title) {
298
	public void setTerminalTitle(final String strTitle) {
364
		setPartName(title);
299
		runInDisplayThread(new Runnable() {
365
		getActiveConnection().setPartName(title);
300
301
			public void run() {
302
				runSetTitle(strTitle);
303
			}});
304
	}
366
	}
305
367
	private void setViewSummary(String summary) {
306
	private void runSetTitle(String strTitle) {
368
		setContentDescription(summary);
307
		if (fCtlTerminal.isDisposed())
308
			return;
309
310
		if (strTitle != null) {
311
			// When parameter 'data' is not null, it is a String containing text to
312
			// display in the view's content description line.  This is used by class
313
			// TerminalText when it processes an ANSI OSC escape sequence that commands
314
			// the terminal to display text in its title bar.
315
		} else if(fCtlTerminal.getTerminalConnector()==null){
316
			strTitle=ViewMessages.NO_CONNECTION_SELECTED;
317
		} else {
318
			// When parameter 'data' is null, we construct a descriptive string to
319
			// display in the content description line.
320
			String strConnected = getStateDisplayName(fCtlTerminal.getState());
321
			String summary = getSettingsSummary();
322
			//TODO Title should use an NLS String and com.ibm.icu.MessageFormat
323
			//In order to make the logic of assembling, and the separators, better adapt to foreign languages
324
			if(summary.length()>0)
325
				summary=summary+" - ";  //$NON-NLS-1$
326
			String name=fCtlTerminal.getTerminalConnector().getName();
327
			if(name.length()>0) {
328
				name+=": "; //$NON-NLS-1$
329
			}
330
			strTitle = name + "("+ summary + strConnected + ")"; //$NON-NLS-1$ //$NON-NLS-2$
331
		}
332
333
		setContentDescription(strTitle);
334
		getViewSite().getActionBars().getStatusLineManager().setMessage(
369
		getViewSite().getActionBars().getStatusLineManager().setMessage(
335
				strTitle);
370
				summary);
336
		setTitleToolTip(getPartName()+": "+strTitle); //$NON-NLS-1$
371
		setTitleToolTip(getPartName()+": "+summary); //$NON-NLS-1$
372
		
337
	}
373
	}
338
	/**
374
	public void updateSummary() {
339
	 * @return the setting summary. If there is no connection, or the connection
375
		setViewSummary(getActiveConnection().getFullSummary());
340
	 * has not been initialized, use the last stored state.
341
	 */
342
	private String getSettingsSummary() {
343
		// TODO: use another mechanism than "?" for the magic non initialized state
344
		// see TerminalConnectorProxy.getSettingsSummary
345
		String summary="?"; //$NON-NLS-1$
346
		if(fCtlTerminal.getTerminalConnector()!=null)
347
			summary=fCtlTerminal.getSettingsSummary();
348
		if("?".equals(summary)) { //$NON-NLS-1$
349
			summary=fStore.get(STORE_SETTING_SUMMARY, ""); //$NON-NLS-1$
350
		}
351
		return summary;
352
	}
353
	public void onTerminalStatus() {
354
		setTerminalTitle(null);
355
	}
356
357
	private String getStateDisplayName(TerminalState state) {
358
		if(state==TerminalState.CONNECTED) {
359
			return ViewMessages.STATE_CONNECTED;
360
		} else if(state==TerminalState.CONNECTING) {
361
			return ViewMessages.STATE_CONNECTING;
362
		} else if(state==TerminalState.OPENED) {
363
			return ViewMessages.STATE_OPENED;
364
		} else if(state==TerminalState.CLOSED) {
365
			return ViewMessages.STATE_CLOSED;
366
		} else {
367
			throw new IllegalStateException(state.toString());
368
		}
369
	}
376
	}
370
377
371
	public void onTerminalFontChanged() {
378
	public void onTerminalFontChanged() {
372
		fCtlTerminal.setFont(JFaceResources.getFont(FONT_DEFINITION));
379
		// set the font for all 
380
		Font font=JFaceResources.getFont(FONT_DEFINITION);
381
		ITerminalViewConnection[] conn=fMultiConnectionManager.getConnections();
382
		for (int i = 0; i < conn.length; i++) {
383
			conn[i].getCtlTerminal().setFont(font);
384
		}
373
	}
385
	}
374
386
375
	// ViewPart interface
387
	// ViewPart interface
Lines 378-402 Link Here
378
		// Bind plugin.xml key bindings to this plugin.  Overrides global Control-W key
390
		// Bind plugin.xml key bindings to this plugin.  Overrides global Control-W key
379
		// sequence.
391
		// sequence.
380
392
381
		setPartName(findUniqueTitle(ViewMessages.PROP_TITLE));
393
		fPageBook=new PageBook(wndParent,SWT.NONE);
382
		setupControls(wndParent);
394
		ISettingsStore s=new SettingStorePrefixDecorator(fStore,"connectionManager"); //$NON-NLS-1$
395
		fMultiConnectionManager.loadState(s,new ITerminalViewConnectionFactory() {
396
			public ITerminalViewConnection create() {
397
				return makeViewConnection();
398
			}
399
		});
400
		// if there is no connection loaded, create at least one
401
		// needed to read old states from the old terminal
402
		if(fMultiConnectionManager.size()==0) {
403
			ITerminalViewConnection conn = makeViewConnection();
404
			fMultiConnectionManager.addConnection(conn);
405
			fMultiConnectionManager.setActiveConnection(conn);
406
			fPageBook.showPage(fCtlTerminal.getRootControl());
407
		}
408
		setTerminalControl(fMultiConnectionManager.getActiveConnection().getCtlTerminal());
409
		setViewTitle(findUniqueTitle(ViewMessages.PROP_TITLE));
383
		setupActions();
410
		setupActions();
384
		setupLocalToolBars();
411
		setupLocalToolBars();
385
		setupContextMenus();
412
		// setup all context menus
413
		ITerminalViewConnection[] conn=fMultiConnectionManager.getConnections();
414
		for (int i = 0; i < conn.length; i++) {
415
			setupContextMenus(conn[i].getCtlTerminal().getControl());
416
		}
386
		setupListeners(wndParent);
417
		setupListeners(wndParent);
387
418
388
		PlatformUI.getWorkbench().getHelpSystem().setHelp(wndParent, TerminalViewPlugin.HELPPREFIX + "terminal_page"); //$NON-NLS-1$
419
		PlatformUI.getWorkbench().getHelpSystem().setHelp(wndParent, TerminalViewPlugin.HELPPREFIX + "terminal_page"); //$NON-NLS-1$
389
420
390
		onTerminalStatus();
421
		legacyLoadState();
422
		legacySetTitle();
423
424
		refresh();
391
		onTerminalFontChanged();
425
		onTerminalFontChanged();
426
392
	}
427
	}
428
393
	public void dispose() {
429
	public void dispose() {
394
		Logger.log("entered."); //$NON-NLS-1$
430
		Logger.log("entered."); //$NON-NLS-1$
395
431
396
		TerminalViewPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPreferenceListener);
432
		TerminalViewPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPreferenceListener);
397
433
398
		JFaceResources.getFontRegistry().removeListener(fPropertyChangeHandler);
434
		JFaceResources.getFontRegistry().removeListener(fPropertyChangeHandler);
399
		fCtlTerminal.disposeTerminal();
435
		
436
		// dispose all connections
437
		ITerminalViewConnection[] conn=fMultiConnectionManager.getConnections();
438
		for (int i = 0; i < conn.length; i++) {
439
			conn[i].getCtlTerminal().disposeTerminal();
440
		}
400
		super.dispose();
441
		super.dispose();
401
	}
442
	}
402
	/**
443
	/**
Lines 409-432 Link Here
409
	/**
450
	/**
410
	 * This method creates the top-level control for the Terminal view.
451
	 * This method creates the top-level control for the Terminal view.
411
	 */
452
	 */
412
	protected void setupControls(Composite wndParent) {
453
	protected void setupControls() {
413
		ITerminalConnector[] connectors = makeConnectors();
454
		ITerminalViewConnection conn = makeViewConnection();
414
		fCtlTerminal = TerminalViewControlFactory.makeControl(this, wndParent, connectors);
455
		fMultiConnectionManager.addConnection(conn);
456
		fMultiConnectionManager.setActiveConnection(conn);
457
		setupContextMenus(fCtlTerminal.getControl());
458
	}
415
459
460
	private ITerminalViewConnection makeViewConnection() {
461
		ITerminalConnector[] connectors = makeConnectors();
462
		TerminalListener listener=new TerminalListener();
463
		ITerminalViewControl ctrl = TerminalViewControlFactory.makeControl(listener, fPageBook, connectors);
464
		setTerminalControl(ctrl);
465
		ITerminalViewConnection conn = new TerminalViewConnection(fCtlTerminal);
466
		listener.setConnection(conn);
467
		conn.setPartName(getPartName());
416
		String connectionType=fStore.get(STORE_CONNECTION_TYPE);
468
		String connectionType=fStore.get(STORE_CONNECTION_TYPE);
417
		for (int i = 0; i < connectors.length; i++) {
469
		for (int i = 0; i < connectors.length; i++) {
418
			connectors[i].load(getStore(connectors[i]));
470
			connectors[i].load(getStore(connectors[i]));
419
			if(connectors[i].getId().equals(connectionType))
471
			if(connectors[i].getId().equals(connectionType))
420
				fCtlTerminal.setConnector(connectors[i]);
472
				ctrl.setConnector(connectors[i]);
421
		}
473
		}
422
		setCommandInputField("true".equals(fStore.get(STORE_HAS_COMMAND_INPUT_FIELD))); //$NON-NLS-1$
423
		updatePreferences();
474
		updatePreferences();
424
		TerminalViewPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPreferenceListener);
475
		TerminalViewPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPreferenceListener);
425
476
		
426
		// restore the title of this view
477
		return conn;
427
		String title=fStore.get(STORE_TITLE);
428
		if(title!=null && title.length()>0)
429
			setPartName(title);
430
	}
478
	}
431
479
432
	/**
480
	/**
Lines 450-464 Link Here
450
	public void init(IViewSite site, IMemento memento) throws PartInitException {
498
	public void init(IViewSite site, IMemento memento) throws PartInitException {
451
		super.init(site, memento);
499
		super.init(site, memento);
452
		fStore=new SettingsStore(memento);
500
		fStore=new SettingsStore(memento);
501
		// have we stored the pinned status?
502
		if(fStore.get(STORE_PINNED)!=null)
503
			setPinned("true".equals(fStore.get(STORE_PINNED))); //$NON-NLS-1$
453
	}
504
	}
454
455
	public void saveState(IMemento memento) {
505
	public void saveState(IMemento memento) {
456
		super.saveState(memento);
506
		super.saveState(memento);
457
		if(fCommandInputField!=null)
507
		fStore.put(STORE_PINNED, isPinned()?"true":"false"); //$NON-NLS-1$ //$NON-NLS-2$
458
			fStore.put(STORE_COMMAND_INPUT_FIELD_HISTORY, fCommandInputField.getHistory());
459
		fStore.put(STORE_HAS_COMMAND_INPUT_FIELD,hasCommandInputField()?"true":"false");   //$NON-NLS-1$//$NON-NLS-2$
460
		fStore.put(STORE_SETTING_SUMMARY, getSettingsSummary());
461
		fStore.put(STORE_TITLE,getPartName());
508
		fStore.put(STORE_TITLE,getPartName());
509
		fMultiConnectionManager.saveState(new SettingStorePrefixDecorator(fStore,"connectionManager")); //$NON-NLS-1$
462
		fStore.saveState(memento);
510
		fStore.saveState(memento);
463
	}
511
	}
464
	private ISettingsStore getStore(ITerminalConnector connector) {
512
	private ISettingsStore getStore(ITerminalConnector connector) {
Lines 466-501 Link Here
466
	}
514
	}
467
515
468
	protected void setupActions() {
516
	protected void setupActions() {
517
		fActionTerminalDropDown = new TerminalActionSelectionDropDown(fMultiConnectionManager);
518
		fActionTerminalPin=new TerminalActionPin(this);
519
		fActionTerminalPin.setChecked(isPinned());
520
		fActionTerminalRemove=new TerminalActionRemove(fMultiConnectionManager);
469
		fActionTerminalNewTerminal = new TerminalActionNewTerminal(this);
521
		fActionTerminalNewTerminal = new TerminalActionNewTerminal(this);
470
//		fActionTerminalScrollLock = new TerminalActionScrollLock(this);
522
//		fActionTerminalScrollLock = new TerminalActionScrollLock(this);
471
		fActionTerminalConnect = new TerminalActionConnect(this);
523
		fActionTerminalConnect = new TerminalActionConnect(this);
472
		fActionTerminalDisconnect = new TerminalActionDisconnect(this);
524
		fActionTerminalDisconnect = new TerminalActionDisconnect(this);
473
		fActionTerminalSettings = new TerminalActionSettings(this);
525
		fActionTerminalSettings = new TerminalActionSettings(this);
474
		fActionEditCopy = new TerminalActionCopy(fCtlTerminal);
526
		fActionEditCopy = new TerminalActionCopy(fCtlDecorator);
475
		fActionEditCut = new TerminalActionCut(fCtlTerminal);
527
		fActionEditCut = new TerminalActionCut(fCtlDecorator);
476
		fActionEditPaste = new TerminalActionPaste(fCtlTerminal);
528
		fActionEditPaste = new TerminalActionPaste(fCtlDecorator);
477
		fActionEditClearAll = new TerminalActionClearAll(fCtlTerminal);
529
		fActionEditClearAll = new TerminalActionClearAll(fCtlDecorator);
478
		fActionEditSelectAll = new TerminalActionSelectAll(fCtlTerminal);
530
		fActionEditSelectAll = new TerminalActionSelectAll(fCtlDecorator);
479
		fActionToggleCommandInputField = new TerminalActionToggleCommandInputField(this);
531
		fActionToggleCommandInputField = new TerminalActionToggleCommandInputField(this);
480
	}
532
	}
481
	protected void setupLocalToolBars() {
533
	protected void setupLocalToolBars() {
482
		IToolBarManager toolBarMgr = getViewSite().getActionBars().getToolBarManager();
534
		IToolBarManager toolBarMgr = getViewSite().getActionBars().getToolBarManager();
483
535
484
		toolBarMgr.add(fActionTerminalNewTerminal);
485
//		toolBarMgr.add(fActionTerminalScrollLock);
536
//		toolBarMgr.add(fActionTerminalScrollLock);
486
		toolBarMgr.add(fActionTerminalConnect);
537
		toolBarMgr.add(fActionTerminalConnect);
487
		toolBarMgr.add(fActionTerminalDisconnect);
538
		toolBarMgr.add(fActionTerminalDisconnect);
488
		toolBarMgr.add(fActionTerminalSettings);
539
		toolBarMgr.add(fActionTerminalSettings);
489
		toolBarMgr.add(fActionToggleCommandInputField);
540
		toolBarMgr.add(fActionToggleCommandInputField);
541
		toolBarMgr.add(new Separator("fixedGroup")); //$NON-NLS-1$
542
		toolBarMgr.add(fActionTerminalPin);
543
		toolBarMgr.add(fActionTerminalDropDown);
544
		toolBarMgr.add(fActionTerminalNewTerminal);
545
		toolBarMgr.add(fActionTerminalRemove);
490
	}
546
	}
491
547
492
	protected void setupContextMenus() {
548
	protected void setupContextMenus(Control ctlText) {
493
		Control ctlText;
494
		MenuManager menuMgr;
549
		MenuManager menuMgr;
495
		Menu menu;
550
		Menu menu;
496
		TerminalContextMenuHandler contextMenuHandler;
551
		TerminalContextMenuHandler contextMenuHandler;
497
552
498
		ctlText = fCtlTerminal.getControl();
499
		menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
553
		menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
500
		menu = menuMgr.createContextMenu(ctlText);
554
		menu = menuMgr.createContextMenu(ctlText);
501
		loadContextMenus(menuMgr);
555
		loadContextMenus(menuMgr);
Lines 554-573 Link Here
554
	}
608
	}
555
609
556
	public boolean hasCommandInputField() {
610
	public boolean hasCommandInputField() {
557
		return fCommandInputField!=null;
611
		return getActiveConnection().hasCommandInputField();
558
	}
612
	}
613
559
	public void setCommandInputField(boolean on) {
614
	public void setCommandInputField(boolean on) {
560
		// save the old history
615
		getActiveConnection().setCommandInputField(on);
561
		if(fCommandInputField!=null) {
562
			fStore.put(STORE_COMMAND_INPUT_FIELD_HISTORY, fCommandInputField.getHistory());
563
			fCommandInputField=null;
564
		}
565
		if(on) {
566
			// TODO make history size configurable
567
			fCommandInputField=new CommandInputFieldWithHistory(100);
568
			fCommandInputField.setHistory(fStore.get(STORE_COMMAND_INPUT_FIELD_HISTORY));
569
		}
570
		fCtlTerminal.setCommandInputField(fCommandInputField);
571
	}
616
	}
572
617
573
	public boolean isScrollLock() {
618
	public boolean isScrollLock() {
Lines 577-580 Link Here
577
	public void setScrollLock(boolean on) {
622
	public void setScrollLock(boolean on) {
578
		fCtlTerminal.setScrollLock(on);
623
		fCtlTerminal.setScrollLock(on);
579
	}
624
	}
625
626
	private ITerminalViewConnection getActiveConnection() {
627
		return fMultiConnectionManager.getActiveConnection();
628
	}
629
	/**
630
	 * @param ctrl this control becomes the currently used one
631
	 */
632
	private void setTerminalControl(ITerminalViewControl ctrl) {
633
		fCtlTerminal=ctrl;
634
		fCtlDecorator.setViewContoler(ctrl);
635
	}
636
	public void connectionsChanged() {
637
		if(getActiveConnection()!=null) {
638
			// update the active {@link ITerminalViewControl}
639
			ITerminalViewControl ctrl = getActiveConnection().getCtlTerminal();
640
			if(fCtlTerminal!=ctrl) {
641
				setTerminalControl(ctrl);
642
				refresh();
643
			}
644
		}	
645
	}
646
647
	/**
648
	 * Show the active {@link ITerminalViewControl} in the view
649
	 */
650
	private void refresh() {
651
		fPageBook.showPage(fCtlTerminal.getRootControl());
652
		updateStatus();
653
		setPartName(getActiveConnection().getPartName());
654
	}
655
656
	public void setPinned(boolean pinned) {
657
		fPinned=pinned;
658
	}
659
	public boolean isPinned() {
660
		return fPinned;
661
	}
662
663
	/**
664
	 * TODO REMOVE This code (added 2008-06-11)
665
	 * Legacy code to real the old state. Once the state of the
666
	 * terminal has been saved this method is not needed anymore.
667
	 * Remove this code with eclipse 3.5.
668
	 */
669
	private void legacyLoadState() {
670
		// TODO legacy: load the old title....
671
		String summary=fStore.get(STORE_SETTING_SUMMARY);
672
		if(summary!=null) {
673
			getActiveConnection().setSummary(summary);
674
			fStore.put(STORE_SETTING_SUMMARY,null);
675
		}
676
	}
677
	/**
678
	 * TODO REMOVE This code (added 2008-06-11)
679
	 * Legacy code to real the old state. Once the state of the
680
	 * terminal has been saved this method is not needed anymore.
681
	 * Remove this code with eclipse 3.5.
682
	 */
683
	private void legacySetTitle() {
684
		// restore the title of this view
685
		String title=fStore.get(STORE_TITLE);
686
		if(title!=null && title.length()>0) {
687
			setViewTitle(title);
688
			fStore.put(STORE_TITLE, null);
689
		}
690
	}
691
580
}
692
}
(-)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/TerminalSettingsDlg.java (-2 / +12 lines)
Lines 196-203 Link Here
196
	}
196
	}
197
	private void setupPanel(Composite wndParent) {
197
	private void setupPanel(Composite wndParent) {
198
		setupSettingsTypePanel(wndParent);
198
		setupSettingsTypePanel(wndParent);
199
		setupConnTypePanel(wndParent);
199
		if(fConnectors.length>0) {
200
		setupSettingsGroup(wndParent);
200
			setupConnTypePanel(wndParent);
201
			setupSettingsGroup(wndParent);
202
		} else {
203
			Label label=new Label(wndParent,SWT.NONE);
204
			label.setText(ViewMessages.VIEW_TITLE);
205
		}
201
	}
206
	}
202
	private void setupSettingsTypePanel(Composite wndParent) {
207
	private void setupSettingsTypePanel(Composite wndParent) {
203
		Group wndGroup;
208
		Group wndGroup;
Lines 246-251 Link Here
246
		fPageBook.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
251
		fPageBook.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
247
	}
252
	}
248
	private void setupListeners() {
253
	private void setupListeners() {
254
		if(fCtlConnTypeCombo==null)
255
			return;
249
		fCtlConnTypeCombo.addSelectionListener(new SelectionAdapter() {
256
		fCtlConnTypeCombo.addSelectionListener(new SelectionAdapter() {
250
			public void widgetSelected(SelectionEvent event) {
257
			public void widgetSelected(SelectionEvent event) {
251
				selectPage(fCtlConnTypeCombo.getSelectionIndex());
258
				selectPage(fCtlConnTypeCombo.getSelectionIndex());
Lines 275-280 Link Here
275
			boolean enable=false;
282
			boolean enable=false;
276
			if(getConnector()!=null)
283
			if(getConnector()!=null)
277
				enable=getConnector().getInitializationErrorMessage()==null;
284
				enable=getConnector().getInitializationErrorMessage()==null;
285
			// enable the OK button if no connectors are available
286
			if(!enable && fConnectors.length==0)
287
				enable=true;
278
			getButton(IDialogConstants.OK_ID).setEnabled(enable);
288
			getButton(IDialogConstants.OK_ID).setEnabled(enable);
279
		}
289
		}
280
	}
290
	}
(-)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
(-)META-INF/MANIFEST.MF (-1 / +1 lines)
Lines 2-8 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %pluginName
3
Bundle-Name: %pluginName
4
Bundle-SymbolicName: org.eclipse.tm.terminal.view;singleton:=true
4
Bundle-SymbolicName: org.eclipse.tm.terminal.view;singleton:=true
5
Bundle-Version: 2.0.0.qualifier
5
Bundle-Version: 2.0.1.qualifier
6
Bundle-Activator: org.eclipse.tm.internal.terminal.view.TerminalViewPlugin
6
Bundle-Activator: org.eclipse.tm.internal.terminal.view.TerminalViewPlugin
7
Bundle-Localization: plugin
7
Bundle-Localization: plugin
8
Require-Bundle: org.eclipse.ui,
8
Require-Bundle: org.eclipse.ui,
(-)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/ShowTerminalConnectionAction.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 connection in the terminal view
19
 */
20
public class ShowTerminalConnectionAction 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 connection the console
30
	 */
31
	public ShowTerminalConnectionAction(ITerminalViewConnectionManager manager, ITerminalViewConnection connection) {
32
		super(quoteName(buildName(manager,connection)), AS_RADIO_BUTTON);
33
		fConnection = connection;
34
		fConnectionManager = manager;
35
		setImageDescriptor(connection.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 prefixed.
49
	 * @param m the connection manager
50
	 * @param connection the connection for which the name should me extracted
51
	 * @return The name to be displayed
52
	 */
53
	private static String buildName(ITerminalViewConnectionManager m,ITerminalViewConnection connection) {
54
		String name = connection.getFullSummary();
55
		if(!checkIfAllPartNamesTheSame(m))
56
			name=connection.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.setActiveConnection(fConnection);
81
	}
82
}
(-)src/org/eclipse/tm/internal/terminal/view/ITerminalViewConnectionManager.java (+83 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 active connection has changed
26
	 * </ul>
27
	 *
28
	 */
29
	interface ITerminalViewConnectionListener {
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
	 * @return the number of connections
46
	 */
47
	int size();
48
	/**
49
	 * @return th connection the view is showing at the moment
50
	 */
51
	ITerminalViewConnection getActiveConnection();
52
53
	/**
54
	 * @param conn make this connection the active connection
55
	 */
56
	void setActiveConnection(ITerminalViewConnection conn);
57
	/**
58
	 * If more than two connections are available, remove the active connection
59
	 */
60
	void removeActive();
61
62
	/**
63
	 * @param conn adds a new connection
64
	 */
65
	void addConnection(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(ITerminalViewConnectionListener listener);
74
	void removeListener(ITerminalViewConnectionListener listener);
75
	
76
	void saveState(ISettingsStore store);
77
	/**
78
	 * @param store
79
	 * @param factory used to create new {@link ITerminalViewConnection}
80
	 */
81
	void loadState(ISettingsStore store,ITerminalViewConnectionFactory factory);
82
	
83
}
(-)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 (+181 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 = "connection"; //$NON-NLS-1$
23
	private static final String STORE_SIZE = "size"; //$NON-NLS-1$
24
	private static final String STORE_ACTIVE_CONNECTION = "active"; //$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 fActiveConnection;
34
	/**
35
	 * The list of {@link ITerminalViewConnection} in the order they
36
	 * were made the active 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 ITerminalViewConnectionListener}
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 getActiveConnection() {
54
		return fActiveConnection;
55
	}
56
	public void setActiveConnection(ITerminalViewConnection conn) {
57
		fActiveConnection=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
			setActiveConnection(conn);
69
	}
70
71
	/**
72
	 * @return the connection that was most recently the active connection or null if there is
73
	 * no previous connection
74
	 */
75
	private ITerminalViewConnection getPreviousConnection() {
76
		// find the first connection that is not the active connection in
77
		// the list
78
		for (Iterator iterator = fConnectionHistory.iterator(); iterator.hasNext();) {
79
			ITerminalViewConnection conn = (ITerminalViewConnection) iterator.next();
80
			if(conn!=fActiveConnection) {
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(ITerminalViewConnectionListener listener) {
98
		fListeners.add(listener);
99
	}
100
101
	public void removeListener(ITerminalViewConnectionListener listener) {
102
		fListeners.remove(listener);
103
	}
104
	protected void fireListeners() {
105
		ITerminalViewConnectionListener[] listeners=(ITerminalViewConnectionListener[]) fListeners.toArray(new ITerminalViewConnectionListener[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
			ITerminalViewConnection connection = (ITerminalViewConnection) iterator.next();
117
			// the name under which we store the connection
118
			String prefix=STORE_CONNECTION_PREFIX+n;
119
			n++;
120
			// remember the active connection by its prefix
121
			if(connection.equals(fActiveConnection))
122
				store.put(STORE_ACTIVE_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 active=store.get(STORE_ACTIVE_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(active))
147
						fActiveConnection=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 removeActive() {
166
		// don't remove the last connection -- we need at least one!
167
		if(fConnections.size()>1) {
168
			fConnections.remove(fActiveConnection);
169
			fConnectionHistory.remove(fActiveConnection);
170
			
171
			// make sure connection is not null....
172
			fActiveConnection=getPreviousConnection();
173
			// if there is no previous connection then make
174
			// the first connection the list the active connection
175
			if(fActiveConnection==null)
176
				fActiveConnection=(ITerminalViewConnection) fConnections.get(0);
177
				
178
			fireListeners();			
179
		}
180
	}
181
}
(-)src/org/eclipse/tm/internal/terminal/view/TerminalViewConnection.java (+195 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 the title is set, then we return the title, else the summary
51
		if(fTitle==null)
52
			return makeSummary();
53
		return fTitle;
54
	}
55
56
	/* (non-Javadoc)
57
	 * @see org.eclipse.tm.internal.terminal.view.ITerminalViewConnection#getImageDescriptor()
58
	 */
59
	public ImageDescriptor getImageDescriptor() {
60
		return TerminalViewPlugin.getDefault().getImageRegistry().getDescriptor(ImageConsts.IMAGE_TERMINAL_VIEW);
61
	}
62
63
	public ITerminalViewControl getCtlTerminal() {
64
		return fCtlTerminal;
65
	}
66
	private ISettingsStore getStore(ISettingsStore store,ITerminalConnector connector) {
67
		return new SettingStorePrefixDecorator(store,connector.getId()+"."); //$NON-NLS-1$
68
	}
69
	public void loadState(ISettingsStore store) {
70
		fPartName=store.get(STORE_PART_NAME);
71
		fSummary=store.get(STORE_SUMMARY);
72
		fHistory=store.get(STORE_COMMAND_INPUT_FIELD_HISTORY);
73
74
		// load the state of the connection types
75
		ITerminalConnector[] connectors=fCtlTerminal.getConnectors();
76
		String connectionType=store.get(STORE_CONNECTION_TYPE);
77
		for (int i = 0; i < connectors.length; i++) {
78
			connectors[i].load(getStore(store,connectors[i]));
79
			// if this is active connection type
80
			if(connectors[i].getId().equals(connectionType))
81
				fCtlTerminal.setConnector(connectors[i]);
82
		}
83
		
84
		if("true".equals(store.get(STORE_HAS_COMMAND_INPUT_FIELD))) //$NON-NLS-1$
85
			setCommandInputField(true);
86
	}
87
88
	public void saveState(ISettingsStore store) {
89
		store.put(STORE_PART_NAME, fPartName);
90
		store.put(STORE_SUMMARY,fSummary);
91
		store.put(STORE_COMMAND_INPUT_FIELD_HISTORY, fHistory);
92
		if(fCommandInputField!=null)
93
			store.put(STORE_COMMAND_INPUT_FIELD_HISTORY, fCommandInputField.getHistory());
94
		else
95
			store.put(STORE_COMMAND_INPUT_FIELD_HISTORY, fHistory);
96
		store.put(STORE_HAS_COMMAND_INPUT_FIELD,hasCommandInputField()?"true":"false");   //$NON-NLS-1$//$NON-NLS-2$
97
		ITerminalConnector[] connectors=fCtlTerminal.getConnectors();
98
		for (int i = 0; i < connectors.length; i++) {
99
			connectors[i].save(getStore(store,connectors[i]));
100
		}
101
		if(fCtlTerminal.getTerminalConnector()!=null) {
102
			store.put(STORE_CONNECTION_TYPE,fCtlTerminal.getTerminalConnector().getId());
103
		}
104
	}
105
	public boolean hasCommandInputField() {
106
		return fCommandInputField!=null;
107
	}
108
	public void setCommandInputField(boolean on) {
109
		// save the old history
110
		if(fCommandInputField!=null) {
111
			fHistory= fCommandInputField.getHistory();
112
			fCommandInputField=null;
113
		}
114
		if(on) {
115
			// TODO make history size configurable
116
			fCommandInputField=new CommandInputFieldWithHistory(100);
117
			fCommandInputField.setHistory(fHistory);
118
		}
119
		fCtlTerminal.setCommandInputField(fCommandInputField);
120
	}
121
122
	public void setState(TerminalState state) {
123
		// update the title....
124
		fTitle=null;		
125
	}
126
127
	public void setTerminalTitle(String title) {
128
		// When parameter 'title' is not null, it is a String containing text to
129
		// display in the view's content description line.  This is used by class
130
		// TerminalText when it processes an ANSI OSC escape sequence that commands
131
		// the terminal to display text in its title bar.
132
		fTitle=title;
133
	}
134
135
	private String getStateDisplayName(TerminalState state) {
136
		if(state==TerminalState.CONNECTED) {
137
			return ViewMessages.STATE_CONNECTED;
138
		} else if(state==TerminalState.CONNECTING) {
139
			return ViewMessages.STATE_CONNECTING;
140
		} else if(state==TerminalState.OPENED) {
141
			return ViewMessages.STATE_OPENED;
142
		} else if(state==TerminalState.CLOSED) {
143
			return ViewMessages.STATE_CLOSED;
144
		} else {
145
			throw new IllegalStateException(state.toString());
146
		}
147
	}
148
149
	private String makeSummary() {
150
		String strTitle = ""; //$NON-NLS-1$
151
		if(fCtlTerminal.getTerminalConnector()==null){
152
			strTitle=ViewMessages.NO_CONNECTION_SELECTED;
153
		} else {
154
			// When parameter 'data' is null, we construct a descriptive string to
155
			// display in the content description line.
156
			String strConnected = getStateDisplayName(fCtlTerminal.getState());
157
			String summary = getSettingsSummary();
158
			//TODO Title should use an NLS String and com.ibm.icu.MessageFormat
159
			//In order to make the logic of assembling, and the separators, better adapt to foreign languages
160
			if(summary.length()>0)
161
				summary=summary+" - ";  //$NON-NLS-1$
162
			String name=fCtlTerminal.getTerminalConnector().getName();
163
			if(name.length()>0) {
164
				name+=": "; //$NON-NLS-1$
165
			}
166
			strTitle = name + "("+ summary + strConnected + ")"; //$NON-NLS-1$ //$NON-NLS-2$
167
		}
168
		return strTitle;
169
	}
170
	/**
171
	 * @return the setting summary. If there is no connection, or the connection
172
	 * has not been initialized, use the last stored state.
173
	 */
174
	private String getSettingsSummary() {
175
		if(fCtlTerminal.getTerminalConnector().isInitialized())
176
			fSummary=fCtlTerminal.getSettingsSummary();
177
		if(fSummary==null)
178
			return ""; //$NON-NLS-1$
179
		return fSummary;
180
	}
181
182
	public void setSummary(String summary) {
183
		fSummary=summary;
184
	}
185
186
	public String getPartName() {
187
		return fPartName==null?ViewMessages.PROP_TITLE:fPartName;
188
	}
189
190
	public void setPartName(String name) {
191
		fPartName=name;
192
		
193
	}
194
195
}
(-)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.ITerminalViewConnectionListener;
21
22
public class TerminalActionRemove extends TerminalAction implements ITerminalViewConnectionListener 
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.removeActive();
41
	}
42
	public void connectionsChanged() {
43
		setEnabled(fConnectionManager.size()>1);
44
	}
45
}
(-)src/org/eclipse/tm/internal/terminal/actions/TerminalActionSelectionDropDown.java (+106 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.ITerminalViewConnectionListener;
26
27
/**
28
 * Drop down action in the console to select the console to display.
29
 */
30
public class TerminalActionSelectionDropDown extends Action implements IMenuCreator, ITerminalViewConnectionListener {
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 active = fConnections.getActiveConnection();
73
		for (int i = 0; i < consoles.length; i++) {
74
			ITerminalViewConnection console = consoles[i];
75
			Action action = new ShowTerminalConnectionAction(fConnections, console);
76
			action.setChecked(console.equals(active));
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
		setEnabled(fConnections.size() > 1);
105
	}
106
}
(-)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 with 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
}
(-)feature.xml (-1 / +1 lines)
Lines 2-8 Link Here
2
<feature
2
<feature
3
      id="org.eclipse.tm.terminal.view"
3
      id="org.eclipse.tm.terminal.view"
4
      label="%featureName"
4
      label="%featureName"
5
      version="2.0.0.qualifier"
5
      version="2.0.1.qualifier"
6
      provider-name="%providerName">
6
      provider-name="%providerName">
7
7
8
   <description>
8
   <description>

Return to bug 172483