Search in sources :

Example 11 with AbstractWidgetProperty

use of org.csstudio.opibuilder.properties.AbstractWidgetProperty 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)

Example 12 with AbstractWidgetProperty

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

the class PropertiesEditingSupport method setValue.

/**
 * {@inheritDoc}
 */
@Override
protected void setValue(final Object element, final Object value) {
    if (element instanceof AbstractWidgetProperty) {
        AbstractWidgetProperty prop = (AbstractWidgetProperty) element;
        prop.setPropertyValue(value);
        getViewer().refresh();
    }
}
Also used : AbstractWidgetProperty(org.csstudio.opibuilder.properties.AbstractWidgetProperty)

Example 13 with AbstractWidgetProperty

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

the class AbstractWidgetAction method getAllProperties.

public AbstractWidgetProperty[] getAllProperties() {
    AbstractWidgetProperty[] propArray = new AbstractWidgetProperty[propertyMap.size()];
    int i = 0;
    for (AbstractWidgetProperty p : propertyMap.values()) propArray[i++] = p;
    return propArray;
}
Also used : AbstractWidgetProperty(org.csstudio.opibuilder.properties.AbstractWidgetProperty)

Example 14 with AbstractWidgetProperty

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

the class RuleData method generateScript.

/**
 *Generate the Javascript string for this rule.
 * @return the script string
 */
public String generateScript() {
    if (expressionList.size() <= 0)
        // $NON-NLS-1$
        return "";
    StringBuilder sb = new StringBuilder(// $NON-NLS-1$
    "importPackage(Packages.org.csstudio.opibuilder.scriptUtil); \n");
    AbstractWidgetProperty property = widgetModel.getProperty(propId);
    boolean needDbl = false, needInt = false, needStr = false, needSev = false;
    for (Expression exp : expressionList) {
        if (!needDbl)
            needDbl = // $NON-NLS-1$
            containRegex(exp.getBooleanExpression(), "pv\\d") || // $NON-NLS-1$
            (outputExpValue && containRegex(exp.getValue().toString(), "pv\\d"));
        if (!needInt) {
            if (// $NON-NLS-1$
            exp.getBooleanExpression().contains("pvInt"))
                needInt = true;
            if (// $NON-NLS-1$
            outputExpValue && exp.getValue().toString().contains("pvInt"))
                needInt = true;
        }
        if (!needStr) {
            if (// $NON-NLS-1$
            exp.getBooleanExpression().contains("pvStr"))
                needStr = true;
            if (// $NON-NLS-1$
            outputExpValue && exp.getValue().toString().contains("pvStr"))
                needStr = true;
        }
        if (!needSev) {
            if (// $NON-NLS-1$
            exp.getBooleanExpression().contains("pvSev"))
                needSev = true;
            if (// $NON-NLS-1$
            outputExpValue && exp.getValue().toString().contains("pvSev"))
                needSev = true;
        }
    }
    for (int i = 0; i < pvList.size(); i++) {
        if (needDbl)
            // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            sb.append("var pv" + i + " = PVUtil." + "getDouble(pvs[" + i + "]);\n");
        if (needInt)
            // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            sb.append("var pvInt" + i + " = PVUtil." + "getLong(pvs[" + i + "]);\n");
        if (needStr)
            // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            sb.append("var pvStr" + i + " = PVUtil." + "getString(pvs[" + i + "]);\n");
        if (needSev)
            // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            sb.append("var pvSev" + i + " = PVUtil.getSeverity(pvs[" + i + "]);\n");
    }
    int i = 0;
    for (Expression exp : expressionList) {
        // $NON-NLS-1$ //$NON-NLS-2$
        sb.append(i == 0 ? "if(" : "else if(");
        sb.append(expressionList.get(i++).getBooleanExpression());
        // $NON-NLS-1$
        sb.append(")\n");
        // $NON-NLS-1$ //$NON-NLS-2$
        sb.append("\twidget.setPropertyValue(\"" + propId + "\",");
        String propValue = generatePropValueString(property, exp);
        // $NON-NLS-1$
        sb.append(propValue + ");\n");
    }
    // $NON-NLS-1$
    sb.append("else\n");
    sb.append(// $NON-NLS-1$ //$NON-NLS-2$
    "\twidget.setPropertyValue(\"" + propId + "\"," + generatePropValueString(property, null) + // $NON-NLS-1$
    ");\n");
    return sb.toString();
}
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