KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > ui > launcher > ConfigurationTab


1 /*******************************************************************************
2  * Copyright (c) 2005, 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.pde.ui.launcher;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.debug.core.ILaunchConfiguration;
15 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
16 import org.eclipse.jface.dialogs.Dialog;
17 import org.eclipse.pde.internal.ui.IHelpContextIds;
18 import org.eclipse.pde.internal.ui.PDEPluginImages;
19 import org.eclipse.pde.internal.ui.PDEUIMessages;
20 import org.eclipse.pde.internal.ui.launcher.ConfigurationAreaBlock;
21 import org.eclipse.pde.internal.ui.launcher.ConfigurationTemplateBlock;
22 import org.eclipse.swt.SWT;
23 import org.eclipse.swt.graphics.Image;
24 import org.eclipse.swt.layout.GridData;
25 import org.eclipse.swt.layout.GridLayout;
26 import org.eclipse.swt.widgets.Composite;
27 import org.eclipse.ui.PlatformUI;
28
29 /**
30  * A launch configuration tab that displays and edits the configuration area
31  * location and template for a PDE launch configuration.
32  * <p>
33  * This class may be instantiated, but it is not intended to be subclassed by clients.
34  * </p>
35  * @since 3.2
36  */

37 public class ConfigurationTab extends AbstractLauncherTab implements IPDELauncherConstants {
38     
39     private ConfigurationAreaBlock fConfigurationArea;
40     private ConfigurationTemplateBlock fTemplateArea;
41     private Image fImage;
42     private boolean fJUnitConfig;
43     
44     /**
45      * Constructor. Equivalent to ConfigurationTab(false).
46      *
47      * @see #ConfigurationTab(boolean)
48      */

49     public ConfigurationTab() {
50         this(false);
51     }
52     
53     /**
54      * Constructor
55      *
56      * @param isJUnitConfig a flag to indicate if the tab is to be used with a Plug-in JUnit launch configuration.
57      */

58     public ConfigurationTab(boolean isJUnitConfig) {
59         fImage = PDEPluginImages.DESC_SETTINGS_OBJ.createImage();
60         fConfigurationArea = new ConfigurationAreaBlock(this);
61         fTemplateArea = new ConfigurationTemplateBlock(this);
62         fJUnitConfig = isJUnitConfig;
63     }
64     
65     /*
66     /* (non-Javadoc)
67      * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
68      */

69     public void createControl(Composite parent) {
70         Composite container = new Composite(parent, SWT.NONE);
71         container.setLayout(new GridLayout());
72         container.setLayoutData(new GridData(GridData.FILL_BOTH));
73         
74         fConfigurationArea.createControl(container);
75         fTemplateArea.createControl(container);
76         
77         Dialog.applyDialogFont(container);
78         setControl(container);
79         PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.LAUNCHER_CONFIGURATION);
80     }
81     
82     /*
83      * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
84      */

85     public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
86         fConfigurationArea.setDefaults(configuration, fJUnitConfig);
87         fTemplateArea.setDefaults(configuration);
88     }
89     
90     /* (non-Javadoc)
91      * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
92      */

93     public void initializeFrom(ILaunchConfiguration configuration) {
94         try {
95             fConfigurationArea.initializeFrom(configuration);
96             fTemplateArea.initializeFrom(configuration);
97         } catch (CoreException e) {
98         }
99     }
100     
101     /*
102     /* (non-Javadoc)
103      * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
104      */

105     public void performApply(ILaunchConfigurationWorkingCopy configuration) {
106         fConfigurationArea.performApply(configuration);
107         fTemplateArea.performApply(configuration);
108     }
109     
110     /*
111     /* (non-Javadoc)
112      * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
113      */

114     public String JavaDoc getName() {
115         return PDEUIMessages.ConfigurationTab_name;
116     }
117     
118     /*
119     /* (non-Javadoc)
120      * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#getImage()
121      */

122     public Image getImage() {
123         return fImage;
124     }
125     
126     /*
127     /* (non-Javadoc)
128      * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#dispose()
129      */

130     public void dispose() {
131         if (fImage != null)
132             fImage.dispose();
133     }
134
135     /**
136      * Validates the page and flags an error if the configuration area
137      * location or the configuration template location does not exist.
138      *
139      * @see org.eclipse.pde.ui.launcher.AbstractLauncherTab#validateTab()
140      */

141     public void validateTab() {
142         String JavaDoc error = fConfigurationArea.validate();
143         if (error == null)
144             error = fTemplateArea.validate();
145         setErrorMessage(error);
146     }
147 }
148
Popular Tags