Search in sources :

Example 1 with AnchorConstraint

use of org.tmdmaker.core.model.constraint.AnchorConstraint in project tmdmaker by tmdmaker.

the class AbstractConnectionModel method setTargetAnchorConstraint.

public void setTargetAnchorConstraint(AnchorConstraint targetAnchorConstraint) {
    AnchorConstraint oldTargetAnchorConstraint = this.targetAnchorConstraint;
    this.targetAnchorConstraint = targetAnchorConstraint;
    firePropertyChange(PROPERTY_CONNECTION, oldTargetAnchorConstraint, this.targetAnchorConstraint);
}
Also used : AnchorConstraint(org.tmdmaker.core.model.constraint.AnchorConstraint)

Example 2 with AnchorConstraint

use of org.tmdmaker.core.model.constraint.AnchorConstraint in project tmdmaker by tmdmaker.

the class AbstractConnectionModel method setSourceAnchorConstraint.

public void setSourceAnchorConstraint(AnchorConstraint sourceAnchorConstraint) {
    AnchorConstraint oldSourceAnchorConstraint = this.sourceAnchorConstraint;
    this.sourceAnchorConstraint = sourceAnchorConstraint;
    firePropertyChange(PROPERTY_CONNECTION, oldSourceAnchorConstraint, this.sourceAnchorConstraint);
}
Also used : AnchorConstraint(org.tmdmaker.core.model.constraint.AnchorConstraint)

Example 3 with AnchorConstraint

use of org.tmdmaker.core.model.constraint.AnchorConstraint 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 4 with AnchorConstraint

use of org.tmdmaker.core.model.constraint.AnchorConstraint in project tmdmaker by tmdmaker.

the class AnchorConstraintMigrator method convertNullLocationPoint.

/**
 * データ移行.
 *
 * バージョン0.4.0より前の場合にデータを補正する。
 */
public void convertNullLocationPoint(AbstractConnectionModel connection) {
    if (connection.sourceXp == 0 && connection.sourceYp == 0 || connection.targetXp == 0 && connection.targetYp == 0) {
        connection.setSourceAnchorConstraint(new AnchorConstraint());
        connection.setTargetAnchorConstraint(new AnchorConstraint());
        return;
    }
    connection.setSourceAnchorConstraint(new AnchorConstraint(connection.sourceXp, connection.sourceYp));
    connection.setTargetAnchorConstraint(new AnchorConstraint(connection.targetXp, connection.targetYp));
}
Also used : AnchorConstraint(org.tmdmaker.core.model.constraint.AnchorConstraint)

Example 5 with AnchorConstraint

use of org.tmdmaker.core.model.constraint.AnchorConstraint in project tmdmaker by tmdmaker.

the class AbstractModelEditPart method getSourceConnectionAnchor.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.Request)
 */
@Override
public ConnectionAnchor getSourceConnectionAnchor(Request request) {
    IFigure thisFigure = this.getFigure();
    if (request instanceof ReconnectRequest) {
        ReconnectRequest reconnectRequest = (ReconnectRequest) request;
        ConnectionEditPart connectionEditPart = reconnectRequest.getConnectionEditPart();
        AbstractConnectionModel relationship = (AbstractConnectionModel) connectionEditPart.getModel();
        if (relationship.getSource() == relationship.getTarget()) {
            return new XYChopboxAnchor(thisFigure);
        }
        EditPart editPart = reconnectRequest.getTarget();
        if (editPart == null || !editPart.getModel().equals(relationship.getSource())) {
            return new XYChopboxAnchor(thisFigure);
        }
        Point location = new Point(reconnectRequest.getLocation());
        thisFigure.translateToRelative(location);
        IFigure sourceFigure = ((AbstractModelEditPart<?>) connectionEditPart.getSource()).getFigure();
        AnchorConstraint newAnchorConstraint = new XYChopboxAnchorHelper(sourceFigure.getBounds()).calculateAnchorConstraint(location);
        return new XYChopboxAnchor(thisFigure, newAnchorConstraint);
    }
    return new XYChopboxAnchor(thisFigure);
}
Also used : ReconnectRequest(org.eclipse.gef.requests.ReconnectRequest) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) AnchorConstraint(org.tmdmaker.core.model.constraint.AnchorConstraint) NodeEditPart(org.eclipse.gef.NodeEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) XYChopboxAnchor(org.tmdmaker.ui.editor.draw2d.anchors.XYChopboxAnchor) Point(org.eclipse.draw2d.geometry.Point) XYChopboxAnchorHelper(org.tmdmaker.ui.editor.draw2d.anchors.XYChopboxAnchorHelper) IFigure(org.eclipse.draw2d.IFigure) AbstractConnectionModel(org.tmdmaker.core.model.AbstractConnectionModel)

Aggregations

AnchorConstraint (org.tmdmaker.core.model.constraint.AnchorConstraint)8 Point (org.eclipse.draw2d.geometry.Point)5 IFigure (org.eclipse.draw2d.IFigure)4 AbstractConnectionModel (org.tmdmaker.core.model.AbstractConnectionModel)4 XYChopboxAnchorHelper (org.tmdmaker.ui.editor.draw2d.anchors.XYChopboxAnchorHelper)4 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)2 EditPart (org.eclipse.gef.EditPart)2 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)2 NodeEditPart (org.eclipse.gef.NodeEditPart)2 ReconnectRequest (org.eclipse.gef.requests.ReconnectRequest)2 AbstractEntityModel (org.tmdmaker.core.model.AbstractEntityModel)2 XYChopboxAnchor (org.tmdmaker.ui.editor.draw2d.anchors.XYChopboxAnchor)2 AbstractModelEditPart (org.tmdmaker.ui.editor.gef3.editparts.node.AbstractModelEditPart)2 SourceConnectionReconnectCommand (org.tmdmaker.ui.editor.gef3.commands.SourceConnectionReconnectCommand)1 TargetConnectionReconnectCommand (org.tmdmaker.ui.editor.gef3.commands.TargetConnectionReconnectCommand)1