Search in sources :

Example 1 with JsonArray

use of org.eclipse.rap.json.JsonArray in project hop by apache.

the class CanvasFacadeImpl method setDataPipeline.

private void setDataPipeline(Canvas canvas, float magnification, AbstractMeta meta) {
    final int iconSize = HopGui.getInstance().getProps().getIconSize();
    PipelineMeta pipelineMeta = (PipelineMeta) meta;
    JsonObject jsonNodes = new JsonObject();
    pipelineMeta.getTransforms().forEach(transformMeta -> {
        JsonObject jsonNode = new JsonObject();
        jsonNode.add("x", transformMeta.getLocation().x);
        jsonNode.add("y", transformMeta.getLocation().y);
        jsonNode.add("selected", transformMeta.isSelected());
        // Translated from org.apache.hop.ui.hopgui.shared.SwtGc.drawTransformIcon(int, int,
        // TransformMeta, float)
        SwtUniversalImage swtImage = null;
        if (transformMeta.isMissing()) {
            swtImage = GuiResource.getInstance().getSwtImageMissing();
        } else if (transformMeta.isDeprecated()) {
            swtImage = GuiResource.getInstance().getSwtImageDeprecated();
        } else {
            String pluginId = transformMeta.getPluginId();
            if (pluginId != null) {
                swtImage = GuiResource.getInstance().getImagesTransforms().get(pluginId);
            }
        }
        if (swtImage == null) {
            return;
        }
        int w = Math.round(iconSize * magnification);
        int h = Math.round(iconSize * magnification);
        Image image = swtImage.getAsBitmapForSize(Display.getCurrent(), w, h);
        // Translated
        jsonNode.add("img", image.internalImage.getResourceName());
        jsonNodes.add(transformMeta.getName(), jsonNode);
    });
    canvas.setData("nodes", jsonNodes);
    JsonArray jsonHops = new JsonArray();
    for (int i = 0; i < pipelineMeta.nrPipelineHops(); i++) {
        JsonObject jsonHop = new JsonObject();
        PipelineHopMeta hop = pipelineMeta.getPipelineHop(i);
        if (hop.getFromTransform() != null && hop.getToTransform() != null) {
            jsonHop.add("from", hop.getFromTransform().getName());
            jsonHop.add("to", hop.getToTransform().getName());
            jsonHops.add(jsonHop);
        }
    }
    canvas.setData("hops", jsonHops);
}
Also used : JsonArray(org.eclipse.rap.json.JsonArray) PipelineHopMeta(org.apache.hop.pipeline.PipelineHopMeta) JsonObject(org.eclipse.rap.json.JsonObject) SwtUniversalImage(org.apache.hop.core.SwtUniversalImage) Image(org.eclipse.swt.graphics.Image) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) SwtUniversalImage(org.apache.hop.core.SwtUniversalImage)

Example 2 with JsonArray

use of org.eclipse.rap.json.JsonArray in project org.eclipse.rap by eclipse-rap.

the class MeasurementUtil method createItemParamObject.

static JsonArray createItemParamObject(MeasurementItem item) {
    FontData fontData = item.getFontData();
    JsonArray result = new JsonArray().add(getId(item)).add(item.getTextToMeasure()).add(createJsonArray(ProtocolUtil.parseFontName(fontData.getName()))).add(fontData.getHeight()).add((fontData.getStyle() & SWT.BOLD) != 0).add((fontData.getStyle() & SWT.ITALIC) != 0).add(item.getWrapWidth()).add(isMarkup(item.getMode()));
    return result;
}
Also used : JsonArray(org.eclipse.rap.json.JsonArray) JsonUtil.createJsonArray(org.eclipse.rap.rwt.internal.protocol.JsonUtil.createJsonArray) FontData(org.eclipse.swt.graphics.FontData)

Example 3 with JsonArray

use of org.eclipse.rap.json.JsonArray in project org.eclipse.rap by eclipse-rap.

the class MeasurementUtil method appendStartupTextSizeProbe.

public static void appendStartupTextSizeProbe(ProtocolMessageWriter writer) {
    JsonArray startupProbes = getStartupProbes();
    if (!startupProbes.isEmpty()) {
        JsonObject parameters = new JsonObject().add(PARAM_ITEMS, startupProbes);
        writer.appendCall(TYPE, METHOD_MEASURE_ITEMS, parameters);
    }
}
Also used : JsonArray(org.eclipse.rap.json.JsonArray) JsonUtil.createJsonArray(org.eclipse.rap.rwt.internal.protocol.JsonUtil.createJsonArray) JsonObject(org.eclipse.rap.json.JsonObject)

Example 4 with JsonArray

use of org.eclipse.rap.json.JsonArray in project org.eclipse.rap by eclipse-rap.

the class MeasurementUtil method createProbeParamObject.

static JsonArray createProbeParamObject(Probe probe) {
    FontData fontData = probe.getFontData();
    JsonArray result = new JsonArray().add(getId(probe)).add(probe.getText()).add(createJsonArray(ProtocolUtil.parseFontName(fontData.getName()))).add(fontData.getHeight()).add((fontData.getStyle() & SWT.BOLD) != 0).add((fontData.getStyle() & SWT.ITALIC) != 0).add(-1).add(true);
    return result;
}
Also used : JsonArray(org.eclipse.rap.json.JsonArray) JsonUtil.createJsonArray(org.eclipse.rap.rwt.internal.protocol.JsonUtil.createJsonArray) FontData(org.eclipse.swt.graphics.FontData)

Example 5 with JsonArray

use of org.eclipse.rap.json.JsonArray in project org.eclipse.rap by eclipse-rap.

the class TreeLCA method renderItemMetrics.

private static void renderItemMetrics(Tree tree) {
    ItemMetrics[] itemMetrics = getItemMetrics(tree);
    if (hasChanged(tree, PROP_ITEM_METRICS, itemMetrics)) {
        JsonArray metrics = new JsonArray();
        for (int i = 0; i < itemMetrics.length; i++) {
            metrics.add(new JsonArray().add(i).add(itemMetrics[i].left).add(itemMetrics[i].width).add(itemMetrics[i].imageLeft).add(itemMetrics[i].imageWidth).add(itemMetrics[i].textLeft).add(itemMetrics[i].textWidth));
        }
        getRemoteObject(tree).set(PROP_ITEM_METRICS, metrics);
    }
}
Also used : JsonArray(org.eclipse.rap.json.JsonArray) JsonUtil.createJsonArray(org.eclipse.rap.rwt.internal.protocol.JsonUtil.createJsonArray)

Aggregations

JsonArray (org.eclipse.rap.json.JsonArray)338 Test (org.junit.Test)278 TestMessage (org.eclipse.rap.rwt.testfixture.internal.TestMessage)125 JsonObject (org.eclipse.rap.json.JsonObject)93 Point (org.eclipse.swt.graphics.Point)42 JsonValue (org.eclipse.rap.json.JsonValue)29 JsonUtil.createJsonArray (org.eclipse.rap.rwt.internal.protocol.JsonUtil.createJsonArray)29 Color (org.eclipse.swt.graphics.Color)28 Image (org.eclipse.swt.graphics.Image)26 Font (org.eclipse.swt.graphics.Font)15 Rectangle (org.eclipse.swt.graphics.Rectangle)15 GridItem (org.eclipse.nebula.widgets.grid.GridItem)13 TestUtil.createImage (org.eclipse.rap.rwt.testfixture.internal.TestUtil.createImage)13 RemoteObjectFactory.getRemoteObject (org.eclipse.rap.rwt.internal.protocol.RemoteObjectFactory.getRemoteObject)11 Listener (org.eclipse.swt.widgets.Listener)11 SetOperation (org.eclipse.rap.rwt.internal.protocol.Operation.SetOperation)9 CreateOperation (org.eclipse.rap.rwt.internal.protocol.Operation.CreateOperation)8 IWidgetGraphicsAdapter (org.eclipse.swt.internal.widgets.IWidgetGraphicsAdapter)8 CallOperation (org.eclipse.rap.rwt.internal.protocol.Operation.CallOperation)7 RemoteObject (org.eclipse.rap.rwt.remote.RemoteObject)7