Search in sources :

Example 11 with ConnectionModel

use of org.csstudio.opibuilder.model.ConnectionModel in project yamcs-studio by yamcs.

the class LinkingContainerEditpart method updateConnectionListForLinkedOpi.

private void updateConnectionListForLinkedOpi(DisplayModel displayModel) {
    connectionList = displayModel.getConnectionList();
    if (!connectionList.isEmpty()) {
        if (originalPoints != null)
            originalPoints.clear();
        else
            originalPoints = new HashMap<ConnectionModel, PointList>();
    }
    for (ConnectionModel conn : connectionList) {
        conn.setLoadedFromLinkedOpi(true);
        if (conn.getPoints() != null)
            originalPoints.put(conn, conn.getPoints().getCopy());
        conn.setScrollPane(((LinkingContainerFigure) getFigure()).getScrollPane());
    }
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ConnectionModel(org.csstudio.opibuilder.model.ConnectionModel)

Example 12 with ConnectionModel

use of org.csstudio.opibuilder.model.ConnectionModel in project yamcs-studio by yamcs.

the class LinkingContainerEditpart method updateConnectionList.

private void updateConnectionList() {
    if (connectionList == null || originalPoints == null)
        return;
    double scaleFactor = ((LinkingContainerFigure) getFigure()).getZoomManager().getZoom();
    final Point tranlateSize = getRelativeToRoot();
    tranlateSize.scale(scaleFactor);
    log.log(Level.FINEST, String.format("Relative to root translation (scaled by %s): %s ", scaleFactor, tranlateSize));
    Point scaledCropTranslation = new Point();
    if (cropTranslation != null)
        scaledCropTranslation = cropTranslation.getCopy();
    scaledCropTranslation.scale(scaleFactor);
    for (ConnectionModel conn : connectionList) {
        PointList points = originalPoints.get(conn).getCopy();
        if (points == null)
            continue;
        log.log(Level.FINER, "Connector: " + conn.getName());
        for (int i = 0; i < points.size(); i++) {
            Point point = points.getPoint(i);
            if (getWidgetModel().isAutoSize()) {
                point.translate(scaledCropTranslation);
                // box
                if (point.x() <= tranlateSize.x())
                    point.translate(conn.getLineWidth() / 2, 0);
                if (point.y() <= tranlateSize.y())
                    point.translate(0, conn.getLineWidth() / 2);
            }
            point.scale(scaleFactor);
            points.setPoint(point, i);
        }
        conn.setPoints(points);
    }
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) ConnectionModel(org.csstudio.opibuilder.model.ConnectionModel) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point)

Example 13 with ConnectionModel

use of org.csstudio.opibuilder.model.ConnectionModel in project yamcs-studio by yamcs.

the class LinkingContainerEditpart method performAutosize.

/**
 * Automatically set the container size according its children's geography size.
 */
@Override
public void performAutosize() {
    Rectangle childrenRange = GeometryUtil.getChildrenRange(this);
    if (connectionList != null) {
        for (ConnectionModel connModel : connectionList) {
            final PointList connectionPoints = connModel.getPoints();
            childrenRange.union(connectionPoints.getBounds());
        }
    }
    cropTranslation = new Point(-childrenRange.x, -childrenRange.y);
    getWidgetModel().setSize(new Dimension(childrenRange.width + figure.getInsets().left + figure.getInsets().right, childrenRange.height + figure.getInsets().top + figure.getInsets().bottom));
    for (Object editPart : getChildren()) {
        AbstractWidgetModel widget = ((AbstractBaseEditPart) editPart).getWidgetModel();
        widget.setLocation(widget.getLocation().translate(cropTranslation));
    }
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) AbstractBaseEditPart(org.csstudio.opibuilder.editparts.AbstractBaseEditPart) Rectangle(org.eclipse.draw2d.geometry.Rectangle) ConnectionModel(org.csstudio.opibuilder.model.ConnectionModel) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 14 with ConnectionModel

use of org.csstudio.opibuilder.model.ConnectionModel in project yamcs-studio by yamcs.

the class ReplaceWidgetCommand method redo.

@Override
public void redo() {
    index = container.getIndexOf(srcWidget);
    container.removeChild(srcWidget);
    container.addChild(index, targetWidget);
    for (ConnectionModel conn : sourceConnections) {
        if (conn.getSource() == srcWidget)
            conn.setSource(targetWidget);
    }
    for (ConnectionModel conn : targetConnections) {
        if (conn.getTarget() == srcWidget)
            conn.setTarget(targetWidget);
    }
    removeConnections(sourceConnections);
    removeConnections(targetConnections);
    List<AbstractWidgetModel> allDescendants = container.getAllDescendants();
    for (ConnectionModel conn : sourceConnections) {
        if (allDescendants.contains(conn.getSource()))
            conn.reconnect();
    }
    for (ConnectionModel conn : targetConnections) {
        if (allDescendants.contains(conn.getTarget()))
            conn.reconnect();
    }
}
Also used : AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) ConnectionModel(org.csstudio.opibuilder.model.ConnectionModel)

Example 15 with ConnectionModel

use of org.csstudio.opibuilder.model.ConnectionModel in project yamcs-studio by yamcs.

the class WidgetDeleteCommand 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)

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