Search in sources :

Example 1 with EntityModelAddCommand

use of org.tmdmaker.ui.editor.gef3.commands.EntityModelAddCommand in project tmdmaker by tmdmaker.

the class FileImportAction method getCreateCommands.

private Command getCreateCommands(List<AbstractEntityModel> list, Point p) {
    CompoundCommand ccommand = new CompoundCommand();
    Diagram diagram = (Diagram) viewer.getContents().getModel();
    int i = 0;
    for (AbstractEntityModel model : list) {
        EntityModelAddCommand c = new EntityModelAddCommand(diagram, p.x + i, p.y + i);
        i += 5;
        c.setModel(model);
        ccommand.add(c);
    }
    return ccommand.unwrap();
}
Also used : EntityModelAddCommand(org.tmdmaker.ui.editor.gef3.commands.EntityModelAddCommand) Point(org.eclipse.draw2d.geometry.Point) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Diagram(org.tmdmaker.core.model.Diagram)

Example 2 with EntityModelAddCommand

use of org.tmdmaker.ui.editor.gef3.commands.EntityModelAddCommand in project tmdmaker by tmdmaker.

the class EntityCreationTool method handleButtonUp.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.gef.tools.CreationTool#handleButtonUp(int)
 */
@Override
protected boolean handleButtonUp(int button) {
    boolean added = false;
    if (stateTransition(STATE_DRAG | STATE_DRAG_IN_PROGRESS, STATE_TERMINAL)) {
        logger.debug("startTransition = {}", getState());
        eraseTargetFeedback();
        unlockTargetEditPart();
        Command curCommand = getCurrentCommand();
        if (curCommand instanceof EntityModelAddCommand) {
            EntityModelAddCommand addCommand = (EntityModelAddCommand) curCommand;
            EntityCreateDialog dialog = new EntityCreateDialog(getCurrentViewer().getControl().getShell());
            if (dialog.open() == Dialog.OK) {
                added = true;
                addCommand.setModel(dialog.getCreateModel());
                performCreation(button);
            } else {
                added = false;
            }
        }
    }
    setState(STATE_TERMINAL);
    handleFinished();
    return added;
}
Also used : Command(org.eclipse.gef.commands.Command) EntityModelAddCommand(org.tmdmaker.ui.editor.gef3.commands.EntityModelAddCommand) EntityModelAddCommand(org.tmdmaker.ui.editor.gef3.commands.EntityModelAddCommand) EntityCreateDialog(org.tmdmaker.ui.dialogs.EntityCreateDialog)

Aggregations

EntityModelAddCommand (org.tmdmaker.ui.editor.gef3.commands.EntityModelAddCommand)2 Point (org.eclipse.draw2d.geometry.Point)1 Command (org.eclipse.gef.commands.Command)1 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)1 AbstractEntityModel (org.tmdmaker.core.model.AbstractEntityModel)1 Diagram (org.tmdmaker.core.model.Diagram)1 EntityCreateDialog (org.tmdmaker.ui.dialogs.EntityCreateDialog)1