use of org.tmdmaker.core.model.AbstractEntityModel in project tmdmaker by tmdmaker.
the class SubsetTypeEditPart method getCommand.
/**
* {@inheritDoc}
*
* @see org.eclipse.gef.editparts.AbstractEditPart#getCommand(org.eclipse.gef.Request)
*/
@Override
public Command getCommand(Request request) {
if (REQ_OPEN.equals(request.getType())) {
logger.debug("{}#getCommand(req)", getClass());
SubsetType subsetType = getModel();
AbstractEntityModel model = subsetType.getSuperset();
SubsetCreateDialog dialog = new SubsetCreateDialog(getViewer().getControl().getShell(), model);
if (dialog.open() == Dialog.OK) {
return dialog.getCcommand();
}
}
return super.getCommand(request);
}
use of org.tmdmaker.core.model.AbstractEntityModel in project tmdmaker by tmdmaker.
the class VirtualSupersetTypeEditPart method getCommand.
/**
* {@inheritDoc}
*
* @see org.eclipse.gef.editparts.AbstractEditPart#getCommand(org.eclipse.gef.Request)
*/
@Override
public Command getCommand(Request request) {
if (!REQ_OPEN.equals(request.getType()))
return super.getCommand(request);
VirtualSupersetType type = getModel();
VirtualSuperset superset = type.getSuperset();
Diagram diagram = superset.getDiagram();
List<AbstractEntityModel> list = type.getSubsetList();
VirtualSupersetCreateDialog dialog = new VirtualSupersetCreateDialog(getViewer().getControl().getShell(), diagram, superset, list);
if (dialog.open() != Dialog.OK)
return null;
return new VirtualSupersetEditCommand(superset, dialog.getEditedValue(), dialog.getSelection(), dialog.getEditedAggregator().isApplyAttribute());
}
use of org.tmdmaker.core.model.AbstractEntityModel in project tmdmaker by tmdmaker.
the class EntityLayoutEditPolicy method createAddCommand.
/**
* {@inheritDoc}
*
* @see org.eclipse.gef.editpolicies.OrderedLayoutEditPolicy#createAddCommand(org.eclipse.gef.EditPart,
* org.eclipse.gef.EditPart)
*/
@Override
protected Command createAddCommand(EditPart child, EditPart after) {
logger.debug("{}#createAddCommand()", getClass());
if (!(child instanceof AttributeEditPart)) {
logger.debug("child is not AttributeEditPart.{}", child);
return null;
}
Attribute toMove = (Attribute) child.getModel();
AbstractModelEditPart<?> originalEntityEditPart = (AbstractModelEditPart<?>) child.getParent();
AbstractEntityModel originalEntity = (AbstractEntityModel) originalEntityEditPart.getModel();
int oldIndex = originalEntityEditPart.getChildren().indexOf(child);
AbstractModelEditPart<?> newEntityEditPart = null;
int newIndex = 0;
// アトリビュートが0件か最終行を指定した場合はnull
if (after == null) {
newEntityEditPart = (AbstractModelEditPart<?>) getHost();
newIndex = newEntityEditPart.getChildren().size();
} else if (after instanceof AttributeEditPart) {
newEntityEditPart = (AbstractModelEditPart<?>) getHost();
newIndex = newEntityEditPart.getChildren().indexOf(after);
} else {
logger.debug("after is null or not AttributeEditPart.{}", after);
return null;
}
AbstractEntityModel newEntity = (AbstractEntityModel) newEntityEditPart.getModel();
return new AttributeTransferCommand(toMove, originalEntity, oldIndex, newEntity, newIndex);
}
use of org.tmdmaker.core.model.AbstractEntityModel in project tmdmaker by tmdmaker.
the class ReconnectableNodeEditPolicy method getReconnectTargetCommand.
/**
* {@inheritDoc}
*
* @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy#getReconnectTargetCommand(org.eclipse.gef.requests.ReconnectRequest)
*/
@Override
protected Command getReconnectTargetCommand(ReconnectRequest request) {
AbstractConnectionModel connection = (AbstractConnectionModel) request.getConnectionEditPart().getModel();
if (connection.getSource() == connection.getTarget()) {
logger.debug("source == target");
return null;
}
AbstractEntityModel newTarget = (AbstractEntityModel) request.getTarget().getModel();
if (!connection.getTarget().equals(newTarget)) {
logger.debug("target not equals newTarget");
return null;
}
Point location = new Point(request.getLocation());
AbstractModelEditPart<?> targetEditPart = (AbstractModelEditPart<?>) request.getConnectionEditPart().getTarget();
IFigure targetFigure = targetEditPart.getFigure();
targetFigure.translateToRelative(location);
AnchorConstraint newAnchorConstraint = new XYChopboxAnchorHelper(targetFigure.getBounds()).calculateAnchorConstraint(location);
return new TargetConnectionReconnectCommand(connection, newAnchorConstraint);
}
use of org.tmdmaker.core.model.AbstractEntityModel in project tmdmaker by tmdmaker.
the class SubsetEntityComponentEditPolicy method createDeleteCommand.
/**
* {@inheritDoc}
*
* @see org.eclipse.gef.editpolicies.ComponentEditPolicy#createDeleteCommand(org.eclipse.gef.requests.GroupRequest)
*/
@Override
protected Command createDeleteCommand(GroupRequest deleteRequest) {
CompoundCommand ccommand = new CompoundCommand();
SubsetDeleteCommand command1 = new SubsetDeleteCommand(getModel());
ccommand.add(command1);
if (getModel().isNotImplement()) {
AbstractEntityModel original = ImplementRule.findOriginalImplementModel(getModel());
ccommand.add(new ImplementDerivationModelsDeleteCommand(getModel(), original));
}
return ccommand;
}
Aggregations