Search in sources :

Example 11 with ConnectionEndpointEditPolicy

use of org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy 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) {
                EditPolicy 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) ConnectionEditPolicy(org.eclipse.gef.editpolicies.ConnectionEditPolicy) ConnectionEndpointEditPolicy(org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy) EditPolicy(org.eclipse.gef.EditPolicy) ManhattanBendpointEditPolicy(org.csstudio.opibuilder.editpolicies.ManhattanBendpointEditPolicy) ManhattanConnectionRouter(org.eclipse.draw2d.ManhattanConnectionRouter) ConnectionRouter(org.eclipse.draw2d.ConnectionRouter)

Example 12 with ConnectionEndpointEditPolicy

use of org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy in project dbeaver by serge-rider.

the class AssociationPart method createEditPolicies.

@Override
protected void createEditPolicies() {
    installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE, new ConnectionEndpointEditPolicy());
    installEditPolicy(EditPolicy.CONNECTION_BENDPOINTS_ROLE, new AssociationBendEditPolicy());
    if (isEditEnabled()) {
        installEditPolicy(EditPolicy.COMPONENT_ROLE, new AssociationEditPolicy());
    }
}
Also used : ConnectionEndpointEditPolicy(org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy) AssociationEditPolicy(org.jkiss.dbeaver.erd.ui.policy.AssociationEditPolicy) AssociationBendEditPolicy(org.jkiss.dbeaver.erd.ui.policy.AssociationBendEditPolicy)

Aggregations

ConnectionEndpointEditPolicy (org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy)12 Command (org.eclipse.gef.commands.Command)3 ConnectionEditPolicy (org.eclipse.gef.editpolicies.ConnectionEditPolicy)3 GroupRequest (org.eclipse.gef.requests.GroupRequest)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 AssociationBendEditPolicy (org.jkiss.dbeaver.ext.erd.policy.AssociationBendEditPolicy)2 AssociationEditPolicy (org.jkiss.dbeaver.ext.erd.policy.AssociationEditPolicy)2 RelationshipEditPolicy (com.cubrid.common.ui.er.policy.RelationshipEditPolicy)1 ConnectionEditPolicy (com.cubrid.cubridmanager.ui.replication.editor.policies.ConnectionEditPolicy)1 ConnectionDeleteCommand (org.csstudio.opibuilder.commands.ConnectionDeleteCommand)1 ManhattanBendpointEditPolicy (org.csstudio.opibuilder.editpolicies.ManhattanBendpointEditPolicy)1 ConnectionRouter (org.eclipse.draw2d.ConnectionRouter)1 ManhattanConnectionRouter (org.eclipse.draw2d.ManhattanConnectionRouter)1 EditPolicy (org.eclipse.gef.EditPolicy)1 ReconnectRequest (org.eclipse.gef.requests.ReconnectRequest)1 AssociationBendEditPolicy (org.jkiss.dbeaver.erd.ui.policy.AssociationBendEditPolicy)1 AssociationEditPolicy (org.jkiss.dbeaver.erd.ui.policy.AssociationEditPolicy)1 ConnectionBendpointEditPolicy (org.knime.workbench.editor2.editparts.policy.ConnectionBendpointEditPolicy)1 IConnection (org.talend.core.model.process.IConnection)1