private void setImage() { Image image = createImage(descriptor.getImage()); if (image != null) { Rectangle bounds = image.getBounds(); JsonArray imageData = new JsonArray(); imageData.add(ImageFactory.getImagePath(image)); imageData.add(bounds.width); imageData.add(bounds.height); remoteObject.set(PROPERTY_IMAGE, imageData); } }
private static void renderSelectionBackgroundGradient(CTabFolder folder) { ICTabFolderAdapter adapter = getCTabFolderAdapter(folder); IWidgetGraphicsAdapter gfxAdapter = adapter.getUserSelectionBackgroundGradient(); Color[] bgGradientColors = gfxAdapter.getBackgroundGradientColors(); int[] bgGradientPercents = gfxAdapter.getBackgroundGradientPercents(); Boolean bgGradientVertical = Boolean.valueOf(gfxAdapter.isBackgroundGradientVertical()); boolean hasChanged = WidgetLCAUtil.hasChanged(folder, PROP_SELECTION_BG_GRADIENT_COLORS, bgGradientColors, null) || WidgetLCAUtil.hasChanged( folder, PROP_SELECTION_BG_GRADIENT_PERCENTS, bgGradientPercents, null) || WidgetLCAUtil.hasChanged( folder, PROP_SELECTION_BG_GRADIENT_VERTICAL, bgGradientVertical, Boolean.FALSE); if (hasChanged) { JsonValue gradient = JsonValue.NULL; if (bgGradientColors != null) { JsonArray colors = new JsonArray(); for (int i = 0; i < bgGradientColors.length; i++) { colors.add(toJson(bgGradientColors[i])); } JsonValue percents = createJsonArray(bgGradientPercents); gradient = new JsonArray().add(colors).add(percents).add(bgGradientVertical.booleanValue()); } getRemoteObject(folder).set(PROP_SELECTION_BG_GRADIENT, gradient); } }
/** * Sets the language scope * * @param scope */ public void setScope(List<String> scope) { checkWidget(); if (scope == null) { SWT.error(SWT.ERROR_NULL_ARGUMENT); } this.scope = scope; JsonArray array = new JsonArray(); for (String s : scope) { array.add(s); } getRemoteObject().set("scope", array); }
/** * Sets an annotation on the text widget * * @param annotation */ public void setAnnotations(List<Annotation> annotations) { checkWidget(); if (annotations == null) { SWT.error(SWT.ERROR_NULL_ARGUMENT); } this.annotations = annotations; JsonArray array = new JsonArray(); for (Annotation a : annotations) { array.add(a.getValue()); } getRemoteObject().set("annotations", array); }
public void setMarkers(List<TextRange> ranges) { checkWidget(); if (ranges == null) { SWT.error(SWT.ERROR_NULL_ARGUMENT); } this.markers = ranges; JsonArray values = new JsonArray(); for (TextRange range : ranges) { values.add(range.getValue()); } // getRemoteObject().call("addMarker", properties); getRemoteObject().set("markers", values); }
@Test public void testRenderSelection() throws IOException { table = new Table(shell, SWT.MULTI); createTableItems(table, 3); table.setSelection(new int[] {0, 2}); getLCA(display).render(display); TestMessage message = Fixture.getProtocolMessage(); JsonArray expected = new JsonArray(); expected.add(getId(table.getItem(2))); expected.add(getId(table.getItem(0))); assertEquals(expected, message.findSetProperty(table, "selection")); }