Search in sources :

Example 6 with ConnectionModel

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();
}
Also used : ConnectionModel(org.csstudio.opibuilder.model.ConnectionModel)

Example 7 with ConnectionModel

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;
}
Also used : AbstractContainerModel(org.csstudio.opibuilder.model.AbstractContainerModel) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) ArrayList(java.util.ArrayList) ConnectionModel(org.csstudio.opibuilder.model.ConnectionModel)

Example 8 with ConnectionModel

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);
}
Also used : ConnectionModel(org.csstudio.opibuilder.model.ConnectionModel)

Example 9 with ConnectionModel

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();
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) ConnectionModel(org.csstudio.opibuilder.model.ConnectionModel)

Example 10 with ConnectionModel

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);
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) Polyline(org.eclipse.draw2d.Polyline) ConnectionModel(org.csstudio.opibuilder.model.ConnectionModel) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

ConnectionModel (org.csstudio.opibuilder.model.ConnectionModel)18 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)10 PointList (org.eclipse.draw2d.geometry.PointList)8 ArrayList (java.util.ArrayList)7 AbstractContainerModel (org.csstudio.opibuilder.model.AbstractContainerModel)6 DisplayModel (org.csstudio.opibuilder.model.DisplayModel)4 SetWidgetPropertyCommand (org.csstudio.opibuilder.commands.SetWidgetPropertyCommand)3 LineAwareElement (org.csstudio.opibuilder.persistence.LineAwareXMLParser.LineAwareElement)3 Point (org.eclipse.draw2d.geometry.Point)3 Element (org.jdom.Element)3 IOException (java.io.IOException)2 Iterator (java.util.Iterator)2 List (java.util.List)2 ConnectionReconnectCommand (org.csstudio.opibuilder.commands.ConnectionReconnectCommand)2 AbstractBaseEditPart (org.csstudio.opibuilder.editparts.AbstractBaseEditPart)2 ConnectionAnchor (org.eclipse.draw2d.ConnectionAnchor)2 Polyline (org.eclipse.draw2d.Polyline)2 Rectangle (org.eclipse.draw2d.geometry.Rectangle)2 JDOMException (org.jdom.JDOMException)2 HashMap (java.util.HashMap)1