Search in sources :

Example 11 with AbstractWidgetModel

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

the class CloneCommand method getWidgetsFromClipboard.

/**
 * Returns a list with widget models that are currently stored on the
 * clipboard.
 *
 * @return a list with widget models or an empty list
 */
@SuppressWarnings("unchecked")
private List<AbstractWidgetModel> getWidgetsFromClipboard() {
    Clipboard clipboard = new Clipboard(Display.getCurrent());
    List<AbstractWidgetModel> result = (List<AbstractWidgetModel>) clipboard.getContents(OPIWidgetsTransfer.getInstance());
    return result;
}
Also used : AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) List(java.util.List) LinkedList(java.util.LinkedList) Clipboard(org.eclipse.swt.dnd.Clipboard)

Example 12 with AbstractWidgetModel

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

the class DeleteGuideCommand method undo.

/**
 * {@inheritDoc}
 */
@Override
public void undo() {
    parent.addGuide(guide);
    Iterator<AbstractWidgetModel> iter = oldParts.keySet().iterator();
    while (iter.hasNext()) {
        AbstractWidgetModel model = iter.next();
        guide.attachPart(model, ((Integer) oldParts.get(model)).intValue());
    }
}
Also used : AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel)

Example 13 with AbstractWidgetModel

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

the class MoveGuideCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    guide.setPosition(guide.getPosition() + pDelta);
    Iterator<AbstractWidgetModel> iter = guide.getAttachedModels().iterator();
    while (iter.hasNext()) {
        AbstractWidgetModel model = iter.next();
        Point location = model.getLocation();
        if (guide.isHorizontal()) {
            location.y += pDelta;
        } else {
            location.x += pDelta;
        }
        model.setLocation(location.x, location.y);
    }
}
Also used : AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) Point(org.eclipse.draw2d.geometry.Point)

Example 14 with AbstractWidgetModel

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

the class MoveGuideCommand method undo.

/**
 * {@inheritDoc}
 */
@Override
public void undo() {
    guide.setPosition(guide.getPosition() - pDelta);
    Iterator<AbstractWidgetModel> iter = guide.getAttachedModels().iterator();
    while (iter.hasNext()) {
        AbstractWidgetModel model = iter.next();
        Point location = model.getLocation();
        if (guide.isHorizontal()) {
            location.y -= pDelta;
        } else {
            location.x -= pDelta;
        }
        model.setLocation(location.x, location.y);
    }
}
Also used : AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) Point(org.eclipse.draw2d.geometry.Point)

Example 15 with AbstractWidgetModel

use of org.csstudio.opibuilder.model.AbstractWidgetModel 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)

Aggregations

AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)50 AbstractContainerModel (org.csstudio.opibuilder.model.AbstractContainerModel)15 ArrayList (java.util.ArrayList)11 AbstractBaseEditPart (org.csstudio.opibuilder.editparts.AbstractBaseEditPart)10 Point (org.eclipse.draw2d.geometry.Point)7 Rectangle (org.eclipse.draw2d.geometry.Rectangle)7 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)7 EditPart (org.eclipse.gef.EditPart)6 ConnectionModel (org.csstudio.opibuilder.model.ConnectionModel)5 DisplayModel (org.csstudio.opibuilder.model.DisplayModel)5 IFigure (org.eclipse.draw2d.IFigure)5 PropertyChangeListener (java.beans.PropertyChangeListener)4 ExecutionMode (org.csstudio.opibuilder.editparts.ExecutionMode)4 AddWidgetCommand (org.csstudio.opibuilder.commands.AddWidgetCommand)3 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)3 ITextFigure (org.csstudio.swt.widgets.figures.ITextFigure)3 EditPolicy (org.eclipse.gef.EditPolicy)3 PropertyChangeEvent (java.beans.PropertyChangeEvent)2 List (java.util.List)2 WidgetCreateCommand (org.csstudio.opibuilder.commands.WidgetCreateCommand)2