mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-15 21:15:23 +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
|
* 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
|
* 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
|
* 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;
|
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.
|
* 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$
|
public static String DATA_KEY_CONTROL = "$_control_$"; //$NON-NLS-1$
|
||||||
|
|
||||||
private final CTabFolder tabFolder;
|
private final CTabFolder tabFolder;
|
||||||
|
|
||||||
private Menu menu;
|
private Menu menu;
|
||||||
|
|
||||||
private boolean fMenuAboutToShow;
|
private boolean fMenuAboutToShow;
|
||||||
|
|
||||||
private TerminalActionCopy fActionEditCopy;
|
private TerminalActionCopy fActionEditCopy;
|
||||||
|
|
||||||
private TerminalActionCut fActionEditCut;
|
private TerminalActionCut fActionEditCut;
|
||||||
|
@ -79,7 +84,7 @@ public class TerminalViewTab extends Composite implements ITerminalListener{
|
||||||
private TerminalActionClearAll fActionEditClearAll;
|
private TerminalActionClearAll fActionEditClearAll;
|
||||||
|
|
||||||
private TerminalActionSelectAll fActionEditSelectAll;
|
private TerminalActionSelectAll fActionEditSelectAll;
|
||||||
private String fInitialWorkingDirCmd;
|
|
||||||
private ITerminalViewControl fTerminalControl;
|
private ITerminalViewControl fTerminalControl;
|
||||||
|
|
||||||
protected class TerminalContextMenuHandler implements MenuListener,
|
protected class TerminalContextMenuHandler implements MenuListener,
|
||||||
|
@ -90,7 +95,7 @@ public class TerminalViewTab extends Composite implements ITerminalListener{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void menuShown(MenuEvent e) {
|
public void menuShown(MenuEvent e) {
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void menuAboutToShow(IMenuManager menuMgr) {
|
public void menuAboutToShow(IMenuManager menuMgr) {
|
||||||
|
@ -180,8 +185,8 @@ public class TerminalViewTab extends Composite implements ITerminalListener{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CTabItem createTabItem(IAdaptable root, String initialWorkingDirCmd) {
|
public CTabItem createTabItem(IAdaptable root,
|
||||||
fInitialWorkingDirCmd = initialWorkingDirCmd;
|
final String initialWorkingDirCmd) {
|
||||||
CTabItem item = new CTabItem(tabFolder, SWT.CLOSE);
|
CTabItem item = new CTabItem(tabFolder, SWT.CLOSE);
|
||||||
setTabTitle(root, item);
|
setTabTitle(root, item);
|
||||||
|
|
||||||
|
@ -194,9 +199,54 @@ public class TerminalViewTab extends Composite implements ITerminalListener{
|
||||||
IHost host = (IHost) root;
|
IHost host = (IHost) root;
|
||||||
|
|
||||||
ITerminalConnector connector = new RSETerminalConnector(host);
|
ITerminalConnector connector = new RSETerminalConnector(host);
|
||||||
fTerminalControl = TerminalViewControlFactory
|
fTerminalControl = TerminalViewControlFactory.makeControl(
|
||||||
.makeControl(this, c,
|
new ITerminalListener() {
|
||||||
new ITerminalConnector[] { connector });
|
|
||||||
|
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
|
// Specify Encoding for Terminal
|
||||||
try {
|
try {
|
||||||
fTerminalControl.setEncoding(host.getDefaultEncoding(true));
|
fTerminalControl.setEncoding(host.getDefaultEncoding(true));
|
||||||
|
@ -300,16 +350,22 @@ public class TerminalViewTab extends Composite implements ITerminalListener{
|
||||||
setTabImage(root, titem);
|
setTabImage(root, titem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTabImage(IAdaptable root, CTabItem titem) {
|
private void setTabImage(IAdaptable root, CTabItem titem) {
|
||||||
ISystemViewElementAdapter va = (ISystemViewElementAdapter) root
|
ISystemViewElementAdapter va = (ISystemViewElementAdapter) root
|
||||||
.getAdapter(ISystemViewElementAdapter.class);
|
.getAdapter(ISystemViewElementAdapter.class);
|
||||||
if (va != null) {
|
if (va != null) {
|
||||||
if (root instanceof IHost) {
|
if (root instanceof IHost) {
|
||||||
ITerminalServiceSubSystem terminalServiceSubSystem = TerminalServiceHelper.getTerminalSubSystem((IHost)root);
|
ITerminalServiceSubSystem terminalServiceSubSystem = TerminalServiceHelper
|
||||||
TerminalElement element = terminalServiceSubSystem.getChild(titem.getText());
|
.getTerminalSubSystem((IHost) root);
|
||||||
|
TerminalElement element = terminalServiceSubSystem
|
||||||
|
.getChild(titem.getText());
|
||||||
if (element != null) {
|
if (element != null) {
|
||||||
va = (ISystemViewElementAdapter) element.getAdapter(ISystemViewElementAdapter.class);
|
va = (ISystemViewElementAdapter) element
|
||||||
titem.setImage(va.getImageDescriptor(element).createImage());
|
.getAdapter(ISystemViewElementAdapter.class);
|
||||||
|
titem
|
||||||
|
.setImage(va.getImageDescriptor(element)
|
||||||
|
.createImage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,43 +373,6 @@ public class TerminalViewTab extends Composite implements ITerminalListener{
|
||||||
titem.setImage(va.getImageDescriptor(root).createImage());
|
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) {
|
private void updateWithUniqueTitle(String title, CTabItem currentItem) {
|
||||||
CTabItem[] items = tabFolder.getItems();
|
CTabItem[] items = tabFolder.getItems();
|
||||||
|
|
Loading…
Add table
Reference in a new issue