Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: f6290f5336dc1a05afbf542f986483ae6db74c5a (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
/*******************************************************************************
 * Copyright (c) 2006, 2013 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.debug.internal.ui;

import java.util.HashSet;
import java.util.Set;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.debug.internal.core.IConfigurationElementConstants;
import org.eclipse.debug.ui.ILaunchConfigurationTab;

/**
 * Provides a proxy to a launchConfigurationTabs extension point
 *
 * @since 3.3
 */
public final class LaunchConfigurationTabExtension {

	/**
	 * The configuration element backing this proxy
	 */
	IConfigurationElement fElement = null;
	private Set<String> fDelegates = null;

	/**
	 * Constructor
	 * @param element the <code>IConfigurationElement</code> for this proxy
	 */
	public LaunchConfigurationTabExtension(IConfigurationElement element) {
		fElement = element;
	}

	/**
	 * Returns the unique id of the tab
	 * @return the unique id of the tab
	 */
	public String getIdentifier() {
		return fElement.getAttribute(IConfigurationElementConstants.ID);
	}

	/**
	 * Returns the human readable name for the tab, not to be confused with the name that appears on the tab itself
	 * @return the name of the tab
	 */
	public String getName() {
		return fElement.getAttribute(IConfigurationElementConstants.NAME);
	}

	/**
	 * Returns the instantiated class of this tab
	 * @return the instantiated class of this tab
	 */
	public ILaunchConfigurationTab getTab() {
		try {
			Object object = fElement.createExecutableExtension(IConfigurationElementConstants.CLASS);
			if(object instanceof ILaunchConfigurationTab) {
				return (ILaunchConfigurationTab) object;
			}
		} catch (CoreException e) {DebugUIPlugin.log(e);}
		return null;
	}

	/**
	 * Returns the unique id of the <code>ILaunchConfigurationTabGroup</code> that this tab contributes to
	 * @return the id of the <code>ILaunchConfigurationTabGroup</code> this tab contributes to
	 */
	public String getTabGroupId() {
		return fElement.getAttribute(IConfigurationElementConstants.GROUP);
	}

	/**
	 * This method returns the id of the tab that this tab should be placed immediately after.
	 * @return the id of the relative tab or <code>null</code> if one has not been specified
	 *
	 */
	public String getRelativeTabId() {
		IConfigurationElement[] elems = fElement.getChildren(IConfigurationElementConstants.PLACEMENT);
		if(elems.length == 1) {
			return elems[0].getAttribute(IConfigurationElementConstants.AFTER);
		}
		return null;
	}

	/**
	 * Returns the id of the plugin that contributed this tab extension
	 * @return the id of the plugin tat contributed this tab
	 */
	public String getPluginIdentifier() {
		return fElement.getContributor().getName();
	}

	/**
	 * Returns a set of strings of the launch delegates that this tab contribution is associated with
	 * @return the set of strings of the associated launch delegates, which can be an empty collection, never <code>null</code>.
	 */
	public Set<String> getDelegateSet() {
		if(fDelegates == null) {
			fDelegates = new HashSet<>();
			IConfigurationElement[] children = fElement.getChildren(IConfigurationElementConstants.ASSOCIATED_DELEGATE);
			String id = null;
			for(int i = 0; i < children.length; i++) {
				id = children[i].getAttribute(IConfigurationElementConstants.DELEGATE);
				if(id != null) {
					fDelegates.add(id);
				}
			}
		}
		return fDelegates;
	}
}

Back to the top