Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 8d8a1d8952ab6a72fac92f3960727c0f3627aab0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*******************************************************************************
 * Copyright (c) 2000, 2006 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.debug.internal.ui.launchConfigurations;


import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.ui.ILaunchGroup;
import org.eclipse.jface.resource.ImageDescriptor;


/**
 * Proxy to a launch group extension
 */
public class LaunchGroupExtension implements ILaunchGroup {

	/**
	 * The configuration element defining this launch group.
	 */
	private IConfigurationElement fConfig;

	/**
	 * The image for this group
	 */
	private ImageDescriptor fImageDescriptor;

	/**
	 * The banner image for this group
	 */
	private ImageDescriptor fBannerImageDescriptor;

	/**
	 * Constructs a launch group extension based on the given configuration
	 * element
	 *
	 * @param element the configuration element defining the
	 *  attributes of this launch group extension
	 * @return a new launch group extension
	 */
	public LaunchGroupExtension(IConfigurationElement element) {
		setConfigurationElement(element);
	}

	/**
	 * Sets the configuration element that defines the attributes
	 * for this launch group extension.
	 *
	 * @param element configuration element
	 */
	private void setConfigurationElement(IConfigurationElement element) {
		fConfig = element;
	}

	/**
	 * Returns the configuration element that defines the attributes
	 * for this launch group extension.
	 *
	 * @param configuration element that defines the attributes
	 *  for this launch group extension
	 */
	protected IConfigurationElement getConfigurationElement() {
		return fConfig;
	}

	/**
	 * Returns the image for this launch group, or <code>null</code> if none
	 *
	 * @return the image for this launch group, or <code>null</code> if none
	 */
	@Override
	public ImageDescriptor getImageDescriptor() {
		if (fImageDescriptor == null) {
			fImageDescriptor = createImageDescriptor("image"); //$NON-NLS-1$
		}
		return fImageDescriptor;
	}

	/**
	 * Returns the banner image for this launch group, or <code>null</code> if
	 * none
	 *
	 * @return the banner image for this launch group, or <code>null</code> if
	 * none
	 */
	@Override
	public ImageDescriptor getBannerImageDescriptor() {
		if (fBannerImageDescriptor == null) {
			fBannerImageDescriptor = createImageDescriptor("bannerImage"); //$NON-NLS-1$
		}
		return fBannerImageDescriptor;
	}

	/**
	 * Returns the label for this launch group
	 *
	 * @return the label for this launch group
	 */
	@Override
	public String getLabel() {
		return getConfigurationElement().getAttribute("label"); //$NON-NLS-1$
	}

	/**
	 * Returns the id for this launch group
	 *
	 * @return the id for this launch group
	 */
	@Override
	public String getIdentifier() {
		return getConfigurationElement().getAttribute("id"); //$NON-NLS-1$
	}

	/**
	 * Returns the category for this launch group, possibly <code>null</code>
	 *
	 * @return the category for this launch group, possibly <code>null</code>
	 */
	@Override
	public String getCategory() {
		return getConfigurationElement().getAttribute("category"); //$NON-NLS-1$
	}

	/**
	 * Returns the mode for this launch group
	 *
	 * @return the mode for this launch group
	 */
	@Override
	public String getMode() {
		return getConfigurationElement().getAttribute("mode"); //$NON-NLS-1$
	}

	/**
	 * Creates an image descriptor based on the given attribute name
	 *
	 * @param attribute
	 * @return ImageDescriptor
	 */
	protected ImageDescriptor createImageDescriptor(String attribute) {
		return DebugUIPlugin.getImageDescriptor(getConfigurationElement(), attribute);
	}

	/**
	 * Returns whether this launch group is public
	 *
	 * @return boolean
	 */
	@Override
	public boolean isPublic() {
		String string = getConfigurationElement().getAttribute("public"); //$NON-NLS-1$
		if (string == null) {
			return true;
		}
		return string.equals("true"); //$NON-NLS-1$
	}

}

Back to the top