KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > launchConfigurations > SetTargetsDialog


1 /*******************************************************************************
2  * Copyright (c) 2005, 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.ant.internal.ui.launchConfigurations;
12
13 import org.eclipse.ant.internal.ui.AntUIPlugin;
14 import org.eclipse.core.runtime.CoreException;
15 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
16 import org.eclipse.jface.dialogs.Dialog;
17 import org.eclipse.jface.dialogs.IDialogSettings;
18 import org.eclipse.swt.SWT;
19 import org.eclipse.swt.widgets.Composite;
20 import org.eclipse.swt.widgets.Control;
21 import org.eclipse.swt.widgets.Shell;
22
23 public class SetTargetsDialog extends Dialog {
24     
25     private static String JavaDoc DIALOG_SETTINGS_SECTION = "SetTargetsDialogSettings"; //$NON-NLS-1$
26

27     private ILaunchConfigurationWorkingCopy fConfiguration;
28     private AntTargetsTab fTargetsTab;
29     
30     public SetTargetsDialog(Shell parentShell, ILaunchConfigurationWorkingCopy config) {
31         super(parentShell);
32         setShellStyle(SWT.RESIZE | getShellStyle());
33         fConfiguration= config;
34     }
35     
36     /* (non-Javadoc)
37      * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
38      */

39     protected Control createDialogArea(Composite parent) {
40         
41         getShell().setText(AntLaunchConfigurationMessages.SetTargetsDialog_0);
42         Composite composite = (Composite)super.createDialogArea(parent);
43         
44         fTargetsTab= new AntTargetsTab();
45         fTargetsTab.createControl(composite);
46         fTargetsTab.initializeFrom(fConfiguration);
47         applyDialogFont(composite);
48         return composite;
49     }
50     
51     /* (non-Javadoc)
52      * @see org.eclipse.jface.dialogs.Dialog#okPressed()
53      */

54     protected void okPressed() {
55         fTargetsTab.performApply(fConfiguration);
56         
57         super.okPressed();
58     }
59
60     protected String JavaDoc getTargetsSelected() {
61         String JavaDoc defaultValue= null;
62         if (!fTargetsTab.isTargetSelected()) {
63             defaultValue= ""; //$NON-NLS-1$
64
}
65         try {
66             return fConfiguration.getAttribute(IAntLaunchConfigurationConstants.ATTR_ANT_TARGETS, defaultValue);
67         } catch (CoreException e) {
68             return defaultValue;
69         }
70     }
71     
72     /* (non-Javadoc)
73      * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings()
74      */

75     protected IDialogSettings getDialogBoundsSettings() {
76          IDialogSettings settings = AntUIPlugin.getDefault().getDialogSettings();
77          IDialogSettings section = settings.getSection(DIALOG_SETTINGS_SECTION);
78          if (section == null) {
79              section = settings.addNewSection(DIALOG_SETTINGS_SECTION);
80          }
81          return section;
82     }
83 }
84     
85
Popular Tags