View | Details | Raw Unified | Return to bug 137057
Collapse All | Expand All

(-)schema/launchDelegates.exsd (-155 / +165 lines)
Lines 1-155 Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.debug.core">
3
<schema targetNamespace="org.eclipse.debug.core">
4
<annotation>
4
<annotation>
5
      <appInfo>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.debug.core" id="launchDelegates" name="Launch Delegates"/>
6
         <meta.schema plugin="org.eclipse.debug.core" id="launchDelegates" name="Launch Delegates"/>
7
      </appInfo>
7
      </appInfo>
8
      <documentation>
8
      <documentation>
9
         This extension point provides a mechanism for contributing a launch delegate to an existing launch configuration type for one or more launch modes. Since launch modes are extensible, it may be neccessary to contribute additional launch delegates to an existing launch configuration type. Each launch delegate is contributed for a specific launch configuration type. A launch delegate supports one or more launch modes, and specifies a delegate responsible for the implementation of launching.
9
         This extension point provides a mechanism for contributing a launch delegate to an existing launch configuration type for one or more launch modes. Since launch modes are extensible, it may be neccessary to contribute additional launch delegates to an existing launch configuration type. Each launch delegate is contributed for a specific launch configuration type. A launch delegate supports one or more launch modes, and specifies a delegate responsible for the implementation of launching.
10
      </documentation>
10
      </documentation>
11
   </annotation>
11
   </annotation>
12
12
13
   <element name="extension">
13
   <element name="extension">
14
      <complexType>
14
      <complexType>
15
         <sequence>
15
         <sequence>
16
            <element ref="launchDelegate" minOccurs="0" maxOccurs="unbounded"/>
16
            <element ref="launchDelegate" minOccurs="0" maxOccurs="unbounded"/>
17
         </sequence>
17
         </sequence>
18
         <attribute name="point" type="string" use="required">
18
         <attribute name="point" type="string" use="required">
19
            <annotation>
19
            <annotation>
20
               <documentation>
20
               <documentation>
21
                  a fully qualified identifier of the target extension point
21
                  a fully qualified identifier of the target extension point
22
               </documentation>
22
               </documentation>
23
            </annotation>
23
            </annotation>
24
         </attribute>
24
         </attribute>
25
         <attribute name="id" type="string">
25
         <attribute name="id" type="string">
26
            <annotation>
26
            <annotation>
27
               <documentation>
27
               <documentation>
28
                  an optional identifier of the extension instance
28
                  an optional identifier of the extension instance
29
               </documentation>
29
               </documentation>
30
            </annotation>
30
            </annotation>
31
         </attribute>
31
         </attribute>
32
         <attribute name="name" type="string">
32
         <attribute name="name" type="string">
33
            <annotation>
33
            <annotation>
34
               <documentation>
34
               <documentation>
35
                  an optional name of the extension instance
35
                  an optional name of the extension instance
36
               </documentation>
36
               </documentation>
37
            </annotation>
37
            </annotation>
38
         </attribute>
38
         </attribute>
39
      </complexType>
39
      </complexType>
40
   </element>
40
   </element>
41
41
42
   <element name="launchDelegate">
42
   <element name="launchDelegate">
43
      <annotation>
43
      <annotation>
44
         <appInfo>
44
         <appInfo>
45
            <meta.element labelAttribute="name"/>
45
            <meta.element labelAttribute="name"/>
46
         </appInfo>
46
         </appInfo>
47
      </annotation>
47
      </annotation>
48
      <complexType>
48
      <complexType>
49
         <sequence>
49
         <sequence>
50
         </sequence>
50
         </sequence>
51
         <attribute name="id" type="string" use="required">
51
         <attribute name="id" type="string" use="required">
52
            <annotation>
52
            <annotation>
53
               <documentation>
53
               <documentation>
54
                  specifies a unique identifier for this launch delegate.
54
                  specifies a unique identifier for this launch delegate.
55
               </documentation>
55
               </documentation>
56
            </annotation>
56
            </annotation>
57
         </attribute>
57
         </attribute>
58
         <attribute name="delegate" type="string" use="required">
58
         <attribute name="delegate" type="string" use="required">
59
            <annotation>
59
            <annotation>
60
               <documentation>
60
               <documentation>
61
                  specifies the fully qualified name of the Java class that implements &lt;code&gt;ILaunchConfigurationDelegate&lt;/code&gt;.
61
                  specifies the fully qualified name of the Java class that implements &lt;code&gt;ILaunchConfigurationDelegate&lt;/code&gt;.
62
Launch configuration instances of this delegate&apos;s type will delegate to instances of this class to perform launching.
62
Launch configuration instances of this delegate&apos;s type will delegate to instances of this class to perform launching.
63
               </documentation>
63
               </documentation>
64
               <appInfo>
64
               <appInfo>
65
                  <meta.attribute kind="java" basedOn="org.eclipse.debug.core.model.ILaunchConfigurationDelegate"/>
65
                  <meta.attribute kind="java" basedOn="org.eclipse.debug.core.model.ILaunchConfigurationDelegate"/>
66
               </appInfo>
66
               </appInfo>
67
            </annotation>
67
            </annotation>
68
         </attribute>
68
         </attribute>
69
         <attribute name="modes" type="string" use="required">
69
         <attribute name="modes" type="string" use="required">
70
            <annotation>
70
            <annotation>
71
               <documentation>
71
               <documentation>
72
                  specifies a comma-separated list of the modes this lauch delegate supports.
72
                  specifies a comma-separated list of the modes this lauch delegate supports.
73
               </documentation>
73
               </documentation>
74
            </annotation>
74
            </annotation>
75
         </attribute>
75
         </attribute>
76
         <attribute name="type" type="string" use="required">
76
         <attribute name="type" type="string" use="required">
77
            <annotation>
77
            <annotation>
78
               <documentation>
78
               <documentation>
79
                  identifier of an existing launch configuration type that this launch delegate is capable of launching.
79
                  identifier of an existing launch configuration type that this launch delegate is capable of launching.
80
               </documentation>
80
               </documentation>
81
            </annotation>
81
            </annotation>
82
         </attribute>
82
         </attribute>
83
         <attribute name="sourcePathComputerId" type="string">
83
         <attribute name="sourcePathComputerId" type="string">
84
            <annotation>
84
            <annotation>
85
               <documentation>
85
               <documentation>
86
                  The unique identifier of a sourcePathComputer extension that is used to compute a default source lookup path for launch configurations of this type. Since 3.1, this attribute cab be specified in a launchDelegate extension when unspecified in the assocaited launchConfigurationType extension. Only one source path computer can be specified per launch configuration type.
86
                  The unique identifier of a sourcePathComputer extension that is used to compute a default source lookup path for launch configurations of this type. Since 3.1, this attribute cab be specified in a launchDelegate extension when unspecified in the assocaited launchConfigurationType extension. Only one source path computer can be specified per launch configuration type.
87
               </documentation>
87
               </documentation>
88
            </annotation>
88
            </annotation>
89
         </attribute>
89
         </attribute>
90
         <attribute name="sourceLocatorId" type="string">
90
         <attribute name="sourceLocatorId" type="string">
91
            <annotation>
91
            <annotation>
92
               <documentation>
92
               <documentation>
93
                  The unique identifier of a sourceLocator extension that is used to create the source locator for sessions launched using launch configurations of this type. Since 3.1, this attribute can be specified in a launchDelegate extension when unspecified in the assocaited launchConfigurationType extension. Only one source locater can be specified per launch configuration type.
93
                  The unique identifier of a sourceLocator extension that is used to create the source locator for sessions launched using launch configurations of this type. Since 3.1, this attribute can be specified in a launchDelegate extension when unspecified in the assocaited launchConfigurationType extension. Only one source locater can be specified per launch configuration type.
94
               </documentation>
94
               </documentation>
95
            </annotation>
95
            </annotation>
96
         </attribute>
96
         </attribute>
97
      </complexType>
97
         <attribute name="name" type="string">
98
   </element>
98
            <annotation>
99
99
               <documentation>
100
   <annotation>
100
                  A human readable name for the delegate
101
      <appInfo>
101
               </documentation>
102
         <meta.section type="since"/>
102
               <appInfo>
103
      </appInfo>
103
                  <meta.attribute translatable="true"/>
104
      <documentation>
104
               </appInfo>
105
         3.0
105
            </annotation>
106
      </documentation>
106
         </attribute>
107
   </annotation>
107
      </complexType>
108
108
   </element>
109
   <annotation>
109
110
      <appInfo>
110
   <annotation>
111
         <meta.section type="examples"/>
111
      <appInfo>
112
      </appInfo>
112
         <meta.section type="since"/>
113
      <documentation>
113
      </appInfo>
114
         The following is an example of a launch delegate extension point:
114
      <documentation>
115
115
         3.0
116
&lt;p&gt;
116
      </documentation>
117
&lt;pre&gt;
117
   </annotation>
118
 &lt;extension point=&quot;org.eclipse.debug.core.launchDelegates&quot;&gt;
118
119
  &lt;launchDelegate
119
   <annotation>
120
   id=&quot;com.example.ExampleProfileDelegate&quot;
120
      <appInfo>
121
   delegate=&quot;com.example.ExampleProfileDelegate&quot;
121
         <meta.section type="examples"/>
122
   type=&quot;org.eclipse.jdt.launching.localJavaApplication&quot;
122
      </appInfo>
123
   modes=&quot;profile&quot;&gt;
123
      <documentation>
124
  &lt;/launchDelegate&gt;
124
         The following is an example of a launch delegate extension point:
125
 &lt;/extension&gt;
125
126
&lt;/pre&gt;
126
&lt;p&gt;
127
&lt;/p&gt;
127
&lt;pre&gt;
128
128
 &lt;extension point=&quot;org.eclipse.debug.core.launchDelegates&quot;&gt;
129
In the example above, the specified launch delegate is contributed to launch Java applications in profile mode.
129
  &lt;launchDelegate
130
      </documentation>
130
   id=&quot;com.example.ExampleProfileDelegate&quot;
131
   </annotation>
131
   delegate=&quot;com.example.ExampleProfileDelegate&quot;
132
132
   type=&quot;org.eclipse.jdt.launching.localJavaApplication&quot;
133
   <annotation>
133
   modes=&quot;profile&quot;&gt;
134
      <appInfo>
134
  &lt;/launchDelegate&gt;
135
         <meta.section type="apiInfo"/>
135
 &lt;/extension&gt;
136
      </appInfo>
136
&lt;/pre&gt;
137
      <documentation>
137
&lt;/p&gt;
138
         Value of the attribute &lt;b&gt;delegate&lt;/b&gt; must be a fully qualified name of a Java class that implements the interface &lt;b&gt;org.eclipse.debug.core.model.ILaunchConfigurationDelegate&lt;/b&gt;.
138
139
      </documentation>
139
In the example above, the specified launch delegate is contributed to launch Java applications in profile mode.
140
   </annotation>
140
      </documentation>
141
141
   </annotation>
142
   <annotation>
142
143
      <appInfo>
143
   <annotation>
144
         <meta.section type="copyright"/>
144
      <appInfo>
145
      </appInfo>
145
         <meta.section type="apiInfo"/>
146
      <documentation>
146
      </appInfo>
147
         Copyright (c) 2000, 2005 IBM Corporation and others.&lt;br&gt;
147
      <documentation>
148
All rights reserved. This program and the accompanying materials are made 
148
         Value of the attribute &lt;b&gt;delegate&lt;/b&gt; must be a fully qualified name of a Java class that implements the interface &lt;b&gt;org.eclipse.debug.core.model.ILaunchConfigurationDelegate&lt;/b&gt;.
149
available under the terms of the Eclipse Public License v1.0 which 
149
      </documentation>
150
accompanies this distribution, and is available at 
150
   </annotation>
151
&lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
151
152
      </documentation>
152
   <annotation>
153
   </annotation>
153
      <appInfo>
154
154
         <meta.section type="copyright"/>
155
</schema>
155
      </appInfo>
156
      <documentation>
157
         Copyright (c) 2000, 2005 IBM Corporation and others.&lt;br&gt;
158
All rights reserved. This program and the accompanying materials are made 
159
available under the terms of the Eclipse Public License v1.0 which 
160
accompanies this distribution, and is available at 
161
&lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
162
      </documentation>
163
   </annotation>
164
165
</schema>
(-)core/org/eclipse/debug/internal/core/LaunchConfigurationType.java (-1 / +5 lines)
Lines 115-121 Link Here
115
	 * 
115
	 * 
116
	 * @return this type's configuration element
116
	 * @return this type's configuration element
117
	 */
117
	 */
118
	protected IConfigurationElement getConfigurationElement() {
118
	public IConfigurationElement getConfigurationElement() {
119
		return fElement;
119
		return fElement;
120
	}
120
	}
121
	
121
	
Lines 162-167 Link Here
162
		if (!supportsMode(mode)) {
162
		if (!supportsMode(mode)) {
163
			throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, MessageFormat.format(DebugCoreMessages.LaunchConfigurationType_9, new String[] {mode, getIdentifier()}), null));  
163
			throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, MessageFormat.format(DebugCoreMessages.LaunchConfigurationType_9, new String[] {mode, getIdentifier()}), null));  
164
		}
164
		}
165
		ILaunchConfigurationDelegate ld = DebugPlugin.getDefault().getLaunchManager().getPreferredDelegate(this, mode);
166
		if(ld != null) {
167
			return ld;
168
		}
165
		if (fDelegates == null) {
169
		if (fDelegates == null) {
166
			// initialize delegate table with base modes
170
			// initialize delegate table with base modes
167
			fDelegates = new Hashtable(3);
171
			fDelegates = new Hashtable(3);
(-)core/org/eclipse/debug/internal/core/LaunchManager.java (-3 / +465 lines)
Lines 69-74 Link Here
69
import org.eclipse.core.runtime.ListenerList;
69
import org.eclipse.core.runtime.ListenerList;
70
import org.eclipse.core.runtime.Platform;
70
import org.eclipse.core.runtime.Platform;
71
import org.eclipse.core.runtime.PlatformObject;
71
import org.eclipse.core.runtime.PlatformObject;
72
import org.eclipse.core.runtime.Preferences;
72
import org.eclipse.core.runtime.SafeRunner;
73
import org.eclipse.core.runtime.SafeRunner;
73
import org.eclipse.core.runtime.Status;
74
import org.eclipse.core.runtime.Status;
74
import org.eclipse.core.variables.VariablesPlugin;
75
import org.eclipse.core.variables.VariablesPlugin;
Lines 86-91 Link Here
86
import org.eclipse.debug.core.IStatusHandler;
87
import org.eclipse.debug.core.IStatusHandler;
87
import org.eclipse.debug.core.model.IDebugTarget;
88
import org.eclipse.debug.core.model.IDebugTarget;
88
import org.eclipse.debug.core.model.IDisconnect;
89
import org.eclipse.debug.core.model.IDisconnect;
90
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
89
import org.eclipse.debug.core.model.IPersistableSourceLocator;
91
import org.eclipse.debug.core.model.IPersistableSourceLocator;
90
import org.eclipse.debug.core.model.IProcess;
92
import org.eclipse.debug.core.model.IProcess;
91
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector;
93
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector;
Lines 136-141 Link Here
136
	private static final String EMPTY_STRING = ""; //$NON-NLS-1$
138
	private static final String EMPTY_STRING = ""; //$NON-NLS-1$
137
    
139
    
138
	/**
140
	/**
141
	 * Constant for the root preference node for saving preferred launch delegates
142
	 * @since 3.3
143
	 */
144
	private static final String PREFERRED_DELEGATE = "preferredDelegates"; //$NON-NLS-1$
145
	
146
	/**
147
	 * Constant for the delegate provider attribute when saving preferred delegates
148
	 * @since 3.3
149
	 */
150
	private static final String DELEGATE_PROVIDER = "provider"; //$NON-NLS-1$
151
	
152
	/**
153
	 * Constant for the mode attribute when saving preferred delegates
154
	 * @since 3.3
155
	 */
156
	private static final String DELEGATE_MODE = "mode"; //$NON-NLS-1$
157
	
158
	/**
139
	 * Status code for which a UI prompter is registered.
159
	 * Status code for which a UI prompter is registered.
140
	 * 
160
	 * 
141
	 * @since 3.2
161
	 * @since 3.2
Lines 150-156 Link Here
150
	 */
170
	 */
151
	protected static final IStatus deleteAssociatedLaunchConfigs = new Status(IStatus.INFO, DEBUG_CORE, 225, EMPTY_STRING, null);
171
	protected static final IStatus deleteAssociatedLaunchConfigs = new Status(IStatus.INFO, DEBUG_CORE, 225, EMPTY_STRING, null);
152
    
172
    
173
	/**
174
	 * Simple class to collect information for a single preferred delegate
175
	 * @since 3.3
176
	 */
177
	class PreferredDelegate {
178
		private String fMode;
179
		private ILaunchConfigurationDelegate fDelegate;
180
		private ILaunchConfigurationType fType;
181
		private String fProvider;
182
		
183
		public PreferredDelegate(ILaunchConfigurationType type, ILaunchConfigurationDelegate delegate, String mode, String provider) {
184
			fMode = mode;
185
			fDelegate = delegate;
186
			fType = type;
187
			fProvider = provider;
188
		}
189
		
190
		public void setProvider(String provider) {
191
			fProvider = provider;
192
		}
193
		
194
		public String getMode() {
195
			return fMode;
196
		}
197
		
198
		public String getProvider() {
199
			return fProvider;
200
		}
201
		
202
		public ILaunchConfigurationDelegate getDelegeate() {
203
			return fDelegate;
204
		}
205
		
206
		public void setDelegate(ILaunchConfigurationDelegate delegate) {
207
			fDelegate = delegate;
208
		}
209
		
210
		public ILaunchConfigurationType getType() {
211
			return fType;
212
		}
213
	}
153
	
214
	
215
	/**
216
	 * Simple class to describe a list of conflicting delegates for a specific type and mode 
217
	 * @since 3.3
218
	 */
219
	class ConflictingDelegate {
220
		private String fMode;
221
		private ILaunchConfigurationType fType;
222
		private String fProvider;
223
		/** map: <provider _id, delegate> **/
224
		private HashMap fConflicts;
225
		
226
		public ConflictingDelegate(ILaunchConfigurationType type, String mode, HashMap conflicts) {
227
			fType = type;
228
			fMode = mode;
229
			fConflicts = conflicts;
230
		}
231
		
232
		public void setProvider(String provider) {
233
			fProvider = provider;
234
		}
235
		
236
		public ILaunchConfigurationType getType() {
237
			return fType;
238
		}
239
		
240
		public String getMode() {
241
			return fMode;
242
		}
243
		
244
		public HashMap getConflicts() {
245
			return fConflicts;
246
		}
247
		
248
		public String getProvider() {
249
			return fProvider;
250
		}
251
	}
154
	
252
	
155
	/**
253
	/**
156
	 * Notifies a launch config listener in a safe runnable to handle
254
	 * Notifies a launch config listener in a safe runnable to handle
Lines 529-534 Link Here
529
	private List fLaunchConfigurationTypes = null; 
627
	private List fLaunchConfigurationTypes = null; 
530
628
531
	/**
629
	/**
630
	 * List of <code>PreferredDelegate</code> objects
631
	 * @since 3.3
632
	 */
633
	private List fPreferredDelegates = null;
634
	
635
	/**
636
	 * List of <code>ConflictingDelegate</code> objects
637
	 * @since 3.3
638
	 */
639
	private List fConflictingDelegates = null;
640
	
641
	/**
642
	 * The last chosen provider id, which allows us to maintain similar default choices for providers.
643
	 */
644
	private String fLastChosenDefaultProvider = null;
645
	
646
	/**
532
	 * Launch configuration cache. Keys are <code>LaunchConfiguration</code>,
647
	 * Launch configuration cache. Keys are <code>LaunchConfiguration</code>,
533
	 * values are <code>LaunchConfigurationInfo</code>.
648
	 * values are <code>LaunchConfigurationInfo</code>.
534
	 */
649
	 */
Lines 1024-1030 Link Here
1024
	}		
1139
	}		
1025
	
1140
	
1026
	/**
1141
	/**
1027
	 * @see ILaunchManager#getDebugTargets()
1142
	 * @see org.eclipse.debug.core.ILaunchManager#getContributedDelegates(java.lang.String)
1143
	 */
1144
	public synchronized List getContributedDelegates(String mode) {
1145
		ArrayList list = new ArrayList(0);
1146
		List delegates = getContributedDelegates();
1147
		ContributedDelegate cd = null;
1148
		for(int i = 0; i < delegates.size(); i++) {
1149
			cd = (ContributedDelegate) delegates.get(i);
1150
			if(cd.getModes().contains(mode)) {
1151
				list.add(cd);
1152
			}
1153
		}
1154
		return list;
1155
	}
1156
	
1157
	/* (non-Javadoc)
1158
	 * @see org.eclipse.debug.core.ILaunchManager#getContributedDelegates(org.eclipse.debug.core.ILaunchConfigurationType, java.lang.String)
1159
	 */
1160
	public synchronized List getContributedDelegates(ILaunchConfigurationType type, String mode) throws CoreException {
1161
		if(!type.supportsMode(mode)) {
1162
			throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, MessageFormat.format(DebugCoreMessages.LaunchConfigurationType_9, new String[] {mode, type.getIdentifier()}), null));
1163
		}
1164
		ArrayList list = new ArrayList(0);
1165
		List delegates = getContributedDelegates();
1166
		ContributedDelegate cd = null;
1167
		for(int i = 0; i < delegates.size(); i++) {
1168
			cd = (ContributedDelegate) delegates.get(i);
1169
			if(cd.getModes().contains(mode) & cd.getLaunchConfigurationType().equals(type.getIdentifier())) {
1170
				list.add(cd);
1171
			}
1172
		}
1173
		return list;
1174
	}
1175
	
1176
	/* (non-Javadoc)
1177
	 * @see org.eclipse.debug.core.ILaunchManager#getContributedDelegates(org.eclipse.debug.core.ILaunchConfigurationType)
1178
	 */
1179
	public synchronized List getContributedDelegates(ILaunchConfigurationType type) throws CoreException {
1180
		ArrayList list = new ArrayList(0);
1181
		List delegates = getContributedDelegates();
1182
		ContributedDelegate cd = null;
1183
		for(int i = 0; i < delegates.size(); i++) {
1184
			cd = (ContributedDelegate) delegates.get(i);
1185
			if(cd.getLaunchConfigurationType().equals(type.getIdentifier())) {
1186
				list.add(cd);
1187
			}
1188
		}
1189
		return list;
1190
	}
1191
1192
	/* (non-Javadoc)
1193
	 * @see org.eclipse.debug.core.ILaunchManager#getDebugTargets()
1028
	 */
1194
	 */
1029
	public IDebugTarget[] getDebugTargets() {
1195
	public IDebugTarget[] getDebugTargets() {
1030
		synchronized (fLaunches) {
1196
		synchronized (fLaunches) {
Lines 1540-1546 Link Here
1540
	}
1706
	}
1541
	
1707
	
1542
	/**
1708
	/**
1543
	 * Load comparator extensions.
1709
	 * Load launch mode extensions.
1544
	 * 
1710
	 * 
1545
	 * @exception CoreException if an exception occurs reading
1711
	 * @exception CoreException if an exception occurs reading
1546
	 *  the extensions
1712
	 *  the extensions
Lines 1942-1947 Link Here
1942
	/**
2108
	/**
1943
	 * Terminates/Disconnects any active debug targets/processes.
2109
	 * Terminates/Disconnects any active debug targets/processes.
1944
	 * Clears launch configuration types.
2110
	 * Clears launch configuration types.
2111
	 * Saves and clears preferred launch delegates
1945
	 */
2112
	 */
1946
	public void shutdown() {
2113
	public void shutdown() {
1947
		fListeners = new ListenerList();
2114
		fListeners = new ListenerList();
Lines 1966-1972 Link Here
1966
		}
2133
		}
1967
		
2134
		
1968
		clearAllLaunchConfigurations();
2135
		clearAllLaunchConfigurations();
1969
2136
		clearPreferredLaunchDelegates();
1970
		getWorkspace().removeResourceChangeListener(this);
2137
		getWorkspace().removeResourceChangeListener(this);
1971
	}
2138
	}
1972
2139
Lines 2017-2021 Link Here
2017
		}		
2184
		}		
2018
	}
2185
	}
2019
	
2186
	
2187
	/**
2188
	 * @see org.eclipse.debug.core.IPreferredLaunchDelegateManager#getPreferredDelegate(org.eclipse.debug.core.ILaunchConfigurationType, java.lang.String)
2189
	 * @since 3.3
2190
	 */
2191
	public ILaunchConfigurationDelegate getPreferredDelegate(ILaunchConfigurationType type, String mode) throws CoreException {
2192
		if(!type.supportsMode(mode)) {
2193
			throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, MessageFormat.format(DebugCoreMessages.LaunchConfigurationType_9, new String[] {mode, type.getIdentifier()}), null));
2194
		}
2195
		PreferredDelegate pd = findPreferredDelegate(type, mode);
2196
		if(pd != null) {
2197
			return pd.getDelegeate();
2198
		}
2199
		return null;
2200
	}
2201
2202
	/**
2203
	 * @see org.eclipse.debug.core.IPreferredLaunchDelegateManager#hasConflictingDelegates(org.eclipse.debug.core.ILaunchConfigurationType, java.lang.String)
2204
	 * @since 3.3
2205
	 */
2206
	public boolean hasConflictingDelegates(ILaunchConfigurationType type, String mode) throws CoreException {
2207
		if(!type.supportsMode(mode)) {
2208
			throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, MessageFormat.format(DebugCoreMessages.LaunchConfigurationType_9, new String[] {mode, type.getIdentifier()}), null));
2209
		}
2210
		return findConflictingDelegate(type, mode) != null;
2211
	}
2212
2213
	/**
2214
	 * @see org.eclipse.debug.core.IPreferredLaunchDelegateManager#setPreferredDelegate(org.eclipse.debug.core.ILaunchConfigurationType, java.lang.String, org.eclipse.debug.core.model.ILaunchConfigurationDelegate)
2215
	 * @since 3.3
2216
	 */
2217
	public void setPreferredDelegate(ILaunchConfigurationType type, String mode, ILaunchConfigurationDelegate delegate, String provider) throws CoreException {
2218
		if(!type.supportsMode(mode)) {
2219
			throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, MessageFormat.format(DebugCoreMessages.LaunchConfigurationType_9, new String[] {mode, type.getIdentifier()}), null));
2220
		}
2221
		initializePreferredDelegates();
2222
		PreferredDelegate pd = findPreferredDelegate(type, mode);
2223
		if(pd == null) {
2224
			fPreferredDelegates.add(new PreferredDelegate(type, delegate, mode, provider));
2225
		}
2226
		else {
2227
			pd.setDelegate(delegate);
2228
			pd.setProvider(provider);
2229
		}
2230
	}
2231
2232
	/* (non-Javadoc)
2233
	 * @see org.eclipse.debug.core.ILaunchManager#getConflictingDelegates(org.eclipse.debug.core.ILaunchConfigurationType, java.lang.String)
2234
	 */
2235
	public HashMap getConflictingDelegates(ILaunchConfigurationType type, String mode) throws CoreException {
2236
		if(!type.supportsMode(mode)) {
2237
			throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, MessageFormat.format(DebugCoreMessages.LaunchConfigurationType_9, new String[] {mode, type.getIdentifier()}), null));
2238
		}
2239
		ConflictingDelegate cd = findConflictingDelegate(type, mode);
2240
		if(cd != null) {
2241
			return cd.getConflicts();
2242
		}
2243
		return new HashMap(0);
2244
	}
2245
2246
	/**
2247
	 * @see org.eclipse.debug.core.IPreferredLaunchDelegateManager#removePreferredDelegate(org.eclipse.debug.core.ILaunchConfigurationType, java.lang.String)
2248
	 * @since 3.3
2249
	 */
2250
	public void removePreferredDelegate(ILaunchConfigurationType type, String mode) throws CoreException {
2251
		if(!type.supportsMode(mode)) {
2252
			throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, MessageFormat.format(DebugCoreMessages.LaunchConfigurationType_9, new String[] {mode, type.getIdentifier()}), null));
2253
		}
2254
		fPreferredDelegates.remove(findPreferredDelegate(type, mode));
2255
	}
2256
	
2257
	/**
2258
	 * Internal method for finding a <code>PreferredDelegate</code> item from a specified type and mode
2259
	 * @param type the type to find
2260
	 * @param mode the mode associated with the type
2261
	 * @return the <code>PreferredDelegate</code> object or <code>null</code> if not found
2262
	 * @since 3.3
2263
	 */
2264
	private PreferredDelegate findPreferredDelegate(ILaunchConfigurationType type, String mode) throws CoreException {
2265
		PreferredDelegate prefer = null;
2266
		initializePreferredDelegates();
2267
		for(int i = 0; i < fPreferredDelegates.size(); i++) {
2268
			prefer = (PreferredDelegate) fPreferredDelegates.get(i);
2269
			if(prefer.getType().getIdentifier().equals(type.getIdentifier()) & prefer.getMode().equals(mode)) {
2270
				return prefer;
2271
			}
2272
		}
2273
		//	if at this stage we have none for conflicting types, pick some defaults.
2274
		//if a there is a shared provider accross multi conflicts try to choose that one to maintain consistency
2275
		if(hasConflictingDelegates(type, mode)) {
2276
			HashMap map = getConflictingDelegates(type, mode);
2277
			if(!map.containsKey(fLastChosenDefaultProvider)) {
2278
				for(Iterator iter = map.keySet().iterator(); iter.hasNext();) {
2279
					fLastChosenDefaultProvider = (String) iter.next();
2280
					break;
2281
				}
2282
			}
2283
			prefer = new PreferredDelegate(type, (ILaunchConfigurationDelegate) map.get(fLastChosenDefaultProvider), mode, fLastChosenDefaultProvider);
2284
			fPreferredDelegates.add(prefer);
2285
			return prefer;
2286
		}
2287
		return null;
2288
	}
2289
	
2290
	/* (non-Javadoc)
2291
	 * @see org.eclipse.debug.core.ILaunchManager#getPreferredDelegateProvider(org.eclipse.debug.core.ILaunchConfigurationType, java.lang.String)
2292
	 */
2293
	public String getPreferredDelegateProvider(ILaunchConfigurationType type, String mode) throws CoreException {
2294
		if(!type.supportsMode(mode)) {
2295
			throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, MessageFormat.format(DebugCoreMessages.LaunchConfigurationType_9, new String[] {mode, type.getIdentifier()}), null));
2296
		}
2297
		PreferredDelegate pd = findPreferredDelegate(type, mode);
2298
		if(pd != null) {
2299
			return pd.getProvider();
2300
		}
2301
		return null;
2302
	}
2303
	
2304
	/**
2305
	 * Returns the <code>ConflictingDelegate</code> object associated with the specified type and given mode
2306
	 * @param type the type to check for
2307
	 * @param mode the mode for the type
2308
	 * @return the <code>ConflictingDelegate</code> object or <code>null</code> if none
2309
	 * @since 3.3
2310
	 */
2311
	private ConflictingDelegate findConflictingDelegate(ILaunchConfigurationType type, String mode) {
2312
		ConflictingDelegate conflict = null;
2313
		initializeConflictingDelegates();
2314
		for(int i = 0; i < fConflictingDelegates.size(); i++) {
2315
			conflict = (ConflictingDelegate) fConflictingDelegates.get(i);
2316
			if(type.getIdentifier().equals(conflict.getType().getIdentifier()) & mode.equals(conflict.getMode())) {
2317
				return conflict;
2318
			}
2319
		}
2320
		return null;
2321
	}
2322
	
2323
	/**
2324
	 * initializes the cache of preferred launch delegates from the <code>DebugPlugin</code> preferences
2325
	 * @since 3.3
2326
	 */
2327
	private synchronized void initializePreferredDelegates() {
2328
		if(fPreferredDelegates == null) {
2329
			fPreferredDelegates = new ArrayList(0);
2330
			Preferences prefs = DebugPlugin.getDefault().getPluginPreferences();
2331
			String docname = prefs.getString(DebugPlugin.PREF_PREFERRED_LAUNCH_DELEGATES); 
2332
			if(!docname.equals(EMPTY_STRING)) {
2333
				try {
2334
					Element root = DebugPlugin.parseDocument(docname);
2335
					NodeList delegates = root.getChildNodes();
2336
					Node child = null;
2337
					Element delegate = null;
2338
					ILaunchConfigurationType type = null;
2339
					String mode = null;
2340
					String provider = null;
2341
					List contributed = null;
2342
					ContributedDelegate cdelegate = null;
2343
					for(int i = 0; i < delegates.getLength(); i++) {
2344
						child = delegates.item(i);
2345
						if(child instanceof Element) {
2346
							delegate = (Element) child;
2347
							type = getLaunchConfigurationType(delegate.getNodeName());
2348
							if(type != null) {
2349
								mode = delegate.getAttribute(DELEGATE_MODE);
2350
								provider = delegate.getAttribute(DELEGATE_PROVIDER);
2351
								if(provider != null && provider.equals(type.getIdentifier())) {
2352
									//use the default one (non-contributed)
2353
									fPreferredDelegates.add(new PreferredDelegate(type, type.getDelegate(mode), mode, provider));
2354
								}
2355
								else {
2356
									//if we are not using the 'default' delegate search the contributed ones
2357
									contributed = getContributedDelegates(type, mode);
2358
									for(int j = 0; j < contributed.size(); j++) {
2359
										cdelegate = (ContributedDelegate) contributed.get(j);
2360
										if(cdelegate.getLaunchConfigurationType().equals(type.getIdentifier()) & cdelegate.getIdentifier().equals(provider)) {
2361
											fPreferredDelegates.add(new PreferredDelegate(type, cdelegate.getDelegate(), mode, cdelegate.getIdentifier()));
2362
										}
2363
									}
2364
								}
2365
							}
2366
						}
2367
					}
2368
				} 
2369
				catch (CoreException e) {DebugPlugin.log(e);}
2370
			}
2371
		}
2372
	}	
2373
	
2374
	/**
2375
	 * initializes the cache of conflicting launch delegates
2376
	 * @since 3.3
2377
	 */
2378
	private synchronized void initializeConflictingDelegates() {
2379
		if(fConflictingDelegates == null) {
2380
			try {
2381
				fConflictingDelegates = new ArrayList();
2382
				List types = getLaunchConfigurationTypeList();
2383
				ILaunchConfigurationType type = null;
2384
				HashMap map = new HashMap();
2385
				HashMap dels = null;
2386
				String mode = null;
2387
				Set modes = null;
2388
				Object obj = null;
2389
				List tmp = null;
2390
				ContributedDelegate contrib = null;
2391
				for(int i = 0; i < types.size(); i++) {
2392
					type = (ILaunchConfigurationType) types.get(i);
2393
					modes = type.getSupportedModes();
2394
				//load up the default modes
2395
					for(Iterator imodes = modes.iterator(); imodes.hasNext();) {
2396
						mode = (String) imodes.next();
2397
						obj = map.get(mode);
2398
						if(obj == null) {
2399
							dels = new HashMap(0);
2400
						}
2401
						else {
2402
							dels = (HashMap)obj;
2403
						}
2404
						dels.put(type.getIdentifier(), type.getDelegate(mode));
2405
						map.put(mode, dels);
2406
					}
2407
				//now get all of the contributed ones for this type
2408
					tmp = getContributedDelegates(type);
2409
					for(int j = 0; j < tmp.size(); j++) {
2410
						contrib = (ContributedDelegate)tmp.get(j);
2411
						modes = contrib.getModes();
2412
						for(Iterator imodes = modes.iterator(); imodes.hasNext();) {
2413
							mode = (String) imodes.next();
2414
							obj = map.get(mode);
2415
							if(obj == null) {
2416
								dels = new HashMap(0);
2417
							}
2418
							else {
2419
								dels = (HashMap)obj;
2420
							}
2421
							if(dels.containsValue(contrib.getDelegate())) {
2422
								dels.remove(type.getIdentifier());
2423
							}
2424
							dels.put(contrib.getIdentifier(), contrib.getDelegate());
2425
							map.put(mode, dels);
2426
						}
2427
					}
2428
				//now for each mode in the map see if there are conflicts, if so add them to the list
2429
					for(Iterator iter = map.keySet().iterator(); iter.hasNext();) {
2430
						mode = (String)iter.next();
2431
						dels = (HashMap)map.get(mode);
2432
						if(dels != null && dels.size() > 1) {
2433
							//we have a conflict
2434
							fConflictingDelegates.add(new ConflictingDelegate(type, mode, dels));
2435
						}
2436
					}
2437
					map.clear();
2438
				}
2439
			}
2440
			catch(CoreException e) {DebugPlugin.log(e);}
2441
		}
2442
	}
2020
	
2443
	
2444
	/**
2445
	 * Cleans up the caches used for the preferred delegates on shutdown
2446
	 * Document elements are created as:
2447
	 * <pre><config_type_id mode="" provider=""/></pre>
2448
	 * Where provider can be either config_type_id or the id of the contributed delegate.
2449
	 * @since 3.3
2450
	 */
2451
	private void clearPreferredLaunchDelegates() {
2452
		if(fPreferredDelegates != null) {
2453
			try {
2454
				Preferences prefs = DebugPlugin.getDefault().getPluginPreferences();
2455
				Document doc = DebugPlugin.newDocument();
2456
				Element	root = doc.createElement(PREFERRED_DELEGATE);
2457
				doc.appendChild(root);
2458
				Element child = null;
2459
				PreferredDelegate delegate = null;
2460
				for(int i = 0; i < fPreferredDelegates.size(); i++) {
2461
					delegate = (PreferredDelegate) fPreferredDelegates.get(i);
2462
					child = doc.createElement(delegate.getType().getIdentifier());
2463
					child.setAttribute(DELEGATE_MODE, delegate.getMode());
2464
					child.setAttribute(DELEGATE_PROVIDER, delegate.getProvider());
2465
					root.appendChild(child);
2466
				}
2467
				try {
2468
					prefs.setValue(DebugPlugin.PREF_PREFERRED_LAUNCH_DELEGATES, serializeDocument(doc));
2469
					DebugPlugin.getDefault().savePluginPreferences();
2470
				}
2471
				catch (IOException ioe) {DebugPlugin.log(ioe);}
2472
				catch (TransformerException te) {DebugPlugin.log(te);}
2473
			} 
2474
			catch (CoreException e) {DebugPlugin.log(e);}
2475
			fPreferredDelegates.clear();
2476
			fPreferredDelegates = null;
2477
		}
2478
		if(fConflictingDelegates != null) {
2479
			fConflictingDelegates.clear();
2480
			fConflictingDelegates = null;
2481
		}
2482
	}
2021
}
2483
}
(-)core/org/eclipse/debug/internal/core/ContributedDelegate.java (-7 / +7 lines)
Lines 65-71 Link Here
65
	 * 
65
	 * 
66
	 * @return this delegate's configuration element
66
	 * @return this delegate's configuration element
67
	 */
67
	 */
68
	protected IConfigurationElement getConfigurationElement() {
68
	public IConfigurationElement getConfigurationElement() {
69
		return fElement;
69
		return fElement;
70
	}	
70
	}	
71
	
71
	
Lines 74-80 Link Here
74
	 * 
74
	 * 
75
	 * @return the set of modes specified in the configuration data
75
	 * @return the set of modes specified in the configuration data
76
	 */
76
	 */
77
	protected Set getModes() {
77
	public Set getModes() {
78
		if (fModes == null) {
78
		if (fModes == null) {
79
			String modes= getConfigurationElement().getAttribute("modes"); //$NON-NLS-1$
79
			String modes= getConfigurationElement().getAttribute("modes"); //$NON-NLS-1$
80
			if (modes == null) {
80
			if (modes == null) {
Lines 94-104 Link Here
94
	 * Returns the type identifier of launch configuration type this delegate is
94
	 * Returns the type identifier of launch configuration type this delegate is
95
	 * contributed to.
95
	 * contributed to.
96
	 */
96
	 */
97
	protected String getLaunchConfigurationType() {
97
	public String getLaunchConfigurationType() {
98
		return getConfigurationElement().getAttribute("type"); //$NON-NLS-1$
98
		return getConfigurationElement().getAttribute("type"); //$NON-NLS-1$
99
	}
99
	}
100
	
100
	
101
	protected ILaunchConfigurationDelegate getDelegate() throws CoreException {
101
	public ILaunchConfigurationDelegate getDelegate() throws CoreException {
102
		if (fDelegate == null) {
102
		if (fDelegate == null) {
103
			Object object = getConfigurationElement().createExecutableExtension("delegate"); //$NON-NLS-1$
103
			Object object = getConfigurationElement().createExecutableExtension("delegate"); //$NON-NLS-1$
104
			if (object instanceof ILaunchConfigurationDelegate) {
104
			if (object instanceof ILaunchConfigurationDelegate) {
Lines 113-119 Link Here
113
	/**
113
	/**
114
	 * Returns the identifier of this extension point.
114
	 * Returns the identifier of this extension point.
115
	 */
115
	 */
116
	protected String getIdentifier() {
116
	public String getIdentifier() {
117
		return getConfigurationElement().getAttribute("id"); //$NON-NLS-1$
117
		return getConfigurationElement().getAttribute("id"); //$NON-NLS-1$
118
	}	
118
	}	
119
	
119
	
Lines 126-132 Link Here
126
	 * 
126
	 * 
127
	 * @since 3.1
127
	 * @since 3.1
128
	 */
128
	 */
129
	protected String getSourcePathComputerId() {
129
	public String getSourcePathComputerId() {
130
		return getConfigurationElement().getAttribute("sourcePathComputerId"); //$NON-NLS-1$
130
		return getConfigurationElement().getAttribute("sourcePathComputerId"); //$NON-NLS-1$
131
	}
131
	}
132
	
132
	
Lines 139-145 Link Here
139
	 * 
139
	 * 
140
	 * @since 3.1
140
	 * @since 3.1
141
	 */
141
	 */
142
	protected String getSourceLocaterId() {
142
	public String getSourceLocaterId() {
143
		return getConfigurationElement().getAttribute("sourceLocatorId"); //$NON-NLS-1$
143
		return getConfigurationElement().getAttribute("sourceLocatorId"); //$NON-NLS-1$
144
	}
144
	}
145
}
145
}
(-)core/org/eclipse/debug/core/ILaunchManager.java (+93 lines)
Lines 11-21 Link Here
11
package org.eclipse.debug.core;
11
package org.eclipse.debug.core;
12
12
13
 
13
 
14
import java.util.HashMap;
15
import java.util.List;
14
import java.util.Map;
16
import java.util.Map;
15
17
16
import org.eclipse.core.resources.IFile;
18
import org.eclipse.core.resources.IFile;
17
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.debug.core.model.IDebugTarget;
20
import org.eclipse.debug.core.model.IDebugTarget;
21
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
19
import org.eclipse.debug.core.model.IPersistableSourceLocator;
22
import org.eclipse.debug.core.model.IPersistableSourceLocator;
20
import org.eclipse.debug.core.model.IProcess;
23
import org.eclipse.debug.core.model.IProcess;
21
import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
24
import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
Lines 127-132 Link Here
127
	 * @return an array of debug targets
130
	 * @return an array of debug targets
128
	 */
131
	 */
129
	public IDebugTarget[] getDebugTargets();
132
	public IDebugTarget[] getDebugTargets();
133
	/**
134
	 * return a list of the contrbuted delegates for the specified mode
135
	 * @param mode the mode to get delegates for
136
	 * @return a list of contributed delegates for the given mode or an empty list if none are found
137
	 * @since 3.3
138
	 */
139
	public List getContributedDelegates(String mode);
140
	/**
141
	 * returns the contributed delegates to the specified type with the given mode.
142
	 * If the type does not support the mode a <code>CoreException</code> is thrown
143
	 * @param type the type to check
144
	 * @param mode the mode for the type
145
	 * @return a listing of contributed delegates for the given type in the specified mode, or an empty list if none are found
146
	 * @throws CoreException
147
	 * @since 3.3
148
	 */
149
	public List getContributedDelegates(ILaunchConfigurationType type, String mode) throws CoreException;
150
	/**
151
	 * returns the contributed delegates to the specified type.
152
	 * @param type the type to check
153
	 * @param mode the mode for the type
154
	 * @return a listing of contributed delegates for the given type, or an empty list if none are found
155
	 * @throws CoreException
156
	 * @since 3.3
157
	 */
158
	public List getContributedDelegates(ILaunchConfigurationType type) throws CoreException;
130
	/** 
159
	/** 
131
	 * Returns an array of environment variables to be used when
160
	 * Returns an array of environment variables to be used when
132
	 * launching the given configuration or <code>null</code> if unspecified.
161
	 * launching the given configuration or <code>null</code> if unspecified.
Lines 236-241 Link Here
236
	public ILaunchConfiguration[] getMigrationCandidates() throws CoreException;
265
	public ILaunchConfiguration[] getMigrationCandidates() throws CoreException;
237
	
266
	
238
	/**
267
	/**
268
	 * Returns the preferred <code>ILaunchConfigurationDelegate</code> for the given type and mode 
269
	 * @param type the type to get the preferred delegate for
270
	 * @param mode the mode the delegate applies to
271
	 * @return the preferred delegate or <code>null</code> if there isn't one or if the type does not support the mode
272
	 * @throws CoreException
273
	 * @since 3.3
274
	 */
275
	public ILaunchConfigurationDelegate getPreferredDelegate(ILaunchConfigurationType type, String mode) throws CoreException;
276
	
277
	/**
278
	 * Returns the id of the provider for the preferred delegate for the specified type and mode
279
	 * @param type the type to find the preferred delegate for
280
	 * @param mode the mode for the type
281
	 * @return the id of the provider for the preferred delegate or <code>null</code> if not found
282
	 * @throws CoreException
283
	 * @since 3.3
284
	 */
285
	public String getPreferredDelegateProvider(ILaunchConfigurationType type, String mode) throws CoreException;
286
	
287
	/**
288
	 * Allows a preferred delegate to be set for the given type under the specified mode
289
	 * If the specified mode is not supported by the type a <code>CoreException</code> is thrown
290
	 * @param type the type set the delegate for
291
	 * @param mode the mode for the type
292
	 * @param delegate the delegate to set as the preferred one
293
	 * @throws CoreException
294
	 * @since 3.3
295
	 */
296
	public void setPreferredDelegate(ILaunchConfigurationType type, String mode, ILaunchConfigurationDelegate delegate, String provider) throws CoreException;
297
	
298
	/**
299
	 * Allows a preferred delegate to be removed from the listing of delegates
300
	 * If the specified mode is not supported by the given type a <code>CoreException</code> is thrown. 
301
	 * @param type the type to remove
302
	 * @param mode the mode for the type
303
	 * @throws CoreException
304
	 * @since 3.3
305
	 */
306
	public void removePreferredDelegate(ILaunchConfigurationType type, String mode) throws CoreException;
307
	
308
	/**
309
	 * Determines if the specified type and mode combination have conflicting launch configuration delegates
310
	 * A conflict is defined as a given launch configuration type having two or more launch delegates for the same mode. 
311
	 * @param type the type to check for
312
	 * @param mode the mode for the type
313
	 * @return true if the specified type and mode have conflicting launch delegate, false otherwise
314
	 * @throws CoreException
315
	 * @since 3.3
316
	 */
317
	public boolean hasConflictingDelegates(ILaunchConfigurationType type, String mode) throws CoreException;
318
	
319
	/**
320
	 * Return a mapping of all of the conflicting launch delegates for the specified type in the given mode
321
	 * Map formulation: <code>(String type_id, HashMap(String provider_id, ILaunchConfigurationDelegate delegate))</code>
322
	 * If no conflicting delegates are found an empty map is returned.
323
	 * @param type the type to check
324
	 * @param mode the mode for the type
325
	 * @return a mapping of provider id to delegate of the conflicting delegates.
326
	 * @throws CoreException
327
	 * @since 3.3
328
	 */
329
	public HashMap getConflictingDelegates(ILaunchConfigurationType type, String mode) throws CoreException;
330
	
331
	/**
239
	 * When a launch configuration is created or moved, registered launch
332
	 * When a launch configuration is created or moved, registered launch
240
	 * configuration listeners (see <code>ILaunchConfigurationListener</code>)
333
	 * configuration listeners (see <code>ILaunchConfigurationListener</code>)
241
	 * are notified of an add notification for the new configuration. If the
334
	 * are notified of an add notification for the new configuration. If the
(-)core/org/eclipse/debug/core/DebugPlugin.java (-2 / +9 lines)
Lines 15-21 Link Here
15
import java.io.File;
15
import java.io.File;
16
import java.io.IOException;
16
import java.io.IOException;
17
import java.io.InputStream;
17
import java.io.InputStream;
18
import com.ibm.icu.text.MessageFormat;
19
import java.util.ArrayList;
18
import java.util.ArrayList;
20
import java.util.HashMap;
19
import java.util.HashMap;
21
import java.util.Iterator;
20
import java.util.Iterator;
Lines 61-66 Link Here
61
import org.xml.sax.SAXException;
60
import org.xml.sax.SAXException;
62
import org.xml.sax.helpers.DefaultHandler;
61
import org.xml.sax.helpers.DefaultHandler;
63
62
63
import com.ibm.icu.text.MessageFormat;
64
64
/**
65
/**
65
 * There is one instance of the debug plug-in available from
66
 * There is one instance of the debug plug-in available from
66
 * <code>DebugPlugin.getDefault()</code>. The debug plug-in provides:
67
 * <code>DebugPlugin.getDefault()</code>. The debug plug-in provides:
Lines 86-91 Link Here
86
	private static final String PI_DEBUG_CORE = "org.eclipse.debug.core"; //$NON-NLS-1$
87
	private static final String PI_DEBUG_CORE = "org.eclipse.debug.core"; //$NON-NLS-1$
87
88
88
	/**
89
	/**
90
	 * Defines the pref name for the preferred launch delegates section
91
	 * 
92
	 * @since 3.3
93
	 */
94
	public static final String PREF_PREFERRED_LAUNCH_DELEGATES = "preferredLaunchDelegates"; //$NON-NLS-1$
95
	
96
	/**
89
	 * Simple identifier constant (value <code>"launchConfigurationTypes"</code>)
97
	 * Simple identifier constant (value <code>"launchConfigurationTypes"</code>)
90
	 * for the launch configuration types extension point.
98
	 * for the launch configuration types extension point.
91
	 * 
99
	 * 
Lines 580-586 Link Here
580
			if (fMemoryBlockManager != null)  {
588
			if (fMemoryBlockManager != null)  {
581
				fMemoryBlockManager.shutdown();
589
				fMemoryBlockManager.shutdown();
582
			}
590
			}
583
			
584
			fEventListeners.clear();
591
			fEventListeners.clear();
585
            
592
            
586
            if (fEventFilters != null) {
593
            if (fEventFilters != null) {
(-)plugin.xml (-9 / +12 lines)
Lines 1838-1847 Link Here
1838
   <extension
1838
   <extension
1839
         point="org.eclipse.debug.ui.launchConfigurationTabGroups">
1839
         point="org.eclipse.debug.ui.launchConfigurationTabGroups">
1840
      <launchConfigurationTabGroup
1840
      <launchConfigurationTabGroup
1841
            type="org.eclipse.jdt.launching.localJavaApplication"
1842
            helpContextId="org.eclipse.jdt.debug.ui.launchConfigHelpContext.local_java_application"
1843
            class="org.eclipse.jdt.internal.debug.ui.launcher.LocalJavaApplicationTabGroup"
1841
            class="org.eclipse.jdt.internal.debug.ui.launcher.LocalJavaApplicationTabGroup"
1844
            id="org.eclipse.jdt.debug.ui.launchConfigurationTabGroup.localJavaApplication">
1842
            helpContextId="org.eclipse.jdt.debug.ui.launchConfigHelpContext.local_java_application"
1843
            id="org.eclipse.jdt.debug.ui.launchConfigurationTabGroup.localJavaApplication"
1844
            launchDelegate="org.eclipse.jdt.launching.JavaLaunchDelegate"
1845
            type="org.eclipse.jdt.launching.localJavaApplication">
1845
            <launchMode 
1846
            <launchMode 
1846
                  mode="debug"
1847
                  mode="debug"
1847
                  perspective="org.eclipse.debug.ui.DebugPerspective"
1848
                  perspective="org.eclipse.debug.ui.DebugPerspective"
Lines 1853-1869 Link Here
1853
            </launchMode>
1854
            </launchMode>
1854
      </launchConfigurationTabGroup>
1855
      </launchConfigurationTabGroup>
1855
      <launchConfigurationTabGroup
1856
      <launchConfigurationTabGroup
1856
            type="org.eclipse.jdt.launching.remoteJavaApplication"
1857
            class="org.eclipse.jdt.internal.debug.ui.launcher.RemoteJavaApplicationTabGroup"
1857
            description="%remoteJavaApplicationTabGroupDescription"
1858
            description="%remoteJavaApplicationTabGroupDescription"
1858
            helpContextId="org.eclipse.jdt.debug.ui.launchConfigHelpContext.remote_java_application"
1859
            helpContextId="org.eclipse.jdt.debug.ui.launchConfigHelpContext.remote_java_application"
1859
            class="org.eclipse.jdt.internal.debug.ui.launcher.RemoteJavaApplicationTabGroup"
1860
            id="org.eclipse.jdt.debug.ui.launchConfigurationTabGroup.remoteJavaApplication"
1860
            id="org.eclipse.jdt.debug.ui.launchConfigurationTabGroup.remoteJavaApplication">
1861
            launchDelegate="org.eclipse.jdt.internal.launching.JavaRemoteApplicationLaunchConfigurationDelegate"
1862
            type="org.eclipse.jdt.launching.remoteJavaApplication">
1861
      </launchConfigurationTabGroup>
1863
      </launchConfigurationTabGroup>
1862
      <launchConfigurationTabGroup
1864
      <launchConfigurationTabGroup
1863
            type="org.eclipse.jdt.launching.javaApplet"
1864
            helpContextId="org.eclipse.jdt.debug.ui.launchConfigHelpContext.java_applet"
1865
            class="org.eclipse.jdt.internal.debug.ui.launcher.JavaAppletTabGroup"
1865
            class="org.eclipse.jdt.internal.debug.ui.launcher.JavaAppletTabGroup"
1866
            id="org.eclipse.jdt.debug.ui.launchConfigurationTabGroup.javaApplet">
1866
            helpContextId="org.eclipse.jdt.debug.ui.launchConfigHelpContext.java_applet"
1867
            id="org.eclipse.jdt.debug.ui.launchConfigurationTabGroup.javaApplet"
1868
            launchDelegate="org.eclipse.jdt.internal.launching.JavaAppletLaunchConfigurationDelegate"
1869
            type="org.eclipse.jdt.launching.javaApplet">
1867
            <launchMode 
1870
            <launchMode 
1868
                  mode="debug"
1871
                  mode="debug"
1869
                  perspective="org.eclipse.debug.ui.DebugPerspective"
1872
                  perspective="org.eclipse.debug.ui.DebugPerspective"
(-)contexts_Debugger.xml (+3 lines)
Lines 735-740 Link Here
735
	<context  id="resetMemoryMonitor_preference_page_context" >
735
	<context  id="resetMemoryMonitor_preference_page_context" >
736
		<description>On this page, you can configure the reset memory monitor behavior. </description>
736
		<description>On this page, you can configure the reset memory monitor behavior. </description>
737
	</context>
737
	</context>
738
	<context id="conflicting_launch_delegates_page">
739
		<description>On this page you can select which launch elements will be used in the event there is a conflict in providers.</description>
740
	</context>
738
	
741
	
739
<!-- 
742
<!-- 
740
	Property Pages 
743
	Property Pages 
(-)plugin.xml (+10 lines)
Lines 144-149 Link Here
144
            name="%LaunchConfigurationsPage.name">
144
            name="%LaunchConfigurationsPage.name">
145
         <keywordReference id="org.eclipse.debug.ui.launchconfigurations"/>
145
         <keywordReference id="org.eclipse.debug.ui.launchconfigurations"/>
146
      </page>
146
      </page>
147
      <page
148
            category="org.eclipse.debug.ui.LaunchingPreferencePage"
149
            class="org.eclipse.debug.internal.ui.preferences.ConflictingLaunchDelegatesPage"
150
            id="org.eclipse.debug.ui.conflictingLaunchDelegatesPage"
151
            name="%ConflictingLaunchDelegatesPage.name">
152
         <keywordReference id="org.eclipse.debug.ui.conflictingLaunchDelegates"/>
153
      </page>
147
   </extension>
154
   </extension>
148
   <extension
155
   <extension
149
         point="org.eclipse.ui.actionSets">
156
         point="org.eclipse.ui.actionSets">
Lines 2288-2293 Link Here
2288
       <keyword
2295
       <keyword
2289
             id="org.eclipse.debug.ui.launchconfigurations"
2296
             id="org.eclipse.debug.ui.launchconfigurations"
2290
             label="%preferenceKeywords.launchConfigurations"/>
2297
             label="%preferenceKeywords.launchConfigurations"/>
2298
       <keyword
2299
             id="org.eclipse.debug.ui.conflictingLaunchDelegates"
2300
             label="launch run debug configurations delegates profile"/>
2291
    </extension>
2301
    </extension>
2292
    <extension
2302
    <extension
2293
          point="org.eclipse.ui.importWizards">
2303
          point="org.eclipse.ui.importWizards">
(-)plugin.properties (+1 lines)
Lines 19-24 Link Here
19
ConsoleFont.label= Console font
19
ConsoleFont.label= Console font
20
ConsoleLineTrackersExtensionName= Console Line Trackers
20
ConsoleLineTrackersExtensionName= Console Line Trackers
21
LaunchingPreferencePage.name=Launching
21
LaunchingPreferencePage.name=Launching
22
ConflictingLaunchDelegatesPage.name=Launch Providers
22
ViewManagementPreferencePage.name=View Management
23
ViewManagementPreferencePage.name=View Management
23
ConsolePreferencePage.name=Console
24
ConsolePreferencePage.name=Console
24
DebugModelContextBindingsName=Debug Model Context Bindings
25
DebugModelContextBindingsName=Debug Model Context Bindings
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupExtension.java (+8 lines)
Lines 131-136 Link Here
131
	}
131
	}
132
	
132
	
133
	/**
133
	/**
134
	 * @return the defined launch delegate for this tab group extension
135
	 * @since 3.3
136
	 */
137
	protected String getLaunchDelegate() {
138
		return getConfigurationElement().getAttribute("launchDelegate"); //$NON-NLS-1$
139
	}
140
	
141
	/**
134
	 * Returns the identifier of the help context associated with this tab
142
	 * Returns the identifier of the help context associated with this tab
135
	 * group, or <code>null</code> if one was not specified.
143
	 * group, or <code>null</code> if one was not specified.
136
	 * 
144
	 * 
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties (+1 lines)
Lines 53-58 Link Here
53
LaunchConfigurationTabGroupViewer_6=- Press the 'Duplicate' button to copy the selected configuration.
53
LaunchConfigurationTabGroupViewer_6=- Press the 'Duplicate' button to copy the selected configuration.
54
LaunchConfigurationTabGroupViewer_5=Configure launch perspective settings from the <a>Perspectives</a> preference page.
54
LaunchConfigurationTabGroupViewer_5=Configure launch perspective settings from the <a>Perspectives</a> preference page.
55
LaunchConfigurationTabGroupViewer_8=- Press the 'Filter' button to configure filtering options.
55
LaunchConfigurationTabGroupViewer_8=- Press the 'Filter' button to configure filtering options.
56
LaunchConfigurationTabGroupViewer_9=Select a <a>default provider</a> for launching when more than one option is available.
56
LaunchConfigurationDialog_Create__manage__and_run_launch_configurations_8=Create, manage, and run configurations
57
LaunchConfigurationDialog_Create__manage__and_run_launch_configurations_8=Create, manage, and run configurations
57
LaunchConfigurationDialog_Dele_te_14=De&lete
58
LaunchConfigurationDialog_Dele_te_14=De&lete
58
LaunchConfigurationDialog_Discard_changes__38=Discard changes?
59
LaunchConfigurationDialog_Discard_changes__38=Discard changes?
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java (-54 / +28 lines)
Lines 11-18 Link Here
11
package org.eclipse.debug.internal.ui.launchConfigurations;
11
package org.eclipse.debug.internal.ui.launchConfigurations;
12
12
13
13
14
import com.ibm.icu.text.MessageFormat;
15
16
import org.eclipse.core.resources.IResource;
14
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.ResourcesPlugin;
15
import org.eclipse.core.resources.ResourcesPlugin;
18
import org.eclipse.core.runtime.CoreException;
16
import org.eclipse.core.runtime.CoreException;
Lines 25-30 Link Here
25
import org.eclipse.debug.internal.ui.DebugUIPlugin;
23
import org.eclipse.debug.internal.ui.DebugUIPlugin;
26
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
24
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
27
import org.eclipse.debug.internal.ui.SWTUtil;
25
import org.eclipse.debug.internal.ui.SWTUtil;
26
import org.eclipse.debug.internal.ui.preferences.ConflictingLaunchDelegatesPage;
28
import org.eclipse.debug.internal.ui.preferences.PerspectivePreferencePage;
27
import org.eclipse.debug.internal.ui.preferences.PerspectivePreferencePage;
29
import org.eclipse.debug.ui.DebugUITools;
28
import org.eclipse.debug.ui.DebugUITools;
30
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
29
import org.eclipse.debug.ui.ILaunchConfigurationDialog;
Lines 39-45 Link Here
39
import org.eclipse.jface.viewers.Viewer;
38
import org.eclipse.jface.viewers.Viewer;
40
import org.eclipse.swt.SWT;
39
import org.eclipse.swt.SWT;
41
import org.eclipse.swt.custom.BusyIndicator;
40
import org.eclipse.swt.custom.BusyIndicator;
42
import org.eclipse.swt.custom.CLabel;
43
import org.eclipse.swt.custom.CTabFolder;
41
import org.eclipse.swt.custom.CTabFolder;
44
import org.eclipse.swt.custom.CTabItem;
42
import org.eclipse.swt.custom.CTabItem;
45
import org.eclipse.swt.custom.StackLayout;
43
import org.eclipse.swt.custom.StackLayout;
Lines 50-56 Link Here
50
import org.eclipse.swt.events.SelectionEvent;
48
import org.eclipse.swt.events.SelectionEvent;
51
import org.eclipse.swt.events.SelectionListener;
49
import org.eclipse.swt.events.SelectionListener;
52
import org.eclipse.swt.graphics.Color;
50
import org.eclipse.swt.graphics.Color;
53
import org.eclipse.swt.graphics.Font;
54
import org.eclipse.swt.graphics.Image;
51
import org.eclipse.swt.graphics.Image;
55
import org.eclipse.swt.layout.GridData;
52
import org.eclipse.swt.layout.GridData;
56
import org.eclipse.swt.layout.GridLayout;
53
import org.eclipse.swt.layout.GridLayout;
Lines 65-70 Link Here
65
import org.eclipse.ui.IWorkbenchPreferenceConstants;
62
import org.eclipse.ui.IWorkbenchPreferenceConstants;
66
import org.eclipse.ui.PlatformUI;
63
import org.eclipse.ui.PlatformUI;
67
64
65
import com.ibm.icu.text.MessageFormat;
66
68
/**
67
/**
69
 * A viewer that displays tabs for a launch configuration, with apply and revert
68
 * A viewer that displays tabs for a launch configuration, with apply and revert
70
 * buttons.
69
 * buttons.
Lines 306-374 Link Here
306
	}
305
	}
307
	
306
	
308
	/**
307
	/**
309
	 * Simple method to create a spacer in the page
310
	 * 
311
	 * @param composite the composite to add the spacer to
312
	 * @param columnSpan the amount of space for the spacer
313
	 * @since 3.2
314
	 */
315
	protected void createSpacer(Composite composite, int columnSpan) {
316
		Label label = new Label(composite, SWT.NONE);
317
		GridData gd = new GridData();
318
		gd.horizontalSpan = columnSpan;
319
		label.setLayoutData(gd);
320
	}
321
	
322
	/**
323
	 * Creates some help text for the tab group launch types
308
	 * Creates some help text for the tab group launch types
324
	 * @param parent thep arent composite
309
	 * @param parent thep arent composite
325
	 * @since 3.2
310
	 * @since 3.2
326
	 */
311
	 */
327
	private void createGettingStarted(Composite parent) {
312
	private void createGettingStarted(Composite parent) {
328
		Font font = parent.getFont();
313
		int width = parent.getBounds().width - 30;
329
		GridData gd = null;
314
		SWTUtil.createWrapCLabel(parent, null, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_1, 1, GridData.FILL_HORIZONTAL, width);
330
		createWrapLabel(parent, null, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_1);
315
		SWTUtil.createWrapCLabel(parent, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_NEW_CONFIG),
331
		createWrapLabel(parent, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_NEW_CONFIG), 
316
				LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_2, 1, GridData.FILL_HORIZONTAL, width);
332
				LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_2);
317
		SWTUtil.createWrapCLabel(parent, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_DUPLICATE_CONFIG), 
333
		createWrapLabel(parent, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_DUPLICATE_CONFIG),
318
				LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_6, 1, GridData.FILL_HORIZONTAL, width);
334
        		LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_6);
319
		SWTUtil.createWrapCLabel(parent, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_DELETE_CONFIG),
335
		createWrapLabel(parent, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_DELETE_CONFIG), 
320
				LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_4, 1, GridData.FILL_HORIZONTAL, width);
336
				LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_4);
321
		SWTUtil.createWrapCLabel(parent, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_FILTER_CONFIGS),
337
        createWrapLabel(parent, DebugUITools.getImage(IInternalDebugUIConstants.IMG_ELCL_FILTER_CONFIGS),
322
				LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_8, 1, GridData.FILL_HORIZONTAL, width);
338
        		LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_8);
323
		SWTUtil.createWrapCLabel(parent, DebugUITools.getImage(IInternalDebugUIConstants.IMG_OVR_TRANSPARENT),
339
        createWrapLabel(parent, DebugUITools.getImage(IInternalDebugUIConstants.IMG_OVR_TRANSPARENT), 
324
				LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_3, 1, GridData.FILL_HORIZONTAL, width);
340
        		LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_3);
341
        
325
        
342
		createSpacer(parent, 2);
326
        SWTUtil.createVerticalSpacer(parent, 1, 2);
343
		Link link = new Link(parent, SWT.LEFT | SWT.WRAP);
327
	//link for perspetives
344
		link.setText(LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_5);
328
		Link link = SWTUtil.createLink(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_5, 1, GridData.FILL_HORIZONTAL, parent.getBounds().width - 30);
345
		link.setFont(font);
346
		gd = new GridData(GridData.FILL_HORIZONTAL);
347
		gd.widthHint = parent.getBounds().width - 30;
348
		link.setLayoutData(gd);
349
		link.addSelectionListener(new SelectionListener() {
329
		link.addSelectionListener(new SelectionListener() {
350
			public void widgetSelected(SelectionEvent e) {
330
			public void widgetSelected(SelectionEvent e) {
351
				SWTUtil.showPreferencePage("org.eclipse.debug.ui.PerspectivePreferencePage", new PerspectivePreferencePage()); //$NON-NLS-1$
331
				SWTUtil.showPreferencePage("org.eclipse.debug.ui.PerspectivePreferencePage", new PerspectivePreferencePage()); //$NON-NLS-1$
352
			}
332
			}
353
			public void widgetDefaultSelected(SelectionEvent e) {}
333
			public void widgetDefaultSelected(SelectionEvent e) {}
354
		});
334
		});
335
		
336
		SWTUtil.createVerticalSpacer(parent, 1, 2);
337
	//link for conflicting delegates
338
		link = SWTUtil.createLink(parent, LaunchConfigurationsMessages.LaunchConfigurationTabGroupViewer_9, 1, GridData.FILL_HORIZONTAL, parent.getBounds().width - 30);
339
		link.addSelectionListener(new SelectionListener() {
340
			public void widgetSelected(SelectionEvent e) {
341
				SWTUtil.showPreferencePage("org.eclipse.debug.ui.conflictingLaunchDelegatesPage", new ConflictingLaunchDelegatesPage()); //$NON-NLS-1$
342
			}
343
			public void widgetDefaultSelected(SelectionEvent e) {}
344
		});
355
	}
345
	}
356
357
    /**
358
     * Create a label on the given parent that wraps text.
359
     * 
360
     * @param parent
361
     * @param text
362
     */
363
    private void createWrapLabel(Composite parent, Image image, String text) {
364
    	CLabel lbl = new CLabel(parent, SWT.NONE | SWT.WRAP);
365
    	lbl.setImage(image);
366
        lbl.setFont(parent.getFont());
367
        lbl.setText(text);
368
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
369
        gd.widthHint = parent.getBounds().width - 30;
370
        lbl.setLayoutData(gd);
371
    }
372
	
346
	
373
	/**
347
	/**
374
	 * Creates the tab folder for displaying config instances
348
	 * Creates the tab folder for displaying config instances
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java (+2 lines)
Lines 90-95 Link Here
90
	public static String LaunchConfigurationsDialog_Warning_2;
90
	public static String LaunchConfigurationsDialog_Warning_2;
91
	public static String LaunchConfigurationsDialog_Information_3;
91
	public static String LaunchConfigurationsDialog_Information_3;
92
	public static String LaunchConfigurationPresentationManager_No_tab_group_defined_for_launch_configuration_type__0__3;
92
	public static String LaunchConfigurationPresentationManager_No_tab_group_defined_for_launch_configuration_type__0__3;
93
94
	public static String LaunchConfigurationTabGroupViewer_9;
93
	public static String PerspectiveManager_Error_1;
95
	public static String PerspectiveManager_Error_1;
94
	public static String PerspectiveManager_Unable_to_switch_perpsectives_as_specified_by_launch___0__4;
96
	public static String PerspectiveManager_Unable_to_switch_perpsectives_as_specified_by_launch___0__4;
95
	public static String PerspectiveManager_Unable_to_switch_to_perspective___0__2;
97
	public static String PerspectiveManager_Unable_to_switch_to_perspective___0__2;
(-)ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationPresentationManager.java (-45 / +97 lines)
Lines 11-20 Link Here
11
package org.eclipse.debug.internal.ui.launchConfigurations;
11
package org.eclipse.debug.internal.ui.launchConfigurations;
12
12
13
 
13
 
14
import com.ibm.icu.text.MessageFormat;
14
import java.util.HashMap;
15
import java.util.Hashtable;
16
import java.util.Iterator;
15
import java.util.Iterator;
17
import java.util.Map;
18
import java.util.Set;
16
import java.util.Set;
19
17
20
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.CoreException;
Lines 26-35 Link Here
26
import org.eclipse.core.runtime.Status;
24
import org.eclipse.core.runtime.Status;
27
import org.eclipse.debug.core.DebugPlugin;
25
import org.eclipse.debug.core.DebugPlugin;
28
import org.eclipse.debug.core.ILaunchConfigurationType;
26
import org.eclipse.debug.core.ILaunchConfigurationType;
27
import org.eclipse.debug.core.ILaunchManager;
29
import org.eclipse.debug.internal.ui.DebugUIPlugin;
28
import org.eclipse.debug.internal.ui.DebugUIPlugin;
30
import org.eclipse.debug.ui.IDebugUIConstants;
29
import org.eclipse.debug.ui.IDebugUIConstants;
31
import org.eclipse.debug.ui.ILaunchConfigurationTabGroup;
30
import org.eclipse.debug.ui.ILaunchConfigurationTabGroup;
32
31
32
import com.ibm.icu.text.MessageFormat;
33
33
/**
34
/**
34
 * Manages contributed launch configuration tabs
35
 * Manages contributed launch configuration tabs
35
 */ 
36
 */ 
Lines 39-55 Link Here
39
	 * The singleton launch configuration presentation manager
40
	 * The singleton launch configuration presentation manager
40
	 */
41
	 */
41
	private static LaunchConfigurationPresentationManager fgDefault;
42
	private static LaunchConfigurationPresentationManager fgDefault;
43
	
44
	private static final String MODELESS = "*"; //$NON-NLS-1$
42
			
45
			
43
	/**
46
	/**
44
	 * Collection of launch configuration tab group extensions
47
	 * Mapping of the types to the extensions
45
	 * defined in plug-in xml. Entries are keyed by launch
48
	 * Map is of form:
46
	 * configuration type identifier (<code>String</code>),
49
	 * HashMap&lt;ILaunchConfigurationType, HashMap&lt;String, HashMap&lt;LaunchConfigurationTabGroupExtension, String&gt;&gt;&gt;
47
	 * and entires are tables of launch modes (<code>String</code>)
50
	 * @since 3.3
48
	 * to <code>LaunchConfigurationTabGroupExtension</code>. "*" is
49
	 * used to represent the default tab group (i.e. unspecified mode).
50
	 */
51
	 */
51
	private Hashtable fTabGroupExtensions;	
52
	private HashMap fMap;
52
			
53
	
53
	/**
54
	/**
54
	 * Constructs the singleton launch configuration presentation
55
	 * Constructs the singleton launch configuration presentation
55
	 * manager.
56
	 * manager.
Lines 74-116 Link Here
74
	 * defined in XML, and adds them to the table of tab group extensions.
75
	 * defined in XML, and adds them to the table of tab group extensions.
75
	 */
76
	 */
76
	private void initializeTabGroupExtensions() {
77
	private void initializeTabGroupExtensions() {
77
		fTabGroupExtensions = new Hashtable();
78
		fMap = new HashMap(0);
78
		IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(DebugUIPlugin.getUniqueIdentifier(), IDebugUIConstants.EXTENSION_POINT_LAUNCH_CONFIGURATION_TAB_GROUPS);
79
		IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(DebugUIPlugin.getUniqueIdentifier(), IDebugUIConstants.EXTENSION_POINT_LAUNCH_CONFIGURATION_TAB_GROUPS);
79
		IConfigurationElement[] groups = extensionPoint.getConfigurationElements();
80
		IConfigurationElement[] groups = extensionPoint.getConfigurationElements();
81
		LaunchConfigurationTabGroupExtension group = null;
82
		ILaunchConfigurationType type = null;
83
		String typeId = null;
84
		IExtension ext = null;
85
		Set modes = null;
86
		String mode = null;
87
		HashMap mod = null;
88
		HashMap grp = null;
80
		for (int i = 0; i < groups.length; i++) {
89
		for (int i = 0; i < groups.length; i++) {
81
			LaunchConfigurationTabGroupExtension group = new LaunchConfigurationTabGroupExtension(groups[i]);
90
			group = new LaunchConfigurationTabGroupExtension(groups[i]);
82
			String typeId = group.getTypeIdentifier();
91
			typeId = group.getTypeIdentifier();
92
			ext = groups[i].getDeclaringExtension();
83
			if (typeId == null) {
93
			if (typeId == null) {
84
				IExtension ext = groups[i].getDeclaringExtension();
85
				IStatus status = new Status(IStatus.ERROR, IDebugUIConstants.PLUGIN_ID, IDebugUIConstants.STATUS_INVALID_EXTENSION_DEFINITION,
94
				IStatus status = new Status(IStatus.ERROR, IDebugUIConstants.PLUGIN_ID, IDebugUIConstants.STATUS_INVALID_EXTENSION_DEFINITION,
86
					 MessageFormat.format("Launch configuration tab group extension {0} does not specify launch configuration type.", (new String[] {ext.getUniqueIdentifier()})), null);  //$NON-NLS-1$
95
					 MessageFormat.format("Launch configuration tab group extension {0} does not specify launch configuration type.", (new String[] {ext.getUniqueIdentifier()})), null);  //$NON-NLS-1$
87
					DebugUIPlugin.log(status);
96
					DebugUIPlugin.log(status);
88
			} else {
97
			} 
89
				// verify it references a valid launch configuration type
98
			else {
90
				ILaunchConfigurationType lct = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(typeId);
99
				type = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(typeId);
91
				if (lct == null) {
100
				if (type == null) {
92
					IExtension ext = groups[i].getDeclaringExtension();
93
					IStatus status = new Status(IStatus.ERROR, IDebugUIConstants.PLUGIN_ID, IDebugUIConstants.STATUS_INVALID_EXTENSION_DEFINITION,
101
					IStatus status = new Status(IStatus.ERROR, IDebugUIConstants.PLUGIN_ID, IDebugUIConstants.STATUS_INVALID_EXTENSION_DEFINITION,
94
					 MessageFormat.format("Launch configuration tab group extension {0} refers to non-existent launch configuration type {1}.", (new String[] {ext.getUniqueIdentifier(), typeId})), null);  //$NON-NLS-1$
102
					 MessageFormat.format("Launch configuration tab group extension {0} refers to non-existent launch configuration type {1}.", (new String[] {ext.getUniqueIdentifier(), typeId})), null);  //$NON-NLS-1$
95
					DebugUIPlugin.log(status);
103
					DebugUIPlugin.log(status);
96
				}
104
				}
97
			}
105
				modes = group.getModes();
98
			if (typeId != null) {
106
				mod = (HashMap) fMap.get(type);
99
				// get the map for the config type
107
				grp = null;
100
				Map map = (Map)fTabGroupExtensions.get(typeId);
108
				if(mod == null) {
101
				if (map == null) {
109
					mod = new HashMap(0);
102
					map = new Hashtable();
110
					fMap.put(type, mod);
103
					fTabGroupExtensions.put(typeId, map);
104
				}
111
				}
105
				Set modes = group.getModes();
106
				if (modes == null) {
112
				if (modes == null) {
107
					// default tabs - store with "*"
113
					grp = new HashMap(0);
108
					map.put("*", group); //$NON-NLS-1$
114
					grp.put(group, null);
109
				} else {
115
					mod.put(MODELESS, grp);
110
					// store per mode
116
				} 
111
					Iterator iterator = modes.iterator();
117
				else {
112
					while (iterator.hasNext()) {
118
					for(Iterator iter = modes.iterator(); iter.hasNext();) {
113
						map.put(iterator.next(), group);
119
						mode = (String) iter.next();
120
						grp = (HashMap) mod.get(mode);
121
						if(grp == null) {
122
							grp = new HashMap(0);
123
							mod.put(mode, grp);
124
						}
125
						grp.put(group, group.getLaunchDelegate());
114
					}
126
					}
115
				}
127
				}
116
			}
128
			}
Lines 144-160 Link Here
144
	 * @return launch tab group extension or <code>null</code>
156
	 * @return launch tab group extension or <code>null</code>
145
	 */
157
	 */
146
	protected LaunchConfigurationTabGroupExtension getExtension(String type, String mode) {
158
	protected LaunchConfigurationTabGroupExtension getExtension(String type, String mode) {
147
		// get the map for the config type
159
		if(mode == null) {
148
		Map map = (Map)fTabGroupExtensions.get(type);
160
			mode = MODELESS;
149
		if (map != null) {
150
			// try the specific mode
151
			Object extension = map.get(mode);
152
			if (extension == null) {
153
				// get the default tabs
154
				extension = map.get("*"); //$NON-NLS-1$
155
			}
156
			return (LaunchConfigurationTabGroupExtension)extension;
157
		}
161
		}
162
		return findExtensionItem(type, mode);
163
	}
164
	
165
	/**
166
	 * Finds the corresponding <code>LaunchConfigurationTabGroupExtension</code> for the given type id and the mode
167
	 * @param type the id of the <code>LaunchConfigurationType</code> we want the tab group for
168
	 * @param mode the mode we want the tab group for
169
	 * @return the corresponding ag group extension or <code>null</code> if not found
170
	 * @since 3.3
171
	 */
172
	private LaunchConfigurationTabGroupExtension findExtensionItem(String type, String mode) {
173
		try {
174
			ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager();
175
			ILaunchConfigurationType lctype = lm.getLaunchConfigurationType(type);
176
			HashMap stype = (HashMap) fMap.get(lctype);
177
			if(stype != null) {
178
				HashMap smode = (HashMap) stype.get(mode);
179
				if(smode == null) {
180
					smode = (HashMap)stype.get(MODELESS);
181
				}
182
				if(smode.size() > 1) {
183
					//choose preferred
184
					String delegate = lm.getPreferredDelegateProvider(lctype, mode);
185
					LaunchConfigurationTabGroupExtension ext = null;
186
					String prefer = null;
187
					for(Iterator iter = smode.keySet().iterator(); iter.hasNext();) {
188
						ext = (LaunchConfigurationTabGroupExtension) iter.next();
189
						prefer = (String) smode.get(ext);
190
						if(delegate == null & prefer == null) {
191
							return ext;
192
						}
193
						else {
194
							if(delegate != null && delegate.equals(prefer)) {
195
								return ext;
196
							}
197
						}
198
					}
199
					//if we are here it is due to contributor's not specifying a delegate name on their group extension
200
					//just return the first one
201
					return (LaunchConfigurationTabGroupExtension) smode.keySet().iterator().next();
202
				}
203
				else {
204
					//return the only one if no preferred given
205
					return (LaunchConfigurationTabGroupExtension) smode.keySet().iterator().next();
206
				}
207
			}
208
		} 
209
		catch (CoreException e) {DebugUIPlugin.log(e);}
158
		return null;
210
		return null;
159
	}
211
	}
160
	
212
	
(-)ui/org/eclipse/debug/internal/ui/SWTUtil.java (+100 lines)
Lines 21-26 Link Here
21
import org.eclipse.jface.util.Assert;
21
import org.eclipse.jface.util.Assert;
22
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.SWT;
23
import org.eclipse.swt.custom.BusyIndicator;
23
import org.eclipse.swt.custom.BusyIndicator;
24
import org.eclipse.swt.custom.CLabel;
24
import org.eclipse.swt.graphics.Font;
25
import org.eclipse.swt.graphics.Font;
25
import org.eclipse.swt.graphics.Image;
26
import org.eclipse.swt.graphics.Image;
26
import org.eclipse.swt.layout.GridData;
27
import org.eclipse.swt.layout.GridData;
Lines 29-34 Link Here
29
import org.eclipse.swt.widgets.Composite;
30
import org.eclipse.swt.widgets.Composite;
30
import org.eclipse.swt.widgets.Group;
31
import org.eclipse.swt.widgets.Group;
31
import org.eclipse.swt.widgets.Label;
32
import org.eclipse.swt.widgets.Label;
33
import org.eclipse.swt.widgets.Link;
32
import org.eclipse.swt.widgets.Text;
34
import org.eclipse.swt.widgets.Text;
33
35
34
/**
36
/**
Lines 148-153 Link Here
148
	}
150
	}
149
	
151
	
150
	/**
152
	/**
153
	 * Creates a new label widget
154
	 * @param parent the parent composite to add this label widget to
155
	 * @param style the SWT style for the widget
156
	 * @param text the text for the label
157
	 * @param hspan the horizontal span to take up in the parent composite
158
	 * @return the new label
159
	 * @since 3.3
160
	 */
161
	public static Label createLabel(Composite parent, int style, String text, int hspan) {
162
		Label l = new Label(parent, style);
163
		l.setFont(parent.getFont());
164
		l.setText(text);
165
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
166
		gd.horizontalSpan = hspan;
167
		l.setLayoutData(gd);
168
		return l;
169
	}
170
	
171
	/**
172
	 * Creates a new wrapping label widget
173
	 * @param parent the parent composite to add this label widget to
174
	 * @param style the SWT style for the widget
175
	 * @param text the text for the label
176
	 * @param hspan the horizontal span to take up in the parent composite
177
	 * @return the new label
178
	 * @since 3.3
179
	 */
180
	public static Label createWrappedLabel(Composite parent, String text, int hspan, int width) {
181
		Label l = new Label(parent, SWT.WRAP);
182
		l.setFont(parent.getFont());
183
		l.setText(text);
184
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
185
		gd.horizontalSpan = hspan;
186
		gd.widthHint = width;
187
		l.setLayoutData(gd);
188
		return l;
189
	}
190
	
191
    /**
192
     * Creates a new <code>CLabel</code> object
193
     * @param parent the parent composite to add this clabel to
194
     * @param image the image for the label
195
     * @param text the text for the label
196
     * @param hspan the horizontal span the label should take up in the parent
197
     * @param fill the fill style for label
198
     * @param width the width for the label
199
     * @return a new <code>CLabel</code> object
200
     * @since 3.3
201
     */
202
    public static CLabel createWrapCLabel(Composite parent, Image image, String text, int hspan, int fill, int width) {
203
    	CLabel lbl = new CLabel(parent, SWT.NONE | SWT.WRAP);
204
    	lbl.setImage(image);
205
        lbl.setFont(parent.getFont());
206
        lbl.setText(text);
207
        GridData gd = new GridData(fill);
208
        gd.widthHint = width/*parent.getBounds().width - 30*/;
209
        gd.horizontalSpan = hspan;
210
        lbl.setLayoutData(gd);
211
        return lbl;
212
    }
213
	
214
	/**
151
	 * Creates a new text widget 
215
	 * Creates a new text widget 
152
	 * @param parent the parent composite to add this text widget to
216
	 * @param parent the parent composite to add this text widget to
153
	 * @param hspan the horizontal span to take up on the parent composite
217
	 * @param hspan the horizontal span to take up on the parent composite
Lines 258-263 Link Here
258
	}
322
	}
259
	
323
	
260
	/**
324
	/**
325
	 * creates a vertical spacer for seperating components
326
	 * @param comp
327
	 * @param numlines
328
	 * @param span the horizontal span for the spacer
329
	 * @since 3.3
330
	 */
331
	public static void createVerticalSpacer(Composite comp, int numlines, int span) {
332
		Label lbl = new Label(comp, SWT.NONE);
333
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
334
		gd.horizontalSpan = span;
335
		gd.heightHint = numlines;
336
		lbl.setLayoutData(gd);
337
	}
338
	
339
	/**
261
	 * Creates a Composite widget
340
	 * Creates a Composite widget
262
	 * @param parent the parent composite to add this composite to
341
	 * @param parent the parent composite to add this composite to
263
	 * @param columns the number of columns within the composite
342
	 * @param columns the number of columns within the composite
Lines 281-286 Link Here
281
	}
360
	}
282
	
361
	
283
	/**
362
	/**
363
	 * Creates a <code>Link</code> object
364
	 * @param parent the parent composite to add this link to
365
	 * @param text the text for the link
366
	 * @param hspan the horizontal span the link object should take up in the parent
367
	 * @param fill the fill style for the link
368
	 * @param width the width in pixels of the link
369
	 * @return a new <code>Link</code> object
370
	 * @since 3.3
371
	 */
372
	public static final Link createLink(Composite parent, String text, int hspan, int fill, int width) {
373
		Link link = new Link(parent, SWT.LEFT | SWT.WRAP);
374
		link.setFont(parent.getFont());
375
		link.setText(text);
376
		GridData gd = new GridData(fill);
377
		gd.widthHint = width;
378
		gd.horizontalSpan = hspan;
379
		link.setLayoutData(gd);
380
		return link;
381
	}
382
	
383
	/**
284
	 * This method allows us to open the preference dialog on the specific page, in this case the perspective page
384
	 * This method allows us to open the preference dialog on the specific page, in this case the perspective page
285
	 * @param id the id of pref page to show
385
	 * @param id the id of pref page to show
286
	 * @param page the actual page to show
386
	 * @param page the actual page to show
(-)ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java (+1 lines)
Lines 73-78 Link Here
73
	public static final String LAUNCHING_PREFERENCE_PAGE = PREFIX + "launching_preference_page_context"; //$NON-NLS-1$
73
	public static final String LAUNCHING_PREFERENCE_PAGE = PREFIX + "launching_preference_page_context"; //$NON-NLS-1$
74
	public static final String LAUNCH_CONFIGURATION_PREFERENCE_PAGE = PREFIX + "launch_configuration_preference_page_context"; //$NON-NLS-1$
74
	public static final String LAUNCH_CONFIGURATION_PREFERENCE_PAGE = PREFIX + "launch_configuration_preference_page_context"; //$NON-NLS-1$
75
	public static final String VIEW_MANAGEMENT_PREFERENCE_PAGE = PREFIX + "view_management_preference_page_context"; //$NON-NLS-1$
75
	public static final String VIEW_MANAGEMENT_PREFERENCE_PAGE = PREFIX + "view_management_preference_page_context"; //$NON-NLS-1$
76
	public static final String CONFLICTING_LAUNCH_DELEGATES_PAGE = PREFIX + "conflicting_launch_delegates_page"; //$NON-NLS-1$
76
	
77
	
77
	// Dialogs
78
	// Dialogs
78
	public static final String LAUNCH_CONFIGURATION_DIALOG = PREFIX + "launch_configuration_dialog"; //$NON-NLS-1$
79
	public static final String LAUNCH_CONFIGURATION_DIALOG = PREFIX + "launch_configuration_dialog"; //$NON-NLS-1$
(-)ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties (+4 lines)
Lines 121-123 Link Here
121
LaunchConfigurationsPreferencePage_1=Launch Configurations
121
LaunchConfigurationsPreferencePage_1=Launch Configurations
122
LaunchConfigurationsPreferencePage_2=Delete configurations when associated project is deleted
122
LaunchConfigurationsPreferencePage_2=Delete configurations when associated project is deleted
123
LaunchConfigurationsPreferencePage_3=Apply window &working set(s)
123
LaunchConfigurationsPreferencePage_3=Apply window &working set(s)
124
ConflictingLaunchDelegatesPage_page_title=Launch Providers
125
ConflictingLaunchDelegatesPage_page_description=Conflicting launch providers are displayed below. To change the default launch provider for a particular conflicting launch mode, select it in the Conflicting Providers list and then check the desired entry in the Default Provider list.
126
ConflictingLaunchDelegatesPage_conflicting_providers=Conflicting Providers
127
ConflictingLaunchDelegatesPage_default_delegate=Default Delegate
(-)ui/org/eclipse/debug/internal/ui/preferences/LaunchConfigurationTreeContentProviderNoChildren.java (-2 / +2 lines)
Lines 29-35 Link Here
29
	 */
29
	 */
30
	public LaunchConfigurationTreeContentProviderNoChildren(String mode, Shell shell) {
30
	public LaunchConfigurationTreeContentProviderNoChildren(String mode, Shell shell) {
31
		super(mode, shell);
31
		super(mode, shell);
32
	}//end constructor
32
	}
33
33
34
	/* (non-Javadoc)
34
	/* (non-Javadoc)
35
	 * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
35
	 * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
Lines 44-47 Link Here
44
	public Object[] getChildren(Object parentElement) {
44
	public Object[] getChildren(Object parentElement) {
45
		return new Object[] {};
45
		return new Object[] {};
46
	}
46
	}
47
}//end class
47
}
(-)ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java (+8 lines)
Lines 15-20 Link Here
15
public class DebugPreferencesMessages extends NLS {
15
public class DebugPreferencesMessages extends NLS {
16
	private static final String BUNDLE_NAME = "org.eclipse.debug.internal.ui.preferences.DebugPreferencesMessages";//$NON-NLS-1$
16
	private static final String BUNDLE_NAME = "org.eclipse.debug.internal.ui.preferences.DebugPreferencesMessages";//$NON-NLS-1$
17
17
18
	public static String ConflictingLaunchDelegatesPage_conflicting_providers;
19
20
	public static String ConflictingLaunchDelegatesPage_default_delegate;
21
22
	public static String ConflictingLaunchDelegatesPage_page_description;
23
24
	public static String ConflictingLaunchDelegatesPage_page_title;
25
18
	public static String ConsolePreferencePage_Console_settings;
26
	public static String ConsolePreferencePage_Console_settings;
19
	public static String ConsolePreferencePage_Show__Console_View_when_there_is_program_error_3;
27
	public static String ConsolePreferencePage_Show__Console_View_when_there_is_program_error_3;
20
	public static String ConsolePreferencePage_Show__Console_View_when_there_is_program_output_3;
28
	public static String ConsolePreferencePage_Show__Console_View_when_there_is_program_output_3;
(-)ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java (-1 lines)
Lines 147-153 Link Here
147
	 * @since 3.2
147
	 * @since 3.2
148
	 */
148
	 */
149
	public static final int PREF_ROW_SIZE_DEFAULT = 16;
149
	public static final int PREF_ROW_SIZE_DEFAULT = 16;
150
	
151
		
150
		
152
	/**
151
	/**
153
	 * Default padded string for renderings
152
	 * Default padded string for renderings
(-)schema/launchConfigurationTabGroups.exsd (-2 / +12 lines)
Lines 86-91 Link Here
86
               </appInfo>
86
               </appInfo>
87
            </annotation>
87
            </annotation>
88
         </attribute>
88
         </attribute>
89
         <attribute name="launchDelegate" type="string">
90
            <annotation>
91
               <documentation>
92
                  this field associates this tab group to a specific id of a launch configuration delegate
93
               </documentation>
94
            </annotation>
95
         </attribute>
89
      </complexType>
96
      </complexType>
90
   </element>
97
   </element>
91
98
Lines 136-142 Link Here
136
  &lt;launchConfigurationTabGroup
143
  &lt;launchConfigurationTabGroup
137
      id=&quot;com.example.ExampleTabGroup&quot;
144
      id=&quot;com.example.ExampleTabGroup&quot;
138
      type=&quot;com.example.ExampleLaunchConfigurationTypeIdentifier&quot;
145
      type=&quot;com.example.ExampleLaunchConfigurationTypeIdentifier&quot;
139
      class=&quot;com.example.ExampleLaunchConfigurationTabGroupClass&quot;&gt;
146
      class=&quot;com.example.ExampleLaunchConfigurationTabGroupClass&quot;
147
      launchDelegate=&quot;com.example.ExampleLaunchDelegate&quot;&gt;
140
  &lt;/launchConfigurationTabGroup&gt;
148
  &lt;/launchConfigurationTabGroup&gt;
141
 &lt;/extension&gt;
149
 &lt;/extension&gt;
142
&lt;/pre&gt;
150
&lt;/pre&gt;
Lines 154-159 Link Here
154
      <documentation>
162
      <documentation>
155
         Value of the attribute &lt;code&gt;class&lt;/code&gt; must be a fully qualified name of a Java class that implements the 
163
         Value of the attribute &lt;code&gt;class&lt;/code&gt; must be a fully qualified name of a Java class that implements the 
156
interface &lt;code&gt;org.eclipse.debug.ui.ILaunchConfigurationTabGroup&lt;/code&gt;.
164
interface &lt;code&gt;org.eclipse.debug.ui.ILaunchConfigurationTabGroup&lt;/code&gt;.
165
166
Value of &lt;code&gt;launchDelegate&lt;/code&gt; must match name an existing id for a &lt;code&gt;LaunchConfigurationDelegate&lt;/code&gt; defined in a &lt;code&gt;LaunchConfigurationType&lt;/code&gt; or &lt;code&gt;LaunchDelegate&lt;/code&gt; extension point.
157
      </documentation>
167
      </documentation>
158
   </annotation>
168
   </annotation>
159
169
Lines 162-168 Link Here
162
         <meta.section type="copyright"/>
172
         <meta.section type="copyright"/>
163
      </appInfo>
173
      </appInfo>
164
      <documentation>
174
      <documentation>
165
Copyright (c) 2000, 2005 IBM Corporation and others.&lt;br&gt;
175
         Copyright (c) 2000, 2005 IBM Corporation and others.&lt;br&gt;
166
All rights reserved. This program and the accompanying materials are made 
176
All rights reserved. This program and the accompanying materials are made 
167
available under the terms of the Eclipse Public License v1.0 which 
177
available under the terms of the Eclipse Public License v1.0 which 
168
accompanies this distribution, and is available at 
178
accompanies this distribution, and is available at 
(-)ui/org/eclipse/debug/internal/ui/preferences/ConflictingLaunchDelegatesPage.java (+334 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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.preferences;
12
13
import java.util.ArrayList;
14
import java.util.Collection;
15
import java.util.HashMap;
16
import java.util.Iterator;
17
import java.util.List;
18
import java.util.Map;
19
import java.util.Set;
20
import java.util.Map.Entry;
21
22
import org.eclipse.core.runtime.CoreException;
23
import org.eclipse.debug.core.DebugPlugin;
24
import org.eclipse.debug.core.ILaunchConfigurationType;
25
import org.eclipse.debug.core.ILaunchManager;
26
import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
27
import org.eclipse.debug.internal.ui.DebugUIPlugin;
28
import org.eclipse.debug.internal.ui.DefaultLabelProvider;
29
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
30
import org.eclipse.debug.internal.ui.SWTUtil;
31
import org.eclipse.jface.preference.PreferencePage;
32
import org.eclipse.jface.viewers.CheckStateChangedEvent;
33
import org.eclipse.jface.viewers.CheckboxTableViewer;
34
import org.eclipse.jface.viewers.ICheckStateListener;
35
import org.eclipse.jface.viewers.ISelectionChangedListener;
36
import org.eclipse.jface.viewers.IStructuredContentProvider;
37
import org.eclipse.jface.viewers.IStructuredSelection;
38
import org.eclipse.jface.viewers.SelectionChangedEvent;
39
import org.eclipse.jface.viewers.StructuredSelection;
40
import org.eclipse.jface.viewers.TableViewer;
41
import org.eclipse.jface.viewers.Viewer;
42
import org.eclipse.swt.SWT;
43
import org.eclipse.swt.graphics.Image;
44
import org.eclipse.swt.layout.GridData;
45
import org.eclipse.swt.widgets.Composite;
46
import org.eclipse.swt.widgets.Control;
47
import org.eclipse.swt.widgets.Group;
48
import org.eclipse.swt.widgets.Table;
49
import org.eclipse.swt.widgets.TableItem;
50
import org.eclipse.ui.IWorkbench;
51
import org.eclipse.ui.IWorkbenchPreferencePage;
52
import org.eclipse.ui.PlatformUI;
53
import org.eclipse.ui.model.WorkbenchViewerSorter;
54
55
/**
56
 * Class provides a pref page to allow users to resolve which launch configuration 
57
 * elements and which launch delegates are to be used in the event of more than 
58
 * one launcher being provided for the same mode and launch.
59
 * 
60
 * See Bug 137057 [launching] Allow user to resolve launcher to user for config/mode when > 1
61
 * 
62
 * @since 3.3
63
 */
64
public class ConflictingLaunchDelegatesPage extends PreferencePage implements IWorkbenchPreferencePage {
65
66
	/**
67
	 * Label provider for both tables
68
	 */
69
	class LabelProvider extends DefaultLabelProvider {
70
		public String getText(Object element) {
71
			if(element instanceof ConflictingProvider) {
72
				ConflictingProvider cp = (ConflictingProvider) element;
73
				return super.getText(cp.getLaunchConfigurationType())+" ("+cp.getMode()+" mode)";  //$NON-NLS-1$//$NON-NLS-2$
74
			}
75
			if(element instanceof Entry) {
76
				return (String) ((Entry)element).getKey();
77
			}
78
			return super.getText(element);
79
		}
80
81
		public Image getImage(Object element) {
82
			if(element instanceof ConflictingProvider) {
83
				return super.getImage(((ConflictingProvider) element).getLaunchConfigurationType());
84
			}
85
			return super.getImage(element);
86
		}
87
	}
88
	
89
	/**
90
	 * Content provider for both tables
91
	 */
92
	class TableContentProvider implements IStructuredContentProvider {
93
94
		Collection elements = null;
95
		
96
		public Object[] getElements(Object inputElement) {
97
			if(elements == null) {
98
				return new Object[0];
99
			}
100
			else {
101
				return elements.toArray();
102
			}
103
		}
104
105
		public void dispose() {}
106
107
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
108
			if(newInput instanceof Collection) {
109
				elements = (Collection) newInput;
110
			}
111
			else if(newInput instanceof Map) {
112
				elements = ((Map)newInput).entrySet();
113
			}
114
		}
115
	}
116
	
117
	/**
118
	 * Provides a wrapper for information needed to describe a conflicting provider
119
	 */
120
	class ConflictingProvider {
121
122
		private ILaunchConfigurationType fType;
123
		private String fMode;
124
		private HashMap fConflicts;
125
		private String fProvider;
126
		private ILaunchConfigurationDelegate fDelegate;
127
		
128
		public ConflictingProvider(ILaunchConfigurationType type, String mode, HashMap conflicts) {
129
			fType = type;
130
			fMode = mode;
131
			fConflicts = conflicts;
132
		}
133
		
134
		public void setPreferredDelegate(String provider, ILaunchConfigurationDelegate delegate) {
135
			fProvider = provider;
136
			fDelegate = delegate;
137
		}
138
		
139
		public String getProvider() {
140
			return fProvider;
141
		}
142
		
143
		public String getMode() {
144
			return fMode;
145
		}
146
		
147
		public ILaunchConfigurationDelegate getDelegate() {
148
			return fDelegate;
149
		}
150
		
151
		public ILaunchConfigurationType getLaunchConfigurationType() {
152
			return fType;
153
		}
154
		
155
		public HashMap getConflicts() {
156
			return fConflicts;
157
		}
158
		
159
	}
160
	
161
	private static final int LABEL_WIDTH_HINT = 450;
162
	private static final int TREE_HEIGHT = 200;
163
	private static final int TREE_WIDTH = 150;
164
	private ILaunchManager fLManager = DebugPlugin.getDefault().getLaunchManager();
165
	
166
	/**
167
	 * maps ConflictingProvider to ILaunchConfigurationDelegate
168
	 */
169
	private HashMap fChangedDelegates = new HashMap();
170
	private List fConflictingProviders = null;
171
	private boolean fDirty = false;
172
	
173
	//widgets
174
	private Table fTable;
175
	private TableViewer fTableViewer;
176
	private CheckboxTableViewer fCheckTableViewer;
177
	private Table fCheckTable;
178
	
179
	/**
180
	 * default constructor 
181
	 */
182
	public ConflictingLaunchDelegatesPage() {
183
		setTitle(DebugPreferencesMessages.ConflictingLaunchDelegatesPage_page_title);
184
		init(null);
185
	}
186
	
187
	/**
188
	 * Constructor
189
	 * @param title the title of the page
190
	 */
191
	public ConflictingLaunchDelegatesPage(String title) {
192
		super(title);
193
	}
194
195
	/* (non-Javadoc)
196
	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
197
	 */
198
	protected Control createContents(Composite parent) {
199
		Composite comp = SWTUtil.createComposite(parent, parent.getFont(), 2, 1, GridData.FILL_BOTH);
200
		SWTUtil.createWrappedLabel(comp, DebugPreferencesMessages.ConflictingLaunchDelegatesPage_page_description, 2, LABEL_WIDTH_HINT);
201
		SWTUtil.createVerticalSpacer(comp, 1, 2);
202
	//create the tree viewer for the conflicting providers
203
		Group group = SWTUtil.createGroup(comp, DebugPreferencesMessages.ConflictingLaunchDelegatesPage_conflicting_providers, 1, 1, GridData.FILL_HORIZONTAL);
204
		fTable = new Table(group, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.BORDER);
205
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
206
		gd.heightHint = TREE_HEIGHT;
207
		gd.widthHint = TREE_WIDTH;
208
		fTable.setLayoutData(gd);
209
		fTableViewer = new TableViewer(fTable);
210
		fTableViewer.setLabelProvider(new LabelProvider());
211
		fTableViewer.setSorter(new WorkbenchViewerSorter());
212
		fTableViewer.setContentProvider(new TableContentProvider());
213
		fTableViewer.setInput(fConflictingProviders);
214
		fTableViewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
215
					public void selectionChanged(SelectionChangedEvent event) {
216
						handleSelectionChangedEvent(event);
217
					}
218
				});
219
	//create the check table viewer for the default provider
220
		group = SWTUtil.createGroup(comp, DebugPreferencesMessages.ConflictingLaunchDelegatesPage_default_delegate, 1, 1, GridData.FILL_HORIZONTAL);
221
		fCheckTable = new Table(group, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.BORDER | SWT.CHECK);
222
		gd = new GridData(GridData.FILL_HORIZONTAL);
223
		gd.heightHint = TREE_HEIGHT;
224
		gd.widthHint = TREE_WIDTH;
225
		fCheckTable.setLayoutData(gd);
226
		fCheckTableViewer = new CheckboxTableViewer(fCheckTable);
227
		fCheckTableViewer.setLabelProvider(new LabelProvider());
228
		fCheckTableViewer.setSorter(new WorkbenchViewerSorter());
229
		fCheckTableViewer.setContentProvider(new TableContentProvider());
230
		fCheckTableViewer.addCheckStateListener(new ICheckStateListener() {
231
			public void checkStateChanged(CheckStateChangedEvent event) {
232
				Object obj = event.getElement();
233
				boolean checked = event.getChecked();
234
				fCheckTableViewer.setAllChecked(false);
235
				fCheckTableViewer.setChecked(obj, checked);
236
				ConflictingProvider cp = getConflictingProvider();
237
				Entry entry = (Entry) obj;
238
				if(checked) {
239
					cp.setPreferredDelegate((String) entry.getKey(), (ILaunchConfigurationDelegate) entry.getValue());
240
				}
241
				else { 
242
					cp.setPreferredDelegate(null, null);
243
				}
244
				fChangedDelegates.put(cp, obj);
245
				fDirty = true;
246
			}
247
		});
248
		if(fTable.getItemCount() > 0) {
249
			fTableViewer.setSelection(new StructuredSelection(fTable.getItem(0).getData()));
250
		}
251
		return comp;
252
	}
253
	
254
	/**
255
	 * @return the <code>ConflictingProvider</code> from the right hand side table
256
	 */
257
	private ConflictingProvider getConflictingProvider() {
258
		return (ConflictingProvider) fTable.getSelection()[0].getData();
259
	}
260
	
261
	/* (non-Javadoc)
262
	 * @see org.eclipse.jface.preference.PreferencePage#createControl(org.eclipse.swt.widgets.Composite)
263
	 */
264
	public void createControl(Composite parent) {
265
		super.createControl(parent);
266
		PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IDebugHelpContextIds.CONFLICTING_LAUNCH_DELEGATES_PAGE);
267
	}
268
269
	/**
270
	 * method handles what to do after the selection changes in the Conflicting Providers tree
271
	 * @param event the selection changed event
272
	 */
273
	private void handleSelectionChangedEvent(SelectionChangedEvent event) {
274
		IStructuredSelection sel = (IStructuredSelection) event.getSelection();
275
		if(!sel.isEmpty()) {
276
			fCheckTableViewer.setInput(getConflictingProvider().getConflicts());
277
			//set the checked state based on what has been changed
278
			TableItem[] items = fCheckTable.getItems();
279
			Entry entry = null;
280
			for(int i = 0; i < items.length; i++) {
281
				entry = (Entry) items[i].getData();
282
				if(entry.getValue().equals(getConflictingProvider().getDelegate())) {
283
					fCheckTableViewer.setChecked(entry, true);
284
				}
285
			}
286
		}
287
	}
288
	
289
	/* (non-Javadoc)
290
	 * @see org.eclipse.jface.preference.PreferencePage#performApply()
291
	 */
292
	public boolean performOk() {
293
		if(fDirty) {
294
			try {
295
				ConflictingProvider cp = null;
296
				for(Iterator iter = fChangedDelegates.keySet().iterator(); iter.hasNext();) {
297
					cp = (ConflictingProvider) iter.next();
298
					if(cp.getProvider() == null) {
299
						fLManager.removePreferredDelegate(cp.getLaunchConfigurationType(), cp.getMode());
300
					}
301
					else {
302
						fLManager.setPreferredDelegate(cp.getLaunchConfigurationType(), cp.getMode(), cp.getDelegate(), cp.getProvider());
303
					}
304
				}
305
			}
306
			catch(CoreException e) {DebugUIPlugin.log(e);}
307
		}
308
		return super.performOk();
309
	}
310
311
	/* (non-Javadoc)
312
	 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
313
	 */
314
	public void init(IWorkbench workbench) {
315
		try {
316
			fConflictingProviders = new ArrayList(0);
317
			ILaunchConfigurationType[] types = fLManager.getLaunchConfigurationTypes();
318
			ConflictingProvider cp = null;
319
			for(int i = 0; i < types.length; i++) {
320
				Set modes = types[i].getSupportedModes();
321
				for(Iterator iter = modes.iterator(); iter.hasNext();) {
322
					String mode = (String) iter.next();
323
					if(fLManager.hasConflictingDelegates(types[i], mode)) {
324
						cp = new ConflictingProvider(types[i], mode, fLManager.getConflictingDelegates(types[i], mode));
325
						cp.setPreferredDelegate(fLManager.getPreferredDelegateProvider(types[i], mode), fLManager.getPreferredDelegate(types[i], mode));
326
						fConflictingProviders.add(cp);
327
					}
328
				}
329
			}
330
		}
331
		catch(CoreException e) {DebugUIPlugin.log(e);}
332
	}
333
334
}

Return to bug 137057