| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Dart project authors. | 2 * Copyright 2012 Dart project authors. |
| 3 * | 3 * |
| 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
| 5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
| 6 * | 6 * |
| 7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
| 8 * | 8 * |
| 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
| 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 import org.eclipse.swt.custom.SashForm; | 56 import org.eclipse.swt.custom.SashForm; |
| 57 import org.eclipse.swt.custom.ScrolledComposite; | 57 import org.eclipse.swt.custom.ScrolledComposite; |
| 58 import org.eclipse.swt.events.DisposeEvent; | 58 import org.eclipse.swt.events.DisposeEvent; |
| 59 import org.eclipse.swt.events.DisposeListener; | 59 import org.eclipse.swt.events.DisposeListener; |
| 60 import org.eclipse.swt.events.ModifyEvent; | 60 import org.eclipse.swt.events.ModifyEvent; |
| 61 import org.eclipse.swt.events.ModifyListener; | 61 import org.eclipse.swt.events.ModifyListener; |
| 62 import org.eclipse.swt.events.SelectionAdapter; | 62 import org.eclipse.swt.events.SelectionAdapter; |
| 63 import org.eclipse.swt.events.SelectionEvent; | 63 import org.eclipse.swt.events.SelectionEvent; |
| 64 import org.eclipse.swt.widgets.Composite; | 64 import org.eclipse.swt.widgets.Composite; |
| 65 import org.eclipse.swt.widgets.Control; | 65 import org.eclipse.swt.widgets.Control; |
| 66 import org.eclipse.swt.widgets.Display; |
| 66 import org.eclipse.swt.widgets.Label; | 67 import org.eclipse.swt.widgets.Label; |
| 67 import org.eclipse.swt.widgets.Shell; | 68 import org.eclipse.swt.widgets.Shell; |
| 68 import org.eclipse.swt.widgets.Text; | 69 import org.eclipse.swt.widgets.Text; |
| 69 import org.eclipse.swt.widgets.ToolBar; | 70 import org.eclipse.swt.widgets.ToolBar; |
| 70 import org.eclipse.ui.IWorkbenchWindow; | 71 import org.eclipse.ui.IWorkbenchWindow; |
| 71 import org.eclipse.ui.internal.WorkbenchPlugin; | 72 import org.eclipse.ui.internal.WorkbenchPlugin; |
| 72 | 73 |
| 73 import java.lang.reflect.InvocationTargetException; | 74 import java.lang.reflect.InvocationTargetException; |
| 74 import java.util.List; | 75 import java.util.List; |
| 75 | 76 |
| 76 /** | 77 /** |
| 77 * A dialog to create, edit, and manage launch configurations. | 78 * A dialog to create, edit, and manage launch configurations. |
| 78 */ | 79 */ |
| 79 @SuppressWarnings("restriction") | 80 @SuppressWarnings("restriction") |
| 80 public class ManageLaunchesDialog extends TitleAreaDialog implements ILaunchConf
igurationDialog, | 81 public class ManageLaunchesDialog extends TitleAreaDialog implements ILaunchConf
igurationDialog, |
| 81 ILaunchConfigurationListener { | 82 ILaunchConfigurationListener { |
| 82 | 83 |
| 84 /** |
| 85 * Asynchronously open the manage launches dialog with the given launch automa
tically selected. |
| 86 */ |
| 87 public static void openAsync(final IWorkbenchWindow window, final ILaunchConfi
guration config) { |
| 88 final Display display = Display.getDefault(); |
| 89 display.asyncExec(new Runnable() { |
| 90 @Override |
| 91 public void run() { |
| 92 final ManageLaunchesDialog dialog = new ManageLaunchesDialog(window); |
| 93 dialog.selectLaunchOnOpen(config); |
| 94 dialog.open(); |
| 95 } |
| 96 }); |
| 97 } |
| 98 |
| 83 private IWorkbenchWindow window; | 99 private IWorkbenchWindow window; |
| 84 | 100 |
| 85 private TableViewer launchesViewer; | 101 private TableViewer launchesViewer; |
| 86 private Composite configUI; | 102 private Composite configUI; |
| 87 private ScrolledComposite launchConfigArea; | 103 private ScrolledComposite launchConfigArea; |
| 88 private Text configNameText; | 104 private Text configNameText; |
| 89 | 105 |
| 90 private ILaunchConfiguration selectedConfig; | 106 private ILaunchConfiguration selectedConfig; |
| 91 private ILaunchConfigurationWorkingCopy workingCopy; | 107 private ILaunchConfigurationWorkingCopy workingCopy; |
| 92 private ILaunchConfigurationTabGroup currentTabGroup; | 108 private ILaunchConfigurationTabGroup currentTabGroup; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 public void selectLaunchConfiguration(String name) { | 224 public void selectLaunchConfiguration(String name) { |
| 209 saveConfig(); | 225 saveConfig(); |
| 210 | 226 |
| 211 ILaunchConfiguration config = getConfigurationNamed(name); | 227 ILaunchConfiguration config = getConfigurationNamed(name); |
| 212 | 228 |
| 213 if (config != null) { | 229 if (config != null) { |
| 214 launchesViewer.setSelection(new StructuredSelection(config)); | 230 launchesViewer.setSelection(new StructuredSelection(config)); |
| 215 } | 231 } |
| 216 } | 232 } |
| 217 | 233 |
| 234 /** |
| 235 * Select the specified launch configuration when the dialog opens. |
| 236 */ |
| 237 public void selectLaunchOnOpen(ILaunchConfiguration config) { |
| 238 selectedConfig = config; |
| 239 } |
| 240 |
| 218 @Override | 241 @Override |
| 219 public void setActiveTab(ILaunchConfigurationTab tab) { | 242 public void setActiveTab(ILaunchConfigurationTab tab) { |
| 220 if (activeTab != null) { | 243 if (activeTab != null) { |
| 221 activeTab.deactivated(workingCopy); | 244 activeTab.deactivated(workingCopy); |
| 222 activeTab.getControl().dispose(); | 245 activeTab.getControl().dispose(); |
| 223 } | 246 } |
| 224 | 247 |
| 225 activeTab = tab; | 248 activeTab = tab; |
| 226 | 249 |
| 227 if (activeTab != null) { | 250 if (activeTab != null) { |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 | 601 |
| 579 private void selectFirstLaunchConfig() { | 602 private void selectFirstLaunchConfig() { |
| 580 final ILaunchConfiguration launchConfig = (ILaunchConfiguration) launchesVie
wer.getElementAt(0); | 603 final ILaunchConfiguration launchConfig = (ILaunchConfiguration) launchesVie
wer.getElementAt(0); |
| 581 | 604 |
| 582 if (launchConfig != null && launchesViewer.getSelection().isEmpty()) { | 605 if (launchConfig != null && launchesViewer.getSelection().isEmpty()) { |
| 583 launchesViewer.setSelection(new StructuredSelection(launchConfig)); | 606 launchesViewer.setSelection(new StructuredSelection(launchConfig)); |
| 584 } | 607 } |
| 585 } | 608 } |
| 586 | 609 |
| 587 private void selectLaunchConfigFromPage() { | 610 private void selectLaunchConfigFromPage() { |
| 588 IResource resource = LaunchUtils.getSelectedResource(window); | |
| 589 | 611 |
| 590 if (resource != null) { | 612 ILaunchConfiguration config = selectedConfig; |
| 591 | 613 if (config == null) { |
| 592 ILaunchConfiguration config = null; | 614 IResource resource = LaunchUtils.getSelectedResource(window); |
| 593 List<ILaunchConfiguration> configs = LaunchUtils.getExistingLaunchesFor(re
source); | 615 if (resource != null) { |
| 594 if (!configs.isEmpty()) { | 616 List<ILaunchConfiguration> configs = LaunchUtils.getExistingLaunchesFor(
resource); |
| 595 config = configs.get(0); | 617 if (!configs.isEmpty()) { |
| 596 } | 618 config = configs.get(0); |
| 597 | 619 } |
| 598 if (config != null) { | |
| 599 launchesViewer.setSelection(new StructuredSelection(config)); | |
| 600 return; | |
| 601 } | 620 } |
| 602 } | 621 } |
| 603 | 622 |
| 604 selectFirstLaunchConfig(); | 623 if (config != null) { |
| 624 launchesViewer.setSelection(new StructuredSelection(config)); |
| 625 } else { |
| 626 selectFirstLaunchConfig(); |
| 627 } |
| 605 } | 628 } |
| 606 | 629 |
| 607 private void show(ILaunchConfiguration config) { | 630 private void show(ILaunchConfiguration config) { |
| 608 try { | 631 try { |
| 609 launchConfig = config; | 632 launchConfig = config; |
| 610 workingCopy = launchConfig.getWorkingCopy(); | 633 workingCopy = launchConfig.getWorkingCopy(); |
| 611 configNameText.setText(workingCopy.getName()); | 634 configNameText.setText(workingCopy.getName()); |
| 612 | 635 |
| 613 currentTabGroup = LaunchConfigurationPresentationManager.getDefault().getT
abGroup( | 636 currentTabGroup = LaunchConfigurationPresentationManager.getDefault().getT
abGroup( |
| 614 workingCopy, | 637 workingCopy, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 throw new CoreException(new Status( | 687 throw new CoreException(new Status( |
| 665 IStatus.ERROR, | 688 IStatus.ERROR, |
| 666 DartDebugUIPlugin.PLUGIN_ID, | 689 DartDebugUIPlugin.PLUGIN_ID, |
| 667 0, | 690 0, |
| 668 Messages.ManageLaunchesDialog_Launch_configuration_already_exists_
with_this_name, | 691 Messages.ManageLaunchesDialog_Launch_configuration_already_exists_
with_this_name, |
| 669 null)); | 692 null)); |
| 670 } | 693 } |
| 671 } | 694 } |
| 672 } | 695 } |
| 673 } | 696 } |
| 674 | |
| 675 } | 697 } |
| OLD | NEW |