Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/ContextContentProvider.java')
-rw-r--r--plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/ContextContentProvider.java82
1 files changed, 82 insertions, 0 deletions
diff --git a/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/ContextContentProvider.java b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/ContextContentProvider.java
new file mode 100644
index 00000000000..0b7f4862454
--- /dev/null
+++ b/plugins/customization/org.eclipse.papyrus.customization.properties/src/org/eclipse/papyrus/customization/properties/providers/ContextContentProvider.java
@@ -0,0 +1,82 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.customization.properties.providers;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.facet.infra.browser.uicore.CustomizableModelContentProvider;
+import org.eclipse.emf.facet.infra.browser.uicore.CustomizationManager;
+import org.eclipse.papyrus.customization.properties.Activator;
+import org.eclipse.papyrus.views.properties.contexts.Context;
+import org.eclipse.papyrus.views.properties.util.Util;
+
+/**
+ * The customization editor's content provider. Based on the EMF Facet
+ * customizable content provider,
+ *
+ * @author Camille Letavernier
+ */
+public class ContextContentProvider extends CustomizableModelContentProvider {
+
+ private CustomizationManager customizationManager = Activator.getDefault().getCustomizationManager();
+
+ /**
+ * Constructor.
+ */
+ public ContextContentProvider() {
+ super(Activator.getDefault().getCustomizationManager());
+ }
+
+ /**
+ * @return the CustomizationManager used by this Content provider
+ */
+ public CustomizationManager getCustomizationManager() {
+ return customizationManager;
+ }
+
+ /**
+ * @param inputElement
+ * : A ResourceSet
+ * @return The root EObjects from the input ResourceSet
+ */
+ @Override
+ public EObject[] getRootElements(Object inputElement) {
+ if(inputElement instanceof ResourceSet) {
+ ResourceSet resourceSet = (ResourceSet)inputElement;
+
+ if(resourceSet.getResources().isEmpty()) {
+ return null;
+ }
+
+ Set<EObject> elements = new LinkedHashSet<EObject>();
+
+ elements.addAll(resourceSet.getResources().get(0).getContents());
+ Set<Context> allContexts = new LinkedHashSet<Context>();
+ for(EObject element : elements) {
+ if(element instanceof Context) {
+ allContexts.addAll(Util.getDependencies((Context)element));
+ }
+ }
+ elements.addAll(allContexts);
+ return elements.toArray(new EObject[elements.size()]);
+ }
+ return null;
+ }
+
+ @Override
+ public boolean hasChildren(Object element) {
+ return getChildren(element).length > 0;
+ }
+}

Back to the top