Search in sources :

Example 1 with ConnectionRouter

use of org.eclipse.draw2d.ConnectionRouter in project netxms by netxms.

the class BendpointEditor method setRoutingConstraints.

/**
 * Set routing constraint on connection figure
 */
private void setRoutingConstraints() {
    if (connection.isDisposed())
        return;
    // $NON-NLS-1$
    ConnectionRouter router = (ConnectionRouter) connection.getData("ROUTER");
    router.setConstraint(connectionFigure, bendpoints);
    connectionFigure.setRoutingConstraint(bendpoints);
}
Also used : ConnectionRouter(org.eclipse.draw2d.ConnectionRouter)

Example 2 with ConnectionRouter

use of org.eclipse.draw2d.ConnectionRouter in project yamcs-studio by yamcs.

the class WidgetConnectionEditPart method createEditPolicies.

@Override
protected void createEditPolicies() {
    if (getExecutionMode() == ExecutionMode.EDIT_MODE && !getWidgetModel().isLoadedFromLinkedOpi()) {
        // Selection handle edit policy.
        // Makes the connection show a feedback, when selected by the user.
        installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE, new ConnectionEndpointEditPolicy() {

            private ConnectionRouter originalRouter = null;

            private Object originalConstraint = null;

            @Override
            protected void showConnectionMoveFeedback(ReconnectRequest request) {
                var connectionHandlesEditpolicy = getEditPolicy(EditPolicy.CONNECTION_BENDPOINTS_ROLE);
                if (connectionHandlesEditpolicy != null && connectionHandlesEditpolicy instanceof ManhattanBendpointEditPolicy) {
                    ((ManhattanBendpointEditPolicy) connectionHandlesEditpolicy).removeSelectionHandles();
                }
                if (getConnection().getConnectionRouter() instanceof FixedPointsConnectionRouter) {
                    originalRouter = getConnection().getConnectionRouter();
                    originalConstraint = originalRouter.getConstraint(getConnection());
                    getConnection().setConnectionRouter(new ManhattanConnectionRouter());
                }
                super.showConnectionMoveFeedback(request);
            }

            @Override
            protected void eraseConnectionMoveFeedback(ReconnectRequest request) {
                if (originalRouter != null) {
                    originalRouter.setConstraint(getConnection(), originalConstraint);
                    getConnection().setConnectionRouter(originalRouter);
                }
                super.eraseConnectionMoveFeedback(request);
            }
        });
        // Allows the removal of the connection model element
        installEditPolicy(EditPolicy.CONNECTION_ROLE, new ConnectionEditPolicy() {

            @Override
            protected Command getDeleteCommand(GroupRequest request) {
                return new ConnectionDeleteCommand(getWidgetModel());
            }
        });
    }
}
Also used : ConnectionEndpointEditPolicy(org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy) ReconnectRequest(org.eclipse.gef.requests.ReconnectRequest) ManhattanBendpointEditPolicy(org.csstudio.opibuilder.editpolicies.ManhattanBendpointEditPolicy) ConnectionEditPolicy(org.eclipse.gef.editpolicies.ConnectionEditPolicy) ConnectionDeleteCommand(org.csstudio.opibuilder.commands.ConnectionDeleteCommand) ConnectionDeleteCommand(org.csstudio.opibuilder.commands.ConnectionDeleteCommand) Command(org.eclipse.gef.commands.Command) GroupRequest(org.eclipse.gef.requests.GroupRequest) ManhattanConnectionRouter(org.eclipse.draw2d.ManhattanConnectionRouter) ManhattanConnectionRouter(org.eclipse.draw2d.ManhattanConnectionRouter) ConnectionRouter(org.eclipse.draw2d.ConnectionRouter)

Example 3 with ConnectionRouter

use of org.eclipse.draw2d.ConnectionRouter in project jbosstools-hibernate by jbosstools.

the class AssociationEditPart method createFigure.

protected IFigure createFigure() {
    PolylineConnection polylineConnection = new PolylineConnection();
    AssociationViewAdapter association = (AssociationViewAdapter) getModel();
    polylineConnection.setTargetDecoration(association.getTargetDecoration());
    ConnectionRouter connectionRouter = association.getConnectionRouter();
    if (connectionRouter != null) {
        polylineConnection.setConnectionRouter(connectionRouter);
    }
    AssociationViewAdapter ava = (AssociationViewAdapter) getModel();
    if (ava.getAssociationName() != null) {
        MidpointLocator mpl = new MidpointLocator(polylineConnection, 0);
        polylineConnection.add(new Label(ava.getAssociationName()), mpl);
    }
    polylineConnection.setForegroundColor(ColorConstants.gray);
    return polylineConnection;
}
Also used : MidpointLocator(org.eclipse.draw2d.MidpointLocator) Label(org.eclipse.draw2d.Label) ConnectionRouter(org.eclipse.draw2d.ConnectionRouter) PolylineConnection(org.eclipse.draw2d.PolylineConnection) AssociationViewAdapter(org.hibernate.eclipse.graph.model.AssociationViewAdapter)

Aggregations

ConnectionRouter (org.eclipse.draw2d.ConnectionRouter)3 ConnectionDeleteCommand (org.csstudio.opibuilder.commands.ConnectionDeleteCommand)1 ManhattanBendpointEditPolicy (org.csstudio.opibuilder.editpolicies.ManhattanBendpointEditPolicy)1 Label (org.eclipse.draw2d.Label)1 ManhattanConnectionRouter (org.eclipse.draw2d.ManhattanConnectionRouter)1 MidpointLocator (org.eclipse.draw2d.MidpointLocator)1 PolylineConnection (org.eclipse.draw2d.PolylineConnection)1 Command (org.eclipse.gef.commands.Command)1 ConnectionEditPolicy (org.eclipse.gef.editpolicies.ConnectionEditPolicy)1 ConnectionEndpointEditPolicy (org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy)1 GroupRequest (org.eclipse.gef.requests.GroupRequest)1 ReconnectRequest (org.eclipse.gef.requests.ReconnectRequest)1 AssociationViewAdapter (org.hibernate.eclipse.graph.model.AssociationViewAdapter)1