mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 07:05:24 +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,324 +65,342 @@ 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;
|
||||
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;
|
||||
private TerminalActionCut fActionEditCut;
|
||||
|
||||
private TerminalActionPaste fActionEditPaste;
|
||||
private TerminalActionPaste fActionEditPaste;
|
||||
|
||||
private TerminalActionClearAll fActionEditClearAll;
|
||||
private TerminalActionClearAll fActionEditClearAll;
|
||||
|
||||
private TerminalActionSelectAll fActionEditSelectAll;
|
||||
|
||||
private TerminalActionSelectAll fActionEditSelectAll;
|
||||
private String fInitialWorkingDirCmd;
|
||||
private ITerminalViewControl fTerminalControl;
|
||||
|
||||
protected class TerminalContextMenuHandler implements MenuListener,
|
||||
IMenuListener {
|
||||
public void menuHidden(MenuEvent event) {
|
||||
fMenuAboutToShow = false;
|
||||
fActionEditCopy.updateAction(fMenuAboutToShow);
|
||||
}
|
||||
protected class TerminalContextMenuHandler implements MenuListener,
|
||||
IMenuListener {
|
||||
public void menuHidden(MenuEvent event) {
|
||||
fMenuAboutToShow = false;
|
||||
fActionEditCopy.updateAction(fMenuAboutToShow);
|
||||
}
|
||||
|
||||
public void menuShown(MenuEvent e) {
|
||||
//
|
||||
}
|
||||
public void menuShown(MenuEvent e) {
|
||||
|
||||
public void menuAboutToShow(IMenuManager menuMgr) {
|
||||
fMenuAboutToShow = true;
|
||||
}
|
||||
|
||||
public void menuAboutToShow(IMenuManager menuMgr) {
|
||||
fMenuAboutToShow = true;
|
||||
fActionEditCopy.updateAction(fMenuAboutToShow);
|
||||
fActionEditCut.updateAction(fMenuAboutToShow);
|
||||
fActionEditSelectAll.updateAction(fMenuAboutToShow);
|
||||
fActionEditPaste.updateAction(fMenuAboutToShow);
|
||||
fActionEditClearAll.updateAction(fMenuAboutToShow);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TerminalViewTab(final Composite parent, TerminalViewer viewer) {
|
||||
super(parent, SWT.NONE);
|
||||
tabFolder = new CTabFolder(this, SWT.NONE);
|
||||
tabFolder.setLayout(new FillLayout());
|
||||
tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
setLayout(new FillLayout());
|
||||
tabFolder.setBackground(parent.getBackground());
|
||||
tabFolder.setSimple(false);
|
||||
tabFolder.setUnselectedImageVisible(false);
|
||||
tabFolder.setUnselectedCloseVisible(false);
|
||||
public TerminalViewTab(final Composite parent, TerminalViewer viewer) {
|
||||
super(parent, SWT.NONE);
|
||||
tabFolder = new CTabFolder(this, SWT.NONE);
|
||||
tabFolder.setLayout(new FillLayout());
|
||||
tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
setLayout(new FillLayout());
|
||||
tabFolder.setBackground(parent.getBackground());
|
||||
tabFolder.setSimple(false);
|
||||
tabFolder.setUnselectedImageVisible(false);
|
||||
tabFolder.setUnselectedCloseVisible(false);
|
||||
|
||||
tabFolder.setMinimizeVisible(false);
|
||||
tabFolder.setMaximizeVisible(false);
|
||||
setupActions();
|
||||
}
|
||||
tabFolder.setMinimizeVisible(false);
|
||||
tabFolder.setMaximizeVisible(false);
|
||||
setupActions();
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
if (!tabFolder.isDisposed()) {
|
||||
tabFolder.dispose();
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
public void dispose() {
|
||||
if (!tabFolder.isDisposed()) {
|
||||
tabFolder.dispose();
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
public CTabFolder getFolder() {
|
||||
return tabFolder;
|
||||
}
|
||||
public CTabFolder getFolder() {
|
||||
return tabFolder;
|
||||
}
|
||||
|
||||
public void remove(Object root) {
|
||||
public void remove(Object root) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public CTabItem getSelectedTab() {
|
||||
if (tabFolder.getItemCount() > 0) {
|
||||
int index = tabFolder.getSelectionIndex();
|
||||
CTabItem item = tabFolder.getItem(index);
|
||||
return item;
|
||||
}
|
||||
public CTabItem getSelectedTab() {
|
||||
if (tabFolder.getItemCount() > 0) {
|
||||
int index = tabFolder.getSelectionIndex();
|
||||
CTabItem item = tabFolder.getItem(index);
|
||||
return item;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void showCurrentPage() {
|
||||
tabFolder.setFocus();
|
||||
}
|
||||
public void showCurrentPage() {
|
||||
tabFolder.setFocus();
|
||||
}
|
||||
|
||||
public void showPageFor(Object root) {
|
||||
for (int i = 0; i < tabFolder.getItemCount(); i++) {
|
||||
CTabItem item = tabFolder.getItem(i);
|
||||
if (item.getData() == root) {
|
||||
tabFolder.setSelection(item);
|
||||
}
|
||||
public void showPageFor(Object root) {
|
||||
for (int i = 0; i < tabFolder.getItemCount(); i++) {
|
||||
CTabItem item = tabFolder.getItem(i);
|
||||
if (item.getData() == root) {
|
||||
tabFolder.setSelection(item);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void showPageFor(String tabName) {
|
||||
for (int i = 0; i < tabFolder.getItemCount(); i++) {
|
||||
CTabItem item = tabFolder.getItem(i);
|
||||
if (item.getText().equals(tabName)) {
|
||||
tabFolder.setSelection(item);
|
||||
return;
|
||||
}
|
||||
public void showPageFor(String tabName) {
|
||||
for (int i = 0; i < tabFolder.getItemCount(); i++) {
|
||||
CTabItem item = tabFolder.getItem(i);
|
||||
if (item.getText().equals(tabName)) {
|
||||
tabFolder.setSelection(item);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void disposePageFor(String tabName) {
|
||||
for (int i = 0; i < tabFolder.getItemCount(); i++) {
|
||||
CTabItem item = tabFolder.getItem(i);
|
||||
if (item.getText().equals(tabName)) {
|
||||
item.dispose();
|
||||
return;
|
||||
}
|
||||
public void disposePageFor(String tabName) {
|
||||
for (int i = 0; i < tabFolder.getItemCount(); i++) {
|
||||
CTabItem item = tabFolder.getItem(i);
|
||||
if (item.getText().equals(tabName)) {
|
||||
item.dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public CTabItem createTabItem(IAdaptable root, String initialWorkingDirCmd) {
|
||||
fInitialWorkingDirCmd = initialWorkingDirCmd;
|
||||
CTabItem item = new CTabItem(tabFolder, SWT.CLOSE);
|
||||
setTabTitle(root, item);
|
||||
}
|
||||
}
|
||||
|
||||
item.setData(root);
|
||||
Composite c = new Composite(tabFolder, SWT.NONE);
|
||||
c.setLayout(new FillLayout());
|
||||
public CTabItem createTabItem(IAdaptable root,
|
||||
final String initialWorkingDirCmd) {
|
||||
CTabItem item = new CTabItem(tabFolder, SWT.CLOSE);
|
||||
setTabTitle(root, item);
|
||||
|
||||
tabFolder.getParent().layout(true);
|
||||
if (root instanceof IHost) {
|
||||
IHost host = (IHost) root;
|
||||
item.setData(root);
|
||||
Composite c = new Composite(tabFolder, SWT.NONE);
|
||||
c.setLayout(new FillLayout());
|
||||
|
||||
ITerminalConnector connector = new RSETerminalConnector(host);
|
||||
fTerminalControl = TerminalViewControlFactory
|
||||
.makeControl(this, c,
|
||||
new ITerminalConnector[] { connector });
|
||||
tabFolder.getParent().layout(true);
|
||||
if (root instanceof IHost) {
|
||||
IHost host = (IHost) root;
|
||||
|
||||
ITerminalConnector connector = new RSETerminalConnector(host);
|
||||
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));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
/* ignore and allow fallback to default encoding */
|
||||
}
|
||||
fTerminalControl.setConnector(connector);
|
||||
fTerminalControl.connectTerminal();
|
||||
item.setData(DATA_KEY_CONTROL, fTerminalControl);
|
||||
}
|
||||
item.setControl(c);
|
||||
tabFolder.setSelection(item);
|
||||
item.addDisposeListener(new DisposeListener() {
|
||||
fTerminalControl.setConnector(connector);
|
||||
fTerminalControl.connectTerminal();
|
||||
item.setData(DATA_KEY_CONTROL, fTerminalControl);
|
||||
}
|
||||
item.setControl(c);
|
||||
tabFolder.setSelection(item);
|
||||
item.addDisposeListener(new DisposeListener() {
|
||||
|
||||
public void widgetDisposed(DisposeEvent e) {
|
||||
Object source = e.getSource();
|
||||
if (source instanceof CTabItem) {
|
||||
CTabItem currentItem = (CTabItem) source;
|
||||
Object data = currentItem.getData(DATA_KEY_CONTROL);
|
||||
if (data instanceof ITerminalViewControl) {
|
||||
((ITerminalViewControl) data).disposeTerminal();
|
||||
}
|
||||
data = currentItem.getData();
|
||||
if (data instanceof IHost) {
|
||||
TerminalServiceHelper.removeTerminalElementFromHost(
|
||||
currentItem, (IHost) data);
|
||||
}
|
||||
}
|
||||
public void widgetDisposed(DisposeEvent e) {
|
||||
Object source = e.getSource();
|
||||
if (source instanceof CTabItem) {
|
||||
CTabItem currentItem = (CTabItem) source;
|
||||
Object data = currentItem.getData(DATA_KEY_CONTROL);
|
||||
if (data instanceof ITerminalViewControl) {
|
||||
((ITerminalViewControl) data).disposeTerminal();
|
||||
}
|
||||
data = currentItem.getData();
|
||||
if (data instanceof IHost) {
|
||||
TerminalServiceHelper.removeTerminalElementFromHost(
|
||||
currentItem, (IHost) data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
setupContextMenus();
|
||||
return item;
|
||||
setupContextMenus();
|
||||
return item;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void setupActions() {
|
||||
fActionEditCopy = new TerminalActionCopy(){
|
||||
protected ITerminalViewControl getTarget() {
|
||||
return getCurrentTerminalViewControl();
|
||||
}
|
||||
};
|
||||
fActionEditCut = new TerminalActionCut(){
|
||||
protected ITerminalViewControl getTarget() {
|
||||
return getCurrentTerminalViewControl();
|
||||
}
|
||||
};
|
||||
fActionEditPaste = new TerminalActionPaste(){
|
||||
protected ITerminalViewControl getTarget() {
|
||||
return getCurrentTerminalViewControl();
|
||||
}
|
||||
};
|
||||
fActionEditClearAll = new TerminalActionClearAll(){
|
||||
protected ITerminalViewControl getTarget() {
|
||||
return getCurrentTerminalViewControl();
|
||||
}
|
||||
};
|
||||
fActionEditSelectAll = new TerminalActionSelectAll(){
|
||||
protected ITerminalViewControl getTarget() {
|
||||
return getCurrentTerminalViewControl();
|
||||
}
|
||||
};
|
||||
}
|
||||
protected void setupActions() {
|
||||
fActionEditCopy = new TerminalActionCopy() {
|
||||
protected ITerminalViewControl getTarget() {
|
||||
return getCurrentTerminalViewControl();
|
||||
}
|
||||
};
|
||||
fActionEditCut = new TerminalActionCut() {
|
||||
protected ITerminalViewControl getTarget() {
|
||||
return getCurrentTerminalViewControl();
|
||||
}
|
||||
};
|
||||
fActionEditPaste = new TerminalActionPaste() {
|
||||
protected ITerminalViewControl getTarget() {
|
||||
return getCurrentTerminalViewControl();
|
||||
}
|
||||
};
|
||||
fActionEditClearAll = new TerminalActionClearAll() {
|
||||
protected ITerminalViewControl getTarget() {
|
||||
return getCurrentTerminalViewControl();
|
||||
}
|
||||
};
|
||||
fActionEditSelectAll = new TerminalActionSelectAll() {
|
||||
protected ITerminalViewControl getTarget() {
|
||||
return getCurrentTerminalViewControl();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected void setupContextMenus() {
|
||||
ITerminalViewControl terminalViewControl = getCurrentTerminalViewControl();
|
||||
if (terminalViewControl == null)
|
||||
return;
|
||||
protected void setupContextMenus() {
|
||||
ITerminalViewControl terminalViewControl = getCurrentTerminalViewControl();
|
||||
if (terminalViewControl == null)
|
||||
return;
|
||||
|
||||
if (menu == null) {
|
||||
MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
|
||||
menu = menuMgr.createContextMenu(tabFolder);
|
||||
loadContextMenus(menuMgr);
|
||||
TerminalContextMenuHandler contextMenuHandler = new TerminalContextMenuHandler();
|
||||
menuMgr.addMenuListener(contextMenuHandler);
|
||||
menu.addMenuListener(contextMenuHandler);
|
||||
}
|
||||
Control ctlText = terminalViewControl.getControl();
|
||||
ctlText.setMenu(menu);
|
||||
}
|
||||
if (menu == null) {
|
||||
MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
|
||||
menu = menuMgr.createContextMenu(tabFolder);
|
||||
loadContextMenus(menuMgr);
|
||||
TerminalContextMenuHandler contextMenuHandler = new TerminalContextMenuHandler();
|
||||
menuMgr.addMenuListener(contextMenuHandler);
|
||||
menu.addMenuListener(contextMenuHandler);
|
||||
}
|
||||
Control ctlText = terminalViewControl.getControl();
|
||||
ctlText.setMenu(menu);
|
||||
}
|
||||
|
||||
protected void loadContextMenus(IMenuManager menuMgr) {
|
||||
menuMgr.add(fActionEditCopy);
|
||||
menuMgr.add(fActionEditPaste);
|
||||
menuMgr.add(new Separator());
|
||||
menuMgr.add(fActionEditClearAll);
|
||||
menuMgr.add(fActionEditSelectAll);
|
||||
menuMgr.add(new Separator());
|
||||
protected void loadContextMenus(IMenuManager menuMgr) {
|
||||
menuMgr.add(fActionEditCopy);
|
||||
menuMgr.add(fActionEditPaste);
|
||||
menuMgr.add(new Separator());
|
||||
menuMgr.add(fActionEditClearAll);
|
||||
menuMgr.add(fActionEditSelectAll);
|
||||
menuMgr.add(new Separator());
|
||||
|
||||
// Other plug-ins can contribute there actions here
|
||||
menuMgr.add(new Separator("Additions")); //$NON-NLS-1$
|
||||
}
|
||||
// Other plug-ins can contribute there actions here
|
||||
menuMgr.add(new Separator("Additions")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
private void setTabTitle(IAdaptable root, CTabItem titem) {
|
||||
ISystemViewElementAdapter va = (ISystemViewElementAdapter) root
|
||||
.getAdapter(ISystemViewElementAdapter.class);
|
||||
if (va != null) {
|
||||
updateWithUniqueTitle(va.getName(root), titem);
|
||||
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());
|
||||
return;
|
||||
}
|
||||
}
|
||||
private void setTabTitle(IAdaptable root, CTabItem titem) {
|
||||
ISystemViewElementAdapter va = (ISystemViewElementAdapter) root
|
||||
.getAdapter(ISystemViewElementAdapter.class);
|
||||
if (va != null) {
|
||||
updateWithUniqueTitle(va.getName(root), titem);
|
||||
setTabImage(root, titem);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
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());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (state == TerminalState.CONNECTED)
|
||||
TerminalServiceHelper.updateTerminalShellForTerminalElement(item);
|
||||
titem.setImage(va.getImageDescriptor(root).createImage());
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
private void updateWithUniqueTitle(String title, CTabItem currentItem) {
|
||||
CTabItem[] items = tabFolder.getItems();
|
||||
int increment = 1;
|
||||
String temp = title;
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (items[i] != currentItem) {
|
||||
String name = items[i].getText();
|
||||
if (name != null) {
|
||||
if (name.equals(temp)) {
|
||||
temp = title + " " + increment++; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
currentItem.setText(temp);
|
||||
}
|
||||
|
||||
public void setTerminalTitle(String title) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
private void updateWithUniqueTitle(String title, CTabItem currentItem) {
|
||||
CTabItem[] items = tabFolder.getItems();
|
||||
int increment = 1;
|
||||
String temp = title;
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (items[i] != currentItem) {
|
||||
String name = items[i].getText();
|
||||
if (name != null) {
|
||||
if (name.equals(temp)) {
|
||||
temp = title + " " + increment++; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
currentItem.setText(temp);
|
||||
}
|
||||
|
||||
private ITerminalViewControl getCurrentTerminalViewControl() {
|
||||
if (tabFolder != null && !tabFolder.isDisposed()) {
|
||||
CTabItem item = tabFolder.getSelection();
|
||||
if (item != null && !item.isDisposed()) {
|
||||
Object data = item.getData(DATA_KEY_CONTROL);
|
||||
if (data instanceof ITerminalViewControl)
|
||||
return ((ITerminalViewControl) data);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private ITerminalViewControl getCurrentTerminalViewControl() {
|
||||
if (tabFolder != null && !tabFolder.isDisposed()) {
|
||||
CTabItem item = tabFolder.getSelection();
|
||||
if (item != null && !item.isDisposed()) {
|
||||
Object data = item.getData(DATA_KEY_CONTROL);
|
||||
if (data instanceof ITerminalViewControl)
|
||||
return ((ITerminalViewControl) data);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue