KickJava   Java API By Example, From Geeks To Geeks.

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


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.debug.internal.ui.launchConfigurations;
12
13  
14 import org.eclipse.core.runtime.IConfigurationElement;
15 import org.eclipse.debug.internal.ui.DebugUIPlugin;
16 import org.eclipse.debug.ui.ILaunchGroup;
17 import org.eclipse.jface.resource.ImageDescriptor;
18
19
20 /**
21  * Proxy to a launch group extension
22  */

23 public class LaunchGroupExtension implements ILaunchGroup {
24     
25     /**
26      * The configuration element defining this launch group.
27      */

28     private IConfigurationElement fConfig;
29     
30     /**
31      * The image for this group
32      */

33     private ImageDescriptor fImageDescriptor;
34     
35     /**
36      * The banner image for this group
37      */

38     private ImageDescriptor fBannerImageDescriptor;
39     
40     /**
41      * Constructs a launch group extension based on the given configuration
42      * element
43      *
44      * @param element the configuration element defining the
45      * attributes of this launch group extension
46      * @return a new launch group extension
47      */

48     public LaunchGroupExtension(IConfigurationElement element) {
49         setConfigurationElement(element);
50     }
51     
52     /**
53      * Sets the configuration element that defines the attributes
54      * for this launch group extension.
55      *
56      * @param element configuration element
57      */

58     private void setConfigurationElement(IConfigurationElement element) {
59         fConfig = element;
60     }
61     
62     /**
63      * Returns the configuration element that defines the attributes
64      * for this launch group extension.
65      *
66      * @param configuration element that defines the attributes
67      * for this launch group extension
68      */

69     protected IConfigurationElement getConfigurationElement() {
70         return fConfig;
71     }
72     
73     /**
74      * Returns the image for this launch group, or <code>null</code> if none
75      *
76      * @return the image for this launch group, or <code>null</code> if none
77      */

78     public ImageDescriptor getImageDescriptor() {
79         if (fImageDescriptor == null) {
80             fImageDescriptor = createImageDescriptor("image"); //$NON-NLS-1$
81
}
82         return fImageDescriptor;
83     }
84     
85     /**
86      * Returns the banner image for this launch group, or <code>null</code> if
87      * none
88      *
89      * @return the banner image for this launch group, or <code>null</code> if
90      * none
91      */

92     public ImageDescriptor getBannerImageDescriptor() {
93         if (fBannerImageDescriptor == null) {
94             fBannerImageDescriptor = createImageDescriptor("bannerImage"); //$NON-NLS-1$
95
}
96         return fBannerImageDescriptor;
97     }
98     
99     /**
100      * Returns the label for this launch group
101      *
102      * @return the label for this launch group
103      */

104     public String JavaDoc getLabel() {
105         return getConfigurationElement().getAttribute("label"); //$NON-NLS-1$
106
}
107         
108     /**
109      * Returns the id for this launch group
110      *
111      * @return the id for this launch group
112      */

113     public String JavaDoc getIdentifier() {
114         return getConfigurationElement().getAttribute("id"); //$NON-NLS-1$
115
}
116     
117     /**
118      * Returns the category for this launch group, possibly <code>null</code>
119      *
120      * @return the category for this launch group, possibly <code>null</code>
121      */

122     public String JavaDoc getCategory() {
123         return getConfigurationElement().getAttribute("category"); //$NON-NLS-1$
124
}
125     
126     /**
127      * Returns the mode for this launch group
128      *
129      * @return the mode for this launch group
130      */

131     public String JavaDoc getMode() {
132         return getConfigurationElement().getAttribute("mode"); //$NON-NLS-1$
133
}
134     
135     /**
136      * Creates an image descriptor based on the given attribute name
137      *
138      * @param attribute
139      * @return ImageDescriptor
140      */

141     protected ImageDescriptor createImageDescriptor(String JavaDoc attribute) {
142         return DebugUIPlugin.getImageDescriptor(getConfigurationElement(), attribute);
143     }
144     
145     /**
146      * Returns whether this launch group is public
147      *
148      * @return boolean
149      */

150     public boolean isPublic() {
151         String JavaDoc string = getConfigurationElement().getAttribute("public"); //$NON-NLS-1$
152
if (string == null) {
153             return true;
154         }
155         return string.equals("true"); //$NON-NLS-1$
156
}
157
158 }
159
160
Popular Tags