Search in sources :

Example 1 with ScalarExpression

use of edu.uah.rsesc.aadlsimulator.xtext.inputConstraint.ScalarExpression in project AGREE by loonwerks.

the class InputConstraintDialog method addNegateMenuItem.

private void addNegateMenuItem(final Menu menu, final Reference ref) {
    final MenuItem menuItem = new MenuItem(menu, SWT.CHECK);
    menuItem.setSelection(ref.get() instanceof NegativeExpression);
    menuItem.setText("Negate");
    menuItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            final boolean checked = ((MenuItem) e.widget).getSelection();
            if (checked) {
                final NegativeExpression negExpr = (NegativeExpression) InputConstraintFactory.eINSTANCE.create(InputConstraintPackage.eINSTANCE.getNegativeExpression());
                negExpr.setValue((ScalarExpression) ref.get());
                ref.set(negExpr);
            } else {
                ref.set(((NegativeExpression) ref.get()).getValue());
            }
            dlg.refreshContraint();
        }
    });
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) ScalarExpression(edu.uah.rsesc.aadlsimulator.xtext.inputConstraint.ScalarExpression) NegativeExpression(edu.uah.rsesc.aadlsimulator.xtext.inputConstraint.NegativeExpression)

Example 2 with ScalarExpression

use of edu.uah.rsesc.aadlsimulator.xtext.inputConstraint.ScalarExpression in project AGREE by loonwerks.

the class InputConstraintDialog method addScalarExpressionsMenuItems.

private void addScalarExpressionsMenuItems(final Menu menu, boolean showBoolean, final Reference ref) {
    if (ref.get() instanceof ScalarExpression && !(ref.get() instanceof BooleanLiteral)) {
        addNegateMenuItem(menu, ref);
    }
    addTextExpressionMenuItem(menu, ref, "Integer...", ResultType.INTEGER, "0");
    addTextExpressionMenuItem(menu, ref, "Real...", ResultType.REAL, "0.0");
    if (showBoolean) {
        final Menu booleanMenu = new Menu(menu);
        final MenuItem booleanMenuItem = new MenuItem(menu, SWT.CASCADE);
        booleanMenuItem.setText("Boolean");
        booleanMenuItem.setMenu(booleanMenu);
        addBooleanLiteralMenuItem(booleanMenu, ref, true);
        addBooleanLiteralMenuItem(booleanMenu, ref, false);
    }
    addReferenceMenuItems(menu, ref);
    addNewEClassMenuItem(menu, ref, "Random Integer", icp.getRandomIntegerExpression());
    addNewEClassMenuItem(menu, ref, "Random Real", icp.getRandomRealExpression());
    addNewEClassMenuItem(menu, ref, "Random Element", icp.getRandomElementExpression());
    addPreviousValueMenuItem(menu, ref);
}
Also used : BooleanLiteral(edu.uah.rsesc.aadlsimulator.xtext.inputConstraint.BooleanLiteral) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) ScalarExpression(edu.uah.rsesc.aadlsimulator.xtext.inputConstraint.ScalarExpression)

Example 3 with ScalarExpression

use of edu.uah.rsesc.aadlsimulator.xtext.inputConstraint.ScalarExpression in project AGREE by loonwerks.

the class BinaryExpressionImpl method basicSetRight.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetRight(ScalarExpression newRight, NotificationChain msgs) {
    ScalarExpression oldRight = right;
    right = newRight;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, InputConstraintPackage.BINARY_EXPRESSION__RIGHT, oldRight, newRight);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) ScalarExpression(edu.uah.rsesc.aadlsimulator.xtext.inputConstraint.ScalarExpression)

Example 4 with ScalarExpression

use of edu.uah.rsesc.aadlsimulator.xtext.inputConstraint.ScalarExpression in project AGREE by loonwerks.

the class BinaryExpressionImpl method basicSetLeft.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetLeft(ScalarExpression newLeft, NotificationChain msgs) {
    ScalarExpression oldLeft = left;
    left = newLeft;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, InputConstraintPackage.BINARY_EXPRESSION__LEFT, oldLeft, newLeft);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) ScalarExpression(edu.uah.rsesc.aadlsimulator.xtext.inputConstraint.ScalarExpression)

Example 5 with ScalarExpression

use of edu.uah.rsesc.aadlsimulator.xtext.inputConstraint.ScalarExpression in project AGREE by loonwerks.

the class NegativeExpressionImpl method basicSetValue.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetValue(ScalarExpression newValue, NotificationChain msgs) {
    ScalarExpression oldValue = value;
    value = newValue;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, InputConstraintPackage.NEGATIVE_EXPRESSION__VALUE, oldValue, newValue);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) ScalarExpression(edu.uah.rsesc.aadlsimulator.xtext.inputConstraint.ScalarExpression)

Aggregations

ScalarExpression (edu.uah.rsesc.aadlsimulator.xtext.inputConstraint.ScalarExpression)8 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)5 NegativeExpression (edu.uah.rsesc.aadlsimulator.xtext.inputConstraint.NegativeExpression)2 MenuItem (org.eclipse.swt.widgets.MenuItem)2 BooleanLiteral (edu.uah.rsesc.aadlsimulator.xtext.inputConstraint.BooleanLiteral)1 RealLiteral (edu.uah.rsesc.aadlsimulator.xtext.inputConstraint.RealLiteral)1 BigDecimal (java.math.BigDecimal)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Menu (org.eclipse.swt.widgets.Menu)1