blob: 3b16eeb0b74fc24b28f43609bbe78f0a70bd5987 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/*******************************************************************************
* Copyright (c) 2011 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.tm.te.core.connection.managers;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.core.runtime.Assert;
import org.eclipse.tm.te.core.connection.interfaces.IConnectionType;
import org.eclipse.tm.te.runtime.extensions.AbstractExtensionPointManager;
import org.eclipse.tm.te.runtime.extensions.ExecutableExtensionProxy;
/**
* Connection type extension point manager implementation.
* <p>
* The class is not intended to be subclassed by clients.
*/
public final class ConnectionTypeExtensionPointManager extends AbstractExtensionPointManager<IConnectionType> {
/**
* Constructor.
*/
/* default */ ConnectionTypeExtensionPointManager() {
}
/* (non-Javadoc)
* @see org.eclipse.tm.te.runtime.extensions.AbstractExtensionPointManager#getExtensionPointId()
*/
@Override
protected String getExtensionPointId() {
return "org.eclipse.tm.te.core.connectionTypes"; //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.tm.te.runtime.extensions.AbstractExtensionPointManager#getConfigurationElementName()
*/
@Override
protected String getConfigurationElementName() {
return "connectionType"; //$NON-NLS-1$
}
/**
* Returns the list of all contributed connection types.
*
* @return The list of contributed connection types, or an empty array.
*/
public IConnectionType[] getConnectionTypes() {
List<IConnectionType> types = new ArrayList<IConnectionType>();
Collection<ExecutableExtensionProxy<IConnectionType>> proxies = getExtensions().values();
for (ExecutableExtensionProxy<IConnectionType> proxy : proxies)
if (proxy.getInstance() != null && !types.contains(proxy.getInstance()))
types.add(proxy.getInstance());
return types.toArray(new IConnectionType[types.size()]);
}
/**
* Returns the connection type identified by its unique id. If no connection
* type with the specified id is registered, <code>null</code> is returned.
*
* @param id The unique id of the connection type. Must not be <code>null</code>
* @return The connection type or <code>null</code>.
*/
public IConnectionType getConnectionType(String id) {
Assert.isNotNull(id);
IConnectionType connectionType = null;
if (getExtensions().containsKey(id)) {
ExecutableExtensionProxy<IConnectionType> proxy = getExtensions().get(id);
connectionType = proxy.getInstance();
}
return connectionType;
}
}
|