Search in sources :

Example 1 with Choice

use of org.eclipse.gemoc.timeline.model.Choice in project gemoc-studio-modeldebugging by eclipse.

the class PossibleStepEditPart method getLeftPossibleStepEditPart.

/**
 * Gets the {@link PossibleStepEditPart} on the left.
 *
 * @return the {@link PossibleStepEditPart} on the left if any, <code>null</code> otherwise
 */
public PossibleStepEditPart getLeftPossibleStepEditPart() {
    final PossibleStepEditPart res;
    final Choice previousChoice = getModel().getChoice().getPreviousChoice();
    if (previousChoice != null) {
        int previousConnectionIndex = previousChoice.getConnectedIndex();
        if (previousConnectionIndex < 0) {
            previousConnectionIndex = 0;
        }
        int connectionIndex = getModel().getChoice().getConnectedIndex();
        if (connectionIndex < 0) {
            connectionIndex = 0;
        }
        int offset = previousConnectionIndex - connectionIndex;
        if (previousChoice.getPossibleSteps().size() > getModel().getPossibleStepIndex() + offset && getModel().getPossibleStepIndex() + offset > -1) {
            res = (PossibleStepEditPart) getViewer().getEditPartRegistry().get(previousChoice.getPossibleSteps().get(getModel().getPossibleStepIndex() + offset));
        } else {
            res = null;
        }
    } else {
        res = null;
    }
    return res;
}
Also used : Choice(org.eclipse.gemoc.timeline.model.Choice)

Example 2 with Choice

use of org.eclipse.gemoc.timeline.model.Choice in project gemoc-studio-modeldebugging by eclipse.

the class TimelineWindowEditPart method deepRefresh.

/**
 * Refresh {@link EditPart} in depth.
 */
private void deepRefresh() {
    refresh();
    for (Branch branch : getModelChildren()) {
        final EditPart branchEditPart = (EditPart) getViewer().getEditPartRegistry().get(branch);
        branchEditPart.refresh();
        for (Choice choice : branch.getChoices()) {
            final EditPart choiceEditPart = (EditPart) getViewer().getEditPartRegistry().get(choice);
            choiceEditPart.refresh();
            for (PossibleStep possibleStep : choice.getPossibleSteps()) {
                final EditPart possibleStepEditPart = (EditPart) getViewer().getEditPartRegistry().get(possibleStep);
                possibleStepEditPart.refresh();
            }
        }
    }
}
Also used : Choice(org.eclipse.gemoc.timeline.model.Choice) PossibleStep(org.eclipse.gemoc.timeline.model.PossibleStep) Branch(org.eclipse.gemoc.timeline.model.Branch) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) EditPart(org.eclipse.gef.EditPart)

Example 3 with Choice

use of org.eclipse.gemoc.timeline.model.Choice in project gemoc-studio by eclipse.

the class PossibleStepEditPart method getRightPossibleStepEditPart.

/**
 * Gets the {@link PossibleStepEditPart} on the right.
 *
 * @return the {@link PossibleStepEditPart} on the right if any, <code>null</code> otherwise
 */
public PossibleStepEditPart getRightPossibleStepEditPart() {
    final PossibleStepEditPart res;
    final Choice nextChoice = getModel().getChoice().getNextChoice();
    if (nextChoice != null) {
        int nextConnectionIndex = nextChoice.getConnectedIndex();
        if (nextConnectionIndex < 0) {
            nextConnectionIndex = 0;
        }
        int connectionIndex = getModel().getChoice().getConnectedIndex();
        if (connectionIndex < 0) {
            connectionIndex = 0;
        }
        int offset = nextConnectionIndex - connectionIndex;
        if (nextChoice.getPossibleSteps().size() > getModel().getPossibleStepIndex() + offset && getModel().getPossibleStepIndex() + offset > -1) {
            res = (PossibleStepEditPart) getViewer().getEditPartRegistry().get(nextChoice.getPossibleSteps().get(getModel().getPossibleStepIndex() + offset));
        } else {
            res = null;
        }
    } else {
        res = null;
    }
    return res;
}
Also used : Choice(org.eclipse.gemoc.timeline.model.Choice)

Example 4 with Choice

use of org.eclipse.gemoc.timeline.model.Choice in project gemoc-studio by eclipse.

the class PossibleStepEditPart method getLeftPossibleStepEditPart.

/**
 * Gets the {@link PossibleStepEditPart} on the left.
 *
 * @return the {@link PossibleStepEditPart} on the left if any, <code>null</code> otherwise
 */
public PossibleStepEditPart getLeftPossibleStepEditPart() {
    final PossibleStepEditPart res;
    final Choice previousChoice = getModel().getChoice().getPreviousChoice();
    if (previousChoice != null) {
        int previousConnectionIndex = previousChoice.getConnectedIndex();
        if (previousConnectionIndex < 0) {
            previousConnectionIndex = 0;
        }
        int connectionIndex = getModel().getChoice().getConnectedIndex();
        if (connectionIndex < 0) {
            connectionIndex = 0;
        }
        int offset = previousConnectionIndex - connectionIndex;
        if (previousChoice.getPossibleSteps().size() > getModel().getPossibleStepIndex() + offset && getModel().getPossibleStepIndex() + offset > -1) {
            res = (PossibleStepEditPart) getViewer().getEditPartRegistry().get(previousChoice.getPossibleSteps().get(getModel().getPossibleStepIndex() + offset));
        } else {
            res = null;
        }
    } else {
        res = null;
    }
    return res;
}
Also used : Choice(org.eclipse.gemoc.timeline.model.Choice)

Example 5 with Choice

use of org.eclipse.gemoc.timeline.model.Choice in project gemoc-studio by eclipse.

the class TimelineEditPartFactory method createEditPart.

@Override
public EditPart createEditPart(EditPart context, Object model) {
    final EditPart res;
    if (model instanceof PossibleStep) {
        res = new PossibleStepEditPart(withLabel);
    } else if (model instanceof Connection) {
        res = new ConnectionEditPart();
    } else if (model instanceof Choice) {
        res = new ChoiceEditPart();
    } else if (model instanceof Branch) {
        res = new BranchEditPart();
    } else if (model instanceof TimelineWindow) {
        res = new TimelineWindowEditPart();
    } else {
        throw new IllegalStateException("don't know what to do with " + model.getClass().getName());
    }
    res.setModel(model);
    return res;
}
Also used : Choice(org.eclipse.gemoc.timeline.model.Choice) PossibleStep(org.eclipse.gemoc.timeline.model.PossibleStep) Branch(org.eclipse.gemoc.timeline.model.Branch) TimelineWindow(org.eclipse.gemoc.timeline.model.TimelineWindow) EditPart(org.eclipse.gef.EditPart) Connection(org.eclipse.gemoc.timeline.model.Connection)

Aggregations

Choice (org.eclipse.gemoc.timeline.model.Choice)8 EditPart (org.eclipse.gef.EditPart)4 Branch (org.eclipse.gemoc.timeline.model.Branch)4 PossibleStep (org.eclipse.gemoc.timeline.model.PossibleStep)4 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)2 Connection (org.eclipse.gemoc.timeline.model.Connection)2 TimelineWindow (org.eclipse.gemoc.timeline.model.TimelineWindow)2