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();
}
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;
}
Aggregations