Example #1
0
 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);
   }
 }
 @Test
 public void testEmptyMessage() {
   JsonObject message = writer.createMessage();
   JsonObject head = message.get("head").asObject();
   assertEquals(0, head.size());
   JsonArray operations = message.get("operations").asArray();
   assertEquals(0, operations.size());
 }
  @Test
  public void testAppendArrayParameter() {
    writer.appendSet(shellId, "key", new JsonArray().add(1).add(2));

    SetOperation operation = (SetOperation) getMessage().getOperation(0);
    JsonArray property = operation.getProperty("key").asArray();
    assertEquals(1, property.get(0).asInt());
    assertEquals(2, property.get(1).asInt());
  }
Example #4
0
 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);
   }
 }
Example #5
0
 /**
  * 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);
 }
Example #6
0
 /**
  * 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);
 }
Example #7
0
 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);
 }
Example #8
0
  @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"));
  }
Example #9
0
  @Test
  public void testRenderFooterFont() throws IOException {
    column.setFooterFont(new Font(display, "Arial", 20, SWT.BOLD));
    lca.renderChanges(column);

    TestMessage message = Fixture.getProtocolMessage();
    JsonValue actual = message.findSetProperty(column, "footerFont");
    assertEquals(JsonArray.readFrom("[[\"Arial\"], 20, true, false]"), actual);
  }
Example #10
0
  @Test
  public void testRenderItemMetrics() throws IOException {
    TableItem item = new TableItem(table, SWT.NONE);
    item.setText("foo");

    lca.renderChanges(table);

    TestMessage message = Fixture.getProtocolMessage();
    JsonArray expected = JsonArray.readFrom("[[0, 0, 26, 3, 0, 3, 20]]");
    assertEquals(expected, message.findSetProperty(table, "itemMetrics"));
  }
  @Test
  public void testRenderOrigin() throws IOException {
    Composite content = new Composite(sc, SWT.NONE);
    sc.setContent(content);

    sc.setOrigin(1, 2);
    lca.renderChanges(sc);

    TestMessage message = Fixture.getProtocolMessage();
    JsonArray expected = JsonArray.readFrom("[ 1, 2 ]");
    assertEquals(expected, message.findSetProperty(sc, "origin"));
  }
Example #12
0
  @Test
  public void testRenderFooterImage() throws IOException {
    Image image = loadImage(display, Fixture.IMAGE_100x50);

    column.setFooterImage(image);
    lca.renderChanges(column);

    TestMessage message = Fixture.getProtocolMessage();
    String imageLocation = ImageFactory.getImagePath(image);
    JsonArray expected = JsonArray.readFrom("[\"" + imageLocation + "\", 100, 50 ]");
    assertEquals(expected, message.findSetProperty(column, "footerImage"));
  }
Example #13
0
  @Test
  public void testRenderCreateWithCheck() throws IOException {
    table = new Table(shell, SWT.CHECK);

    lca.renderInitialization(table);

    TestMessage message = Fixture.getProtocolMessage();
    CreateOperation operation = message.findCreateOperation(table);
    assertTrue(getStyles(operation).contains("CHECK"));
    JsonArray expected = JsonArray.readFrom("[4, 21]");
    assertEquals(expected, operation.getProperties().get("checkBoxMetrics"));
  }