Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2013-04-26 09:06:44 -0400
committervlorenzo2013-04-26 09:06:44 -0400
commit118a113822ffd8c1ebd1f46b176834ecf274c419 (patch)
treef57fe21f299b95ebee8a32f178736f49d0f43d40 /sandbox
parent1e085960bee1470cac5de7fb15d03c8f50589f49 (diff)
downloadorg.eclipse.papyrus-118a113822ffd8c1ebd1f46b176834ecf274c419.tar.gz
org.eclipse.papyrus-118a113822ffd8c1ebd1f46b176834ecf274c419.tar.xz
org.eclipse.papyrus-118a113822ffd8c1ebd1f46b176834ecf274c419.zip
401764: [Table 2] The classes managing the table model and Nattable must be refactored
https://bugs.eclipse.org/bugs/show_bug.cgi?id=401764 Correct a small name error in the table metamodel + fix the synchronized tables
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/TableV3/org.eclipse.papyrus.sysml.nattable/src/org/eclipse/papyrus/sysml/nattable/manager/axis/RequirementAxisManager.java92
1 files changed, 6 insertions, 86 deletions
diff --git a/sandbox/TableV3/org.eclipse.papyrus.sysml.nattable/src/org/eclipse/papyrus/sysml/nattable/manager/axis/RequirementAxisManager.java b/sandbox/TableV3/org.eclipse.papyrus.sysml.nattable/src/org/eclipse/papyrus/sysml/nattable/manager/axis/RequirementAxisManager.java
index 5b5ef1d5d1a..ca0e3026b13 100644
--- a/sandbox/TableV3/org.eclipse.papyrus.sysml.nattable/src/org/eclipse/papyrus/sysml/nattable/manager/axis/RequirementAxisManager.java
+++ b/sandbox/TableV3/org.eclipse.papyrus.sysml.nattable/src/org/eclipse/papyrus/sysml/nattable/manager/axis/RequirementAxisManager.java
@@ -3,18 +3,14 @@ package org.eclipse.papyrus.sysml.nattable.manager.axis;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.papyrus.infra.nattable.manager.axis.AbstractSynchronizedOnFeatureAxisManager;
import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager;
import org.eclipse.papyrus.infra.nattable.manager.table.NattableModelManager;
import org.eclipse.papyrus.infra.nattable.model.nattable.Table;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.AxisManagerRepresentation;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.EStructuralFeatureValueFillingConfiguration;
-import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisconfiguration.IAxisConfiguration;
import org.eclipse.papyrus.infra.nattable.model.nattable.nattableaxisprovider.AbstractAxisProvider;
import org.eclipse.papyrus.sysml.service.types.matcher.RequirementMatcher;
import org.eclipse.swt.widgets.Display;
@@ -22,47 +18,20 @@ import org.eclipse.uml2.uml.UMLPackage;
-public class RequirementAxisManager extends AbstractSynchronizedOnFeatureAxisManager {//FIXME : this abstract class must inherits from the UML Element axis manager
-
- private Adapter featureListener;
-
- private boolean isRefreshing = false;
-
-
+public class RequirementAxisManager extends AbstractSynchronizedOnFeatureAxisManager {
@Override
public void init(INattableModelManager manager, AxisManagerRepresentation rep, Table table, AbstractAxisProvider provider, boolean mustRefreshOnAxisChanges) {
super.init(manager, rep, table, provider, false);//false, with this axis manager, the contents is derived of the feature
- updateAxisContents();
-
- EStructuralFeatureValueFillingConfiguration config = null;
- for(final IAxisConfiguration current : this.rep.getSpecificAxisConfiguration()) {
- if(current instanceof EStructuralFeatureValueFillingConfiguration) {
- config = (EStructuralFeatureValueFillingConfiguration)current;
- break;
- }
- }
- final EStructuralFeature listenFeature = config.getListenFeature();
+ }
- // this.featureListener = new UMLDerivedUnionAdapter() {
- //
- // @Override
- // public void notifyChanged(Notification notification) {
- // // TODO Auto-generated method stub
- // super.notifyChanged(notification);
- // }
- //
- // @Override
- // public void notifyChanged(Notification notification, EClass eClass, EStructuralFeature derivedUnion) {
- // // TODO Auto-generated method stub
- // super.notifyChanged(notification, eClass, derivedUnion);
- // }
+ @Override
+ protected void addContextFeatureValueListener() {
this.featureListener = new AdapterImpl() {
@Override
public void notifyChanged(Notification msg) {
- if(msg.getFeature() == listenFeature || msg.getFeature() == UMLPackage.eINSTANCE.getStructuredClassifier_OwnedAttribute()) {
- //FIXME : add test
+ if(msg.getFeature() == RequirementAxisManager.this.currentListenFeature || msg.getFeature() == UMLPackage.eINSTANCE.getPackage_PackagedElement()) {
if(!RequirementAxisManager.this.isRefreshing) {//to avoid to many thread
RequirementAxisManager.this.isRefreshing = true;
Display.getDefault().asyncExec(new Runnable() {
@@ -80,58 +49,14 @@ public class RequirementAxisManager extends AbstractSynchronizedOnFeatureAxisMan
getTable().getContext().eAdapters().add(this.featureListener);
}
-
@Override
public void dispose() {
getTable().getContext().eAdapters().remove(this.featureListener);
super.dispose();
}
- /**
- * calculus of the contents of the axis
- */
@Override
- public synchronized void updateAxisContents() {
- final EObject context = getTable().getContext();
- //FIXME
- EStructuralFeatureValueFillingConfiguration config = null;
- for(final IAxisConfiguration current : this.rep.getSpecificAxisConfiguration()) {
- if(current instanceof EStructuralFeatureValueFillingConfiguration) {
- config = (EStructuralFeatureValueFillingConfiguration)current;
- break;
- }
- }
- final EStructuralFeature ref = config.getListenFeature();
-
- Object value = context.eGet(ref);
- assert value instanceof List<?>;
-
- List<?> interestingObject = filterObject((List<?>)value);
- interestingObject = sortObjects(interestingObject);
-
- final List axisElements = getTableManager().getElementsList(getRepresentedContentProvider());
- for(int i = 0; i < interestingObject.size(); i++) {
- final Object object = interestingObject.get(i);
- int currentIndex = axisElements.indexOf(object);
- if(currentIndex == -1) {
- axisElements.add(object);
- } else if(currentIndex != i) {
- axisElements.remove(currentIndex);
- axisElements.add(i, object);
- }
- }
- }
-
- /**
- *
- * @param objects
- * @return
- */
- protected List<?> sortObjects(final List<?> objects) { //FIXME : move me in an upper class
- return objects;
- }
-
- protected List<?> filterObject(final List<?> objects) {
+ protected List<Object> filterObject(final List<?> objects) {
final List<Object> interestingObjects = new ArrayList<Object>();
final RequirementMatcher matcher = new RequirementMatcher();
for(Object object : objects) {
@@ -144,9 +69,4 @@ public class RequirementAxisManager extends AbstractSynchronizedOnFeatureAxisMan
return interestingObjects;
}
- @Override
- public boolean canReoderElements() {
- return false;
- }
-
}

Back to the top