Search in sources :

Example 1 with ComboFigure

use of org.csstudio.opibuilder.widgets.figures.ComboFigure in project yamcs-studio by yamcs.

the class ComboEditPart method doCreateFigure.

/**
 * {@inheritDoc}
 */
@Override
protected IFigure doCreateFigure() {
    final ComboModel model = getWidgetModel();
    updatePropSheet(model.isItemsFromPV());
    ComboFigure comboFigure = new ComboFigure(this);
    combo = comboFigure.getSWTWidget();
    List<String> items = getWidgetModel().getItems();
    updateCombo(items);
    markAsControlPV(AbstractPVWidgetModel.PROP_PVNAME, AbstractPVWidgetModel.PROP_PVVALUE);
    return comboFigure;
}
Also used : ComboModel(org.csstudio.opibuilder.widgets.model.ComboModel) ComboFigure(org.csstudio.opibuilder.widgets.figures.ComboFigure)

Example 2 with ComboFigure

use of org.csstudio.opibuilder.widgets.figures.ComboFigure in project yamcs-studio by yamcs.

the class ComboEditPart method registerPropertyChangeHandlers.

@Override
@SuppressWarnings("unchecked")
protected void registerPropertyChangeHandlers() {
    setPropertyChangeHandler(PROP_PVNAME, (oldValue, newValue, figure) -> {
        registerLoadItemsListener();
        return false;
    });
    autoSizeWidget((ComboFigure) getFigure());
    setPropertyChangeHandler(PROP_PVVALUE, (oldValue, newValue, refreshableFigure) -> {
        if (newValue != null) {
            var stringValue = VTypeHelper.getString((VType) newValue);
            if (Arrays.asList(combo.getItems()).contains(stringValue)) {
                combo.setText(stringValue);
            } else {
                combo.deselectAll();
            // 
            // if(getWidgetModel().isBorderAlarmSensitve())
            // autoSizeWidget((ComboFigure) refreshableFigure);
            }
        }
        return true;
    });
    setPropertyChangeHandler(PROP_ITEMS, (oldValue, newValue, refreshableFigure) -> {
        if (newValue != null && newValue instanceof List) {
            updateCombo((List<String>) newValue);
            if (getWidgetModel().isItemsFromPV()) {
                combo.setText(VTypeHelper.getString(getPVValue(PROP_PVNAME)));
            }
        }
        return true;
    });
    IWidgetPropertyChangeHandler handler = (oldValue, newValue, refreshableFigure) -> {
        updatePropSheet((Boolean) newValue);
        return false;
    };
    getWidgetModel().getProperty(PROP_ITEMS_FROM_PV).addPropertyChangeListener(evt -> handler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure()));
    // size change handlers--always apply the default height
    IWidgetPropertyChangeHandler handle = (oldValue, newValue, figure) -> {
        autoSizeWidget((ComboFigure) figure);
        return true;
    };
    setPropertyChangeHandler(PROP_WIDTH, handle);
    setPropertyChangeHandler(PROP_HEIGHT, handle);
    setPropertyChangeHandler(PROP_BORDER_STYLE, handle);
    setPropertyChangeHandler(PROP_BORDER_WIDTH, handle);
    setPropertyChangeHandler(PROP_FONT, handle);
}
Also used : PROP_PVVALUE(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVVALUE) Arrays(java.util.Arrays) PROP_BORDER_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_WIDTH) ComboModel(org.csstudio.opibuilder.widgets.model.ComboModel) PROP_HEIGHT(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT) PROP_ITEMS_FROM_PV(org.csstudio.opibuilder.widgets.model.ComboModel.PROP_ITEMS_FROM_PV) PROP_PVNAME(org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVNAME) IFigure(org.eclipse.draw2d.IFigure) PROP_ITEMS(org.csstudio.opibuilder.widgets.model.ComboModel.PROP_ITEMS) IPV(org.yamcs.studio.data.IPV) ComboFigure(org.csstudio.opibuilder.widgets.figures.ComboFigure) IPVListener(org.yamcs.studio.data.IPVListener) ExecutionMode(org.csstudio.opibuilder.editparts.ExecutionMode) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Combo(org.eclipse.swt.widgets.Combo) VTypeHelper(org.yamcs.studio.data.VTypeHelper) VEnum(org.yamcs.studio.data.vtype.VEnum) PROP_FONT(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_FONT) List(java.util.List) VType(org.yamcs.studio.data.vtype.VType) AbstractPVWidgetEditPart(org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart) SelectionEvent(org.eclipse.swt.events.SelectionEvent) PROP_BORDER_STYLE(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_STYLE) PROP_WIDTH(org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) SelectionListener(org.eclipse.swt.events.SelectionListener) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) List(java.util.List) ComboFigure(org.csstudio.opibuilder.widgets.figures.ComboFigure)

Aggregations

ComboFigure (org.csstudio.opibuilder.widgets.figures.ComboFigure)2 ComboModel (org.csstudio.opibuilder.widgets.model.ComboModel)2 Arrays (java.util.Arrays)1 List (java.util.List)1 AbstractPVWidgetEditPart (org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart)1 ExecutionMode (org.csstudio.opibuilder.editparts.ExecutionMode)1 PROP_BORDER_STYLE (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_STYLE)1 PROP_BORDER_WIDTH (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_BORDER_WIDTH)1 PROP_FONT (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_FONT)1 PROP_HEIGHT (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_HEIGHT)1 PROP_WIDTH (org.csstudio.opibuilder.model.AbstractWidgetModel.PROP_WIDTH)1 PROP_PVNAME (org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVNAME)1 PROP_PVVALUE (org.csstudio.opibuilder.model.IPVWidgetModel.PROP_PVVALUE)1 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)1 PROP_ITEMS (org.csstudio.opibuilder.widgets.model.ComboModel.PROP_ITEMS)1 PROP_ITEMS_FROM_PV (org.csstudio.opibuilder.widgets.model.ComboModel.PROP_ITEMS_FROM_PV)1 IFigure (org.eclipse.draw2d.IFigure)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1