Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2012-08-20 13:55:18 +0000
committervlorenzo2012-08-20 13:55:18 +0000
commita05eaed2a52810c733568defe992d57c5a9868a7 (patch)
treed9872ee7961fd919254a12d9946f6297a8c63c90 /incoming
parentcbfda6844af254abed01f706f9632aea899b53b0 (diff)
downloadorg.eclipse.papyrus-a05eaed2a52810c733568defe992d57c5a9868a7.tar.gz
org.eclipse.papyrus-a05eaed2a52810c733568defe992d57c5a9868a7.tar.xz
org.eclipse.papyrus-a05eaed2a52810c733568defe992d57c5a9868a7.zip
A save of my work on the new tables
Add a method to get the contents of a table
Diffstat (limited to 'incoming')
-rw-r--r--incoming/TableEFacet/org.eclipse.papyrus.infra.table.efacet.metamodel/.classpath1
-rw-r--r--incoming/TableEFacet/org.eclipse.papyrus.infra.table.efacet.metamodel/.project7
-rw-r--r--incoming/TableEFacet/org.eclipse.papyrus.infra.table.efacet.metamodel/src/org/eclipse/papyrus/infra/table/efacet/metamodel/papyrustable/TableContentsUtils.java80
3 files changed, 88 insertions, 0 deletions
diff --git a/incoming/TableEFacet/org.eclipse.papyrus.infra.table.efacet.metamodel/.classpath b/incoming/TableEFacet/org.eclipse.papyrus.infra.table.efacet.metamodel/.classpath
index cedf0d0d0b5..afb9bb46ef3 100644
--- a/incoming/TableEFacet/org.eclipse.papyrus.infra.table.efacet.metamodel/.classpath
+++ b/incoming/TableEFacet/org.eclipse.papyrus.infra.table.efacet.metamodel/.classpath
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src-gen"/>
+ <classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
diff --git a/incoming/TableEFacet/org.eclipse.papyrus.infra.table.efacet.metamodel/.project b/incoming/TableEFacet/org.eclipse.papyrus.infra.table.efacet.metamodel/.project
index a30af94362b..4774efeb9ab 100644
--- a/incoming/TableEFacet/org.eclipse.papyrus.infra.table.efacet.metamodel/.project
+++ b/incoming/TableEFacet/org.eclipse.papyrus.infra.table.efacet.metamodel/.project
@@ -20,8 +20,15 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>org.eclipse.emf.facet.common.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
+ <nature>org.eclipse.emf.facet.common.ProjectNature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
diff --git a/incoming/TableEFacet/org.eclipse.papyrus.infra.table.efacet.metamodel/src/org/eclipse/papyrus/infra/table/efacet/metamodel/papyrustable/TableContentsUtils.java b/incoming/TableEFacet/org.eclipse.papyrus.infra.table.efacet.metamodel/src/org/eclipse/papyrus/infra/table/efacet/metamodel/papyrustable/TableContentsUtils.java
new file mode 100644
index 00000000000..7098cd7bfb7
--- /dev/null
+++ b/incoming/TableEFacet/org.eclipse.papyrus.infra.table.efacet.metamodel/src/org/eclipse/papyrus/infra/table/efacet/metamodel/papyrustable/TableContentsUtils.java
@@ -0,0 +1,80 @@
+/**
+ * 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:
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ */
+package org.eclipse.papyrus.infra.table.efacet.metamodel.papyrustable;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.facet.widgets.table.metamodel.v0_2_0.table.Row;
+
+
+public class TableContentsUtils {
+
+
+ private TableContentsUtils() {
+ //to prevent instanciation
+ }
+
+ /**
+ *
+ * @param papyrusTable
+ * the table to analyse
+ * @param synchronizedContent
+ * <li>if <code>true</code> the method returns the list of the elements which should be contained by the table (using the queries or the
+ * features)</li> <li>if <code>false</code> the method returns the list of the elements currently contained by the table (we use the
+ * serialized table)</li>
+ * @return
+ */
+ public static final List<EObject> getTableContents(final PapyrusTable papyrusTable, final EObject tableContext, final boolean synchronizedContent) {
+ final List<EObject> result = new LinkedList<EObject>();
+ if(synchronizedContent && !papyrusTable.isUsingUser()) {
+ if(papyrusTable.isUsingContextFeature()) {
+ final EReference feature = papyrusTable.getContextFeature();
+ Object value = null;
+ try {
+ value = tableContext.eGet(feature);
+ } catch (final Exception e) {
+ //nothing to do
+ }
+ // if(value == null) {//teh feature has not been found
+ // final EStructuralFeature matchingFeature = tableContext.eClass().getEStructuralFeature(feature.getName());
+ // if(matchingFeature != null) {
+ // value = tableContext.eGet(matchingFeature);
+ // }
+ //
+ // }
+
+
+ if(value instanceof List<?>) {
+ result.addAll((List<EObject>)value);
+ } else if(value instanceof EObject) {
+ result.add((EObject)value);
+ }
+ } else if(papyrusTable.isUsingQueries()) {
+ //TODO
+ }
+ } else {
+ //duplicated code from TableWidgetUtils#public static List<EObject> getElements(final Table tableInstance) {
+ //TODO ask to Mia-Software to change this method in a upper plugin to avoid dependencies on UI
+ if(papyrusTable.getTable() != null) {
+ for(final Row row : papyrusTable.getTable().getRows()) {
+ result.add(row.getElement());
+ }
+ }
+ }
+ return result;
+ }
+}

Back to the top