1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/*******************************************************************************
* Copyright (c) 2011, 2014 Wind River Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.tcf.te.runtime.stepper.extensions.manager;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager;
import org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroup;
/**
* Step group extension manager implementation.
*/
public final class StepGroupExtensionPointManager extends AbstractExtensionPointManager<IStepGroup> {
/* (non-Javadoc)
* @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getExtensionPointId()
*/
@Override
protected String getExtensionPointId() {
return "org.eclipse.tcf.te.runtime.stepper.stepGroups"; //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getConfigurationElementName()
*/
@Override
protected String getConfigurationElementName() {
return "stepGroup"; //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#doCreateExtensionProxy(org.eclipse.core.runtime.IConfigurationElement)
*/
@Override
protected ExecutableExtensionProxy<IStepGroup> doCreateExtensionProxy(IConfigurationElement element) throws CoreException {
return new StepGroupExtensionProxy(element);
}
/**
* Returns the list of all contributed step groups.
*
* @param unique If <code>true</code>, the method returns new instances for each
* contributed step group.
*
* @return The list of contributed step groups, or an empty array.
*/
public IStepGroup[] getStepGroups(boolean unique) {
List<IStepGroup> contributions = new ArrayList<IStepGroup>();
Collection<ExecutableExtensionProxy<IStepGroup>> delegates = getExtensions().values();
for (ExecutableExtensionProxy<IStepGroup> delegate : delegates) {
IStepGroup instance = unique ? delegate.newInstance() : delegate.getInstance();
if (instance != null && !contributions.contains(instance)) {
contributions.add(instance);
}
}
return contributions.toArray(new IStepGroup[contributions.size()]);
}
/**
* Returns the step group identified by its unique id. If no step group with the specified id is
* registered, <code>null</code> is returned.
*
* @param id The step group unique id. Must not be <code>null</code>
* @param unique If <code>true</code>, the method returns new instances of the step group contribution.
*
* @return The step group instance or <code>null</code>.
*/
public IStepGroup getStepGroup(String id, boolean unique) {
Assert.isNotNull(id);
IStepGroup contribution = null;
if (getExtensions().containsKey(id)) {
ExecutableExtensionProxy<IStepGroup> proxy = getExtensions().get(id);
// Get the extension instance
contribution = unique ? proxy.newInstance() : proxy.getInstance();
}
return contribution;
}
/* (non-Javadoc)
* @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#doStoreExtensionTo(java.util.Map, org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy, org.eclipse.core.runtime.IConfigurationElement)
*/
@Override
protected void doStoreExtensionTo(Map<String, ExecutableExtensionProxy<IStepGroup>> extensions, ExecutableExtensionProxy<IStepGroup> candidate, IConfigurationElement element) throws CoreException {
Assert.isNotNull(extensions);
Assert.isNotNull(candidate);
Assert.isNotNull(element);
// If no extension with this id had been registered before, register now.
if (!extensions.containsKey(candidate.getId())) {
extensions.put(candidate.getId(), candidate);
}
else if (extensions.get(candidate.getId()) instanceof StepGroupExtensionProxy) {
StepGroupExtensionProxy proxy = (StepGroupExtensionProxy)extensions.get(candidate.getId());
proxy.addGroupExtension(element);
}
else {
super.doStoreExtensionTo(extensions, candidate, element);
}
}
}
|