KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > launchConfigurations > LaunchConfigurationSelectionDialog


1 /*******************************************************************************
2  * Copyright (c) 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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 /**
30  * This class provides a dialog for selecting a given launch configuration from a listing
31  *
32  * @since 3.3.0
33  * CONTEXTLAUNCHING
34  */

35 public class LaunchConfigurationSelectionDialog extends ListDialog {
36
37     private static final String JavaDoc DIALOG_SETTINGS = IDebugUIConstants.PLUGIN_ID + ".SELECT_LAUNCH_CONFIGURATION_DIALOG"; //$NON-NLS-1$;
38

39     /**
40      * Constructor
41      * @param parent
42      */

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     /**
52      * @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite)
53      */

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     /**
61      * @see org.eclipse.ui.dialogs.ListDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
62      */

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     /**
74      * @see org.eclipse.ui.dialogs.SelectionDialog#getDialogBoundsSettings()
75      */

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     /* (non-Javadoc)
86      * @see org.eclipse.jface.dialogs.Dialog#getInitialSize()
87      */

88     protected Point getInitialSize() {
89         IDialogSettings settings = getDialogBoundsSettings();
90         if(settings != null) {
91             try {
92                 int width = settings.getInt("DIALOG_WIDTH"); //$NON-NLS-1$
93
int height = settings.getInt("DIALOG_HEIGHT"); //$NON-NLS-1$
94
if(width > 0 & height > 0) {
95                     return new Point(width, height);
96                 }
97             }
98             catch (NumberFormatException JavaDoc nfe) {
99                 return new Point(450, 450);
100             }
101         }
102         return new Point(450, 450);
103     }
104     
105 }
106
Popular Tags