use of org.csstudio.opibuilder.widgets.figures.MenuButtonFigure in project yamcs-studio by yamcs.
the class MenuButtonEditPart method doCreateFigure.
@Override
protected IFigure doCreateFigure() {
var model = getWidgetModel();
updatePropSheet(model.isActionsFromPV());
var figure = new MenuButtonFigure();
figure.setOpaque(!model.isTransparent());
figure.setText(model.getLabel());
figure.setDownArrowVisible(model.showDownArrow());
if (getExecutionMode() == ExecutionMode.RUN_MODE) {
figure.addMouseListener(new MouseListener() {
@Override
public void mouseDoubleClicked(MouseEvent me) {
}
@Override
public void mousePressed(MouseEvent me) {
if (me.button == 1 && figure.containsPoint(me.getLocation())) {
me.consume();
}
}
@Override
public void mouseReleased(MouseEvent me) {
// see https://github.com/ControlSystemStudio/cs-studio/issues/1818
if (me.button == 1 && getExecutionMode().equals(ExecutionMode.RUN_MODE) && figure.containsPoint(me.getLocation())) {
var cursorLocation = Display.getCurrent().getCursorLocation();
showMenu(me.getLocation(), cursorLocation.x, cursorLocation.y);
}
}
});
}
figure.addMouseMotionListener(new MouseMotionListener.Stub() {
@Override
public void mouseEntered(MouseEvent me) {
if (getExecutionMode().equals(ExecutionMode.RUN_MODE)) {
var backColor = figure.getBackgroundColor();
var darkColor = GraphicsUtil.mixColors(backColor.getRGB(), new RGB(0, 0, 0), 0.9);
figure.setBackgroundColor(CustomMediaFactory.getInstance().getColor(darkColor));
}
}
@Override
public void mouseExited(MouseEvent me) {
if (getExecutionMode().equals(ExecutionMode.RUN_MODE)) {
figure.setBackgroundColor(CustomMediaFactory.getInstance().getColor(getWidgetModel().getBackgroundColor()));
}
}
});
markAsControlPV(PROP_PVNAME, PROP_PVVALUE);
return figure;
}
use of org.csstudio.opibuilder.widgets.figures.MenuButtonFigure in project yamcs-studio by yamcs.
the class MenuButtonEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
setPropertyChangeHandler(PROP_PVNAME, (oldValue, newValue, figure) -> {
registerLoadActionsListener();
return false;
});
setPropertyChangeHandler(PROP_PVVALUE, (oldValue, newValue, refreshableFigure) -> {
if ((newValue != null) && (newValue instanceof Scalar)) {
((MenuButtonFigure) refreshableFigure).setText(VTypeHelper.getString((VType) newValue));
}
return true;
});
setPropertyChangeHandler(PROP_LABEL, (oldValue, newValue, refreshableFigure) -> {
((MenuButtonFigure) refreshableFigure).setText(newValue.toString());
return true;
});
setPropertyChangeHandler(PROP_TRANSPARENT, (oldValue, newValue, refreshableFigure) -> {
((MenuButtonFigure) refreshableFigure).setOpaque(!(Boolean) newValue);
return true;
});
setPropertyChangeHandler(PROP_SHOW_DOWN_ARROW, (oldValue, newValue, refreshableFigure) -> {
((MenuButtonFigure) refreshableFigure).setDownArrowVisible((boolean) newValue);
return true;
});
IWidgetPropertyChangeHandler handler = (oldValue, newValue, refreshableFigure) -> {
updatePropSheet((Boolean) newValue);
return false;
};
getWidgetModel().getProperty(PROP_ACTIONS_FROM_PV).addPropertyChangeListener(evt -> handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure()));
}
Aggregations