Lines 26-31
Link Here
|
26 |
import java.util.Set; |
26 |
import java.util.Set; |
27 |
|
27 |
|
28 |
import org.eclipse.core.runtime.Preferences; |
28 |
import org.eclipse.core.runtime.Preferences; |
|
|
29 |
import org.eclipse.jface.action.Action; |
29 |
import org.eclipse.jface.action.IMenuListener; |
30 |
import org.eclipse.jface.action.IMenuListener; |
30 |
import org.eclipse.jface.action.IMenuManager; |
31 |
import org.eclipse.jface.action.IMenuManager; |
31 |
import org.eclipse.jface.action.IToolBarManager; |
32 |
import org.eclipse.jface.action.IToolBarManager; |
Lines 35-40
Link Here
|
35 |
import org.eclipse.jface.util.IPropertyChangeListener; |
36 |
import org.eclipse.jface.util.IPropertyChangeListener; |
36 |
import org.eclipse.jface.util.PropertyChangeEvent; |
37 |
import org.eclipse.jface.util.PropertyChangeEvent; |
37 |
import org.eclipse.jface.window.Window; |
38 |
import org.eclipse.jface.window.Window; |
|
|
39 |
import org.eclipse.swt.SWT; |
38 |
import org.eclipse.swt.events.MenuEvent; |
40 |
import org.eclipse.swt.events.MenuEvent; |
39 |
import org.eclipse.swt.events.MenuListener; |
41 |
import org.eclipse.swt.events.MenuListener; |
40 |
import org.eclipse.swt.widgets.Composite; |
42 |
import org.eclipse.swt.widgets.Composite; |
Lines 45-50
Link Here
|
45 |
import org.eclipse.tm.internal.terminal.actions.TerminalActionConnect; |
47 |
import org.eclipse.tm.internal.terminal.actions.TerminalActionConnect; |
46 |
import org.eclipse.tm.internal.terminal.actions.TerminalActionDisconnect; |
48 |
import org.eclipse.tm.internal.terminal.actions.TerminalActionDisconnect; |
47 |
import org.eclipse.tm.internal.terminal.actions.TerminalActionNewTerminal; |
49 |
import org.eclipse.tm.internal.terminal.actions.TerminalActionNewTerminal; |
|
|
50 |
import org.eclipse.tm.internal.terminal.actions.TerminalActionPin; |
51 |
import org.eclipse.tm.internal.terminal.actions.TerminalActionRemove; |
52 |
import org.eclipse.tm.internal.terminal.actions.TerminalActionSelectionDropDown; |
48 |
import org.eclipse.tm.internal.terminal.actions.TerminalActionSettings; |
53 |
import org.eclipse.tm.internal.terminal.actions.TerminalActionSettings; |
49 |
import org.eclipse.tm.internal.terminal.actions.TerminalActionToggleCommandInputField; |
54 |
import org.eclipse.tm.internal.terminal.actions.TerminalActionToggleCommandInputField; |
50 |
import org.eclipse.tm.internal.terminal.control.CommandInputFieldWithHistory; |
55 |
import org.eclipse.tm.internal.terminal.control.CommandInputFieldWithHistory; |
Lines 61-66
Link Here
|
61 |
import org.eclipse.tm.internal.terminal.provisional.api.Logger; |
66 |
import org.eclipse.tm.internal.terminal.provisional.api.Logger; |
62 |
import org.eclipse.tm.internal.terminal.provisional.api.TerminalConnectorExtension; |
67 |
import org.eclipse.tm.internal.terminal.provisional.api.TerminalConnectorExtension; |
63 |
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; |
68 |
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; |
|
|
69 |
import org.eclipse.tm.internal.terminal.view.ITerminalViewConnectionManager.ITerminalViewConnectionFactory; |
70 |
import org.eclipse.tm.internal.terminal.view.ITerminalViewConnectionManager.TerminalViewConnectionListener; |
64 |
import org.eclipse.ui.IMemento; |
71 |
import org.eclipse.ui.IMemento; |
65 |
import org.eclipse.ui.IViewReference; |
72 |
import org.eclipse.ui.IViewReference; |
66 |
import org.eclipse.ui.IViewSite; |
73 |
import org.eclipse.ui.IViewSite; |
Lines 69-75
Link Here
|
69 |
import org.eclipse.ui.PlatformUI; |
76 |
import org.eclipse.ui.PlatformUI; |
70 |
import org.eclipse.ui.part.ViewPart; |
77 |
import org.eclipse.ui.part.ViewPart; |
71 |
|
78 |
|
72 |
public class TerminalView extends ViewPart implements ITerminalView, ITerminalListener { |
79 |
public class TerminalView extends ViewPart implements ITerminalView, ITerminalListener, TerminalViewConnectionListener { |
73 |
private static final String STORE_CONNECTION_TYPE = "ConnectionType"; //$NON-NLS-1$ |
80 |
private static final String STORE_CONNECTION_TYPE = "ConnectionType"; //$NON-NLS-1$ |
74 |
|
81 |
|
75 |
private static final String STORE_SETTING_SUMMARY = "SettingSummary"; //$NON-NLS-1$ |
82 |
private static final String STORE_SETTING_SUMMARY = "SettingSummary"; //$NON-NLS-1$ |
Lines 108-119
Link Here
|
108 |
|
115 |
|
109 |
protected TerminalPropertyChangeHandler fPropertyChangeHandler; |
116 |
protected TerminalPropertyChangeHandler fPropertyChangeHandler; |
110 |
|
117 |
|
|
|
118 |
protected Action fActionTerminalDropDown; |
119 |
protected Action fActionTerminalPin; |
120 |
protected Action fActionTerminalRemove; |
121 |
|
111 |
protected boolean fMenuAboutToShow; |
122 |
protected boolean fMenuAboutToShow; |
112 |
|
123 |
|
113 |
private SettingsStore fStore; |
124 |
private SettingsStore fStore; |
114 |
|
125 |
|
115 |
private CommandInputFieldWithHistory fCommandInputField; |
126 |
private CommandInputFieldWithHistory fCommandInputField; |
116 |
|
127 |
|
|
|
128 |
private final TerminalViewConnectionManager fMultiConnectionManager=new TerminalViewConnectionManager(); |
117 |
/** |
129 |
/** |
118 |
* Listens to changes in the preferences |
130 |
* Listens to changes in the preferences |
119 |
*/ |
131 |
*/ |
Lines 126-134
Link Here
|
126 |
} |
138 |
} |
127 |
} |
139 |
} |
128 |
}; |
140 |
}; |
|
|
141 |
|
142 |
private PageBook fPageBook; |
143 |
|
144 |
private boolean fPinned=true; |
145 |
|
129 |
public TerminalView() { |
146 |
public TerminalView() { |
130 |
Logger |
147 |
Logger |
131 |
.log("==============================================================="); //$NON-NLS-1$ |
148 |
.log("==============================================================="); //$NON-NLS-1$ |
|
|
149 |
fMultiConnectionManager.addListener(this); |
132 |
} |
150 |
} |
133 |
|
151 |
|
134 |
String findUniqueTitle(String title) { |
152 |
String findUniqueTitle(String title) { |
Lines 189-214
Link Here
|
189 |
*/ |
207 |
*/ |
190 |
public void onTerminalNewTerminal() { |
208 |
public void onTerminalNewTerminal() { |
191 |
Logger.log("creating new Terminal instance."); //$NON-NLS-1$ |
209 |
Logger.log("creating new Terminal instance."); //$NON-NLS-1$ |
192 |
|
210 |
if(fPinned) { |
193 |
try { |
211 |
try { |
194 |
// The second argument to showView() is a unique String identifying the |
212 |
// The second argument to showView() is a unique String identifying the |
195 |
// secondary view instance. If it ever matches a previously used secondary |
213 |
// secondary view instance. If it ever matches a previously used secondary |
196 |
// view identifier, then this call will not create a new Terminal view, |
214 |
// view identifier, then this call will not create a new Terminal view, |
197 |
// which is undesirable. Therefore, we append the current time in |
215 |
// which is undesirable. Therefore, we append the current time in |
198 |
// milliseconds to the secondary view identifier to ensure it is always |
216 |
// milliseconds to the secondary view identifier to ensure it is always |
199 |
// unique. This code runs only when the user clicks the New Terminal |
217 |
// 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 |
218 |
// button, so there is no risk that this code will run twice in a single |
201 |
// millisecond. |
219 |
// millisecond. |
202 |
|
220 |
|
203 |
getSite().getPage().showView( |
221 |
getSite().getPage().showView( |
204 |
"org.eclipse.tm.terminal.view.TerminalView",//$NON-NLS-1$ |
222 |
"org.eclipse.tm.terminal.view.TerminalView",//$NON-NLS-1$ |
205 |
"SecondaryTerminal" + System.currentTimeMillis(), //$NON-NLS-1$ |
223 |
"SecondaryTerminal" + System.currentTimeMillis(), //$NON-NLS-1$ |
206 |
IWorkbenchPage.VIEW_ACTIVATE); |
224 |
IWorkbenchPage.VIEW_ACTIVATE); |
207 |
} catch (PartInitException ex) { |
225 |
} catch (PartInitException ex) { |
208 |
Logger.logException(ex); |
226 |
Logger.logException(ex); |
|
|
227 |
} |
228 |
} else { |
229 |
setupControls(); |
230 |
onTerminalSettings(); |
209 |
} |
231 |
} |
210 |
} |
232 |
} |
211 |
|
233 |
|
|
|
234 |
|
212 |
public void onTerminalConnect() { |
235 |
public void onTerminalConnect() { |
213 |
//if (isConnected()) |
236 |
//if (isConnected()) |
214 |
if (fCtlTerminal.getState()!=TerminalState.CLOSED) |
237 |
if (fCtlTerminal.getState()!=TerminalState.CLOSED) |
Lines 363-369
Link Here
|
363 |
// sequence. |
386 |
// sequence. |
364 |
|
387 |
|
365 |
setPartName(findUniqueTitle(ViewMessages.PROP_TITLE)); |
388 |
setPartName(findUniqueTitle(ViewMessages.PROP_TITLE)); |
366 |
setupControls(wndParent); |
389 |
fPageBook=new PageBook(wndParent,SWT.NONE); |
|
|
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 |
if(fMultiConnectionManager.size()==0) { |
398 |
setupControls(); |
399 |
fPageBook.showPage(fCtlTerminal.getRootControl()); |
400 |
} |
367 |
setupActions(); |
401 |
setupActions(); |
368 |
setupLocalToolBars(); |
402 |
setupLocalToolBars(); |
369 |
setupContextMenus(); |
403 |
setupContextMenus(); |
Lines 393-402
Link Here
|
393 |
/** |
427 |
/** |
394 |
* This method creates the top-level control for the Terminal view. |
428 |
* This method creates the top-level control for the Terminal view. |
395 |
*/ |
429 |
*/ |
396 |
protected void setupControls(Composite wndParent) { |
430 |
protected void setupControls() { |
397 |
ITerminalConnector[] connectors = makeConnectors(); |
431 |
ITerminalViewConnection conn = makeViewConnection(); |
398 |
fCtlTerminal = TerminalViewControlFactory.makeControl(this, wndParent, connectors); |
432 |
fMultiConnectionManager.addConnection(conn); |
|
|
433 |
fMultiConnectionManager.setConnection(conn); |
434 |
} |
399 |
|
435 |
|
|
|
436 |
private ITerminalViewConnection makeViewConnection() { |
437 |
ITerminalConnector[] connectors = makeConnectors(); |
438 |
fCtlTerminal = TerminalViewControlFactory.makeControl(this, fPageBook, connectors); |
439 |
ITerminalViewConnection conn = new TerminalViewConnection(fCtlTerminal); |
400 |
String connectionType=fStore.get(STORE_CONNECTION_TYPE); |
440 |
String connectionType=fStore.get(STORE_CONNECTION_TYPE); |
401 |
for (int i = 0; i < connectors.length; i++) { |
441 |
for (int i = 0; i < connectors.length; i++) { |
402 |
connectors[i].load(getStore(connectors[i])); |
442 |
connectors[i].load(getStore(connectors[i])); |
Lines 411-416
Link Here
|
411 |
String title=fStore.get(STORE_TITLE); |
451 |
String title=fStore.get(STORE_TITLE); |
412 |
if(title!=null && title.length()>0) |
452 |
if(title!=null && title.length()>0) |
413 |
setPartName(title); |
453 |
setPartName(title); |
|
|
454 |
return conn; |
414 |
} |
455 |
} |
415 |
|
456 |
|
416 |
/** |
457 |
/** |
Lines 443-448
Link Here
|
443 |
fStore.put(STORE_HAS_COMMAND_INPUT_FIELD,hasCommandInputField()?"true":"false"); //$NON-NLS-1$//$NON-NLS-2$ |
484 |
fStore.put(STORE_HAS_COMMAND_INPUT_FIELD,hasCommandInputField()?"true":"false"); //$NON-NLS-1$//$NON-NLS-2$ |
444 |
fStore.put(STORE_SETTING_SUMMARY, getSettingsSummary()); |
485 |
fStore.put(STORE_SETTING_SUMMARY, getSettingsSummary()); |
445 |
fStore.put(STORE_TITLE,getPartName()); |
486 |
fStore.put(STORE_TITLE,getPartName()); |
|
|
487 |
fMultiConnectionManager.saveState(new SettingStorePrefixDecorator(fStore,"connectionManager")); //$NON-NLS-1$ |
446 |
fStore.saveState(memento); |
488 |
fStore.saveState(memento); |
447 |
} |
489 |
} |
448 |
private ISettingsStore getStore(ITerminalConnector connector) { |
490 |
private ISettingsStore getStore(ITerminalConnector connector) { |
Lines 450-455
Link Here
|
450 |
} |
492 |
} |
451 |
|
493 |
|
452 |
protected void setupActions() { |
494 |
protected void setupActions() { |
|
|
495 |
fActionTerminalDropDown = new TerminalActionSelectionDropDown(fMultiConnectionManager); |
496 |
fActionTerminalPin=new TerminalActionPin(this); |
497 |
fActionTerminalPin.setChecked(isPinned()); |
498 |
fActionTerminalRemove=new TerminalActionRemove(fMultiConnectionManager); |
453 |
fActionTerminalNewTerminal = new TerminalActionNewTerminal(this); |
499 |
fActionTerminalNewTerminal = new TerminalActionNewTerminal(this); |
454 |
// fActionTerminalScrollLock = new TerminalActionScrollLock(this); |
500 |
// fActionTerminalScrollLock = new TerminalActionScrollLock(this); |
455 |
fActionTerminalConnect = new TerminalActionConnect(this); |
501 |
fActionTerminalConnect = new TerminalActionConnect(this); |
Lines 465-476
Link Here
|
465 |
protected void setupLocalToolBars() { |
511 |
protected void setupLocalToolBars() { |
466 |
IToolBarManager toolBarMgr = getViewSite().getActionBars().getToolBarManager(); |
512 |
IToolBarManager toolBarMgr = getViewSite().getActionBars().getToolBarManager(); |
467 |
|
513 |
|
468 |
toolBarMgr.add(fActionTerminalNewTerminal); |
514 |
toolBarMgr.add(fActionTerminalRemove); |
469 |
// toolBarMgr.add(fActionTerminalScrollLock); |
515 |
// toolBarMgr.add(fActionTerminalScrollLock); |
470 |
toolBarMgr.add(fActionTerminalConnect); |
516 |
toolBarMgr.add(fActionTerminalConnect); |
471 |
toolBarMgr.add(fActionTerminalDisconnect); |
517 |
toolBarMgr.add(fActionTerminalDisconnect); |
472 |
toolBarMgr.add(fActionTerminalSettings); |
518 |
toolBarMgr.add(fActionTerminalSettings); |
473 |
toolBarMgr.add(fActionToggleCommandInputField); |
519 |
toolBarMgr.add(fActionToggleCommandInputField); |
|
|
520 |
toolBarMgr.add(new Separator("fixedGroup")); //$NON-NLS-1$ |
521 |
toolBarMgr.add(fActionTerminalPin); |
522 |
toolBarMgr.add(fActionTerminalDropDown); |
523 |
toolBarMgr.add(fActionTerminalNewTerminal); |
474 |
} |
524 |
} |
475 |
|
525 |
|
476 |
protected void setupContextMenus() { |
526 |
protected void setupContextMenus() { |
Lines 561-564
Link Here
|
561 |
public void setScrollLock(boolean on) { |
611 |
public void setScrollLock(boolean on) { |
562 |
fCtlTerminal.setScrollLock(on); |
612 |
fCtlTerminal.setScrollLock(on); |
563 |
} |
613 |
} |
|
|
614 |
|
615 |
public void connectionsChanged() { |
616 |
if(fMultiConnectionManager.getCurrentConnection()!=null) { |
617 |
ITerminalViewControl ctrl = fMultiConnectionManager.getCurrentConnection().getCtlTerminal(); |
618 |
if(fCtlTerminal!=ctrl) { |
619 |
fCtlTerminal=ctrl; |
620 |
fPageBook.showPage(fCtlTerminal.getRootControl()); |
621 |
updateStatus(); |
622 |
onTerminalStatus(); |
623 |
} |
624 |
} |
625 |
|
626 |
} |
627 |
|
628 |
public void setPinned(boolean pinned) { |
629 |
fPinned=pinned; |
630 |
} |
631 |
private boolean isPinned() { |
632 |
return fPinned; |
633 |
} |
564 |
} |
634 |
} |