|
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 ---------------------------------------// |