KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2006, 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 package org.eclipse.debug.internal.ui.launchConfigurations;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.Iterator JavaDoc;
15 import java.util.List JavaDoc;
16 import java.util.Set JavaDoc;
17
18 import org.eclipse.core.runtime.CoreException;
19 import org.eclipse.debug.core.ILaunchConfiguration;
20 import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
21 import org.eclipse.debug.ui.IDebugUIConstants;
22 import org.eclipse.jface.viewers.IBaseLabelProvider;
23 import org.eclipse.jface.viewers.ILabelProvider;
24 import org.eclipse.jface.viewers.ILabelProviderListener;
25 import org.eclipse.swt.SWT;
26 import org.eclipse.swt.graphics.Image;
27 import org.eclipse.swt.widgets.Shell;
28
29 /**
30  * This class provides a dialog to present the user with a list of of viable launch options in the event
31  * the plug-in that provides either a launch option or a contributed launch delegate is no longer available.
32  * The user can select one of the launch mode/option configuration from this dialog and repair the option
33  * configuration state of the the current launch configuration
34  *
35  * @since 3.3
36  */

37 public class SelectLaunchModesDialog extends AbstractDebugListSelectionDialog{
38
39     /**
40      * Builds labels for list control
41      */

42     class OptionsLabelProvider implements ILabelProvider {
43         public Image getImage(Object JavaDoc element) {return null;}
44         public String JavaDoc getText(Object JavaDoc element) {
45             Set JavaDoc modes = (Set JavaDoc) element;
46             List JavaDoc names = LaunchConfigurationPresentationManager.getDefault().getLaunchModeNames(modes);
47             return names.toString();
48         }
49         public void addListener(ILabelProviderListener listener) {}
50         public void dispose() {}
51         public boolean isLabelProperty(Object JavaDoc element, String JavaDoc property) {return false;}
52         public void removeListener(ILabelProviderListener listener) {}
53     }
54     
55     private List JavaDoc fValidModes = null;
56     
57     /**
58      * Constructor
59      * @param parentShell the parent shell
60      * @param mode the current mode context
61      * @param configuration the current launch configuration context
62      *
63      * @throws CoreException
64      */

65     public SelectLaunchModesDialog(Shell parentShell, String JavaDoc mode, ILaunchConfiguration configuration) throws CoreException {
66         super(parentShell);
67         super.setTitle(LaunchConfigurationsMessages.SelectLaunchOptionsDialog_3);
68         setShellStyle(getShellStyle() | SWT.RESIZE);
69         fValidModes = new ArrayList JavaDoc();
70         Set JavaDoc modes = configuration.getType().getSupportedModeCombinations();
71         Set JavaDoc modeset = null;
72         for(Iterator JavaDoc iter = modes.iterator(); iter.hasNext();) {
73             modeset = (Set JavaDoc) iter.next();
74             if(modeset.contains(mode)) {
75                 fValidModes.add(modeset);
76             }
77         }
78     }
79     
80     /* (non-Javadoc)
81      * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getDialogSettingsId()
82      */

83     protected String JavaDoc getDialogSettingsId() {
84         return IDebugUIConstants.PLUGIN_ID + ".SELECT_LAUNCH_MODES_DIALOG"; //$NON-NLS-1$
85
}
86
87     /* (non-Javadoc)
88      * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getLabelProvider()
89      */

90     protected IBaseLabelProvider getLabelProvider() {
91         return new OptionsLabelProvider();
92     }
93     
94     /* (non-Javadoc)
95      * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getViewerInput()
96      */

97     protected Object JavaDoc getViewerInput() {
98         return fValidModes.toArray();
99     }
100
101     /* (non-Javadoc)
102      * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getHelpContextId()
103      */

104     protected String JavaDoc getHelpContextId() {
105         return IDebugHelpContextIds.SELECT_LAUNCH_MODES_DIALOG;
106     }
107
108     /* (non-Javadoc)
109      * @see org.eclipse.debug.internal.ui.launchConfigurations.AbstractDebugSelectionDialog#getViewerLabel()
110      */

111     protected String JavaDoc getViewerLabel() {
112         return LaunchConfigurationsMessages.SelectLaunchOptionsDialog_4;
113     }
114 }
115
Popular Tags