Search in sources :

Example 1 with AbstractEntityModel

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);
}
Also used : SubsetType(org.tmdmaker.core.model.SubsetType) SubsetCreateDialog(org.tmdmaker.ui.dialogs.SubsetCreateDialog) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel)

Example 2 with AbstractEntityModel

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());
}
Also used : VirtualSupersetType(org.tmdmaker.core.model.VirtualSupersetType) VirtualSupersetCreateDialog(org.tmdmaker.ui.dialogs.VirtualSupersetCreateDialog) VirtualSuperset(org.tmdmaker.core.model.VirtualSuperset) VirtualSupersetEditCommand(org.tmdmaker.ui.editor.gef3.commands.VirtualSupersetEditCommand) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel) Diagram(org.tmdmaker.core.model.Diagram)

Example 3 with AbstractEntityModel

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);
}
Also used : AbstractModelEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.AbstractModelEditPart) AttributeEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.AttributeEditPart) Attribute(org.tmdmaker.core.model.Attribute) AttributeTransferCommand(org.tmdmaker.ui.editor.gef3.commands.AttributeTransferCommand) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel)

Example 4 with AbstractEntityModel

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);
}
Also used : AbstractModelEditPart(org.tmdmaker.ui.editor.gef3.editparts.node.AbstractModelEditPart) TargetConnectionReconnectCommand(org.tmdmaker.ui.editor.gef3.commands.TargetConnectionReconnectCommand) AnchorConstraint(org.tmdmaker.core.model.constraint.AnchorConstraint) Point(org.eclipse.draw2d.geometry.Point) XYChopboxAnchorHelper(org.tmdmaker.ui.editor.draw2d.anchors.XYChopboxAnchorHelper) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel) AbstractConnectionModel(org.tmdmaker.core.model.AbstractConnectionModel) IFigure(org.eclipse.draw2d.IFigure)

Example 5 with AbstractEntityModel

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;
}
Also used : ImplementDerivationModelsDeleteCommand(org.tmdmaker.ui.editor.gef3.commands.ImplementDerivationModelsDeleteCommand) SubsetDeleteCommand(org.tmdmaker.ui.editor.gef3.commands.SubsetDeleteCommand) AbstractEntityModel(org.tmdmaker.core.model.AbstractEntityModel) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Aggregations

AbstractEntityModel (org.tmdmaker.core.model.AbstractEntityModel)58 ArrayList (java.util.ArrayList)22 Diagram (org.tmdmaker.core.model.Diagram)14 Entity (org.tmdmaker.core.model.Entity)12 Identifier (org.tmdmaker.core.model.Identifier)11 Test (org.junit.Test)9 VirtualSuperset (org.tmdmaker.core.model.VirtualSuperset)9 ModelName (org.tmdmaker.core.model.parts.ModelName)9 IAttribute (org.tmdmaker.core.model.IAttribute)7 VirtualSupersetType (org.tmdmaker.core.model.VirtualSupersetType)6 List (java.util.List)5 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)5 AbstractConnectionModel (org.tmdmaker.core.model.AbstractConnectionModel)5 Attribute (org.tmdmaker.core.model.Attribute)5 AbstractModelEditPart (org.tmdmaker.ui.editor.gef3.editparts.node.AbstractModelEditPart)5 Map (java.util.Map)4 Point (org.eclipse.draw2d.geometry.Point)4 ReusedIdentifier (org.tmdmaker.core.model.ReusedIdentifier)4 VirtualSubsetBuilder (org.tmdmaker.core.model.virtual.VirtualSubsetBuilder)4 File (java.io.File)3