mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 02:36:01 +02:00
Bug 309899 - New local terminal launch configurations should have reasonable default values
This commit is contained in:
parent
d0e0ec6893
commit
c143c839dd
6 changed files with 80 additions and 27 deletions
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<?eclipse version="3.3"?>
|
<?eclipse version="3.3"?>
|
||||||
<!--
|
<!--
|
||||||
# Copyright (c) 2008 Mirko Raner and others
|
# Copyright (c) 2008, 2010 Mirko Raner and others
|
||||||
# All rights reserved. This program and the accompanying materials
|
# All rights reserved. This program and the accompanying materials
|
||||||
# are made available under the terms of the Eclipse Public License v1.0
|
# are made available under the terms of the Eclipse Public License v1.0
|
||||||
# which accompanies this distribution, and is available at
|
# which accompanies this distribution, and is available at
|
||||||
|
@ -37,6 +37,7 @@
|
||||||
id="org.eclipse.tm.terminal.local.launch"
|
id="org.eclipse.tm.terminal.local.launch"
|
||||||
delegate="org.eclipse.tm.internal.terminal.local.launch.LocalTerminalLaunchDelegate"
|
delegate="org.eclipse.tm.internal.terminal.local.launch.LocalTerminalLaunchDelegate"
|
||||||
category="org.eclipse.ui.externaltools"
|
category="org.eclipse.ui.externaltools"
|
||||||
|
public="false"
|
||||||
modes="run"
|
modes="run"
|
||||||
/>
|
/>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
|
@ -50,7 +50,7 @@ import org.eclipse.tm.internal.terminal.provisional.api.provider.TerminalConnect
|
||||||
* <code>vi</code> editor).
|
* <code>vi</code> editor).
|
||||||
*
|
*
|
||||||
* @author Mirko Raner
|
* @author Mirko Raner
|
||||||
* @version $Revision: 1.2 $
|
* @version $Revision: 1.3 $
|
||||||
*/
|
*/
|
||||||
public class LocalTerminalConnector extends TerminalConnectorImpl
|
public class LocalTerminalConnector extends TerminalConnectorImpl
|
||||||
implements IDebugEventSetListener {
|
implements IDebugEventSetListener {
|
||||||
|
@ -269,6 +269,9 @@ implements IDebugEventSetListener {
|
||||||
}
|
}
|
||||||
catch (CoreException exception) {
|
catch (CoreException exception) {
|
||||||
|
|
||||||
|
control.setState(TerminalState.CLOSED);
|
||||||
|
Shell shell = LocalTerminalSettingsPage.getShell();
|
||||||
|
ErrorDialog.openError(shell, null, null, exception.getStatus());
|
||||||
Logger.logException(exception);
|
Logger.logException(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import org.eclipse.osgi.util.NLS;
|
||||||
* messages used by the Local Terminal Connector.
|
* messages used by the Local Terminal Connector.
|
||||||
*
|
*
|
||||||
* @author Mirko Raner
|
* @author Mirko Raner
|
||||||
* @version $Revision: 1.2 $
|
* @version $Revision: 1.3 $
|
||||||
*/
|
*/
|
||||||
public class LocalTerminalMessages extends NLS {
|
public class LocalTerminalMessages extends NLS {
|
||||||
|
|
||||||
|
@ -41,6 +41,9 @@ public class LocalTerminalMessages extends NLS {
|
||||||
/** The label for the "Edit..." button. */
|
/** The label for the "Edit..." button. */
|
||||||
public static String labelEdit;
|
public static String labelEdit;
|
||||||
|
|
||||||
|
/** The label for the "Delete" button. */
|
||||||
|
public static String labelDelete;
|
||||||
|
|
||||||
/** The label for the "Enable terminal echo" check box. */
|
/** The label for the "Enable terminal echo" check box. */
|
||||||
public static String enableLocalEcho;
|
public static String enableLocalEcho;
|
||||||
|
|
||||||
|
@ -80,6 +83,12 @@ public class LocalTerminalMessages extends NLS {
|
||||||
/** The error message for an invalid working directory location. */
|
/** The error message for an invalid working directory location. */
|
||||||
public static String invalidWorkingDirectory;
|
public static String invalidWorkingDirectory;
|
||||||
|
|
||||||
|
/** The question message for confirming deletion of a launch configuration. */
|
||||||
|
public static String questionDeleteLaunchConfiguration;
|
||||||
|
|
||||||
|
/** The question title for confirming deletion of a launch configuration. */
|
||||||
|
public static String questionTitleDeleteLaunchConfiguration;
|
||||||
|
|
||||||
/** The error message for attempting to directly launch a Terminal launch configuration. */
|
/** The error message for attempting to directly launch a Terminal launch configuration. */
|
||||||
public static String errorDirectLaunch;
|
public static String errorDirectLaunch;
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ lineSeparatorLF=LF
|
||||||
lineSeparatorCR=CR
|
lineSeparatorCR=CR
|
||||||
labelNew=New...
|
labelNew=New...
|
||||||
labelEdit=Edit...
|
labelEdit=Edit...
|
||||||
|
labelDelete=Delete
|
||||||
terminalTabName=Terminal
|
terminalTabName=Terminal
|
||||||
terminalSettings=Terminal settings\:
|
terminalSettings=Terminal settings\:
|
||||||
newTerminalLaunchName=New Terminal Launch
|
newTerminalLaunchName=New Terminal Launch
|
||||||
|
@ -28,6 +29,8 @@ locationNotSpecified=Executable location was not specified in configuration ''{0
|
||||||
invalidLocation=Executable does not exist for the external tool named ''{0}''
|
invalidLocation=Executable does not exist for the external tool named ''{0}''
|
||||||
invalidWorkingDirectory=The path {0} is not a directory and cannot be used as working directory \
|
invalidWorkingDirectory=The path {0} is not a directory and cannot be used as working directory \
|
||||||
for ''{1}''
|
for ''{1}''
|
||||||
|
questionDeleteLaunchConfiguration=Do you wish to delete the selected launch configuration?
|
||||||
|
questionTitleDeleteLaunchConfiguration=Confirm Launch Configuration Deletion
|
||||||
errorDirectLaunch=Terminal launch configurations can only be launched from the Terminal view. \
|
errorDirectLaunch=Terminal launch configurations can only be launched from the Terminal view. \
|
||||||
Please open the Terminal view and click the view's Settings button to select and launch a local \
|
Please open the Terminal view and click the view's Settings button to select and launch a local \
|
||||||
Terminal.
|
Terminal.
|
||||||
|
|
|
@ -12,14 +12,13 @@
|
||||||
package org.eclipse.tm.internal.terminal.local;
|
package org.eclipse.tm.internal.terminal.local;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||||
import org.eclipse.debug.core.ILaunchManager;
|
import org.eclipse.debug.core.ILaunchManager;
|
||||||
import org.eclipse.debug.internal.ui.DebugUIPlugin;
|
|
||||||
import org.eclipse.debug.ui.DebugUITools;
|
import org.eclipse.debug.ui.DebugUITools;
|
||||||
import org.eclipse.debug.ui.ILaunchGroup;
|
import org.eclipse.debug.ui.ILaunchGroup;
|
||||||
|
import org.eclipse.jface.dialogs.ErrorDialog;
|
||||||
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||||
|
@ -41,13 +40,16 @@ import org.eclipse.tm.internal.terminal.local.launch.LocalTerminalLaunchUtilitie
|
||||||
import org.eclipse.tm.internal.terminal.local.ui.DependentHeightComposite;
|
import org.eclipse.tm.internal.terminal.local.ui.DependentHeightComposite;
|
||||||
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
|
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
|
||||||
import org.eclipse.tm.internal.terminal.provisional.api.Logger;
|
import org.eclipse.tm.internal.terminal.provisional.api.Logger;
|
||||||
|
import org.eclipse.ui.IWorkbench;
|
||||||
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The class {@link LocalTerminalSettingsPage} is an implementation {@link ISettingsPage} for
|
* The class {@link LocalTerminalSettingsPage} is an implementation {@link ISettingsPage} for
|
||||||
* local program connections.
|
* local program connections.
|
||||||
*
|
*
|
||||||
* @author Mirko Raner
|
* @author Mirko Raner
|
||||||
* @version $Revision: 1.2 $
|
* @version $Revision: 1.3 $
|
||||||
*/
|
*/
|
||||||
public class LocalTerminalSettingsPage
|
public class LocalTerminalSettingsPage
|
||||||
implements ISettingsPage, ISelectionChangedListener, SelectionListener {
|
implements ISettingsPage, ISelectionChangedListener, SelectionListener {
|
||||||
|
@ -56,6 +58,7 @@ implements ISettingsPage, ISelectionChangedListener, SelectionListener {
|
||||||
private TableViewer viewer;
|
private TableViewer viewer;
|
||||||
private Button buttonEdit;
|
private Button buttonEdit;
|
||||||
private Button buttonNew;
|
private Button buttonNew;
|
||||||
|
private Button buttonDelete;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@link LocalTerminalSettingsPage} that reflects the settings of the specified
|
* Creates a new {@link LocalTerminalSettingsPage} that reflects the settings of the specified
|
||||||
|
@ -117,10 +120,12 @@ implements ISettingsPage, ISelectionChangedListener, SelectionListener {
|
||||||
viewer.setContentProvider(new LocalTerminalLaunchListProvider());
|
viewer.setContentProvider(new LocalTerminalLaunchListProvider());
|
||||||
viewer.setInput(new Object());
|
viewer.setInput(new Object());
|
||||||
viewer.addSelectionChangedListener(this);
|
viewer.addSelectionChangedListener(this);
|
||||||
table.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 0, 2));
|
table.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 0, 3));
|
||||||
buttonNew = pushButton(tableAndButtons, LocalTerminalMessages.labelNew, false);
|
buttonNew = pushButton(tableAndButtons, LocalTerminalMessages.labelNew, false);
|
||||||
buttonEdit = pushButton(tableAndButtons, LocalTerminalMessages.labelEdit, true);
|
buttonEdit = pushButton(tableAndButtons, LocalTerminalMessages.labelEdit, false);
|
||||||
buttonEdit.setEnabled(settings.getLaunchConfigurationName() != null);
|
buttonEdit.setEnabled(settings.getLaunchConfigurationName() != null);
|
||||||
|
buttonDelete = pushButton(tableAndButtons, LocalTerminalMessages.labelDelete, true);
|
||||||
|
buttonDelete.setEnabled(settings.getLaunchConfigurationName() != null);
|
||||||
//
|
//
|
||||||
// NOTE: echo and line separator settings were moved to the launch configuration!
|
// NOTE: echo and line separator settings were moved to the launch configuration!
|
||||||
|
|
||||||
|
@ -196,14 +201,15 @@ implements ISettingsPage, ISelectionChangedListener, SelectionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables or disables the Edit... button depending on whether a launch configuration is
|
* Enables or disables the Edit... and Delete buttons depending on whether a launch
|
||||||
* currently selected in the viewer.
|
* configuration is currently selected in the viewer.
|
||||||
*
|
*
|
||||||
* @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
|
* @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
|
||||||
*/
|
*/
|
||||||
public void selectionChanged(SelectionChangedEvent event) {
|
public void selectionChanged(SelectionChangedEvent event) {
|
||||||
|
|
||||||
buttonEdit.setEnabled(!event.getSelection().isEmpty());
|
buttonEdit.setEnabled(!event.getSelection().isEmpty());
|
||||||
|
buttonDelete.setEnabled(!event.getSelection().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -236,15 +242,11 @@ implements ISettingsPage, ISelectionChangedListener, SelectionListener {
|
||||||
}
|
}
|
||||||
if (widget.equals(buttonNew)) {
|
if (widget.equals(buttonNew)) {
|
||||||
|
|
||||||
ILaunchConfigurationWorkingCopy newlyCreatedConfiguration;
|
|
||||||
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
|
|
||||||
String baseName = LocalTerminalMessages.newTerminalLaunchName;
|
|
||||||
String uniqueName = launchManager.generateLaunchConfigurationName(baseName);
|
|
||||||
ILaunchConfigurationType type = LocalTerminalUtilities.TERMINAL_LAUNCH_TYPE;
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
newlyCreatedConfiguration = type.newInstance(null, uniqueName);
|
ILaunchConfigurationWorkingCopy newLaunch;
|
||||||
configuration = newlyCreatedConfiguration.doSave();
|
newLaunch = LocalTerminalLaunchUtilities.createNewLaunchConfigurationWorkingCopy();
|
||||||
|
configuration = newLaunch.doSave();
|
||||||
}
|
}
|
||||||
catch (CoreException couldNotCreateNewLaunchConfiguration) {
|
catch (CoreException couldNotCreateNewLaunchConfiguration) {
|
||||||
|
|
||||||
|
@ -254,7 +256,6 @@ implements ISettingsPage, ISelectionChangedListener, SelectionListener {
|
||||||
if (widget.equals(buttonEdit) || configuration != null) {
|
if (widget.equals(buttonEdit) || configuration != null) {
|
||||||
|
|
||||||
ILaunchGroup group;
|
ILaunchGroup group;
|
||||||
Shell shell = DebugUIPlugin.getShell();
|
|
||||||
IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
|
IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
|
||||||
if (configuration == null) {
|
if (configuration == null) {
|
||||||
|
|
||||||
|
@ -262,14 +263,11 @@ implements ISettingsPage, ISelectionChangedListener, SelectionListener {
|
||||||
}
|
}
|
||||||
group = DebugUITools.getLaunchGroup(configuration, ILaunchManager.RUN_MODE);
|
group = DebugUITools.getLaunchGroup(configuration, ILaunchManager.RUN_MODE);
|
||||||
String groupID = group.getIdentifier();
|
String groupID = group.getIdentifier();
|
||||||
DebugUITools.openLaunchConfigurationDialog(shell, configuration, groupID, null);
|
DebugUITools.openLaunchConfigurationDialog(getShell(), configuration, groupID, null);
|
||||||
//
|
//
|
||||||
// TODO: handle return value (maybe start terminal right away if "Run" was selected)
|
// TODO: handle return value (maybe start terminal right away if "Run" was selected)
|
||||||
// - a return value of Window.CANCEL indicates that "Close" was selected
|
// - a return value of Window.CANCEL indicates that "Close" was selected
|
||||||
// - a return value of Window.OK indicates that "Run" was selected
|
// - a return value of Window.OK indicates that "Run" was selected
|
||||||
// TODO: prevent "Run" button from launching in the regular console
|
|
||||||
// (maybe tweak process factory settings before opening the configuration in the
|
|
||||||
// dialog?)
|
|
||||||
|
|
||||||
viewer.refresh();
|
viewer.refresh();
|
||||||
viewer.setSelection(new StructuredSelection(configuration), true);
|
viewer.setSelection(new StructuredSelection(configuration), true);
|
||||||
|
@ -279,6 +277,37 @@ implements ISettingsPage, ISelectionChangedListener, SelectionListener {
|
||||||
// creates a different ILaunchConfiguration object, rather than just renaming the
|
// creates a different ILaunchConfiguration object, rather than just renaming the
|
||||||
// existing one)
|
// existing one)
|
||||||
}
|
}
|
||||||
|
if (widget.equals(buttonDelete)) {
|
||||||
|
|
||||||
|
String title = LocalTerminalMessages.questionTitleDeleteLaunchConfiguration;
|
||||||
|
String question = LocalTerminalMessages.questionDeleteLaunchConfiguration;
|
||||||
|
if (MessageDialog.openQuestion(getShell(), title, question)) {
|
||||||
|
|
||||||
|
IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
|
||||||
|
configuration = (ILaunchConfiguration)selection.getFirstElement();
|
||||||
|
try {
|
||||||
|
|
||||||
|
configuration.delete();
|
||||||
|
}
|
||||||
|
catch (CoreException exception) {
|
||||||
|
|
||||||
|
ErrorDialog.openError(getShell(), null, null, exception.getStatus());
|
||||||
|
}
|
||||||
|
viewer.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static Shell getShell() {
|
||||||
|
|
||||||
|
IWorkbench workbench = PlatformUI.getWorkbench();
|
||||||
|
IWorkbenchWindow activeWindow = workbench.getActiveWorkbenchWindow();
|
||||||
|
if (activeWindow != null) {
|
||||||
|
|
||||||
|
return activeWindow.getShell();
|
||||||
|
}
|
||||||
|
IWorkbenchWindow[] allWindows = workbench.getWorkbenchWindows();
|
||||||
|
return allWindows.length > 0? allWindows[0].getShell():null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------ PRIVATE SECTION ---------------------------------------//
|
//------------------------------------ PRIVATE SECTION ---------------------------------------//
|
||||||
|
|
|
@ -39,7 +39,7 @@ import org.eclipse.tm.internal.terminal.provisional.api.Logger;
|
||||||
* because the original class is not part of the public API of its plug-in.
|
* because the original class is not part of the public API of its plug-in.
|
||||||
*
|
*
|
||||||
* @author Mirko Raner and others
|
* @author Mirko Raner and others
|
||||||
* @version $Revision: 1.2 $
|
* @version $Revision: 1.3 $
|
||||||
*/
|
*/
|
||||||
public class LocalTerminalLaunchUtilities {
|
public class LocalTerminalLaunchUtilities {
|
||||||
|
|
||||||
|
@ -226,10 +226,13 @@ public class LocalTerminalLaunchUtilities {
|
||||||
ILaunchConfigurationWorkingCopy workingCopy;
|
ILaunchConfigurationWorkingCopy workingCopy;
|
||||||
ILaunchManager manager = LocalTerminalUtilities.LAUNCH_MANAGER;
|
ILaunchManager manager = LocalTerminalUtilities.LAUNCH_MANAGER;
|
||||||
String userHome = System.getProperty("user.home", "/"); //$NON-NLS-1$//$NON-NLS-2$
|
String userHome = System.getProperty("user.home", "/"); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
String name = manager.generateLaunchConfigurationName("Terminal"); //$NON-NLS-1$
|
String defaultShell = getDefaultShell().getAbsolutePath();
|
||||||
|
String name = defaultShell.substring(defaultShell.lastIndexOf(File.separator) + 1);
|
||||||
|
name = manager.generateLaunchConfigurationName("Terminal (" + name + ')'); //$NON-NLS-1$
|
||||||
workingCopy = LocalTerminalUtilities.TERMINAL_LAUNCH_TYPE.newInstance(null, name);
|
workingCopy = LocalTerminalUtilities.TERMINAL_LAUNCH_TYPE.newInstance(null, name);
|
||||||
workingCopy.setAttribute(ATTR_LOCATION, getDefaultShell().getAbsolutePath());
|
workingCopy.setAttribute(ATTR_LOCATION, defaultShell);
|
||||||
workingCopy.setAttribute(ATTR_WORKING_DIRECTORY, userHome);
|
workingCopy.setAttribute(ATTR_WORKING_DIRECTORY, userHome);
|
||||||
|
workingCopy.setAttribute(ATTR_LOCAL_ECHO, runningOnWindows());
|
||||||
return workingCopy;
|
return workingCopy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +249,7 @@ public class LocalTerminalLaunchUtilities {
|
||||||
String shell = System.getenv("SHELL"); //$NON-NLS-1$
|
String shell = System.getenv("SHELL"); //$NON-NLS-1$
|
||||||
if (shell == null) {
|
if (shell == null) {
|
||||||
|
|
||||||
if (Platform.OS_WIN32.equals(Platform.getOS())) {
|
if (runningOnWindows()) {
|
||||||
|
|
||||||
shell = "C:\\Windows\\System32\\cmd.exe"; //$NON-NLS-1$
|
shell = "C:\\Windows\\System32\\cmd.exe"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
@ -260,6 +263,11 @@ public class LocalTerminalLaunchUtilities {
|
||||||
|
|
||||||
//------------------------------------- PRIVATE SECTION --------------------------------------//
|
//------------------------------------- PRIVATE SECTION --------------------------------------//
|
||||||
|
|
||||||
|
private static boolean runningOnWindows() {
|
||||||
|
|
||||||
|
return Platform.OS_WIN32.equals(Platform.getOS());
|
||||||
|
}
|
||||||
|
|
||||||
private static IStringVariableManager getStringVariableManager() {
|
private static IStringVariableManager getStringVariableManager() {
|
||||||
|
|
||||||
return VariablesPlugin.getDefault().getStringVariableManager();
|
return VariablesPlugin.getDefault().getStringVariableManager();
|
||||||
|
|
Loading…
Add table
Reference in a new issue