Commit 0bf6738a authored by Marco Volpe's avatar Marco Volpe

Partial implementation of tree-like list for structures.

* Some problems encountered. Note added in the issue tracker.

Issue-Ref: 3936
Issue-Url: https://af3-developer.fortiss.org/issues/3936Signed-off-by: Marco Volpe's avatarMarco Volpe <volpe@fortiss.org>
parent 452e9c4e
DataStateFXEditor.java e64fcec84ea83e5ba99e48a6825063471e9ea70d GREEN DataStateFXEditor.java e64fcec84ea83e5ba99e48a6825063471e9ea70d GREEN
DataStateFXEditorBase.java 83655742fdcfdade31eabd7deafa88862f28ba22 GREEN DataStateFXEditorBase.java 83655742fdcfdade31eabd7deafa88862f28ba22 GREEN
DataStateFXEditorBinding.java 46ab36b197a6fca102a5e2d75aa24b1fbba26b89 GREEN DataStateFXEditorBinding.java 46ab36b197a6fca102a5e2d75aa24b1fbba26b89 GREEN
DataStateFXEditorContentProvider.java 324cd24e2219ba2cf360b0f82e3628ca1b5dabba GREEN DataStateFXEditorContentProvider.java 28fa66e359d4e795f54b8f5e55003d6c24546cd4 YELLOW
DataStateFXEditorUIProvider.java 4993d4a6685b7738dd28a7a55177ab43fe81fc53 GREEN DataStateFXEditorUIProvider.java 3e7afff596c2c02c5b8122f26d54516f69129af7 YELLOW
StateAutomatonControllerFactory.java 67f7f7bbc318018080a4569d84e0f1830ce33bda GREEN StateAutomatonControllerFactory.java 67f7f7bbc318018080a4569d84e0f1830ce33bda GREEN
StateAutomatonFXEditor.java eea88e496c873ec92f6b2a0735cbd3d542a3063f GREEN StateAutomatonFXEditor.java eea88e496c873ec92f6b2a0735cbd3d542a3063f GREEN
StateAutomatonFXEditorBase.java 901e1ce52a2a53fb73c160b0af7fd7fbfc1e3044 GREEN StateAutomatonFXEditorBase.java 901e1ce52a2a53fb73c160b0af7fd7fbfc1e3044 GREEN
......
...@@ -15,14 +15,27 @@ ...@@ -15,14 +15,27 @@
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.af3.state.ui.editor.fx; package org.fortiss.af3.state.ui.editor.fx;
import static java.util.Collections.emptyList; import java.util.ArrayList;
//import static java.util.Collections.emptyList;
import java.util.Collection; import java.util.Collection;
import java.util.Comparator;
import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.component.model.behavior.common.DataStateVariable; import org.fortiss.af3.component.model.behavior.common.DataStateVariable;
import org.fortiss.af3.component.model.behavior.common.IDataStateVariableProvider; import org.fortiss.af3.component.model.behavior.common.IDataStateVariableProvider;
import org.fortiss.af3.expression.model.definitions.Enumeration;
import org.fortiss.af3.expression.model.definitions.EnumerationMember;
import org.fortiss.af3.expression.model.definitions.FunctionDefinition;
import org.fortiss.af3.expression.model.definitions.Structure;
import org.fortiss.af3.expression.model.definitions.StructureMember;
import org.fortiss.af3.expression.model.definitions.TypeDefinition;
import org.fortiss.af3.expression.model.types.TDefinedType;
import org.fortiss.af3.project.model.typesystem.IType;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeContentProviderBase; import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeContentProviderBase;
import org.fortiss.tooling.kernel.model.INamedCommentedElement;
import org.fortiss.tooling.kernel.model.INamedElement;
/** /**
* Content provider for the FX-based data state editor. * Content provider for the FX-based data state editor.
...@@ -30,10 +43,90 @@ import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeCon ...@@ -30,10 +43,90 @@ import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeCon
* @author volpe * @author volpe
*/ */
public class DataStateFXEditorContentProvider extends DynamicTreeContentProviderBase<EObject> { public class DataStateFXEditorContentProvider extends DynamicTreeContentProviderBase<EObject> {
/** {@inheritDoc} */
@Override
protected Comparator<EObject> getSortingComparator() {
return (e1, e2) -> {
if(e1 instanceof TypeDefinition) {
if(e2 instanceof TypeDefinition) {
String e1Name = ((TypeDefinition)e1).getName();
return e1Name.compareToIgnoreCase(((TypeDefinition)e2).getName());
}
return -1;
} else if(e1 instanceof FunctionDefinition) {
if(e2 instanceof FunctionDefinition) {
String e1FuncName = ((FunctionDefinition)e1).getFunction().getName();
String e2FuncName = ((FunctionDefinition)e2).getFunction().getName();
return e1FuncName.compareToIgnoreCase(e2FuncName);
}
return 1;
} else if(e1 instanceof INamedElement && e2 instanceof INamedElement) {
String e1Name = ((INamedElement)e1).getName();
return e1Name.compareToIgnoreCase(((INamedElement)e2).getName());
}
return 0;
};
}
/** {@inheritDoc} */
@Override
protected boolean filter(EObject eo, String filterValue) {
if(filterValue == null || "".equals(filterValue.trim())) {
return true;
}
if(eo instanceof INamedCommentedElement) {
INamedCommentedElement nce = (INamedCommentedElement)eo;
String name = nce.getName();
String effectiveFilter = filterValue.toLowerCase();
if(name != null && name.toLowerCase().contains(effectiveFilter)) {
return true;
}
String comment = nce.getComment();
return comment != null && comment.toLowerCase().contains(effectiveFilter);
}
return false;
}
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
protected Collection<DataStateVariable> getChildren(EObject parent) { protected Collection<? extends EObject> getChildren(EObject parent) {
return parent instanceof IDataStateVariableProvider ArrayList<EObject> result = new ArrayList<EObject>();
? ((IDataStateVariableProvider)parent).getDataStateVariables() : emptyList(); // List<DataStateVariable> list = new ArrayList<DataStateVariable>();
if(parent instanceof IDataStateVariableProvider)
result.addAll(((IDataStateVariableProvider)parent).getDataStateVariables());
if(parent instanceof DataStateVariable) {
DataStateVariable dsv = (DataStateVariable)parent;
IType parentType = dsv.getVariableType();
if(parentType instanceof TDefinedType) {
TypeDefinition parentTypeDef = ((TDefinedType)parentType).getDef();
if(parentTypeDef instanceof Enumeration) {
// TODO: to be adapted
for(EnumerationMember dc : ((Enumeration)parent).getMembers()) {
result.add(dc);
}
}
if(parentTypeDef instanceof Structure) {
// TODO: to be adapted
for(StructureMember mem : ((Structure)parentTypeDef).getMembers()) {
result.add(mem);
}
}
}
}
return result;
} }
/* *//** {@inheritDoc} *//*
* @Override
* protected Collection<DataStateVariable> getChildren(EObject
* parent) {
* return parent instanceof IDataStateVariableProvider
* ? ((IDataStateVariableProvider)parent).getDataStateVariables() :
* emptyList();
* }
*/
} }
...@@ -21,6 +21,7 @@ import static org.fortiss.af3.expression.utils.ExpressionUtils.createDefaultCons ...@@ -21,6 +21,7 @@ import static org.fortiss.af3.expression.utils.ExpressionUtils.createDefaultCons
import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.component.model.behavior.common.DataStateVariable; import org.fortiss.af3.component.model.behavior.common.DataStateVariable;
import org.fortiss.af3.expression.model.definitions.StructureMember;
import org.fortiss.af3.expression.model.types.TInt; import org.fortiss.af3.expression.model.types.TInt;
import org.fortiss.af3.expression.ui.databinding.convert.StringToIExpressionTermConverter; import org.fortiss.af3.expression.ui.databinding.convert.StringToIExpressionTermConverter;
import org.fortiss.af3.expression.ui.databinding.convert.StringToTypeConverter; import org.fortiss.af3.expression.ui.databinding.convert.StringToTypeConverter;
...@@ -49,23 +50,43 @@ public class DataStateFXEditorUIProvider extends DynamicTreeTableUIProviderBase< ...@@ -49,23 +50,43 @@ public class DataStateFXEditorUIProvider extends DynamicTreeTableUIProviderBase<
IType type; IType type;
switch(column) { switch(column) {
case 0: case 0:
return ((DataStateVariable)element).getIdentifier(); if(element instanceof DataStateVariable) {
return ((DataStateVariable)element).getIdentifier();
}
if(element instanceof StructureMember) {
return ((StructureMember)element).getName();
}
case 1: case 1:
type = ((DataStateVariable)element).getType(); if(element instanceof DataStateVariable) {
return type != null ? type.toString() : ""; type = ((DataStateVariable)element).getType();
return type != null ? type.toString() : "";
}
if(element instanceof StructureMember) {
type = ((StructureMember)element).getType();
return type != null ? type.toString() : "";
}
case 2: case 2:
final ITerm term = ((DataStateVariable)element).getInitialValue(); if(element instanceof DataStateVariable) {
return term != null ? term.toString() : ""; final ITerm term = ((DataStateVariable)element).getInitialValue();
return term != null ? term.toString() : "";
}
if(element instanceof StructureMember) {
return "";
}
case 3: case 3:
type = ((IVariableDefinition)element).getVariableType(); if(element instanceof DataStateVariable) {
if(type instanceof TInt) { type = ((IVariableDefinition)element).getVariableType();
return Integer.toString(((TInt)type).getLowerBound()); if(type instanceof TInt) {
return Integer.toString(((TInt)type).getLowerBound());
}
} }
return ""; return "";
case 4: case 4:
type = ((IVariableDefinition)element).getVariableType(); if(element instanceof DataStateVariable) {
if(type instanceof TInt) { type = ((IVariableDefinition)element).getVariableType();
return Integer.toString(((TInt)type).getUpperBound()); if(type instanceof TInt) {
return Integer.toString(((TInt)type).getUpperBound());
}
} }
return ""; return "";
default: default:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment