mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-03 07:05:24 +02:00
bug 196456: [terminal] Multiple Terminal Instances should be distinguishable
https://bugs.eclipse.org/bugs/show_bug.cgi?id=196456
This commit is contained in:
parent
f87d3d8141
commit
37f90eb1eb
4 changed files with 80 additions and 7 deletions
|
@ -39,11 +39,13 @@ import org.eclipse.swt.widgets.Control;
|
|||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
|
||||
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnectorInfo;
|
||||
|
||||
class TerminalSettingsDlg extends Dialog {
|
||||
private Combo fCtlConnTypeCombo;
|
||||
private Text fTerminalTitleText;
|
||||
private final ITerminalConnectorInfo[] fConnectors;
|
||||
private final ISettingsPage[] fPages;
|
||||
/**
|
||||
|
@ -54,6 +56,7 @@ class TerminalSettingsDlg extends Dialog {
|
|||
private int fSelectedConnector;
|
||||
private PageBook fPageBook;
|
||||
private IDialogSettings fDialogSettings;
|
||||
private String fTerminalTitle;
|
||||
|
||||
public TerminalSettingsDlg(Shell shell, ITerminalConnectorInfo[] connectors, ITerminalConnectorInfo connector) {
|
||||
super(shell);
|
||||
|
@ -139,6 +142,7 @@ class TerminalSettingsDlg extends Dialog {
|
|||
if(fSelectedConnector>=0) {
|
||||
getPage(fSelectedConnector).saveSettings();
|
||||
}
|
||||
fTerminalTitle=fTerminalTitleText.getText();
|
||||
super.okPressed();
|
||||
}
|
||||
protected void cancelPressed() {
|
||||
|
@ -184,9 +188,29 @@ class TerminalSettingsDlg extends Dialog {
|
|||
return getPage(fSelectedConnector).validateSettings();
|
||||
}
|
||||
private void setupPanel(Composite wndParent) {
|
||||
setupSettingsTypePanel(wndParent);
|
||||
setupConnTypePanel(wndParent);
|
||||
setupSettingsGroup(wndParent);
|
||||
}
|
||||
private void setupSettingsTypePanel(Composite wndParent) {
|
||||
Group wndGroup;
|
||||
GridLayout gridLayout;
|
||||
|
||||
wndGroup = new Group(wndParent, SWT.NONE);
|
||||
gridLayout = new GridLayout(2, false);
|
||||
wndGroup.setLayout(gridLayout);
|
||||
wndGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
wndGroup.setText(ViewMessages.VIEW_SETTINGS);
|
||||
|
||||
|
||||
Label label=new Label(wndGroup,SWT.NONE);
|
||||
label.setText(ViewMessages.VIEW_TITLE);
|
||||
label.setLayoutData(new GridData(GridData.BEGINNING));
|
||||
|
||||
fTerminalTitleText = new Text(wndGroup, SWT.BORDER);
|
||||
fTerminalTitleText.setText(fTerminalTitle);
|
||||
fTerminalTitleText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
}
|
||||
private void setupConnTypePanel(Composite wndParent) {
|
||||
Group wndGroup;
|
||||
GridLayout gridLayout;
|
||||
|
@ -205,6 +229,7 @@ class TerminalSettingsDlg extends Dialog {
|
|||
gridData.widthHint = 200;
|
||||
fCtlConnTypeCombo.setLayoutData(gridData);
|
||||
}
|
||||
|
||||
private void setupSettingsGroup(Composite parent) {
|
||||
Group group = new Group(parent, SWT.NONE);
|
||||
group.setText(ViewMessages.SETTINGS + ":"); //$NON-NLS-1$
|
||||
|
@ -254,4 +279,11 @@ class TerminalSettingsDlg extends Dialog {
|
|||
}
|
||||
return fDialogSettings;
|
||||
}
|
||||
public void setTerminalTitle(String partName) {
|
||||
fTerminalTitle=partName;
|
||||
|
||||
}
|
||||
public String getTerminalTitle() {
|
||||
return fTerminalTitle;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.tm.internal.terminal.view;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.runtime.Preferences;
|
||||
import org.eclipse.jface.action.ActionContributionItem;
|
||||
import org.eclipse.jface.action.IMenuListener;
|
||||
|
@ -57,6 +60,7 @@ import org.eclipse.tm.internal.terminal.provisional.api.TerminalConnectorExtensi
|
|||
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
||||
import org.eclipse.ui.IActionBars;
|
||||
import org.eclipse.ui.IMemento;
|
||||
import org.eclipse.ui.IViewReference;
|
||||
import org.eclipse.ui.IViewSite;
|
||||
import org.eclipse.ui.IWorkbenchActionConstants;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
|
@ -74,6 +78,8 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
|
||||
private static final String STORE_COMMAND_INPUT_FIELD_HISTORY = "CommandInputFieldHistory"; //$NON-NLS-1$
|
||||
|
||||
private static final String STORE_TITLE = "Title"; //$NON-NLS-1$
|
||||
|
||||
public static final String FONT_DEFINITION = "terminal.views.view.font.definition"; //$NON-NLS-1$
|
||||
|
||||
protected ITerminalViewControl fCtlTerminal;
|
||||
|
@ -107,7 +113,7 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
private SettingsStore fStore;
|
||||
|
||||
private CommandInputFieldWithHistory fCommandInputField;
|
||||
|
||||
|
||||
/**
|
||||
* Listens to changes in the preferences
|
||||
*/
|
||||
|
@ -124,6 +130,32 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
Logger
|
||||
.log("==============================================================="); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
String findUniqueTitle(String title) {
|
||||
IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
|
||||
String id= getViewSite().getId();
|
||||
Set names=new HashSet();
|
||||
for (int i = 0; i < pages.length; i++) {
|
||||
IViewReference[] views = pages[i].getViewReferences();
|
||||
for (int j = 0; j < views.length; j++) {
|
||||
IViewReference view = views[j];
|
||||
// only look for views with the same ID
|
||||
if(id.equals(view.getId())) {
|
||||
String name=view.getTitle();
|
||||
if(name!=null)
|
||||
names.add(view.getPartName());
|
||||
}
|
||||
}
|
||||
}
|
||||
// find a unique name
|
||||
int i=1;
|
||||
String uniqueTitle=title;
|
||||
while(true) {
|
||||
if(!names.contains(uniqueTitle))
|
||||
return uniqueTitle;
|
||||
uniqueTitle=title+" "+i++; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Update the text limits from the preferences
|
||||
*/
|
||||
|
@ -226,7 +258,7 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
// persistent settings.
|
||||
|
||||
TerminalSettingsDlg dlgTerminalSettings = new TerminalSettingsDlg(getViewSite().getShell(),fCtlTerminal.getConnectors(),fCtlTerminal.getTerminalConnectorInfo());
|
||||
|
||||
dlgTerminalSettings.setTerminalTitle(getPartName());
|
||||
Logger.log("opening Settings dialog."); //$NON-NLS-1$
|
||||
|
||||
if (dlgTerminalSettings.open() == Window.CANCEL) {
|
||||
|
@ -239,6 +271,7 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
// When the settings dialog is closed, we persist the Terminal settings.
|
||||
|
||||
saveSettings(dlgTerminalSettings.getConnector());
|
||||
setPartName(dlgTerminalSettings.getTerminalTitle());
|
||||
return dlgTerminalSettings.getConnector();
|
||||
}
|
||||
|
||||
|
@ -285,6 +318,7 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
setContentDescription(strTitle);
|
||||
getViewSite().getActionBars().getStatusLineManager().setMessage(
|
||||
strTitle);
|
||||
setTitleToolTip(getPartName()+": "+strTitle); //$NON-NLS-1$
|
||||
}
|
||||
/**
|
||||
* @return the setting summary. If there is no connection, or the connection
|
||||
|
@ -388,8 +422,7 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
// Bind plugin.xml key bindings to this plugin. Overrides global Control-W key
|
||||
// sequence.
|
||||
|
||||
setPartName(ViewMessages.PROP_TITLE);
|
||||
|
||||
setPartName(findUniqueTitle(ViewMessages.PROP_TITLE));
|
||||
setupControls(wndParent);
|
||||
setupActions();
|
||||
setupMenus();
|
||||
|
@ -403,7 +436,6 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
public void dispose() {
|
||||
Logger.log("entered."); //$NON-NLS-1$
|
||||
|
||||
setPartName("Terminal"); //$NON-NLS-1$
|
||||
TerminalViewPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPreferenceListener);
|
||||
|
||||
JFaceResources.getFontRegistry().removeListener(fPropertyChangeHandler);
|
||||
|
@ -440,7 +472,11 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
setCommandInputField("true".equals(fStore.get(STORE_HAS_COMMAND_INPUT_FIELD))); //$NON-NLS-1$
|
||||
updatePreferences();
|
||||
TerminalViewPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPreferenceListener);
|
||||
|
||||
|
||||
// restore the title of this view
|
||||
String title=fStore.get(STORE_TITLE);
|
||||
if(title!=null && title.length()>0)
|
||||
setPartName(title);
|
||||
}
|
||||
|
||||
private void saveSettings(ITerminalConnectorInfo connector) {
|
||||
|
@ -464,6 +500,7 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi
|
|||
fStore.put(STORE_COMMAND_INPUT_FIELD_HISTORY, fCommandInputField.getHistory());
|
||||
fStore.put(STORE_HAS_COMMAND_INPUT_FIELD,hasCommandInputField()?"true":"false"); //$NON-NLS-1$//$NON-NLS-2$
|
||||
fStore.put(STORE_SETTING_SUMMARY, getSettingsSummary());
|
||||
fStore.put(STORE_TITLE,getPartName());
|
||||
fStore.saveState(memento);
|
||||
}
|
||||
private ISettingsStore getStore(ITerminalConnectorInfo connector) {
|
||||
|
|
|
@ -28,7 +28,9 @@ public class ViewMessages extends NLS {
|
|||
|
||||
public static String TERMINALSETTINGS;
|
||||
public static String CONNECTIONTYPE;
|
||||
|
||||
public static String VIEW_TITLE;
|
||||
public static String VIEW_SETTINGS;
|
||||
|
||||
public static String LIMITOUTPUT;
|
||||
public static String BUFFERLINES;
|
||||
public static String SERIALTIMEOUT;
|
||||
|
|
|
@ -20,6 +20,8 @@ SETTINGS = Settings
|
|||
|
||||
TERMINALSETTINGS = Terminal Settings
|
||||
CONNECTIONTYPE = Connection Type
|
||||
VIEW_TITLE = View Title:
|
||||
VIEW_SETTINGS = View Settings:
|
||||
|
||||
LIMITOUTPUT = Limit terminal output
|
||||
BUFFERLINES = Terminal buffer lines:
|
||||
|
|
Loading…
Add table
Reference in a new issue