Search in sources :

Example 1 with ImageSet

use of com.serotonin.m2m2.view.ImageSet in project ma-modules-public by infiniteautomation.

the class GraphicalViewDwr method saveAnalogGraphicComponent.

@DwrPermission(user = true)
public ProcessResult saveAnalogGraphicComponent(String viewComponentId, double min, double max, boolean displayText, String imageSetId) {
    ProcessResult response = new ProcessResult();
    // Validate
    if (min >= max)
        response.addContextualMessage("graphicRendererAnalogMin", "viewEdit.graphic.invalidMinMax");
    ImageSet imageSet = getImageSet(imageSetId);
    if (imageSet == null)
        response.addContextualMessage("graphicRendererAnalogImageSet", "viewEdit.graphic.missingImageSet");
    if (!response.getHasMessages()) {
        AnalogGraphicComponent c = (AnalogGraphicComponent) getViewComponent(viewComponentId);
        c.setMin(min);
        c.setMax(max);
        c.setDisplayText(displayText);
        c.tsetImageSet(imageSet);
        resetPointComponent(c);
    }
    return response;
}
Also used : AnalogGraphicComponent(com.serotonin.m2m2.gviews.component.AnalogGraphicComponent) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) ImageSet(com.serotonin.m2m2.view.ImageSet) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 2 with ImageSet

use of com.serotonin.m2m2.view.ImageSet in project ma-modules-public by infiniteautomation.

the class GraphicalViewDwr method saveMultistateGraphicComponent.

@DwrPermission(user = true)
public ProcessResult saveMultistateGraphicComponent(String viewComponentId, List<IntStringPair> imageStates, int defaultImage, boolean displayText, String imageSetId) {
    ProcessResult response = new ProcessResult();
    // Validate
    ImageSet imageSet = getImageSet(imageSetId);
    if (imageSet == null)
        response.addContextualMessage("graphicRendererMultistateImageSet", "viewEdit.graphic.missingImageSet");
    if (!response.getHasMessages()) {
        MultistateGraphicComponent c = (MultistateGraphicComponent) getViewComponent(viewComponentId);
        c.setImageStateList(imageStates);
        c.setDefaultImage(defaultImage);
        c.setDisplayText(displayText);
        c.tsetImageSet(imageSet);
        resetPointComponent(c);
    }
    return response;
}
Also used : MultistateGraphicComponent(com.serotonin.m2m2.gviews.component.MultistateGraphicComponent) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) ImageSet(com.serotonin.m2m2.view.ImageSet) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 3 with ImageSet

use of com.serotonin.m2m2.view.ImageSet in project ma-modules-public by infiniteautomation.

the class GraphicalViewDwr method saveBinaryGraphicComponent.

@DwrPermission(user = true)
public ProcessResult saveBinaryGraphicComponent(String viewComponentId, int zeroImage, int oneImage, boolean displayText, String imageSetId) {
    ProcessResult response = new ProcessResult();
    // Validate
    ImageSet imageSet = getImageSet(imageSetId);
    if (imageSet == null)
        response.addContextualMessage("graphicRendererBinaryImageSet", "viewEdit.graphic.missingImageSet");
    else {
        if (zeroImage == -1)
            response.addContextualMessage("graphicRendererBinaryImageSetZeroMsg", "viewEdit.graphic.missingZeroImage");
        if (oneImage == -1)
            response.addContextualMessage("graphicRendererBinaryImageSetOneMsg", "viewEdit.graphic.missingOneImage");
    }
    if (!response.getHasMessages()) {
        BinaryGraphicComponent c = (BinaryGraphicComponent) getViewComponent(viewComponentId);
        c.tsetImageSet(imageSet);
        c.setZeroImage(zeroImage);
        c.setOneImage(oneImage);
        c.setDisplayText(displayText);
        resetPointComponent(c);
    }
    return response;
}
Also used : BinaryGraphicComponent(com.serotonin.m2m2.gviews.component.BinaryGraphicComponent) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) ImageSet(com.serotonin.m2m2.view.ImageSet) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 4 with ImageSet

use of com.serotonin.m2m2.view.ImageSet in project ma-modules-public by infiniteautomation.

the class ImageSetComponent method jsonRead.

@Override
public void jsonRead(JsonReader reader, JsonObject jsonObject) throws JsonException {
    super.jsonRead(reader, jsonObject);
    JsonValue jsonImageId = jsonObject.get("imageSet");
    if (jsonImageId != null) {
        String id = jsonImageId.toString();
        imageSet = Common.getImageSet(id);
        if (imageSet == null)
            throw new TranslatableJsonException("emport.error.component.unknownImageSet", id, Common.getImageSetIds());
    }
}
Also used : JsonValue(com.serotonin.json.type.JsonValue) TranslatableJsonException(com.serotonin.m2m2.i18n.TranslatableJsonException)

Aggregations

ProcessResult (com.serotonin.m2m2.i18n.ProcessResult)3 ImageSet (com.serotonin.m2m2.view.ImageSet)3 DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)3 JsonValue (com.serotonin.json.type.JsonValue)1 AnalogGraphicComponent (com.serotonin.m2m2.gviews.component.AnalogGraphicComponent)1 BinaryGraphicComponent (com.serotonin.m2m2.gviews.component.BinaryGraphicComponent)1 MultistateGraphicComponent (com.serotonin.m2m2.gviews.component.MultistateGraphicComponent)1 TranslatableJsonException (com.serotonin.m2m2.i18n.TranslatableJsonException)1