Search in sources :

Example 6 with AbstractWidgetProperty

use of org.csstudio.opibuilder.properties.AbstractWidgetProperty in project yamcs-studio by yamcs.

the class AbstractBaseEditPart method activate.

@Override
public void activate() {
    if (!isActive()) {
        super.activate();
        initFigure(getFigure());
        // add listener to all properties.
        for (String id : getWidgetModel().getAllPropertyIDs()) {
            AbstractWidgetProperty property = getWidgetModel().getProperty(id);
            if (property != null) {
                WidgetPropertyChangeListener listener = new WidgetPropertyChangeListener(this, property);
                property.addPropertyChangeListener(listener);
                propertyListenerMap.put(id, listener);
                property.setExecutionMode(executionMode);
                property.setWidgetModel(getWidgetModel());
            }
        }
        registerBasePropertyChangeHandlers();
        registerPropertyChangeHandlers();
        if (executionMode == ExecutionMode.RUN_MODE) {
            // hook open display action
            Set<String> allPropIds = getWidgetModel().getAllPropertyIDs();
            if (allPropIds.contains(AbstractWidgetModel.PROP_ACTIONS) && allPropIds.contains(AbstractWidgetModel.PROP_ENABLED)) {
                hookMouseClickAction();
            }
            // script and rules execution
            ScriptsInput scriptsInput = getWidgetModel().getScriptsInput();
            scriptDataList = new ArrayList<>(scriptsInput.getScriptList());
            for (RuleData rd : getWidgetModel().getRulesInput().getRuleDataList()) {
                scriptDataList.add(rd.convertToScriptData());
            }
            for (final ScriptData scriptData : scriptDataList) {
                final IPV[] pvArray = new IPV[scriptData.getPVList().size()];
                int i = 0;
                for (PVTuple pvTuple : scriptData.getPVList()) {
                    String pvName = pvTuple.pvName;
                    if (pvMap.containsKey(pvName)) {
                        pvArray[i] = pvMap.get(pvName);
                    } else {
                        try {
                            IPV pv = BOYPVFactory.createPV(pvName, false, 2);
                            pvMap.put(pvName, pv);
                            addToConnectionHandler(pvName, pv);
                            pvArray[i] = pv;
                        } catch (Exception e) {
                            String message = NLS.bind("Unable to connect to PV: {0}! \n" + "This may cause error when executing the script.", pvName);
                            OPIBuilderPlugin.getLogger().log(Level.WARNING, message, e);
                            ConsoleService.getInstance().writeError(message);
                            pvArray[i] = null;
                        }
                    }
                    i++;
                }
                ScriptService.getInstance().registerScript(scriptData, AbstractBaseEditPart.this, pvArray);
                UIBundlingThread.getInstance().addRunnable(new Runnable() {

                    @Override
                    public void run() {
                        if (!isActive()) {
                            // already deactivated
                            return;
                        }
                        hasStartedPVs = true;
                        for (IPV pv : pvArray) if (pv != null && !pv.isStarted())
                            try {
                                pv.start();
                            } catch (Exception e) {
                                OPIBuilderPlugin.getLogger().log(Level.WARNING, "Unable to start PV " + pv.getName(), // $NON-NLS-1$
                                e);
                            }
                    }
                });
            }
        }
        doActivate();
    }
    // Rap specified code
    displayDisposeListener = new Runnable() {

        @Override
        public void run() {
            deactivate();
        }
    };
}
Also used : AbstractWidgetProperty(org.csstudio.opibuilder.properties.AbstractWidgetProperty) ScriptData(org.csstudio.opibuilder.script.ScriptData) PVTuple(org.csstudio.opibuilder.script.PVTuple) WidgetPropertyChangeListener(org.csstudio.opibuilder.properties.WidgetPropertyChangeListener) IPV(org.csstudio.simplepv.IPV) Point(org.eclipse.draw2d.geometry.Point) RuleData(org.csstudio.opibuilder.script.RuleData) ScriptsInput(org.csstudio.opibuilder.script.ScriptsInput)

Example 7 with AbstractWidgetProperty

use of org.csstudio.opibuilder.properties.AbstractWidgetProperty in project yamcs-studio by yamcs.

the class PVWidgetEditpartDelegate method startUpdateSuppressTimer.

/**
 * Start the updateSuppressTimer. All property change listeners of PV_Value property will
 * temporarily removed until timer is due.
 */
protected synchronized void startUpdateSuppressTimer() {
    AbstractWidgetProperty pvValueProperty = editpart.getWidgetModel().getProperty(controlPVValuePropId);
    pvValueListeners = pvValueProperty.getAllPropertyChangeListeners();
    pvValueProperty.removeAllPropertyChangeListeners();
    updateSuppressTimer.start(timerTask, getUpdateSuppressTime());
}
Also used : AbstractWidgetProperty(org.csstudio.opibuilder.properties.AbstractWidgetProperty)

Example 8 with AbstractWidgetProperty

use of org.csstudio.opibuilder.properties.AbstractWidgetProperty in project yamcs-studio by yamcs.

the class PVWidgetEditpartDelegate method initUpdateSuppressTimer.

/**
 * Initialize the updateSuppressTimer
 */
private synchronized void initUpdateSuppressTimer() {
    if (updateSuppressTimer == null)
        updateSuppressTimer = new OPITimer();
    if (timerTask == null)
        timerTask = new Runnable() {

            @Override
            public void run() {
                AbstractWidgetProperty pvValueProperty = editpart.getWidgetModel().getProperty(controlPVValuePropId);
                // recover update
                if (pvValueListeners != null) {
                    for (PropertyChangeListener listener : pvValueListeners) {
                        pvValueProperty.addPropertyChangeListener(listener);
                    }
                }
                // forcefully set PV_Value property again
                pvValueProperty.setPropertyValue(pvValueProperty.getPropertyValue(), true);
            }
        };
}
Also used : PropertyChangeListener(java.beans.PropertyChangeListener) AbstractWidgetProperty(org.csstudio.opibuilder.properties.AbstractWidgetProperty) OPITimer(org.csstudio.opibuilder.util.OPITimer)

Example 9 with AbstractWidgetProperty

use of org.csstudio.opibuilder.properties.AbstractWidgetProperty in project yamcs-studio by yamcs.

the class AbstractWidgetModel method setPropertyVisibleAndSavable.

/**
 *Set if property should be visible in property sheet and if savable to xml file.
 * @param prop_id id of the property
 * @param visible true if visible in property sheet.
 * @param isSavable true if this property should be saved to xml file.
 */
public void setPropertyVisibleAndSavable(final String prop_id, final boolean visible, final boolean isSavable) {
    checkPropertyExist(prop_id);
    AbstractWidgetProperty property = propertyMap.get(prop_id);
    if (property.setVisibleInPropSheet(visible)) {
        if (visible)
            propertyDescriptors.put(prop_id, property.getPropertyDescriptor());
        else
            propertyDescriptors.remove(prop_id);
    }
    property.setSavable(isSavable);
}
Also used : AbstractWidgetProperty(org.csstudio.opibuilder.properties.AbstractWidgetProperty)

Example 10 with AbstractWidgetProperty

use of org.csstudio.opibuilder.properties.AbstractWidgetProperty in project yamcs-studio by yamcs.

the class AbstractWidgetModel method removeProperty.

/**
 *Remove a property from the model.
 * @param prop_id
 */
public synchronized void removeProperty(final String prop_id) {
    if (!propertyMap.containsKey(prop_id))
        return;
    AbstractWidgetProperty property = propertyMap.get(prop_id);
    property.removeAllPropertyChangeListeners();
    if (property.isVisibleInPropSheet())
        propertyDescriptors.remove(prop_id);
    propertyMap.remove(prop_id);
}
Also used : AbstractWidgetProperty(org.csstudio.opibuilder.properties.AbstractWidgetProperty)

Aggregations

AbstractWidgetProperty (org.csstudio.opibuilder.properties.AbstractWidgetProperty)14 PropertyChangeListener (java.beans.PropertyChangeListener)4 PropertyChangeEvent (java.beans.PropertyChangeEvent)3 List (java.util.List)1 BooleanProperty (org.csstudio.opibuilder.properties.BooleanProperty)1 ColorProperty (org.csstudio.opibuilder.properties.ColorProperty)1 ComboProperty (org.csstudio.opibuilder.properties.ComboProperty)1 IntegerProperty (org.csstudio.opibuilder.properties.IntegerProperty)1 PointListProperty (org.csstudio.opibuilder.properties.PointListProperty)1 StringProperty (org.csstudio.opibuilder.properties.StringProperty)1 WidgetPropertyChangeListener (org.csstudio.opibuilder.properties.WidgetPropertyChangeListener)1 PVTuple (org.csstudio.opibuilder.script.PVTuple)1 RuleData (org.csstudio.opibuilder.script.RuleData)1 ScriptData (org.csstudio.opibuilder.script.ScriptData)1 ScriptsInput (org.csstudio.opibuilder.script.ScriptsInput)1 OPITimer (org.csstudio.opibuilder.util.OPITimer)1 ROIProperty (org.csstudio.opibuilder.widgets.model.IntensityGraphModel.ROIProperty)1 IPV (org.csstudio.simplepv.IPV)1 IntensityGraphFigure (org.csstudio.swt.widgets.figures.IntensityGraphFigure)1 Point (org.eclipse.draw2d.geometry.Point)1