1 11 package org.eclipse.debug.internal.ui.launchConfigurations; 12 13 14 import java.util.ArrayList ; 15 import java.util.HashMap ; 16 import java.util.HashSet ; 17 import java.util.Hashtable ; 18 import java.util.List ; 19 import java.util.Map ; 20 import java.util.Set ; 21 22 import org.eclipse.core.runtime.CoreException; 23 import org.eclipse.core.runtime.IConfigurationElement; 24 import org.eclipse.debug.internal.core.IConfigurationElementConstants; 25 import org.eclipse.debug.ui.ILaunchConfigurationTabGroup; 26 27 28 31 public class LaunchConfigurationTabGroupExtension { 32 33 36 private IConfigurationElement fConfig = null; 37 38 42 private List fModes = null; 43 44 48 private Map fDescriptions = null; 49 50 53 private Map fPerspectives = null; 54 55 63 public LaunchConfigurationTabGroupExtension(IConfigurationElement element) { 64 setConfigurationElement(element); 65 } 66 67 73 private void setConfigurationElement(IConfigurationElement element) { 74 fConfig = element; 75 } 76 77 84 protected IConfigurationElement getConfigurationElement() { 85 return fConfig; 86 } 87 88 95 protected List getModes() { 96 if (fModes == null) { 97 fModes = new ArrayList (); 98 fPerspectives = new Hashtable (); 99 IConfigurationElement[] modes = fConfig.getChildren(IConfigurationElementConstants.LAUNCH_MODE); 100 if (modes.length > 0) { 101 IConfigurationElement element = null; 102 String perspective = null, mode = null; 103 Set mset = null; 104 for (int i = 0; i < modes.length; i++) { 105 element = modes[i]; 106 mode = element.getAttribute(IConfigurationElementConstants.MODE); 107 mset = new HashSet (); 108 mset.add(mode); 109 fModes.add(mset); 110 perspective = element.getAttribute(IConfigurationElementConstants.PERSPECTIVE); 111 if (perspective != null) { 112 fPerspectives.put(mset, perspective); 113 } 114 } 115 } 116 } 117 return fModes; 118 } 119 120 127 protected String getPerspective(Set modes) { 128 getModes(); 129 return (String )fPerspectives.get(modes); 130 } 131 132 139 protected String getTypeIdentifier() { 140 return getConfigurationElement().getAttribute(IConfigurationElementConstants.TYPE); 141 } 142 143 151 protected String getHelpContextId() { 152 return getConfigurationElement().getAttribute(IConfigurationElementConstants.HELP_CONTEXT_ID); 153 } 154 155 161 protected String getIdentifier() { 162 return getConfigurationElement().getAttribute(IConfigurationElementConstants.ID); 163 } 164 165 172 public ILaunchConfigurationTabGroup newTabGroup() throws CoreException { 173 return (ILaunchConfigurationTabGroup)getConfigurationElement().createExecutableExtension(IConfigurationElementConstants.CLASS); 174 } 175 176 183 public String getDescription(Set modes) { 184 String description = null; 185 if(fDescriptions == null) { 186 fDescriptions = new HashMap (); 187 IConfigurationElement[] children = fConfig.getChildren(IConfigurationElementConstants.LAUNCH_MODE); 188 IConfigurationElement child = null; 189 String mode = null; 190 HashSet set = null; 191 for (int i = 0; i < children.length; i++) { 192 child = children[i]; 193 mode = child.getAttribute(IConfigurationElementConstants.MODE); 194 if(mode != null) { 195 set = new HashSet (); 196 set.add(mode); 197 } 198 description = child.getAttribute(IConfigurationElementConstants.DESCRIPTION); 199 if(description != null) { 200 fDescriptions.put(set, description); 201 } 202 } 203 204 } 205 description = (String ) fDescriptions.get(modes); 206 if(description == null) { 207 description = fConfig.getAttribute(IConfigurationElementConstants.DESCRIPTION); 208 209 } 210 return (description == null ? "" : description); } 212 213 } 214 215 | Popular Tags |