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)));
}
}
}
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;
}
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));
}
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());
}
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();
}
}
Aggregations