use of org.csstudio.opibuilder.editpolicies.ManhattanBendpointEditPolicy in project yamcs-studio by yamcs.
the class WidgetConnectionEditPart method updateRouter.
private void updateRouter(PolylineConnection connection) {
var router = ConnectionRouter.NULL;
switch(getWidgetModel().getRouterType()) {
case MANHATTAN:
// Allow move bendpoint
if (getExecutionMode() == ExecutionMode.EDIT_MODE) {
installEditPolicy(EditPolicy.CONNECTION_BENDPOINTS_ROLE, new ManhattanBendpointEditPolicy());
}
// no points, use manhattan
if (getWidgetModel().getPoints().size() == 0) {
router = new ManhattanConnectionRouter();
break;
}
// has points, use points for routing
router = new FixedPointsConnectionRouter();
((FixedPointsConnectionRouter) router).setConnectionModel(getWidgetModel());
connection.setConnectionRouter(router);
refreshBendpoints(connection);
return;
case STRAIGHT_LINE:
// no bendpoint
if (getExecutionMode() == ExecutionMode.EDIT_MODE) {
installEditPolicy(EditPolicy.CONNECTION_BENDPOINTS_ROLE, null);
}
router = ConnectionRouter.NULL;
default:
break;
}
connection.setConnectionRouter(router);
}
use of org.csstudio.opibuilder.editpolicies.ManhattanBendpointEditPolicy 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());
}
});
}
}
Aggregations