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 |
} |