Search in sources :

Example 1 with ReferenceSlot

use of org.yakindu.sct.model.sruntime.ReferenceSlot 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)

Aggregations

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