1 11 12 package org.eclipse.debug.internal.ui.launchConfigurations; 13 14 import org.eclipse.debug.internal.ui.DebugUIPlugin; 15 import org.eclipse.debug.internal.ui.DefaultLabelProvider; 16 import org.eclipse.debug.internal.ui.IDebugHelpContextIds; 17 import org.eclipse.debug.ui.IDebugUIConstants; 18 import org.eclipse.jface.dialogs.IDialogSettings; 19 import org.eclipse.jface.viewers.ArrayContentProvider; 20 import org.eclipse.jface.viewers.ISelectionChangedListener; 21 import org.eclipse.jface.viewers.SelectionChangedEvent; 22 import org.eclipse.swt.graphics.Point; 23 import org.eclipse.swt.widgets.Composite; 24 import org.eclipse.swt.widgets.Control; 25 import org.eclipse.swt.widgets.Shell; 26 import org.eclipse.ui.PlatformUI; 27 import org.eclipse.ui.dialogs.ListDialog; 28 29 35 public class LaunchConfigurationSelectionDialog extends ListDialog { 36 37 private static final String DIALOG_SETTINGS = IDebugUIConstants.PLUGIN_ID + ".SELECT_LAUNCH_CONFIGURATION_DIALOG"; 39 43 public LaunchConfigurationSelectionDialog(Shell parent) { 44 super(parent); 45 setTitle(LaunchConfigurationsMessages.LaunchConfigurationSelectionDialog_0); 46 setMessage(LaunchConfigurationsMessages.LaunchConfigurationSelectionDialog_1); 47 setLabelProvider(new DefaultLabelProvider()); 48 setContentProvider(new ArrayContentProvider()); 49 } 50 51 54 protected Control createContents(Composite parent) { 55 Composite comp = (Composite) super.createContents(parent); 56 PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IDebugHelpContextIds.SELECT_LAUNCH_CONFIGURATION_DIALOG); 57 return comp; 58 } 59 60 63 protected void createButtonsForButtonBar(Composite parent) { 64 super.createButtonsForButtonBar(parent); 65 getOkButton().setEnabled(false); 66 getTableViewer().addSelectionChangedListener(new ISelectionChangedListener() { 67 public void selectionChanged(SelectionChangedEvent event) { 68 getOkButton().setEnabled(!event.getSelection().isEmpty()); 69 } 70 }); 71 } 72 73 76 protected IDialogSettings getDialogBoundsSettings() { 77 IDialogSettings settings = DebugUIPlugin.getDefault().getDialogSettings(); 78 IDialogSettings section = settings.getSection(DIALOG_SETTINGS); 79 if (section == null) { 80 section = settings.addNewSection(DIALOG_SETTINGS); 81 } 82 return section; 83 } 84 85 88 protected Point getInitialSize() { 89 IDialogSettings settings = getDialogBoundsSettings(); 90 if(settings != null) { 91 try { 92 int width = settings.getInt("DIALOG_WIDTH"); int height = settings.getInt("DIALOG_HEIGHT"); if(width > 0 & height > 0) { 95 return new Point(width, height); 96 } 97 } 98 catch (NumberFormatException nfe) { 99 return new Point(450, 450); 100 } 101 } 102 return new Point(450, 450); 103 } 104 105 } 106 | Popular Tags |