Search in sources :

Example 66 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 67 with AbstractWidgetModel

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

the class ChangeOrientationAction method run.

@Override
public void run() {
    CompoundCommand compoundCommand = new CompoundCommand(orientationType.getLabel());
    for (AbstractWidgetModel widgetModel : getSelectedWidgetModels()) {
        compoundCommand.add(new ChangeOrientationCommand(widgetModel, orientationType));
    }
    execute(compoundCommand);
}
Also used : AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) ChangeOrientationCommand(org.csstudio.opibuilder.commands.ChangeOrientationCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 68 with AbstractWidgetModel

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

the class DistributeWidgetsAction method getVerticalCompressCommand.

private Command getVerticalCompressCommand() {
    AbstractWidgetModel[] sortedModelArray = getSortedModelArray(false);
    CompoundCommand cmd = new CompoundCommand("Vertical Compress Distribution");
    int startX = sortedModelArray[0].getY() + sortedModelArray[0].getHeight();
    for (int i = 1; i < sortedModelArray.length; i++) {
        cmd.add(new SetWidgetPropertyCommand(sortedModelArray[i], AbstractWidgetModel.PROP_YPOS, startX));
        startX += sortedModelArray[i].getHeight();
    }
    return cmd;
}
Also used : SetWidgetPropertyCommand(org.csstudio.opibuilder.commands.SetWidgetPropertyCommand) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 69 with AbstractWidgetModel

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

the class DistributeWidgetsAction method getHorizontalCenterCommand.

private Command getHorizontalCenterCommand() {
    AbstractWidgetModel[] sortedModelArray = getSortedModelArray(true);
    CompoundCommand cmd = new CompoundCommand("Horizontal Center Distribution");
    int averageGap = (getCenterLoc(sortedModelArray[sortedModelArray.length - 1], true) - getCenterLoc(sortedModelArray[0], true)) / (sortedModelArray.length - 1);
    int startX = getCenterLoc(sortedModelArray[0], true);
    for (int i = 1; i < sortedModelArray.length - 1; i++) {
        cmd.add(new SetWidgetPropertyCommand(sortedModelArray[i], AbstractWidgetModel.PROP_XPOS, startX + averageGap - sortedModelArray[i].getWidth() / 2));
        startX += averageGap;
    }
    return cmd;
}
Also used : SetWidgetPropertyCommand(org.csstudio.opibuilder.commands.SetWidgetPropertyCommand) AbstractWidgetModel(org.csstudio.opibuilder.model.AbstractWidgetModel) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 70 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)

Aggregations

AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)82 AbstractContainerModel (org.csstudio.opibuilder.model.AbstractContainerModel)27 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)22 Rectangle (org.eclipse.draw2d.geometry.Rectangle)18 AbstractBaseEditPart (org.csstudio.opibuilder.editparts.AbstractBaseEditPart)17 ArrayList (java.util.ArrayList)15 Point (org.eclipse.draw2d.geometry.Point)14 SetWidgetPropertyCommand (org.csstudio.opibuilder.commands.SetWidgetPropertyCommand)12 ConnectionModel (org.csstudio.opibuilder.model.ConnectionModel)10 DisplayModel (org.csstudio.opibuilder.model.DisplayModel)9 IFigure (org.eclipse.draw2d.IFigure)9 PropertyChangeEvent (java.beans.PropertyChangeEvent)8 PropertyChangeListener (java.beans.PropertyChangeListener)8 Dimension (org.eclipse.draw2d.geometry.Dimension)8 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)7 EditPart (org.eclipse.gef.EditPart)7 PointList (org.eclipse.draw2d.geometry.PointList)6 List (java.util.List)5 AddWidgetCommand (org.csstudio.opibuilder.commands.AddWidgetCommand)5 WidgetCreateCommand (org.csstudio.opibuilder.commands.WidgetCreateCommand)5