Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 309899 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.xml (-1 / +2 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.3"?>
2
<?eclipse version="3.3"?>
3
<!--
3
<!--
4
# Copyright (c) 2008 Mirko Raner and others
4
# Copyright (c) 2008, 2010 Mirko Raner and others
5
# All rights reserved. This program and the accompanying materials
5
# All rights reserved. This program and the accompanying materials
6
# are made available under the terms of the Eclipse Public License v1.0
6
# are made available under the terms of the Eclipse Public License v1.0
7
# which accompanies this distribution, and is available at
7
# which accompanies this distribution, and is available at
Lines 37-42 Link Here
37
   id="org.eclipse.tm.terminal.local.launch"
37
   id="org.eclipse.tm.terminal.local.launch"
38
   delegate="org.eclipse.tm.internal.terminal.local.launch.LocalTerminalLaunchDelegate"
38
   delegate="org.eclipse.tm.internal.terminal.local.launch.LocalTerminalLaunchDelegate"
39
   category="org.eclipse.ui.externaltools"
39
   category="org.eclipse.ui.externaltools"
40
   public="false"
40
   modes="run"
41
   modes="run"
41
  />
42
  />
42
 </extension>
43
 </extension>
(-)src/org/eclipse/tm/internal/terminal/local/LocalTerminalConnector.java (+3 lines)
Lines 269-274 Link Here
269
		}
269
		}
270
		catch (CoreException exception) {
270
		catch (CoreException exception) {
271
271
272
			control.setState(TerminalState.CLOSED);
273
			Shell shell = LocalTerminalSettingsPage.getShell();
274
			ErrorDialog.openError(shell, null, null, exception.getStatus());
272
			Logger.logException(exception);
275
			Logger.logException(exception);
273
		}
276
		}
274
	}
277
	}
(-)src/org/eclipse/tm/internal/terminal/local/LocalTerminalMessages.java (+9 lines)
Lines 41-46 Link Here
41
	/** The label for the "Edit..." button. */
41
	/** The label for the "Edit..." button. */
42
	public static String labelEdit;
42
	public static String labelEdit;
43
43
44
	/** The label for the "Delete" button. */
45
	public static String labelDelete;
46
44
	/** The label for the "Enable terminal echo" check box. */
47
	/** The label for the "Enable terminal echo" check box. */
45
	public static String enableLocalEcho;
48
	public static String enableLocalEcho;
46
49
Lines 80-85 Link Here
80
	/** The error message for an invalid working directory location. */
83
	/** The error message for an invalid working directory location. */
81
	public static String invalidWorkingDirectory;
84
	public static String invalidWorkingDirectory;
82
85
86
	/** The question message for confirming deletion of a launch configuration. */
87
	public static String questionDeleteLaunchConfiguration;
88
89
	/** The question title for confirming deletion of a launch configuration. */
90
	public static String questionTitleDeleteLaunchConfiguration;
91
83
	/** The error message for attempting to directly launch a Terminal launch configuration. */
92
	/** The error message for attempting to directly launch a Terminal launch configuration. */
84
	public static String errorDirectLaunch;
93
	public static String errorDirectLaunch;
85
94
(-)src/org/eclipse/tm/internal/terminal/local/LocalTerminalMessages.properties (+3 lines)
Lines 18-23 Link Here
18
lineSeparatorCR=CR
18
lineSeparatorCR=CR
19
labelNew=New...
19
labelNew=New...
20
labelEdit=Edit...
20
labelEdit=Edit...
21
labelDelete=Delete
21
terminalTabName=Terminal
22
terminalTabName=Terminal
22
terminalSettings=Terminal settings\:
23
terminalSettings=Terminal settings\:
23
newTerminalLaunchName=New Terminal Launch
24
newTerminalLaunchName=New Terminal Launch
Lines 28-33 Link Here
28
invalidLocation=Executable does not exist for the external tool named ''{0}''
29
invalidLocation=Executable does not exist for the external tool named ''{0}''
29
invalidWorkingDirectory=The path {0} is not a directory and cannot be used as working directory \
30
invalidWorkingDirectory=The path {0} is not a directory and cannot be used as working directory \
30
 for ''{1}''
31
 for ''{1}''
32
questionDeleteLaunchConfiguration=Do you wish to delete the selected launch configuration?
33
questionTitleDeleteLaunchConfiguration=Confirm Launch Configuration Deletion
31
errorDirectLaunch=Terminal launch configurations can only be launched from the Terminal view. \
34
errorDirectLaunch=Terminal launch configurations can only be launched from the Terminal view. \
32
 Please open the Terminal view and click the view's Settings button to select and launch a local \
35
 Please open the Terminal view and click the view's Settings button to select and launch a local \
33
 Terminal.
36
 Terminal.
(-)src/org/eclipse/tm/internal/terminal/local/LocalTerminalSettingsPage.java (-19 / +48 lines)
Lines 12-25 Link Here
12
package org.eclipse.tm.internal.terminal.local;
12
package org.eclipse.tm.internal.terminal.local;
13
13
14
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.debug.core.DebugPlugin;
16
import org.eclipse.debug.core.ILaunchConfiguration;
15
import org.eclipse.debug.core.ILaunchConfiguration;
17
import org.eclipse.debug.core.ILaunchConfigurationType;
18
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
16
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
19
import org.eclipse.debug.core.ILaunchManager;
17
import org.eclipse.debug.core.ILaunchManager;
20
import org.eclipse.debug.internal.ui.DebugUIPlugin;
21
import org.eclipse.debug.ui.DebugUITools;
18
import org.eclipse.debug.ui.DebugUITools;
22
import org.eclipse.debug.ui.ILaunchGroup;
19
import org.eclipse.debug.ui.ILaunchGroup;
20
import org.eclipse.jface.dialogs.ErrorDialog;
21
import org.eclipse.jface.dialogs.MessageDialog;
23
import org.eclipse.jface.viewers.ISelectionChangedListener;
22
import org.eclipse.jface.viewers.ISelectionChangedListener;
24
import org.eclipse.jface.viewers.IStructuredSelection;
23
import org.eclipse.jface.viewers.IStructuredSelection;
25
import org.eclipse.jface.viewers.SelectionChangedEvent;
24
import org.eclipse.jface.viewers.SelectionChangedEvent;
Lines 41-46 Link Here
41
import org.eclipse.tm.internal.terminal.local.ui.DependentHeightComposite;
40
import org.eclipse.tm.internal.terminal.local.ui.DependentHeightComposite;
42
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
41
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
43
import org.eclipse.tm.internal.terminal.provisional.api.Logger;
42
import org.eclipse.tm.internal.terminal.provisional.api.Logger;
43
import org.eclipse.ui.IWorkbench;
44
import org.eclipse.ui.IWorkbenchWindow;
45
import org.eclipse.ui.PlatformUI;
44
46
45
/**
47
/**
46
 * The class {@link LocalTerminalSettingsPage} is an implementation {@link ISettingsPage} for
48
 * The class {@link LocalTerminalSettingsPage} is an implementation {@link ISettingsPage} for
Lines 56-61 Link Here
56
	private TableViewer viewer;
58
	private TableViewer viewer;
57
	private Button buttonEdit;
59
	private Button buttonEdit;
58
	private Button buttonNew;
60
	private Button buttonNew;
61
	private Button buttonDelete;
59
62
60
	/**
63
	/**
61
	 * Creates a new {@link LocalTerminalSettingsPage} that reflects the settings of the specified
64
	 * Creates a new {@link LocalTerminalSettingsPage} that reflects the settings of the specified
Lines 117-126 Link Here
117
		viewer.setContentProvider(new LocalTerminalLaunchListProvider());
120
		viewer.setContentProvider(new LocalTerminalLaunchListProvider());
118
		viewer.setInput(new Object());
121
		viewer.setInput(new Object());
119
		viewer.addSelectionChangedListener(this);
122
		viewer.addSelectionChangedListener(this);
120
		table.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 0, 2));
123
		table.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 0, 3));
121
		buttonNew = pushButton(tableAndButtons, LocalTerminalMessages.labelNew, false);
124
		buttonNew = pushButton(tableAndButtons, LocalTerminalMessages.labelNew, false);
122
		buttonEdit = pushButton(tableAndButtons, LocalTerminalMessages.labelEdit, true);
125
		buttonEdit = pushButton(tableAndButtons, LocalTerminalMessages.labelEdit, false);
123
		buttonEdit.setEnabled(settings.getLaunchConfigurationName() != null);
126
		buttonEdit.setEnabled(settings.getLaunchConfigurationName() != null);
127
		buttonDelete = pushButton(tableAndButtons, LocalTerminalMessages.labelDelete, true);
128
		buttonDelete.setEnabled(settings.getLaunchConfigurationName() != null);
124
		//
129
		//
125
		// NOTE: echo and line separator settings were moved to the launch configuration!
130
		// NOTE: echo and line separator settings were moved to the launch configuration!
126
131
Lines 196-209 Link Here
196
	}
201
	}
197
202
198
	/**
203
	/**
199
	 * Enables or disables the Edit... button depending on whether a launch configuration is
204
	 * Enables or disables the Edit... and Delete buttons depending on whether a launch
200
	 * currently selected in the viewer.
205
	 * configuration is currently selected in the viewer.
201
	 *
206
	 *
202
	 * @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
207
	 * @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
203
	 */
208
	 */
204
	public void selectionChanged(SelectionChangedEvent event) {
209
	public void selectionChanged(SelectionChangedEvent event) {
205
210
206
		buttonEdit.setEnabled(!event.getSelection().isEmpty());
211
		buttonEdit.setEnabled(!event.getSelection().isEmpty());
212
		buttonDelete.setEnabled(!event.getSelection().isEmpty());
207
	}
213
	}
208
214
209
	/**
215
	/**
Lines 236-250 Link Here
236
		}
242
		}
237
		if (widget.equals(buttonNew)) {
243
		if (widget.equals(buttonNew)) {
238
244
239
			ILaunchConfigurationWorkingCopy newlyCreatedConfiguration;
240
			ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
241
			String baseName = LocalTerminalMessages.newTerminalLaunchName;
242
			String uniqueName = launchManager.generateLaunchConfigurationName(baseName);
243
			ILaunchConfigurationType type = LocalTerminalUtilities.TERMINAL_LAUNCH_TYPE;
244
			try {
245
			try {
245
246
246
				newlyCreatedConfiguration = type.newInstance(null, uniqueName);
247
				ILaunchConfigurationWorkingCopy newLaunch;
247
				configuration = newlyCreatedConfiguration.doSave();
248
				newLaunch = LocalTerminalLaunchUtilities.createNewLaunchConfigurationWorkingCopy();
249
				configuration = newLaunch.doSave();
248
			}
250
			}
249
			catch (CoreException couldNotCreateNewLaunchConfiguration) {
251
			catch (CoreException couldNotCreateNewLaunchConfiguration) {
250
252
Lines 254-260 Link Here
254
		if (widget.equals(buttonEdit) || configuration != null) {
256
		if (widget.equals(buttonEdit) || configuration != null) {
255
257
256
			ILaunchGroup group;
258
			ILaunchGroup group;
257
			Shell shell = DebugUIPlugin.getShell();
258
			IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
259
			IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
259
			if (configuration == null) {
260
			if (configuration == null) {
260
261
Lines 262-275 Link Here
262
			}
263
			}
263
			group = DebugUITools.getLaunchGroup(configuration, ILaunchManager.RUN_MODE);
264
			group = DebugUITools.getLaunchGroup(configuration, ILaunchManager.RUN_MODE);
264
			String groupID = group.getIdentifier();
265
			String groupID = group.getIdentifier();
265
			DebugUITools.openLaunchConfigurationDialog(shell, configuration, groupID, null);
266
			DebugUITools.openLaunchConfigurationDialog(getShell(), configuration, groupID, null);
266
			//
267
			//
267
			// TODO: handle return value (maybe start terminal right away if "Run" was selected)
268
			// TODO: handle return value (maybe start terminal right away if "Run" was selected)
268
			// - a return value of Window.CANCEL indicates that "Close" was selected
269
			// - a return value of Window.CANCEL indicates that "Close" was selected
269
			// - a return value of Window.OK indicates that "Run" was selected
270
			// - a return value of Window.OK indicates that "Run" was selected
270
			// TODO: prevent "Run" button from launching in the regular console
271
			//       (maybe tweak process factory settings before opening the configuration in the
272
			//       dialog?)
273
271
274
			viewer.refresh();
272
			viewer.refresh();
275
			viewer.setSelection(new StructuredSelection(configuration), true);
273
			viewer.setSelection(new StructuredSelection(configuration), true);
Lines 279-284 Link Here
279
			//       creates a different ILaunchConfiguration object, rather than just renaming the
277
			//       creates a different ILaunchConfiguration object, rather than just renaming the
280
			//       existing one)
278
			//       existing one)
281
		}
279
		}
280
		if (widget.equals(buttonDelete)) {
281
282
			String title = LocalTerminalMessages.questionTitleDeleteLaunchConfiguration;
283
			String question = LocalTerminalMessages.questionDeleteLaunchConfiguration;
284
			if (MessageDialog.openQuestion(getShell(), title, question)) {
285
286
				IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
287
				configuration = (ILaunchConfiguration)selection.getFirstElement();
288
				try {
289
290
					configuration.delete();
291
				}
292
				catch (CoreException exception) {
293
294
					ErrorDialog.openError(getShell(), null, null, exception.getStatus());
295
				}
296
				viewer.refresh();
297
			}
298
		}
299
	}
300
301
	static Shell getShell() {
302
303
		IWorkbench workbench = PlatformUI.getWorkbench();
304
		IWorkbenchWindow activeWindow = workbench.getActiveWorkbenchWindow();
305
		if (activeWindow != null) {
306
307
			return activeWindow.getShell();
308
		}
309
		IWorkbenchWindow[] allWindows = workbench.getWorkbenchWindows();
310
		return allWindows.length > 0? allWindows[0].getShell():null;
282
	}
311
	}
283
312
284
	//------------------------------------ PRIVATE SECTION ---------------------------------------//
313
	//------------------------------------ PRIVATE SECTION ---------------------------------------//
(-)src/org/eclipse/tm/internal/terminal/local/launch/LocalTerminalLaunchUtilities.java (-3 / +11 lines)
Lines 226-235 Link Here
226
		ILaunchConfigurationWorkingCopy workingCopy;
226
		ILaunchConfigurationWorkingCopy workingCopy;
227
		ILaunchManager manager = LocalTerminalUtilities.LAUNCH_MANAGER;
227
		ILaunchManager manager = LocalTerminalUtilities.LAUNCH_MANAGER;
228
		String userHome = System.getProperty("user.home", "/"); //$NON-NLS-1$//$NON-NLS-2$
228
		String userHome = System.getProperty("user.home", "/"); //$NON-NLS-1$//$NON-NLS-2$
229
		String name = manager.generateLaunchConfigurationName("Terminal"); //$NON-NLS-1$
229
		String defaultShell = getDefaultShell().getAbsolutePath();
230
		String name = defaultShell.substring(defaultShell.lastIndexOf(File.separator) + 1);
231
		name = manager.generateLaunchConfigurationName("Terminal (" + name + ')'); //$NON-NLS-1$
230
		workingCopy = LocalTerminalUtilities.TERMINAL_LAUNCH_TYPE.newInstance(null, name);
232
		workingCopy = LocalTerminalUtilities.TERMINAL_LAUNCH_TYPE.newInstance(null, name);
231
		workingCopy.setAttribute(ATTR_LOCATION, getDefaultShell().getAbsolutePath());
233
		workingCopy.setAttribute(ATTR_LOCATION, defaultShell);
232
		workingCopy.setAttribute(ATTR_WORKING_DIRECTORY, userHome);
234
		workingCopy.setAttribute(ATTR_WORKING_DIRECTORY, userHome);
235
		workingCopy.setAttribute(ATTR_LOCAL_ECHO, runningOnWindows());
233
		return workingCopy;
236
		return workingCopy;
234
	}
237
	}
235
238
Lines 246-252 Link Here
246
		String shell = System.getenv("SHELL"); //$NON-NLS-1$
249
		String shell = System.getenv("SHELL"); //$NON-NLS-1$
247
		if (shell == null) {
250
		if (shell == null) {
248
251
249
			if (Platform.OS_WIN32.equals(Platform.getOS())) {
252
			if (runningOnWindows()) {
250
253
251
				shell = "C:\\Windows\\System32\\cmd.exe"; //$NON-NLS-1$
254
				shell = "C:\\Windows\\System32\\cmd.exe"; //$NON-NLS-1$
252
			}
255
			}
Lines 260-265 Link Here
260
263
261
	//------------------------------------- PRIVATE SECTION --------------------------------------//
264
	//------------------------------------- PRIVATE SECTION --------------------------------------//
262
265
266
	private static boolean runningOnWindows() {
267
268
		return Platform.OS_WIN32.equals(Platform.getOS());
269
	}
270
263
	private static IStringVariableManager getStringVariableManager() {
271
	private static IStringVariableManager getStringVariableManager() {
264
272
265
		return VariablesPlugin.getDefault().getStringVariableManager();
273
		return VariablesPlugin.getDefault().getStringVariableManager();

Return to bug 309899