KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > LaunchConfigurationTabExtension


1 /*******************************************************************************
2  * Copyright (c) 2006, 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.debug.internal.ui;
12
13 import java.util.HashSet JavaDoc;
14 import java.util.Set JavaDoc;
15
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.core.runtime.IConfigurationElement;
18 import org.eclipse.debug.internal.core.IConfigurationElementConstants;
19 import org.eclipse.debug.ui.ILaunchConfigurationTab;
20
21 /**
22  * Provides a proxy to a launchConfigurationTabs extension point
23  *
24  * @since 3.3
25  */

26 public final class LaunchConfigurationTabExtension {
27
28     /**
29      * The configuration element backing this proxy
30      */

31     IConfigurationElement fElement = null;
32     private Set JavaDoc fDelegates = null;
33     
34     /**
35      * Constructor
36      * @param element the <code>IConfigurationElement</code> for this proxy
37      */

38     public LaunchConfigurationTabExtension(IConfigurationElement element) {
39         fElement = element;
40     }
41     
42     /**
43      * Returns the unique id of the tab
44      * @return the unique id of the tab
45      */

46     public String JavaDoc getIdentifier() {
47         return fElement.getAttribute(IConfigurationElementConstants.ID);
48     }
49
50     /**
51      * Returns the human readable name for the tab, not to be confused with the name that appears on the tab itself
52      * @return the name of the tab
53      */

54     public String JavaDoc getName() {
55         return fElement.getAttribute(IConfigurationElementConstants.NAME);
56     }
57
58     /**
59      * Returns the instantiated class of this tab
60      * @return the instantiated class of this tab
61      */

62     public ILaunchConfigurationTab getTab() {
63         try {
64             Object JavaDoc object = fElement.createExecutableExtension(IConfigurationElementConstants.CLASS);
65             if(object instanceof ILaunchConfigurationTab) {
66                 return (ILaunchConfigurationTab) object;
67             }
68         } catch (CoreException e) {DebugUIPlugin.log(e);}
69         return null;
70     }
71
72     /**
73      * Returns the unique id of the <code>ILaunchConfigurationTabGroup</code> that this tab contributes to
74      * @return the id of the <code>ILaunchConfigurationTabGroup</code> this tab contributes to
75      */

76     public String JavaDoc getTabGroupId() {
77         return fElement.getAttribute(IConfigurationElementConstants.GROUP);
78     }
79     
80     /**
81      * This method returns the id of the tab that this tab should be placed immediately after.
82      * @return the id of the relative tab or <code>null</code> if one has not been specified
83      *
84      */

85     public String JavaDoc getRelativeTabId() {
86         IConfigurationElement[] elems = fElement.getChildren(IConfigurationElementConstants.PLACEMENT);
87         if(elems.length == 1) {
88             return elems[0].getAttribute(IConfigurationElementConstants.AFTER);
89         }
90         return null;
91     }
92     
93     /**
94      * Returns the id of the plugin that contributed this tab extension
95      * @return the id of the plugin tat contributed this tab
96      */

97     public String JavaDoc getPluginIdentifier() {
98         return fElement.getContributor().getName();
99     }
100     
101     /**
102      * Returns a set of strings of the launch delegates that this tab contribution is associated with
103      * @return the set of strings of the associated launch delegates, which can be an empty collection, never <code>null</code>.
104      */

105     public Set JavaDoc getDelegateSet() {
106         if(fDelegates == null) {
107             fDelegates = new HashSet JavaDoc();
108             IConfigurationElement[] children = fElement.getChildren(IConfigurationElementConstants.ASSOCIATED_DELEGATE);
109             String JavaDoc id = null;
110             for(int i = 0; i < children.length; i++) {
111                 id = children[i].getAttribute(IConfigurationElementConstants.DELEGATE);
112                 if(id != null) {
113                     fDelegates.add(id);
114                 }
115             }
116         }
117         return fDelegates;
118     }
119 }
120
Popular Tags