Search in sources :

Example 1 with PrimitiveType

use of org.yakindu.base.types.PrimitiveType in project statecharts by Yakindu.

the class ExecutionContextLabelProvider method updateValueCell.

private void updateValueCell(ViewerCell cell) {
    Object element = cell.getElement();
    if (element instanceof ReferenceSlot) {
        ReferenceSlot refSlot = (ReferenceSlot) element;
        String label = "";
        if (refSlot.getReference() != null) {
            String refFqn = refSlot.getReference().getFqName();
            Object refValue = refSlot.getReference().getValue();
            label = refValue != null ? refFqn + " = " + refValue : refFqn;
        }
        cell.setText(label);
    } else if (element instanceof ExecutionSlot) {
        Object value = ((ExecutionSlot) element).getValue();
        if (value != null) {
            if (!((ExecutionSlot) element).isWritable() || isReadOnly) {
                cell.setText(getCellTextValue(element, value));
            } else if (isPrimitiveType(element)) {
                PrimitiveType primitiveType = (PrimitiveType) ((ExecutionSlot) element).getType().getOriginType();
                if (isBooleanType(value, primitiveType)) {
                    TreeItem currentItem = (TreeItem) cell.getItem();
                    NativeCellWidgetUtil.addNativeCheckbox(cell, element, value, new TreeEditorDisposeListener(currentItem));
                    // layout cells with checkbox widgets to update positions if tree contents have
                    // changed
                    cell.getControl().getParent().layout();
                } else {
                    cell.setText(getCellTextValue(element, value));
                }
            }
        } else {
            cell.setText("");
        }
    }
}
Also used : ReferenceSlot(org.yakindu.sct.model.sruntime.ReferenceSlot) ExecutionSlot(org.yakindu.sct.model.sruntime.ExecutionSlot) TreeItem(org.eclipse.swt.widgets.TreeItem) PrimitiveType(org.yakindu.base.types.PrimitiveType)

Example 2 with PrimitiveType

use of org.yakindu.base.types.PrimitiveType in project statecharts by Yakindu.

the class AbstractTypeSystemTest method createPrimitive.

protected PrimitiveType createPrimitive(String name) {
    PrimitiveType result = TypesFactory.eINSTANCE.createPrimitiveType();
    result.setName(name);
    return result;
}
Also used : PrimitiveType(org.yakindu.base.types.PrimitiveType)

Example 3 with PrimitiveType

use of org.yakindu.base.types.PrimitiveType in project statecharts by Yakindu.

the class AbstractTypeSystem method declarePrimitive.

protected Type declarePrimitive(String name) {
    PrimitiveType primitive = TypesFactory.eINSTANCE.createPrimitiveType();
    primitive.setName(name);
    declareType(primitive, name);
    resource.getContents().add(primitive);
    return primitive;
}
Also used : PrimitiveType(org.yakindu.base.types.PrimitiveType)

Aggregations

PrimitiveType (org.yakindu.base.types.PrimitiveType)3 TreeItem (org.eclipse.swt.widgets.TreeItem)1 ExecutionSlot (org.yakindu.sct.model.sruntime.ExecutionSlot)1 ReferenceSlot (org.yakindu.sct.model.sruntime.ReferenceSlot)1