mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-15 13:05:22 +02:00
[244437] Moved ITerminalListener implementation to separate inner class.
This commit is contained in:
parent
de1312524d
commit
5de65b0325
1 changed files with 285 additions and 266 deletions
|
@ -18,6 +18,7 @@
|
|||
* Yu-Fen Kuo (MontaVista) - [227572] RSE Terminal doesn't reset the "connected" state when the shell exits
|
||||
* Martin Oberhuber (Wind River) - [227571] RSE Terminal should honor Encoding set on the IHost
|
||||
* Michael Scharf (Wind River) - [236203] [rseterminal] Potentially UI blocking code in TerminalViewTab.createTabItem
|
||||
* Anna Dushistova (MontaVista) - [244437] [rseterminal] Possible race condition when multiple Terminals are launched after each other
|
||||
********************************************************************************/
|
||||
package org.eclipse.rse.internal.terminals.ui.views;
|
||||
|
||||
|
@ -64,12 +65,16 @@ import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
|||
/**
|
||||
* This is the desktop view wrapper of the System View viewer.
|
||||
*/
|
||||
public class TerminalViewTab extends Composite implements ITerminalListener{
|
||||
public class TerminalViewTab extends Composite {
|
||||
|
||||
public static String DATA_KEY_CONTROL = "$_control_$"; //$NON-NLS-1$
|
||||
|
||||
private final CTabFolder tabFolder;
|
||||
|
||||
private Menu menu;
|
||||
|
||||
private boolean fMenuAboutToShow;
|
||||
|
||||
private TerminalActionCopy fActionEditCopy;
|
||||
|
||||
private TerminalActionCut fActionEditCut;
|
||||
|
@ -79,7 +84,7 @@ public class TerminalViewTab extends Composite implements ITerminalListener{
|
|||
private TerminalActionClearAll fActionEditClearAll;
|
||||
|
||||
private TerminalActionSelectAll fActionEditSelectAll;
|
||||
private String fInitialWorkingDirCmd;
|
||||
|
||||
private ITerminalViewControl fTerminalControl;
|
||||
|
||||
protected class TerminalContextMenuHandler implements MenuListener,
|
||||
|
@ -90,7 +95,7 @@ public class TerminalViewTab extends Composite implements ITerminalListener{
|
|||
}
|
||||
|
||||
public void menuShown(MenuEvent e) {
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
public void menuAboutToShow(IMenuManager menuMgr) {
|
||||
|
@ -180,8 +185,8 @@ public class TerminalViewTab extends Composite implements ITerminalListener{
|
|||
}
|
||||
}
|
||||
|
||||
public CTabItem createTabItem(IAdaptable root, String initialWorkingDirCmd) {
|
||||
fInitialWorkingDirCmd = initialWorkingDirCmd;
|
||||
public CTabItem createTabItem(IAdaptable root,
|
||||
final String initialWorkingDirCmd) {
|
||||
CTabItem item = new CTabItem(tabFolder, SWT.CLOSE);
|
||||
setTabTitle(root, item);
|
||||
|
||||
|
@ -194,9 +199,54 @@ public class TerminalViewTab extends Composite implements ITerminalListener{
|
|||
IHost host = (IHost) root;
|
||||
|
||||
ITerminalConnector connector = new RSETerminalConnector(host);
|
||||
fTerminalControl = TerminalViewControlFactory
|
||||
.makeControl(this, c,
|
||||
new ITerminalConnector[] { connector });
|
||||
fTerminalControl = TerminalViewControlFactory.makeControl(
|
||||
new ITerminalListener() {
|
||||
|
||||
public void setState(final TerminalState state) {
|
||||
if (state == TerminalState.CLOSED
|
||||
|| state == TerminalState.CONNECTED) {
|
||||
Display.getDefault().asyncExec(new Runnable() {
|
||||
public void run() {
|
||||
CTabItem item = tabFolder
|
||||
.getSelection();
|
||||
if (item != null && !item.isDisposed()) {
|
||||
Object data = item.getData();
|
||||
if (data instanceof IHost) {
|
||||
IHost host = (IHost) data;
|
||||
final ITerminalServiceSubSystem terminalServiceSubSystem = TerminalServiceHelper
|
||||
.getTerminalSubSystem(host);
|
||||
|
||||
if (state == TerminalState.CONNECTED)
|
||||
TerminalServiceHelper
|
||||
.updateTerminalShellForTerminalElement(item);
|
||||
|
||||
setTabImage(host, item);
|
||||
ISystemRegistry registry = RSECorePlugin
|
||||
.getTheSystemRegistry();
|
||||
registry
|
||||
.fireEvent(new SystemResourceChangeEvent(
|
||||
terminalServiceSubSystem,
|
||||
ISystemResourceChangeEvents.EVENT_REFRESH,
|
||||
terminalServiceSubSystem));
|
||||
}
|
||||
}
|
||||
if (state == TerminalState.CONNECTED) {
|
||||
if (initialWorkingDirCmd != null) {
|
||||
fTerminalControl
|
||||
.pasteString(initialWorkingDirCmd);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setTerminalTitle(String title) {
|
||||
|
||||
}
|
||||
}, c, new ITerminalConnector[] { connector });
|
||||
// Specify Encoding for Terminal
|
||||
try {
|
||||
fTerminalControl.setEncoding(host.getDefaultEncoding(true));
|
||||
|
@ -236,27 +286,27 @@ public class TerminalViewTab extends Composite implements ITerminalListener{
|
|||
}
|
||||
|
||||
protected void setupActions() {
|
||||
fActionEditCopy = new TerminalActionCopy(){
|
||||
fActionEditCopy = new TerminalActionCopy() {
|
||||
protected ITerminalViewControl getTarget() {
|
||||
return getCurrentTerminalViewControl();
|
||||
}
|
||||
};
|
||||
fActionEditCut = new TerminalActionCut(){
|
||||
fActionEditCut = new TerminalActionCut() {
|
||||
protected ITerminalViewControl getTarget() {
|
||||
return getCurrentTerminalViewControl();
|
||||
}
|
||||
};
|
||||
fActionEditPaste = new TerminalActionPaste(){
|
||||
fActionEditPaste = new TerminalActionPaste() {
|
||||
protected ITerminalViewControl getTarget() {
|
||||
return getCurrentTerminalViewControl();
|
||||
}
|
||||
};
|
||||
fActionEditClearAll = new TerminalActionClearAll(){
|
||||
fActionEditClearAll = new TerminalActionClearAll() {
|
||||
protected ITerminalViewControl getTarget() {
|
||||
return getCurrentTerminalViewControl();
|
||||
}
|
||||
};
|
||||
fActionEditSelectAll = new TerminalActionSelectAll(){
|
||||
fActionEditSelectAll = new TerminalActionSelectAll() {
|
||||
protected ITerminalViewControl getTarget() {
|
||||
return getCurrentTerminalViewControl();
|
||||
}
|
||||
|
@ -300,16 +350,22 @@ public class TerminalViewTab extends Composite implements ITerminalListener{
|
|||
setTabImage(root, titem);
|
||||
}
|
||||
}
|
||||
|
||||
private void setTabImage(IAdaptable root, CTabItem titem) {
|
||||
ISystemViewElementAdapter va = (ISystemViewElementAdapter) root
|
||||
.getAdapter(ISystemViewElementAdapter.class);
|
||||
if (va != null) {
|
||||
if (root instanceof IHost){
|
||||
ITerminalServiceSubSystem terminalServiceSubSystem = TerminalServiceHelper.getTerminalSubSystem((IHost)root);
|
||||
TerminalElement element = terminalServiceSubSystem.getChild(titem.getText());
|
||||
if (element != null){
|
||||
va = (ISystemViewElementAdapter) element.getAdapter(ISystemViewElementAdapter.class);
|
||||
titem.setImage(va.getImageDescriptor(element).createImage());
|
||||
if (root instanceof IHost) {
|
||||
ITerminalServiceSubSystem terminalServiceSubSystem = TerminalServiceHelper
|
||||
.getTerminalSubSystem((IHost) root);
|
||||
TerminalElement element = terminalServiceSubSystem
|
||||
.getChild(titem.getText());
|
||||
if (element != null) {
|
||||
va = (ISystemViewElementAdapter) element
|
||||
.getAdapter(ISystemViewElementAdapter.class);
|
||||
titem
|
||||
.setImage(va.getImageDescriptor(element)
|
||||
.createImage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -317,43 +373,6 @@ public class TerminalViewTab extends Composite implements ITerminalListener{
|
|||
titem.setImage(va.getImageDescriptor(root).createImage());
|
||||
}
|
||||
}
|
||||
public void setState(final TerminalState state) {
|
||||
if (state == TerminalState.CLOSED || state == TerminalState.CONNECTED){
|
||||
Display.getDefault().asyncExec(new Runnable(){
|
||||
public void run() {
|
||||
CTabItem item = tabFolder.getSelection();
|
||||
if (item != null && !item.isDisposed()){
|
||||
Object data = item.getData();
|
||||
if (data instanceof IHost){
|
||||
IHost host = (IHost)data;
|
||||
final ITerminalServiceSubSystem terminalServiceSubSystem = TerminalServiceHelper.getTerminalSubSystem(host);
|
||||
|
||||
if (state == TerminalState.CONNECTED)
|
||||
TerminalServiceHelper.updateTerminalShellForTerminalElement(item);
|
||||
|
||||
setTabImage(host, item);
|
||||
ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry();
|
||||
registry.fireEvent(new SystemResourceChangeEvent(terminalServiceSubSystem,
|
||||
ISystemResourceChangeEvents.EVENT_REFRESH, terminalServiceSubSystem));
|
||||
}
|
||||
}
|
||||
if(state == TerminalState.CONNECTED) {
|
||||
if(fInitialWorkingDirCmd != null) {
|
||||
fTerminalControl.pasteString(fInitialWorkingDirCmd);
|
||||
fInitialWorkingDirCmd = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setTerminalTitle(String title) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
private void updateWithUniqueTitle(String title, CTabItem currentItem) {
|
||||
CTabItem[] items = tabFolder.getItems();
|
||||
|
|
Loading…
Add table
Reference in a new issue