Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Akehurst2014-05-15 17:29:21 +0000
committerDavid Akehurst2014-05-17 07:20:48 +0000
commitec345753c29cf2f9acf9b765be0a54b3e3f9a81f (patch)
tree7e29f174304c5e2c458f2b32c5f1945fe3d69799 /plugins/uml/org.eclipse.papyrus.uml.extensionpoints/src/org/eclipse/papyrus/uml/extensionpoints/Registry.java
parente39e50efd845db6b228ec79e197cf0780506fce7 (diff)
downloadorg.eclipse.papyrus-ec345753c29cf2f9acf9b765be0a54b3e3f9a81f.tar.gz
org.eclipse.papyrus-ec345753c29cf2f9acf9b765be0a54b3e3f9a81f.tar.xz
org.eclipse.papyrus-ec345753c29cf2f9acf9b765be0a54b3e3f9a81f.zip
[434594] Enable Model (Library/Metamodel/Profile) Registrations to be
added to via code Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=43459 Change-Id: Ib4eb7db3f1e82664a8c15a0c2ea2c06797d4b39e Signed-off-by: David Akehurst <dave@akehurst.net>
Diffstat (limited to 'plugins/uml/org.eclipse.papyrus.uml.extensionpoints/src/org/eclipse/papyrus/uml/extensionpoints/Registry.java')
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.extensionpoints/src/org/eclipse/papyrus/uml/extensionpoints/Registry.java92
1 files changed, 92 insertions, 0 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.extensionpoints/src/org/eclipse/papyrus/uml/extensionpoints/Registry.java b/plugins/uml/org.eclipse.papyrus.uml.extensionpoints/src/org/eclipse/papyrus/uml/extensionpoints/Registry.java
new file mode 100644
index 00000000000..9120f04b8ca
--- /dev/null
+++ b/plugins/uml/org.eclipse.papyrus.uml.extensionpoints/src/org/eclipse/papyrus/uml/extensionpoints/Registry.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2006 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:
+ * Dr. David H. Akehurst - enable programmatic registration
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.extensionpoints;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.papyrus.uml.extensionpoints.library.IRegisteredLibrary;
+import org.eclipse.papyrus.uml.extensionpoints.library.RegisteredLibrary;
+import org.eclipse.papyrus.uml.extensionpoints.metamodel.IRegisteredMetamodel;
+import org.eclipse.papyrus.uml.extensionpoints.metamodel.RegisteredMetamodel;
+import org.eclipse.papyrus.uml.extensionpoints.profile.IRegisteredProfile;
+import org.eclipse.papyrus.uml.extensionpoints.profile.RegisteredProfile;
+
+public class Registry {
+
+ /** attribute that acts as a cache for the list of registered libraries */
+ private static List<IRegisteredLibrary> registeredLibraries;
+
+ public static List<IRegisteredLibrary> getRegisteredLibraries() {
+ if(null == registeredLibraries) {
+ registeredLibraries = RegisteredLibrary.getRegisteredLibraries();
+ }
+ return registeredLibraries;
+ }
+
+ public static void addRegisteredLibrary(IRegisteredLibrary lib) {
+ if(null == registeredLibraries) {
+ registeredLibraries = RegisteredLibrary.getRegisteredLibraries();
+ }
+ registeredLibraries.add(lib);
+ }
+
+ /** attribute that acts as a cache for the list of registered metamodels */
+ private static List<IRegisteredMetamodel> registeredMetamodels;
+
+ public static List<IRegisteredMetamodel> getRegisteredMetamodels() {
+ if(null == registeredMetamodels) {
+ registeredMetamodels = RegisteredMetamodel.getRegisteredMetamodels();
+ }
+ return registeredMetamodels;
+ }
+
+ public static void addRegisteredMetamodel(IRegisteredMetamodel lib) {
+ if(null == registeredMetamodels) {
+ registeredMetamodels = RegisteredMetamodel.getRegisteredMetamodels();
+ }
+ registeredMetamodels.add(lib);
+ }
+
+ /** attribute that acts as a cache for the list of registered profiles */
+ private static List<IRegisteredProfile> registeredProfiles;
+
+ public static List<IRegisteredProfile> getRegisteredProfiles() {
+ if(null == registeredProfiles) {
+ registeredProfiles = RegisteredProfile.getRegisteredProfiles();
+ }
+ return registeredProfiles;
+ }
+ public static IRegisteredProfile getRegisteredProfile(String name, String path) {
+ Assert.isNotNull(name);
+ List<IRegisteredProfile> profiles = Registry.getRegisteredProfiles();
+ for(int i = 0; i < profiles.size(); i++) {
+ IRegisteredProfile profile = profiles.get(i);
+
+ // name corresponds. is path equal?
+ if(name.equals(profile.getName())) {
+ // no path indicated => first name that corresponds => profile returned
+ if(path == null) {
+ return profile;
+ } else if(path.equals(profile.getPath())) {
+ return profile;
+ }
+ }
+ }
+ return null;
+ }
+ public static void addRegisteredProfile(IRegisteredProfile lib) {
+ if(null == registeredProfiles) {
+ registeredProfiles = RegisteredProfile.getRegisteredProfiles();
+ }
+ registeredProfiles.add(lib);
+ }
+}

Back to the top