Search in sources :

Example 1 with ExecutionSlot

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

use of org.yakindu.sct.model.sruntime.ExecutionSlot in project statecharts by Yakindu.

the class ExecutionContextLabelProvider method getEnumName.

protected String getEnumName(Object element, Object value) {
    EnumerationType enumType = (EnumerationType) ((ExecutionSlot) element).getType().getOriginType();
    String text = enumType.getEnumerator().get(((Long) value).intValue()).getName();
    return text;
}
Also used : ExecutionSlot(org.yakindu.sct.model.sruntime.ExecutionSlot) EnumerationType(org.yakindu.base.types.EnumerationType)

Example 3 with ExecutionSlot

use of org.yakindu.sct.model.sruntime.ExecutionSlot in project statecharts by Yakindu.

the class EnumerationEditingSupport method convertValue.

@Override
protected Object convertValue(Object element, Object value) {
    if (element instanceof ExecutionSlot) {
        if (value != null && value instanceof Integer) {
            int index = ((Integer) value).intValue();
            EnumerationType e = getEnumerationType((ExecutionSlot) element);
            if (index < 0) {
                return new Long(e.getEnumerator().iterator().next().getLiteralValue());
            }
            return new Long(e.getEnumerator().get(index).getLiteralValue());
        }
    }
    return null;
}
Also used : ExecutionSlot(org.yakindu.sct.model.sruntime.ExecutionSlot) EnumerationType(org.yakindu.base.types.EnumerationType)

Example 4 with ExecutionSlot

use of org.yakindu.sct.model.sruntime.ExecutionSlot in project statecharts by Yakindu.

the class EnumerationEditingSupport method getCellEditor.

@Override
public CellEditor getCellEditor(Object element) {
    if (element instanceof ExecutionSlot) {
        EnumerationType e = getEnumerationType((ExecutionSlot) element);
        List<String> enumeratorNames = new ArrayList<String>();
        for (Enumerator enumerator : e.getEnumerator()) {
            enumeratorNames.add(enumerator.getName());
        }
        return new ComboBoxCellEditor((Composite) getViewer().getControl(), enumeratorNames.toArray(new String[] {}), SWT.READ_ONLY);
    }
    return null;
}
Also used : ExecutionSlot(org.yakindu.sct.model.sruntime.ExecutionSlot) Enumerator(org.yakindu.base.types.Enumerator) EnumerationType(org.yakindu.base.types.EnumerationType) ArrayList(java.util.ArrayList) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor)

Example 5 with ExecutionSlot

use of org.yakindu.sct.model.sruntime.ExecutionSlot in project statecharts by Yakindu.

the class ReferenceSlotImpl method setReference.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setReference(ExecutionSlot newReference) {
    ExecutionSlot oldReference = reference;
    reference = newReference;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, SRuntimePackage.REFERENCE_SLOT__REFERENCE, oldReference, reference));
}
Also used : ExecutionSlot(org.yakindu.sct.model.sruntime.ExecutionSlot) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Aggregations

ExecutionSlot (org.yakindu.sct.model.sruntime.ExecutionSlot)5 EnumerationType (org.yakindu.base.types.EnumerationType)3 ArrayList (java.util.ArrayList)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1 Enumerator (org.yakindu.base.types.Enumerator)1 PrimitiveType (org.yakindu.base.types.PrimitiveType)1 ReferenceSlot (org.yakindu.sct.model.sruntime.ReferenceSlot)1