use of org.csstudio.opibuilder.model.ConnectionModel in project yamcs-studio by yamcs.
the class ConnectionCreateCommand method execute.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.commands.Command#execute()
*/
@Override
public void execute() {
// create a new connection between source and target
if (connection == null) {
connection = new ConnectionModel(source.getRootDisplayModel());
SchemaService.getInstance().applySchema(connection);
}
connection.setSource(source);
connection.setSourceTerminal(sourceTerminal);
connection.setTarget(target);
connection.setTargetTerminal(targetTerminal);
connection.reconnect();
}
use of org.csstudio.opibuilder.model.ConnectionModel in project yamcs-studio by yamcs.
the class ReplaceWidgetCommand method getAllConnections.
private List<ConnectionModel> getAllConnections(AbstractWidgetModel widget, boolean source) {
List<ConnectionModel> result = new ArrayList<ConnectionModel>();
result.addAll(source ? widget.getSourceConnections() : widget.getTargetConnections());
if (widget instanceof AbstractContainerModel) {
for (AbstractWidgetModel child : ((AbstractContainerModel) widget).getAllDescendants()) {
result.addAll(source ? child.getSourceConnections() : child.getTargetConnections());
}
}
return result;
}
use of org.csstudio.opibuilder.model.ConnectionModel in project yamcs-studio by yamcs.
the class ReplaceWidgetCommand method undo.
@Override
public void undo() {
container.removeChild(targetWidget);
container.addChild(index, srcWidget);
for (ConnectionModel conn : sourceConnections) {
if (conn.getSource() == targetWidget)
conn.setSource(srcWidget);
}
for (ConnectionModel conn : targetConnections) {
if (conn.getTarget() == targetWidget)
conn.setTarget(srcWidget);
}
removeConnections(sourceConnections);
removeConnections(targetConnections);
addConnections(sourceConnections);
addConnections(targetConnections);
}
use of org.csstudio.opibuilder.model.ConnectionModel in project yamcs-studio by yamcs.
the class WidgetCreateCommand method execute.
@Override
public void execute() {
oldBounds = newWidget.getBounds();
generateNewWUID(newWidget);
// If the new created widget has connections on it, remove their points.
for (ConnectionModel conn : newWidget.getSourceConnections()) {
conn.setPoints(new PointList());
}
redo();
}
use of org.csstudio.opibuilder.model.ConnectionModel in project yamcs-studio by yamcs.
the class AbstractPolyEditPart method registerPropertyChangeHandlers.
/**
* {@inheritDoc}
*/
@Override
protected void registerPropertyChangeHandlers() {
super.registerPropertyChangeHandlers();
// points
IWidgetPropertyChangeHandler pointsHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
Polyline polyline = (Polyline) refreshableFigure;
PointList points = (PointList) newValue;
if (points.size() != polyline.getPoints().size()) {
anchorMap = null;
// delete connections on deleted points
if (points.size() < polyline.getPoints().size()) {
for (ConnectionModel conn : getWidgetModel().getSourceConnections()) {
if (Integer.parseInt(conn.getSourceTerminal()) >= points.size()) {
conn.disconnect();
}
}
for (ConnectionModel conn : getWidgetModel().getTargetConnections()) {
if (Integer.parseInt(conn.getTargetTerminal()) >= points.size()) {
conn.disconnect();
}
}
}
}
// deselect the widget (this refreshes the polypoint drag
// handles)
int selectionState = getSelected();
setSelected(EditPart.SELECTED_NONE);
polyline.setPoints(points);
doRefreshVisuals(polyline);
// restore the selection state
setSelected(selectionState);
return false;
}
};
setPropertyChangeHandler(AbstractPolyModel.PROP_POINTS, pointsHandler);
IWidgetPropertyChangeHandler rotationHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
getWidgetModel().setPoints(PointsUtil.rotatePoints(getWidgetModel().getOriginalPoints().getCopy(), (Double) newValue), false);
return false;
}
};
setPropertyChangeHandler(AbstractPolyModel.PROP_ROTATION, rotationHandler);
}
Aggregations