Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra')
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/Activator.java69
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/messages/Messages.java17
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/messages/messages.properties1
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/modelelement/PapyrusTableFactory.java51
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/modelelement/PapyrusTableModelElement.java159
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/CustomizationContentProvider.java99
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/CustomizationLabelProvider.java74
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/ElementTypeContentProvider.java173
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/FacetLabelProvider.java40
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/FillingQueriesContentProvider.java164
-rw-r--r--deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/PasteElementContainmentFeatureContentProvider.java70
11 files changed, 917 insertions, 0 deletions
diff --git a/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/Activator.java b/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/Activator.java
new file mode 100644
index 00000000000..7d655b26980
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/Activator.java
@@ -0,0 +1,69 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.properties;
+
+import org.eclipse.papyrus.infra.core.log.LogHelper;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.table.properties"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /** Logging helper */
+ public static LogHelper log;
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(final BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ log = new LogHelper(plugin);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(final BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/messages/Messages.java b/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/messages/Messages.java
new file mode 100644
index 00000000000..ba166b9f37d
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/messages/Messages.java
@@ -0,0 +1,17 @@
+package org.eclipse.papyrus.infra.table.properties.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.infra.table.properties.messages.messages"; //$NON-NLS-1$
+
+ public static String ElementTypeContentProvider_EnterTheNameOfTheWantedElement;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/messages/messages.properties b/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/messages/messages.properties
new file mode 100644
index 00000000000..d29d940cb36
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/messages/messages.properties
@@ -0,0 +1 @@
+ElementTypeContentProvider_EnterTheNameOfTheWantedElement=Enter the name of the element you're looking for. You can use * as a wildcard
diff --git a/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/modelelement/PapyrusTableFactory.java b/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/modelelement/PapyrusTableFactory.java
new file mode 100644
index 00000000000..75875548fb4
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/modelelement/PapyrusTableFactory.java
@@ -0,0 +1,51 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.properties.modelelement;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.table.properties.Activator;
+import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
+import org.eclipse.papyrus.views.properties.modelelement.EMFModelElementFactory;
+import org.eclipse.papyrus.views.properties.modelelement.ModelElement;
+
+/**
+ *
+ * The factory for the PapyrusTable
+ *
+ */
+public class PapyrusTableFactory extends EMFModelElementFactory{
+
+ /**
+ *
+ * @see org.eclipse.papyrus.views.properties.modelelement.EMFModelElementFactory#createFromSource(java.lang.Object, org.eclipse.papyrus.views.properties.contexts.DataContextElement)
+ *
+ * @param sourceElement
+ * @param context
+ * @return
+ */
+ @Override
+ public ModelElement createFromSource(final Object sourceElement, final DataContextElement context) {
+ EObject source = EMFHelper.getEObject(sourceElement);
+ if(source == null) {
+ Activator.log.warn("Unable to resolve the selected element to an EObject"); //$NON-NLS-1$
+ return null;
+ }
+
+ EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(source);
+ return new PapyrusTableModelElement(source, domain);
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/modelelement/PapyrusTableModelElement.java b/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/modelelement/PapyrusTableModelElement.java
new file mode 100644
index 00000000000..7732a6fc141
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/modelelement/PapyrusTableModelElement.java
@@ -0,0 +1,159 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.properties.modelelement;
+
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.emf.databinding.FeaturePath;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.TableInstance;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance2.TableInstance2;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrustableinstancePackage;
+import org.eclipse.papyrus.infra.table.properties.provider.CustomizationContentProvider;
+import org.eclipse.papyrus.infra.table.properties.provider.CustomizationLabelProvider;
+import org.eclipse.papyrus.infra.table.properties.provider.ElementTypeContentProvider;
+import org.eclipse.papyrus.infra.table.properties.provider.FacetLabelProvider;
+import org.eclipse.papyrus.infra.table.properties.provider.FillingQueriesContentProvider;
+import org.eclipse.papyrus.infra.table.properties.provider.PasteElementContainmentFeatureContentProvider;
+import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory;
+import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
+import org.eclipse.papyrus.views.properties.modelelement.EMFModelElement;
+
+
+
+
+public class PapyrusTableModelElement extends EMFModelElement {
+
+ /** these 3 value are used for the preference of the display of the localCustom in the property view */
+ /** any local customization is displayed */
+ public static final int NO_LOCALS = 0;
+
+ /** only one of the local customization is displayed */
+ public static final int ONLY_ONE_LOCALS = NO_LOCALS + 1;
+
+ /** all local customizations are displayed */
+ public static final int ALL_LOCALS = ONLY_ONE_LOCALS + 1;
+
+ /** the property path for the customization */
+ public static final String TABLE_CUSTOMIZATIONS = "table.customizations"; //$NON-NLS-1$
+
+ /** the property path for the customization */
+ public static final String TABLE_FACETS2 = "table.facets2"; //$NON-NLS-1$
+
+ /** the property path for the customization */
+ public static final String TABLE_FILLING_QUERIES = "fillingQueries"; //$NON-NLS-1$
+
+ public static final String TABLE_CONTEXT = "table.context"; //$NON-NLS-1$
+
+ /** the current value of the preference for the display of the local customization */
+ private static int local_preference = ALL_LOCALS;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param source
+ */
+ public PapyrusTableModelElement(final EObject source) {
+ super(source);
+ }
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param source
+ * @param domain
+ */
+ public PapyrusTableModelElement(final EObject source, final EditingDomain domain) {
+ super(source, domain);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.views.properties.modelelement.EMFModelElement#getContentProvider(java.lang.String)
+ *
+ * @param propertyPath
+ * @return
+ */
+ @Override
+ public IStaticContentProvider getContentProvider(final String propertyPath) {
+ if(TABLE_FILLING_QUERIES.equals(propertyPath)) {
+ FeaturePath featurePath = getFeaturePath(TABLE_CONTEXT);
+ EObject table = getSource(featurePath);
+ Assert.isTrue(table instanceof TableInstance);
+ return new FillingQueriesContentProvider((TableInstance)table);
+ }
+ if(TABLE_CUSTOMIZATIONS.equals(propertyPath)) {
+ FeaturePath featurePath = getFeaturePath(TABLE_CUSTOMIZATIONS);
+ EStructuralFeature feature = getFeature(featurePath);
+ return new CustomizationContentProvider(feature, getSource(featurePath), local_preference);
+ }
+
+ EStructuralFeature feature = getFeature(propertyPath);
+ if(feature == PapyrustableinstancePackage.eINSTANCE.getPapyrusTableInstance_PastedElementId()) {
+ return new ElementTypeContentProvider();
+ }
+
+ if(feature == PapyrustableinstancePackage.eINSTANCE.getPapyrusTableInstance_PastedElementContainmentFeature()) {
+ if(source instanceof PapyrusTableInstance) {
+ return new PasteElementContainmentFeatureContentProvider((PapyrusTableInstance)source);
+ }
+ }
+
+ return super.getContentProvider(propertyPath);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.views.properties.modelelement.EMFModelElement#getLabelProvider(java.lang.String)
+ *
+ * @param propertyPath
+ * @return
+ */
+ @Override
+ public ILabelProvider getLabelProvider(final String propertyPath) {
+ if(TABLE_CUSTOMIZATIONS.equals(propertyPath)) {
+ FeaturePath featurePath = getFeaturePath(TABLE_CUSTOMIZATIONS);
+ EObject table = getSource(featurePath);
+ Assert.isTrue(table instanceof TableInstance2);
+ return new CustomizationLabelProvider((TableInstance2)table, local_preference);
+ }
+ if(TABLE_FACETS2.equals(propertyPath)) {
+ return new FacetLabelProvider();
+ }
+ return super.getLabelProvider(propertyPath);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.views.properties.modelelement.EMFModelElement#getValueFactory(java.lang.String)
+ *
+ * @param propertyPath
+ * @return
+ */
+ @Override
+ public ReferenceValueFactory getValueFactory(final String propertyPath) {
+ //allow to disabled the edition of the filling queries
+ if(TABLE_FILLING_QUERIES.equals(propertyPath)) {
+ return null;
+ }
+ return super.getValueFactory(propertyPath);
+ }
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/CustomizationContentProvider.java b/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/CustomizationContentProvider.java
new file mode 100644
index 00000000000..e5f2e99fc0b
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/CustomizationContentProvider.java
@@ -0,0 +1,99 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.properties.provider;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.facet.infra.browser.custom.MetamodelView;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance2.TableInstance2;
+import org.eclipse.papyrus.infra.emf.providers.strategy.SemanticEMFContentProvider;
+import org.eclipse.papyrus.infra.table.properties.modelelement.PapyrusTableModelElement;
+
+/**
+ *
+ * The content provider for the MetamodelView
+ *
+ */
+public class CustomizationContentProvider extends SemanticEMFContentProvider {
+
+ /**
+ * the table instance
+ */
+ private final TableInstance2 source;
+
+ /**
+ * the preference
+ */
+ private final int preference;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param feature
+ * the feature
+ * @param eObject
+ * the eobject
+ * @param pref
+ * the preference : it allows to display to choose how to display the local customization :
+ * <ul>
+ * <li>all customization</li>
+ * <li>one customization</li>
+ * <li>no customization</li>
+ * </ul>
+ */
+ public CustomizationContentProvider(final EStructuralFeature feature, final EObject eObject, final int pref) {
+ super(eObject, feature);
+ preference = pref;
+ Assert.isTrue(eObject instanceof TableInstance2);
+ source = (TableInstance2)eObject;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.views.properties.providers.EcoreReferenceContentProvider#getElements()
+ *
+ * @return
+ */
+ @Override
+ public Object[] getElements() {
+ Object[] elements = new Object[0];
+ List<MetamodelView> allCustom = new ArrayList<MetamodelView>();
+ allCustom.addAll(source.getCustomizations());
+ List<MetamodelView> allLocalCustom = new ArrayList<MetamodelView>();
+ allLocalCustom.addAll(source.getLocalCustomizations());
+ switch(preference) {
+ case PapyrusTableModelElement.NO_LOCALS:
+ allCustom.removeAll(allLocalCustom);
+ elements = allCustom.toArray();
+ break;
+ case PapyrusTableModelElement.ONLY_ONE_LOCALS:
+ allLocalCustom.remove(0);
+ allCustom.removeAll(allLocalCustom);
+ elements = allCustom.toArray();
+ break;
+ case PapyrusTableModelElement.ALL_LOCALS:
+ elements = allCustom.toArray();
+ break;
+ default:
+ break;
+ }
+ return elements;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/CustomizationLabelProvider.java b/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/CustomizationLabelProvider.java
new file mode 100644
index 00000000000..4c60d0bf35f
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/CustomizationLabelProvider.java
@@ -0,0 +1,74 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.properties.provider;
+
+import org.eclipse.emf.facet.infra.browser.custom.MetamodelView;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance2.TableInstance2;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.papyrus.infra.table.properties.modelelement.PapyrusTableModelElement;
+
+/**
+ *
+ * LabelProvider for the MetamodelView
+ *
+ */
+public class CustomizationLabelProvider extends LabelProvider {
+
+ /** the table instance*/
+ private final TableInstance2 table;
+
+ /** the preference : allows to manage the text displayed to represent the MetamodelView*/
+ private final int preference;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param table
+ * the table instance
+ * @param pref
+ * the preference
+ */
+ public CustomizationLabelProvider(final TableInstance2 table, final int pref) {
+ preference = pref;
+ this.table = table;
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+ *
+ * @param element
+ * @return
+ */
+ @Override
+ public String getText(final Object element) {
+ final MetamodelView metamodelView = (MetamodelView) element;
+ if(table.getLocalCustomizations().contains(metamodelView)){
+ switch(preference){
+ case PapyrusTableModelElement.NO_LOCALS :
+ //it is not possible
+ return ""; //$NON-NLS-1$
+ case PapyrusTableModelElement.ONLY_ONE_LOCALS :
+ return "localCustomizations"; //$NON-NLS-1$
+ case PapyrusTableModelElement.ALL_LOCALS :
+ return "localCustomization" + " " + metamodelView.getMetamodelURI(); //$NON-NLS-1$ //$NON-NLS-2$
+ default :
+ return metamodelView.getName();
+ }
+ }else{
+ return metamodelView.getName();
+ }
+ }
+} \ No newline at end of file
diff --git a/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/ElementTypeContentProvider.java b/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/ElementTypeContentProvider.java
new file mode 100644
index 00000000000..a6d6f0eda9d
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/ElementTypeContentProvider.java
@@ -0,0 +1,173 @@
+package org.eclipse.papyrus.infra.table.properties.provider;
+
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry;
+import org.eclipse.gmf.runtime.emf.type.core.IClientContext;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.services.edit.internal.context.TypeContext;
+import org.eclipse.papyrus.infra.table.properties.Activator;
+import org.eclipse.papyrus.infra.table.properties.messages.Messages;
+import org.eclipse.papyrus.infra.widgets.editors.AbstractEditor;
+import org.eclipse.papyrus.infra.widgets.editors.ICommitListener;
+import org.eclipse.papyrus.infra.widgets.editors.StringEditor;
+import org.eclipse.papyrus.infra.widgets.providers.AbstractStaticContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.IGraphicalContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.PatternViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
+
+public class ElementTypeContentProvider extends AbstractStaticContentProvider implements ITreeContentProvider, IGraphicalContentProvider {
+
+ private Set<String> values = null;
+
+
+ public String[] getElements() {
+ if(this.values == null) {
+ this.values = getValues();
+ }
+
+ return this.values.toArray(new String[values.size()]);
+ }
+
+
+ private Set<String> getValues() {
+ final Set<String> allValues = getAllPossiblesValues();
+ return allValues;
+ }
+
+ private Set<String> getAllPossiblesValues() {
+
+ IClientContext clientContext = null;
+ try {
+ clientContext = TypeContext.getContext();
+ } catch (ServiceException e1) {
+ Activator.log.error(e1);
+ }
+ IElementType[] types = ElementTypeRegistry.getInstance().getElementTypes(clientContext);
+ final Set<String> ids = new TreeSet<String>();
+ for(IElementType iElementType : types) {
+ final String id = iElementType.getId();
+ if(id.contains("sysml.stereotype.") || id.contains("uml.stereotype.")) {//FIXME should not be done here -> should be adapted in the Papyrus Table V3 //$NON-NLS-1$ //$NON-NLS-2$
+ //nothing to do
+ } else {
+ ids.add(id);
+ }
+ }
+ return ids;
+ }
+
+
+ public Object[] getChildren(Object parentElement) {
+ return new Object[0];
+ }
+
+ public Object getParent(Object element) {
+ return null; //Flat provider
+ }
+
+ public boolean hasChildren(Object element) {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void createBefore(Composite parent) {
+ createPatternFilter(parent);
+ }
+
+ protected ViewerFilter patternFilter;
+
+ private String currentFilterPattern = ""; //$NON-NLS-1$
+
+ private StructuredViewer viewer;
+
+ protected void createPatternFilter(Composite parent) {
+ StringEditor editor = new StringEditor(parent, SWT.NONE);
+ editor.setLabel("Filter:"); //$NON-NLS-1$
+ editor.setToolTipText(Messages.ElementTypeContentProvider_EnterTheNameOfTheWantedElement);
+ editor.setValidateOnDelay(true);
+ patternFilter = new PatternViewerFilter();
+ ((PatternViewerFilter)patternFilter).setPattern(currentFilterPattern);
+
+ editor.addCommitListener(new ICommitListener() {
+
+ public void commit(AbstractEditor editor) {
+ String filterPattern = (String)((StringEditor)editor).getValue();
+ ((PatternViewerFilter)patternFilter).setPattern(filterPattern);
+ viewer.refresh();
+ if(!("".equals(filterPattern) || currentFilterPattern.equals(filterPattern))) { //$NON-NLS-1$
+ Object firstMatch = getFirstMatchingElement(null);
+ if(firstMatch != null) {
+ // revealSemanticElement(Collections.singletonList(firstMatch));
+ }
+ currentFilterPattern = filterPattern;
+ }
+ }
+
+ });
+
+ List<ViewerFilter> filters = new LinkedList<ViewerFilter>(Arrays.asList(viewer.getFilters()));
+ filters.add(patternFilter);
+ viewer.setFilters(filters.toArray(new ViewerFilter[filters.size()]));
+ }
+
+
+ public void createAfter(Composite parent) {
+ }
+
+
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ super.inputChanged(viewer, oldInput, newInput);
+ this.viewer = (StructuredViewer)viewer;
+ }
+
+ /**
+ * Returns the first (encapsulated) element matching the current filters
+ *
+ * @return
+ */
+ protected Object getFirstMatchingElement(Object parent) {
+ //Browse from the root element
+ if(parent == null) {
+ for(Object parentElement : getElements(viewer.getInput())) {
+ Object firstMatch = getFirstMatchingElement(parentElement);
+ if(firstMatch != null) {
+ return firstMatch;
+ }
+ }
+ return null;
+ }
+
+ for(ViewerFilter filter : viewer.getFilters()) {
+ if(!filter.select(viewer, getParent(parent), parent)) {
+ return null;
+ }
+ }
+
+ //Browse the child elements
+ for(Object childElement : getChildren(parent)) {
+ Object firstMatch = getFirstMatchingElement(childElement);
+ if(firstMatch != null) {
+ return firstMatch;
+ }
+ }
+
+ //No match found
+ return null;
+ }
+
+
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/FacetLabelProvider.java b/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/FacetLabelProvider.java
new file mode 100644
index 00000000000..3c4872d0ab2
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/FacetLabelProvider.java
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.properties.provider;
+
+import org.eclipse.emf.facet.infra.facet.Facet;
+import org.eclipse.jface.viewers.LabelProvider;
+
+/**
+ *
+ * The label provider for the facets
+ *
+ */
+public class FacetLabelProvider extends LabelProvider{
+
+ /**
+ *
+ * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+ *
+ * @param element
+ * @return
+ */
+ @Override
+ public String getText(final Object element) {
+ if(element instanceof Facet){
+ return ((Facet)element).getName();
+ }
+ return super.getText(element);
+ }
+} \ No newline at end of file
diff --git a/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/FillingQueriesContentProvider.java b/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/FillingQueriesContentProvider.java
new file mode 100644
index 00000000000..2c78d470d45
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/FillingQueriesContentProvider.java
@@ -0,0 +1,164 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.table.properties.provider;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.facet.infra.query.ModelQuery;
+import org.eclipse.emf.facet.infra.query.ModelQuerySet;
+import org.eclipse.emf.facet.infra.query.core.ModelQuerySetCatalog;
+import org.eclipse.emf.facet.widgets.nattable.instance.tableinstance.TableInstance;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.papyrus.infra.widgets.providers.IHierarchicContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
+
+/**
+ *
+ * Thi content provider for the FillingQueries editor
+ *
+ */
+public class FillingQueriesContentProvider implements IHierarchicContentProvider, IStaticContentProvider{
+
+ private final TableInstance table;
+ public FillingQueriesContentProvider(final TableInstance table) {
+ this.table = table;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider#getElements()
+ *
+ * @return
+ */
+ public Object[] getElements() {
+ //we return only the querySet with interesting queries
+ Collection<ModelQuerySet> allQueriesSet = new ArrayList<ModelQuerySet>();
+ Collection<ModelQuerySet> querySetToKeep = new ArrayList<ModelQuerySet>();
+ allQueriesSet.addAll(ModelQuerySetCatalog.getSingleton().getAllModelQuerySets());
+ for(ModelQuerySet current : allQueriesSet){
+ if(getChildren(current).length!=0){
+ querySetToKeep.add(current);
+ }
+ }
+ return querySetToKeep.toArray();
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang.Object)
+ *
+ * @param inputElement
+ * @return
+ */
+ public Object[] getElements(final Object inputElement) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+ *
+ * @param parentElement
+ * @return
+ */
+ public Object[] getChildren(final Object parentElement) {
+ if(parentElement instanceof ModelQuerySet){
+ List<ModelQuery> queries = new ArrayList<ModelQuery>();
+ queries.addAll(((ModelQuerySet)parentElement).getQueries());
+ List<ModelQuery> queriesToKeep = new ArrayList<ModelQuery>();
+ EObject context = this.table.getContext();
+ EClass eClassContext = context.eClass();
+ for(ModelQuery current : queries){
+ //TODO we should test the return type, no?
+ EList<EClass> scope = current.getScope();
+ for(EClass currentEClass : scope){
+ if(currentEClass.isSuperTypeOf(eClassContext) || eClassContext.isInstance(current)){
+
+ queriesToKeep.add(current);
+ }else{
+ queriesToKeep.add(current);
+ //nothing to do
+ }
+
+ }
+ }
+ return queries.toArray();
+ }
+ return new Object[0];
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
+ *
+ * @param element
+ * @return
+ */
+ public Object getParent(final Object element) {
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+ *
+ * @param element
+ * @return
+ */
+ public boolean hasChildren(final Object element) {
+ return getChildren(element).length!=0;
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ *
+ */
+ public void dispose() {
+ //nothing to do
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ *
+ * @param viewer
+ * @param oldInput
+ * @param newInput
+ */
+ public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) {
+ //nothing to do
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.widgets.providers.IHierarchicContentProvider#isValidValue(java.lang.Object)
+ *
+ * @param element
+ * @return
+ */
+ public boolean isValidValue(final Object element) {
+ if(element instanceof ModelQuery){
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/PasteElementContainmentFeatureContentProvider.java b/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/PasteElementContainmentFeatureContentProvider.java
new file mode 100644
index 00000000000..7dd29503fb4
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.infra.table.properties/src/org/eclipse/papyrus/infra/table/properties/provider/PasteElementContainmentFeatureContentProvider.java
@@ -0,0 +1,70 @@
+/*****************************************************************************
+ * Copyright (c) 2012 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.infra.table.properties.provider;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.papyrus.infra.table.instance.papyrustableinstance.PapyrusTableInstance;
+import org.eclipse.papyrus.infra.widgets.providers.AbstractStaticContentProvider;
+
+
+public class PasteElementContainmentFeatureContentProvider extends AbstractStaticContentProvider implements ITreeContentProvider {
+
+ private PapyrusTableInstance contextTable;
+
+ public PasteElementContainmentFeatureContentProvider(PapyrusTableInstance contextTable) {
+ this.contextTable = contextTable;
+ }
+
+ public EClass[] getElements() {
+ EObject context = contextTable.getTable().getContext();
+
+ if(context == null) {
+ return new EClass[0];
+ }
+
+ EClass contextMetaclass = context.eClass();
+ return new EClass[]{ contextMetaclass };
+ }
+
+ public EReference[] getChildren(Object parentElement) {
+ if(parentElement instanceof EClass) {
+ EClass contextMetaclass = (EClass)parentElement;
+ List<EReference> result = new LinkedList<EReference>();
+ for(EReference reference : contextMetaclass.getEAllReferences()) {
+ if(reference.isContainment() && reference.getUpperBound() != 1) {
+ result.add(reference);
+ }
+ }
+ return result.toArray(new EReference[result.size()]);
+ }
+
+ return new EReference[0];
+ }
+
+ public Object getParent(Object element) {
+ if(element instanceof EReference) {
+ return ((EReference)element).getEContainingClass();
+ }
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ return getChildren(element).length > 0;
+ }
+
+}

Back to the top