Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 3a77565cd2f877ecf10587b16094a233583582e4 (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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*****************************************************************************
 * Copyright (c) 2013 CEA LIST.
 *
 *
 * 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:
 *  Patrick Tessier (CEA LIST) patrick.tessier@cea.fr - Initial API and implementation
 *
 *****************************************************************************/
package org.eclipse.papyrus.adltool.designer.bundle;

import java.util.ArrayList;

import org.eclipse.pde.core.project.IBundleProjectDescription;
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
import org.eclipse.uml2.uml.Component;
import org.osgi.framework.Bundle;


/**
 * this registry redirect the job to a good implementation.
 *
 */
@SuppressWarnings("restriction")
public class BundleDesignerRegistry implements IBundleDescriptionDesigner {
	protected WorkspaceBundleDescriptionDesigner workspaceBundleDescriptionDesigner;
	protected LoadedBundleDescriptionDesigner loadedBundleDescriptionDesigner;
	protected FeatureDescriptionDesigner featureDescriptionDesigner;


	/**
	 * create the registry
	 * Constructor.
	 *
	 */
	public BundleDesignerRegistry() {
		workspaceBundleDescriptionDesigner = new WorkspaceBundleDescriptionDesigner();
		loadedBundleDescriptionDesigner = new LoadedBundleDescriptionDesigner();
		featureDescriptionDesigner = new FeatureDescriptionDesigner();
	}

	/**
	 *
	 * @see org.eclipse.papyrus.adltool.designer.bundle.IBundleDescriptionDesigner#getBundleValue(java.lang.Object, java.lang.String)
	 *
	 * @param bundleProject
	 * @param key
	 * @return the value that correspond to the key
	 */
	public String getBundleValue(Object bundleProject, String key) {
		if (bundleProject instanceof IBundleProjectDescription) {
			return workspaceBundleDescriptionDesigner.getBundleValue(bundleProject, key);

		}
		else if (bundleProject instanceof Bundle) {
			return loadedBundleDescriptionDesigner.getBundleValue(bundleProject, key);
		}
		else if (bundleProject instanceof IFeatureModel) {
			return featureDescriptionDesigner.getBundleValue(bundleProject, key);
		}
		return null;
	}

	/**
	 *
	 * @see org.eclipse.papyrus.adltool.designer.bundle.IBundleDescriptionDesigner#fillPluginProperties(org.eclipse.uml2.uml.Component, java.lang.Object)
	 *
	 * @param bundleComponent
	 * @param bundleProject
	 */
	public void fillPluginProperties(Component bundleComponent, Object bundleProject) {
		if (bundleProject instanceof IBundleProjectDescription) {
			workspaceBundleDescriptionDesigner.fillPluginProperties(bundleComponent, bundleProject);

		}
		else if (bundleProject instanceof Bundle) {
			loadedBundleDescriptionDesigner.fillPluginProperties(bundleComponent, bundleProject);
		}
		else if (bundleProject instanceof IFeatureModel) {
			featureDescriptionDesigner.fillPluginProperties(bundleComponent, bundleProject);
		}
	}

	/**
	 *
	 * @see org.eclipse.papyrus.adltool.designer.bundle.IBundleDescriptionDesigner#getSymbolicName(java.lang.Object)
	 *
	 * @param bundleProject
	 * @return a string that correspond to the symbolic name
	 */
	public String getSymbolicName(Object bundleProject) {
		if (bundleProject instanceof IBundleProjectDescription) {
			return workspaceBundleDescriptionDesigner.getSymbolicName(bundleProject);

		}
		else if (bundleProject instanceof Bundle) {
			return loadedBundleDescriptionDesigner.getSymbolicName(bundleProject);
		}
		else if (bundleProject instanceof IFeatureModel) {
			return featureDescriptionDesigner.getSymbolicName(bundleProject);
		}
		return null;
	}

	/**
	 *
	 * @see org.eclipse.papyrus.adltool.designer.bundle.IBundleDescriptionDesigner#fillExportedPackages(org.eclipse.uml2.uml.Component, java.lang.Object)
	 *
	 * @param bundleComponent
	 * @param bundleProject
	 */
	public void fillExportedPackages(Component bundleComponent, Object bundleProject) {
		if (bundleProject instanceof IBundleProjectDescription) {
			workspaceBundleDescriptionDesigner.fillExportedPackages(bundleComponent, bundleProject);

		}
		else if (bundleProject instanceof Bundle) {
			loadedBundleDescriptionDesigner.fillExportedPackages(bundleComponent, bundleProject);
		}
		else if (bundleProject instanceof IFeatureModel) {
			featureDescriptionDesigner.fillExportedPackages(bundleComponent, bundleProject);
		}

	}

	/**
	 *
	 * @see org.eclipse.papyrus.adltool.designer.bundle.IBundleDescriptionDesigner#getRequiredBundle(org.eclipse.uml2.uml.Component, java.lang.Object)
	 *
	 * @param bundleComponent
	 * @param bundleProject
	 * @return the list of required Bundle
	 */
	public ArrayList<ReferencedOSGIElement> getRequiredBundle(Component bundleComponent, Object bundleProject) {
		if (bundleProject instanceof IBundleProjectDescription) {
			return workspaceBundleDescriptionDesigner.getRequiredBundle(bundleComponent, bundleProject);

		}
		else if (bundleProject instanceof Bundle) {
			return loadedBundleDescriptionDesigner.getRequiredBundle(bundleComponent, bundleProject);
		}
		else if (bundleProject instanceof IFeatureModel) {
			return featureDescriptionDesigner.getRequiredBundle(bundleComponent, bundleProject);
		}

		return new ArrayList<ReferencedOSGIElement>();
	}

	public String getName(Object bundleProject) {
		if (bundleProject instanceof IBundleProjectDescription) {
			return workspaceBundleDescriptionDesigner.getName(bundleProject);

		}
		else if (bundleProject instanceof Bundle) {
			return loadedBundleDescriptionDesigner.getName(bundleProject);
		}
		else if (bundleProject instanceof IFeatureModel) {
			return featureDescriptionDesigner.getName(bundleProject);
		}
		return null;
	}
}

Back to the top