KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > actions > ProjectSelectionDialog


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.jdt.internal.debug.ui.actions;
12
13
14 import org.eclipse.jdt.debug.ui.IJavaDebugUIConstants;
15 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
16 import org.eclipse.jface.dialogs.IDialogSettings;
17 import org.eclipse.jface.viewers.ILabelProvider;
18 import org.eclipse.jface.viewers.IStructuredContentProvider;
19 import org.eclipse.swt.SWT;
20 import org.eclipse.swt.events.SelectionAdapter;
21 import org.eclipse.swt.events.SelectionEvent;
22 import org.eclipse.swt.graphics.Font;
23 import org.eclipse.swt.widgets.Button;
24 import org.eclipse.swt.widgets.Composite;
25 import org.eclipse.swt.widgets.Control;
26 import org.eclipse.swt.widgets.Shell;
27 import org.eclipse.ui.dialogs.ListSelectionDialog;
28
29 /**
30  * A dialog for selecting projects to add to a classpath or source
31  * lookup path. Optionally specifies whether
32  * exported entries and required projects should also be added.
33  */

34 public class ProjectSelectionDialog extends ListSelectionDialog {
35     
36     private boolean fAddExportedEntries = true;
37     private boolean fAddRequiredProjects = true;
38
39     /**
40      * @see ListSelectionDialog
41      */

42     public ProjectSelectionDialog(
43         Shell parentShell,
44         Object JavaDoc input,
45         IStructuredContentProvider contentProvider,
46         ILabelProvider labelProvider,
47         String JavaDoc message) {
48         super(parentShell, input, contentProvider, labelProvider, message);
49         setShellStyle(getShellStyle() | SWT.RESIZE);
50     }
51
52     /**
53      * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
54      */

55     protected Control createDialogArea(Composite parent) {
56         Font font = parent.getFont();
57         
58         Composite composite = (Composite)super.createDialogArea(parent);
59         
60         final Button addExported = new Button(composite, SWT.CHECK);
61         addExported.setText(ActionMessages.ProjectSelectionDialog_Add_exported_entries_of_selected_projects__1);
62         addExported.addSelectionListener(new SelectionAdapter() {
63             public void widgetSelected(SelectionEvent e) {
64                 fAddExportedEntries = addExported.getSelection();
65             }
66         });
67         addExported.setSelection(fAddExportedEntries);
68         addExported.setFont(font);
69         
70         final Button addRequired = new Button(composite, SWT.CHECK);
71         addRequired.setText(ActionMessages.ProjectSelectionDialog_Add_required_projects_of_selected_projects__2);
72         addRequired.addSelectionListener(new SelectionAdapter() {
73             public void widgetSelected(SelectionEvent e) {
74                 fAddRequiredProjects = addRequired.getSelection();
75             }
76         });
77         addRequired.setSelection(fAddRequiredProjects);
78         addRequired.setFont(font);
79         
80         applyDialogFont(composite);
81         return composite;
82     }
83     
84     /**
85      * Returns whether the user has selected to add exported entries.
86      *
87      * @return whether the user has selected to add exported entries
88      */

89     public boolean isAddExportedEntries() {
90         return fAddExportedEntries;
91     }
92     
93     /**
94      * Returns whether the user has selected to add required projects.
95      *
96      * @return whether the user has selected to add required projects
97      */

98     public boolean isAddRequiredProjects() {
99         return fAddRequiredProjects;
100     }
101     
102     /**
103      * Returns the name of the section that this dialog stores its settings in
104      *
105      * @return String
106      */

107     protected String JavaDoc getDialogSettingsSectionName() {
108         return IJavaDebugUIConstants.PLUGIN_ID + ".P ROJECT_SELECTION_DIALOG_SECTION"; //$NON-NLS-1$
109
}
110     
111      /* (non-Javadoc)
112      * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings()
113      */

114     protected IDialogSettings getDialogBoundsSettings() {
115          IDialogSettings settings = JDIDebugUIPlugin.getDefault().getDialogSettings();
116          IDialogSettings section = settings.getSection(getDialogSettingsSectionName());
117          if (section == null) {
118              section = settings.addNewSection(getDialogSettingsSectionName());
119          }
120          return section;
121     }
122 }
123
Popular Tags