Search in sources :

Example 16 with StringProperty

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

the class XYGraphModel method addTraceProperty.

private void addTraceProperty(TraceProperty traceProperty, int traceIndex) {
    String propID = makeTracePropID(traceProperty.propIDPre, traceIndex);
    WidgetPropertyCategory category = new NameDefinedCategory("Trace " + traceIndex);
    switch(traceProperty) {
        case NAME:
            addProperty(new StringProperty(propID, traceProperty.toString(), category, "$(" + makeTracePropID(TraceProperty.YPV.propIDPre, traceIndex) + ")"));
            break;
        case ANTI_ALIAS:
            // case CHRONOLOGICAL:
            addProperty(new BooleanProperty(propID, traceProperty.toString(), category, true));
            break;
        case BUFFER_SIZE:
            addProperty(new IntegerProperty(propID, traceProperty.toString(), category, DEFAULT_BUFFER_SIZE, 1, MAX_BUFFER_SIZE));
            break;
        case CONCATENATE_DATA:
            addProperty(new BooleanProperty(propID, traceProperty.toString(), category, true));
            break;
        // break;
        case LINE_WIDTH:
            addProperty(new IntegerProperty(propID, traceProperty.toString(), category, 1, 1, 100));
            break;
        case PLOTMODE:
            addProperty(new ComboProperty(propID, traceProperty.toString(), category, PlotMode.stringValues(), 0));
            break;
        case POINT_SIZE:
            addProperty(new IntegerProperty(propID, traceProperty.toString(), category, 4, 1, 200));
            break;
        case POINT_STYLE:
            addProperty(new ComboProperty(propID, traceProperty.toString(), category, PointStyle.stringValues(), 0));
            break;
        case TRACE_COLOR:
            addProperty(new ColorProperty(propID, traceProperty.toString(), category, XYGraph.DEFAULT_TRACES_COLOR[traceIndex % XYGraph.DEFAULT_TRACES_COLOR.length]));
            break;
        case TRACE_TYPE:
            addProperty(new ComboProperty(propID, traceProperty.toString(), category, TraceType.stringValues(), 0));
            break;
        // break;
        case UPDATE_DELAY:
            addProperty(new IntegerProperty(propID, traceProperty.toString(), category, 100, 0, 655350));
            break;
        case UPDATE_MODE:
            addProperty(new ComboProperty(propID, traceProperty.toString(), category, UpdateMode.stringValues(), 0));
            break;
        case XAXIS_INDEX:
            addProperty(new ComboProperty(propID, traceProperty.toString(), category, AXES_ARRAY, 0));
            break;
        case XPV:
            addPVProperty(new PVNameProperty(propID, traceProperty.toString(), category, ""), new PVValueProperty(makeTracePropID(TraceProperty.XPV_VALUE.propIDPre, traceIndex), null));
            break;
        case YPV:
            addPVProperty(new PVNameProperty(propID, traceProperty.toString(), category, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            traceIndex == 0 ? "$(" + PROP_PVNAME + ")" : ""), new PVValueProperty(makeTracePropID(TraceProperty.YPV_VALUE.propIDPre, traceIndex), null));
            break;
        case YAXIS_INDEX:
            addProperty(new ComboProperty(propID, traceProperty.toString(), category, AXES_ARRAY, 1));
            break;
        case VISIBLE:
            addProperty(new BooleanProperty(propID, traceProperty.toString(), category, true));
            break;
        default:
            break;
    }
}
Also used : ComboProperty(org.csstudio.opibuilder.properties.ComboProperty) IntegerProperty(org.csstudio.opibuilder.properties.IntegerProperty) BooleanProperty(org.csstudio.opibuilder.properties.BooleanProperty) StringProperty(org.csstudio.opibuilder.properties.StringProperty) WidgetPropertyCategory(org.csstudio.opibuilder.properties.WidgetPropertyCategory) PVValueProperty(org.csstudio.opibuilder.properties.PVValueProperty) NameDefinedCategory(org.csstudio.opibuilder.properties.NameDefinedCategory) ColorProperty(org.csstudio.opibuilder.properties.ColorProperty) PVNameProperty(org.csstudio.opibuilder.properties.PVNameProperty)

Example 17 with StringProperty

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

the class PVWidgetEditpartDelegate method doActivate.

public void doActivate() {
    saveFigureOKStatus(editpart.getFigure());
    if (editpart.getExecutionMode() == ExecutionMode.RUN_MODE) {
        pvMap.clear();
        final Map<StringProperty, PVValueProperty> pvPropertyMap = editpart.getWidgetModel().getPVMap();
        for (final StringProperty sp : pvPropertyMap.keySet()) {
            if (sp.getPropertyValue() == null || ((String) sp.getPropertyValue()).trim().length() <= 0)
                continue;
            try {
                IPV pv = BOYPVFactory.createPV((String) sp.getPropertyValue(), isAllValuesBuffered);
                pvMap.put(sp.getPropertyID(), pv);
                editpart.addToConnectionHandler((String) sp.getPropertyValue(), pv);
                WidgetPVListener pvListener = new WidgetPVListener(sp.getPropertyID());
                pv.addListener(pvListener);
                pvListenerMap.put(sp.getPropertyID(), pvListener);
            } catch (Exception e) {
                OPIBuilderPlugin.getLogger().log(Level.WARNING, "Unable to connect to PV:" + (String) sp.getPropertyValue(), // $NON-NLS-1$
                e);
            }
        }
    }
}
Also used : StringProperty(org.csstudio.opibuilder.properties.StringProperty) PVValueProperty(org.csstudio.opibuilder.properties.PVValueProperty) IPV(org.csstudio.simplepv.IPV)

Example 18 with StringProperty

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

the class PVWidgetEditpartDelegate method registerBasePropertyChangeHandlers.

public void registerBasePropertyChangeHandlers() {
    IWidgetPropertyChangeHandler borderHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            editpart.setFigureBorder(editpart.calculateBorder());
            return true;
        }
    };
    editpart.setPropertyChangeHandler(IPVWidgetModel.PROP_BORDER_ALARMSENSITIVE, borderHandler);
    // value
    IWidgetPropertyChangeHandler valueHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(final Object oldValue, final Object newValue, final IFigure figure) {
            // No valid value is given. Do nothing.
            if (newValue == null || !(newValue instanceof VType))
                return false;
            AlarmSeverity newSeverity = VTypeHelper.getAlarmSeverity((VType) newValue);
            if (newSeverity == null)
                return false;
            if (newSeverity != alarmSeverity) {
                alarmSeverity = newSeverity;
                fireAlarmSeverityChanged(newSeverity, figure);
            }
            return true;
        }
    };
    editpart.setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVVALUE, valueHandler);
    // Border Alarm Sensitive
    addAlarmSeverityListener(new AlarmSeverityListener() {

        @Override
        public boolean severityChanged(AlarmSeverity severity, IFigure figure) {
            if (!isBorderAlarmSensitive)
                return false;
            editpart.setFigureBorder(editpart.calculateBorder());
            return true;
        }
    });
    // BackColor Alarm Sensitive
    addAlarmSeverityListener(new AlarmSeverityListener() {

        @Override
        public boolean severityChanged(AlarmSeverity severity, IFigure figure) {
            if (!isBackColorAlarmSensitive)
                return false;
            figure.setBackgroundColor(calculateBackColor());
            return true;
        }
    });
    // ForeColor Alarm Sensitive
    addAlarmSeverityListener(new AlarmSeverityListener() {

        @Override
        public boolean severityChanged(AlarmSeverity severity, IFigure figure) {
            if (!isForeColorAlarmSensitive)
                return false;
            figure.setForegroundColor(calculateForeColor());
            return true;
        }
    });
    // Pulsing Alarm Sensitive
    addAlarmSeverityListener(new AlarmSeverityListener() {

        @Override
        public boolean severityChanged(AlarmSeverity severity, IFigure figure) {
            if (!isAlarmPulsing)
                return false;
            if (severity == AlarmSeverity.MAJOR || severity == AlarmSeverity.MINOR) {
                startPulsing();
            } else {
                stopPulsing();
            }
            return true;
        }
    });
    class PVNamePropertyChangeHandler implements IWidgetPropertyChangeHandler {

        private String pvNamePropID;

        public PVNamePropertyChangeHandler(String pvNamePropID) {
            this.pvNamePropID = pvNamePropID;
        }

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            IPV oldPV = pvMap.get(pvNamePropID);
            editpart.removeFromConnectionHandler((String) oldValue);
            if (oldPV != null) {
                oldPV.stop();
                oldPV.removeListener(pvListenerMap.get(pvNamePropID));
            }
            pvMap.remove(pvNamePropID);
            String newPVName = ((String) newValue).trim();
            if (newPVName.length() <= 0)
                return false;
            try {
                lastWriteAccess = null;
                IPV newPV = BOYPVFactory.createPV(newPVName, isAllValuesBuffered);
                WidgetPVListener pvListener = new WidgetPVListener(pvNamePropID);
                newPV.addListener(pvListener);
                pvMap.put(pvNamePropID, newPV);
                editpart.addToConnectionHandler(newPVName, newPV);
                pvListenerMap.put(pvNamePropID, pvListener);
                newPV.start();
            } catch (Exception e) {
                OPIBuilderPlugin.getLogger().log(Level.WARNING, // $NON-NLS-1$
                "Unable to connect to PV:" + newPVName, e);
            }
            return false;
        }
    }
    // PV name
    for (StringProperty pvNameProperty : editpart.getWidgetModel().getPVMap().keySet()) {
        if (editpart.getExecutionMode() == ExecutionMode.RUN_MODE)
            editpart.setPropertyChangeHandler(pvNameProperty.getPropertyID(), new PVNamePropertyChangeHandler(pvNameProperty.getPropertyID()));
    }
    if (editpart.getExecutionMode() == ExecutionMode.EDIT_MODE)
        editpart.getWidgetModel().getProperty(IPVWidgetModel.PROP_PVNAME).addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                // reselect the widget to update feedback.
                int selected = editpart.getSelected();
                if (selected != EditPart.SELECTED_NONE) {
                    editpart.setSelected(EditPart.SELECTED_NONE);
                    editpart.setSelected(selected);
                }
            }
        });
    IWidgetPropertyChangeHandler backColorHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            saveBackColor = ((OPIColor) newValue).getSWTColor();
            return false;
        }
    };
    editpart.setPropertyChangeHandler(AbstractWidgetModel.PROP_COLOR_BACKGROUND, backColorHandler);
    IWidgetPropertyChangeHandler foreColorHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            saveForeColor = ((OPIColor) newValue).getSWTColor();
            return false;
        }
    };
    editpart.setPropertyChangeHandler(AbstractWidgetModel.PROP_COLOR_FOREGROUND, foreColorHandler);
    IWidgetPropertyChangeHandler backColorAlarmSensitiveHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            isBackColorAlarmSensitive = (Boolean) newValue;
            figure.setBackgroundColor(calculateBackColor());
            return true;
        }
    };
    editpart.setPropertyChangeHandler(AbstractPVWidgetModel.PROP_BACKCOLOR_ALARMSENSITIVE, backColorAlarmSensitiveHandler);
    IWidgetPropertyChangeHandler foreColorAlarmSensitiveHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            isForeColorAlarmSensitive = (Boolean) newValue;
            figure.setForegroundColor(calculateForeColor());
            return true;
        }
    };
    editpart.setPropertyChangeHandler(AbstractPVWidgetModel.PROP_FORECOLOR_ALARMSENSITIVE, foreColorAlarmSensitiveHandler);
    IWidgetPropertyChangeHandler alarmPulsingHandler = new IWidgetPropertyChangeHandler() {

        @Override
        public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
            isAlarmPulsing = (Boolean) newValue;
            stopPulsing();
            fireAlarmSeverityChanged(alarmSeverity, figure);
            return true;
        }
    };
    editpart.setPropertyChangeHandler(AbstractPVWidgetModel.PROP_ALARM_PULSING, alarmPulsingHandler);
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) AlarmSeverity(org.diirt.vtype.AlarmSeverity) PropertyChangeListener(java.beans.PropertyChangeListener) StringProperty(org.csstudio.opibuilder.properties.StringProperty) IPV(org.csstudio.simplepv.IPV) VType(org.diirt.vtype.VType) IWidgetPropertyChangeHandler(org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler) IFigure(org.eclipse.draw2d.IFigure)

Example 19 with StringProperty

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

the class AbstractLinkingContainerModel method configureBaseProperties.

@Override
protected void configureBaseProperties() {
    super.configureBaseProperties();
    addProperty(new FilePathProperty(PROP_OPI_FILE, "OPI File", // $NON-NLS-1$
    WidgetPropertyCategory.Behavior, // $NON-NLS-1$
    new Path(""), new String[] { OPIBuilderPlugin.OPI_FILE_EXTENSION }));
    addProperty(new StringProperty(PROP_GROUP_NAME, "Group Name", WidgetPropertyCategory.Behavior, // $NON-NLS-1$
    ""));
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) StringProperty(org.csstudio.opibuilder.properties.StringProperty) FilePathProperty(org.csstudio.opibuilder.properties.FilePathProperty)

Example 20 with StringProperty

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

the class ConnectionModel method configureProperties.

@Override
protected void configureProperties() {
    addProperty(new IntegerProperty(PROP_LINE_WIDTH, "Line Width", WidgetPropertyCategory.Display, 1, 1, 100));
    addProperty(new ComboProperty(PROP_LINE_STYLE, "Line Style", WidgetPropertyCategory.Display, LineStyle.stringValues(), 0));
    addProperty(new ColorProperty(PROP_LINE_COLOR, "Line Color", WidgetPropertyCategory.Display, CustomMediaFactory.COLOR_BLACK));
    addProperty(new ComboProperty(PROP_ROUTER, "Router", WidgetPropertyCategory.Display, RouterType.stringValues(), 0));
    addProperty(new ComboProperty(PROP_ARROW_TYPE, "Arrows", WidgetPropertyCategory.Display, ArrowType.stringValues(), 0));
    addProperty(new BooleanProperty(PROP_FILL_ARROW, "Fill Arrow", WidgetPropertyCategory.Display, true));
    addProperty(new IntegerProperty(PROP_ARROW_LENGTH, "Arrow Length", WidgetPropertyCategory.Display, 15, 5, 1000));
    addProperty(new BooleanProperty(PROP_ANTIALIAS, "Anti Alias", WidgetPropertyCategory.Display, true));
    addProperty(new StringProperty(PROP_SRC_TERM, "Source Terminal", WidgetPropertyCategory.Display, ""));
    addProperty(new StringProperty(PROP_TGT_TERM, "Target Terminal", WidgetPropertyCategory.Display, ""));
    addProperty(new PointListProperty(PROP_POINTS, "Points", WidgetPropertyCategory.Display, new PointList()));
    addProperty(new ComboProperty(PROP_LINE_JUMP_ADD, "Add Line Jump To", WidgetPropertyCategory.Display, LineJumpAdd.stringValues(), 0));
    addProperty(new ComboProperty(PROP_LINE_JUMP_STYLE, "Line Jump Style", WidgetPropertyCategory.Display, LineJumpStyle.stringValues(), 0));
    addProperty(new IntegerProperty(PROP_LINE_JUMP_SIZE, "Line Jump Size", WidgetPropertyCategory.Display, 10, 1, 100));
    AbstractWidgetProperty loadedFromLinkingContainer = new StringProperty(PROP_IS_LOADED_FROM_LINKING_CONTAINER, "Is Loaded From Linking Container", WidgetPropertyCategory.Behavior, "false");
    addProperty(loadedFromLinkingContainer);
    setPropertyVisibleAndSavable(PROP_IS_LOADED_FROM_LINKING_CONTAINER, false, false);
    setPropertyVisibleAndSavable(PROP_POINTS, false, true);
    AbstractWidgetProperty srcWUIDProp = new StringProperty(PROP_SRC_WUID, "Source WUID", WidgetPropertyCategory.Display, "");
    addProperty(srcWUIDProp);
    srcWUIDProp.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (displayModel == null)
                return;
            String wuid = evt.getNewValue().toString();
            String path = getPropertyValue(PROP_SRC_PATH).toString();
            AbstractWidgetModel w = null;
            if (path == null || path.equals("")) {
                w = getTerminal(displayModel, null, wuid);
            } else {
                List<String> paths = Arrays.asList(path.split(PATH_DELIMITER));
                w = getTerminal(displayModel, paths, wuid);
            }
            if (w != null) {
                source = w;
                reconnect();
            } else
                throw new IllegalArgumentException("Non exist widget PATH:[" + path + "],\nWUID:[" + wuid + "]");
        }
    });
    AbstractWidgetProperty tgtWUIDProp = new StringProperty(PROP_TGT_WUID, "Target WUID", WidgetPropertyCategory.Display, "");
    addProperty(tgtWUIDProp);
    tgtWUIDProp.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (displayModel == null)
                return;
            String wuid = evt.getNewValue().toString();
            String path = getPropertyValue(PROP_TGT_PATH).toString();
            AbstractWidgetModel w = null;
            if (path == null || path.equals("")) {
                w = getTerminal(displayModel, null, wuid);
            } else {
                List<String> paths = Arrays.asList(path.split(PATH_DELIMITER));
                w = getTerminal(displayModel, paths, wuid);
            }
            if (w != null) {
                target = w;
                reconnect();
            } else
                throw new IllegalArgumentException("Non exist widget PATH:[" + path + "],\nWUID:[" + wuid + "]");
        }
    });
    AbstractWidgetProperty srcPathProp = new StringProperty(PROP_SRC_PATH, "Source Path", WidgetPropertyCategory.Display, "");
    addProperty(srcPathProp);
    AbstractWidgetProperty tgtPathProp = new StringProperty(PROP_TGT_PATH, "Target Path", WidgetPropertyCategory.Display, "");
    addProperty(tgtPathProp);
    setPropertyVisibleAndSavable(PROP_SRC_WUID, false, true);
    setPropertyVisibleAndSavable(PROP_TGT_WUID, false, true);
    setPropertyVisibleAndSavable(PROP_SRC_PATH, false, true);
    setPropertyVisibleAndSavable(PROP_TGT_PATH, false, true);
    setPropertyVisibleAndSavable(PROP_SRC_TERM, false, true);
    setPropertyVisibleAndSavable(PROP_TGT_TERM, false, true);
    removeProperty(PROP_BORDER_COLOR);
    removeProperty(PROP_BORDER_STYLE);
    removeProperty(PROP_BORDER_WIDTH);
    removeProperty(PROP_VISIBLE);
    removeProperty(PROP_ENABLED);
    removeProperty(PROP_TOOLTIP);
    removeProperty(PROP_ACTIONS);
    removeProperty(PROP_FONT);
    removeProperty(PROP_XPOS);
    removeProperty(PROP_YPOS);
    removeProperty(PROP_WIDTH);
    removeProperty(PROP_HEIGHT);
    removeProperty(PROP_RULES);
    removeProperty(PROP_ACTIONS);
    removeProperty(PROP_SCRIPTS);
    removeProperty(PROP_COLOR_BACKGROUND);
    removeProperty(PROP_COLOR_FOREGROUND);
    removeProperty(PROP_SCALE_OPTIONS);
}
Also used : ComboProperty(org.csstudio.opibuilder.properties.ComboProperty) IntegerProperty(org.csstudio.opibuilder.properties.IntegerProperty) PointList(org.eclipse.draw2d.geometry.PointList) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) BooleanProperty(org.csstudio.opibuilder.properties.BooleanProperty) AbstractWidgetProperty(org.csstudio.opibuilder.properties.AbstractWidgetProperty) StringProperty(org.csstudio.opibuilder.properties.StringProperty) PointListProperty(org.csstudio.opibuilder.properties.PointListProperty) PointList(org.eclipse.draw2d.geometry.PointList) List(java.util.List) ColorProperty(org.csstudio.opibuilder.properties.ColorProperty)

Aggregations

StringProperty (org.csstudio.opibuilder.properties.StringProperty)21 BooleanProperty (org.csstudio.opibuilder.properties.BooleanProperty)16 IntegerProperty (org.csstudio.opibuilder.properties.IntegerProperty)12 ColorProperty (org.csstudio.opibuilder.properties.ColorProperty)8 ComboProperty (org.csstudio.opibuilder.properties.ComboProperty)8 PropertyChangeEvent (java.beans.PropertyChangeEvent)4 PropertyChangeListener (java.beans.PropertyChangeListener)4 FilePathProperty (org.csstudio.opibuilder.properties.FilePathProperty)4 FontProperty (org.csstudio.opibuilder.properties.FontProperty)4 ActionsProperty (org.csstudio.opibuilder.properties.ActionsProperty)3 DoubleProperty (org.csstudio.opibuilder.properties.DoubleProperty)3 PVNameProperty (org.csstudio.opibuilder.properties.PVNameProperty)3 PVValueProperty (org.csstudio.opibuilder.properties.PVValueProperty)3 WidgetPropertyCategory (org.csstudio.opibuilder.properties.WidgetPropertyCategory)3 IPath (org.eclipse.core.runtime.IPath)3 Path (org.eclipse.core.runtime.Path)3 NameDefinedCategory (org.csstudio.opibuilder.properties.NameDefinedCategory)2 IPV (org.csstudio.simplepv.IPV)2 RGB (org.eclipse.swt.graphics.RGB)2 UID (java.rmi.server.UID)1