Search in sources :

Example 36 with AbstractWidgetModel

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

the class GroupingContainerEditPart method resizeChildren.

private void resizeChildren(int newValue, int oldValue, boolean isWidth) {
    if (!getWidgetModel().isLocked())
        return;
    if (getExecutionMode() == ExecutionMode.RUN_MODE && getWidgetModel().getRootDisplayModel().getDisplayScaleData().isAutoScaleWidgets() && (getWidgetModel().getScaleOptions().isHeightScalable() || getWidgetModel().getScaleOptions().isWidthScalable()))
        return;
    double ratio = (newValue - oldValue) / (double) oldValue;
    for (AbstractWidgetModel child : getWidgetModel().getChildren()) {
        if (isWidth) {
            child.setX((int) (child.getX() * (1 + ratio)));
            child.setWidth((int) (child.getWidth() * (1 + ratio)));
        } else {
            child.setY((int) (child.getY() * (1 + ratio)));
            child.setHeight((int) (child.getHeight() * (1 + ratio)));
        }
    }
}
Also used : AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel)

Example 37 with AbstractWidgetModel

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

the class TabEditPart method doCreateFigure.

@Override
protected IFigure doCreateFigure() {
    TabFigure tabFigure = new TabFigure();
    tabFigure.setHorizontal(getWidgetModel().isHorizontal());
    tabFigure.setMinimumTabHeight(getWidgetModel().getMinimumTabHeight());
    tabFigure.addTabListener(new ITabListener() {

        @Override
        public void activeTabIndexChanged(int oldIndex, int newIndex) {
            for (AbstractWidgetModel child : getWidgetModel().getChildren()) child.setPropertyValue(AbstractWidgetModel.PROP_VISIBLE, false);
            getWidgetModel().getChildren().get(newIndex).setPropertyValue(AbstractWidgetModel.PROP_VISIBLE, true);
        // if (getExecutionMode() == ExecutionMode.RUN_MODE)
        // setPropertyValue(TabModel.PROP_ACTIVE_TAB, newIndex);
        }
    });
    return tabFigure;
}
Also used : ITabListener(org.csstudio.swt.widgets.figures.TabFigure.ITabListener) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) TabFigure(org.csstudio.swt.widgets.figures.TabFigure)

Example 38 with AbstractWidgetModel

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

the class AbstractFixRatioSizeFeedbackFactory method showSizeOnDropFeedback.

@Override
public void showSizeOnDropFeedback(CreateRequest request, IFigure feedbackFigure, Insets insets) {
    Point p = new Point(request.getLocation().getCopy());
    IFigure feedback = getSizeOnDropFeedback(request);
    feedback.translateToRelative(p);
    Dimension size = request.getSize().getCopy();
    feedback.translateToRelative(size);
    if (isSquareSizeRequired((AbstractWidgetModel) request.getNewObject())) {
        if (size.width < getMinimumWidth() && size.height < getMinimumWidth())
            size.width = getMinimumWidth();
        else
            size.width = Math.max(size.width, getWidthFromHeight(size.height, (AbstractWidgetModel) request.getNewObject()));
        size.height = getHeightFromWidth(size.width, (AbstractWidgetModel) request.getNewObject());
    }
    feedback.setBounds(new Rectangle(p, size).expand(insets));
}
Also used : AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) IFigure(org.eclipse.draw2d.IFigure)

Example 39 with AbstractWidgetModel

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

the class ShowMacrosAction method run.

@Override
public void run(IAction action) {
    AbstractWidgetModel widget = (AbstractWidgetModel) getSelectedWidget().getModel();
    String message = NLS.bind("The predefined macros of {0}:\n", widget.getName());
    StringBuilder sb = new StringBuilder(message);
    Map<String, String> macroMap = OPIBuilderMacroUtil.getWidgetMacroMap(widget);
    for (final Map.Entry<String, String> entry : macroMap.entrySet()) {
        sb.append(entry.getKey() + "=" + entry.getValue() + "\n");
    }
    sb.append("\n");
    sb.append("Note: Macros are loaded during OPI opening, so this won't reflect the macro changes after opening." + "To reflect the latest changes, please reopen the OPI and show macros again.");
    // show the dialog first, because on some linux systems the console print brings the workbench window to top,
    // blocking entire CSS
    MessageDialog.openInformation(targetPart.getSite().getShell(), "Predefined Macros", sb.toString());
    ConsoleService.getInstance().writeInfo(sb.toString());
}
Also used : AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) Map(java.util.Map)

Example 40 with AbstractWidgetModel

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

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