private int addButton(SIPCommButton button, int gridX, int xBounds, boolean isLast) {
    lastAddedButton = button;

    constraints.insets = new Insets(0, 0, V_GAP, 0);
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = gridX;
    constraints.gridy = 2;
    constraints.gridwidth = 1;
    constraints.gridheight = 1;
    constraints.weightx = 0f;
    constraints.weighty = 0f;
    this.add(button, constraints);

    int yBounds =
        TOP_BORDER
            + BOTTOM_BORDER
            + 2 * V_GAP
            + ComponentUtils.getStringSize(nameLabel, nameLabel.getText()).height
            + ComponentUtils.getStringSize(displayDetailsLabel, displayDetailsLabel.getText())
                .height;

    button.setBounds(xBounds, yBounds, BUTTON_WIDTH, BUTTON_HEIGHT);

    button.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));

    setButtonBg(button, gridX, isLast);

    return button.getWidth();
  }
Esempio n. 2
0
 @Override
 public TagComponent cloneAndCombineTo(Combinable other) {
   XPathComponent otherCopy = other.cloneComponent();
   return new TagComponent(
       this.xPathExpression,
       ComponentUtils.joinComponents(this.combinatedComponents, otherCopy),
       ComponentUtils.joinFilters(this.elementFilterList, otherCopy));
 }
  /** test that {@link ComponentUtils#updateIdWithSuffix} works ok */
  @Test
  public void testUpdateIdWithSuffix() {
    ComponentUtils.updateIdWithSuffix(component, null);
    assertTrue(component.getId().equalsIgnoreCase(componentId));

    String suffix = "_field";
    ComponentUtils.updateIdWithSuffix(component, suffix);
    assertTrue(component.getId().equalsIgnoreCase(componentId + suffix));
  }
Esempio n. 4
0
  public void testContainsExpressionIsTrue() throws Exception {
    // given
    String anExpression = "%{foo}";

    // when
    boolean actual = ComponentUtils.containsExpression(anExpression);

    // then
    assertTrue(actual);
  }
Esempio n. 5
0
  public void testIsExpressionIsFalse() throws Exception {
    // given
    String anExpression = "foo";

    // when
    boolean actual = ComponentUtils.isExpression(anExpression);

    // then
    assertFalse(actual);
  }
Esempio n. 6
0
  public void testAltSyntaxIsTrue() throws Exception {
    // given
    ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack();

    // when
    boolean actual = ComponentUtils.altSyntax(stack);

    // then
    assertTrue(actual);
  }
Esempio n. 7
0
  public void testAltSyntaxIsFalse() throws Exception {
    // given
    loadConfigurationProviders(new MockConfigurationProvider());
    ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack();

    // when
    boolean actual = ComponentUtils.altSyntax(stack);

    // then
    assertFalse(actual);
  }
Esempio n. 8
0
  public void testStripExpression() throws Exception {
    // given
    ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack();
    String anExpression = "%{foo}";

    // when
    String actual = ComponentUtils.stripExpressionIfAltSyntax(stack, anExpression);

    // then
    assertEquals(actual, "foo");
  }
Esempio n. 9
0
  public void testNoStripExpressionIfNoAltSyntax() throws Exception {
    // given
    loadConfigurationProviders(new MockConfigurationProvider());
    ValueStack stack = container.getInstance(ValueStackFactory.class).createValueStack();
    String anExpression = "%{foo}";

    // when
    String actual = ComponentUtils.stripExpressionIfAltSyntax(stack, anExpression);

    // then
    assertEquals(actual, "%{foo}");
  }
Esempio n. 10
0
  public AjaxRequestBuilder delay(String delay) {
    if (!ComponentUtils.isValueBlank(delay) && !delay.equals("none")) {
      buffer.append(",d:").append(delay);

      if (context.isProjectStage(ProjectStage.Development)) {
        try {
          Integer.parseInt(delay);
        } catch (NumberFormatException e) {
          throw new FaceletException("Delay attribute should only take numbers or \"none\"");
        }
      }
    }

    return this;
  }
  /** Test {@link ComponentUtils#cleanContextDeap} using a BreadcrumbItem object */
  @Test
  public void testCleanContextDeap() {
    Map<String, Object> context = new HashMap<String, Object>();
    context.put("contextkey", "value");
    context.put("contextkey2", "value2");

    BreadcrumbItem breadcrumbItem = new BreadcrumbItem();
    breadcrumbItem.setContext(context);

    InputField inputField = new InputFieldBase();
    inputField.setContext(context);

    Label fieldLabel = new Label();
    fieldLabel.setContext(context);

    Tooltip labelTootlip = new Tooltip();
    labelTootlip.setContext(context);
    fieldLabel.setToolTip(labelTootlip);

    inputField.setFieldLabel(fieldLabel);

    breadcrumbItem.setSiblingBreadcrumbComponent(inputField);

    Tooltip tooltip = new Tooltip();
    tooltip.setContext(context);

    breadcrumbItem.setToolTip(tooltip);

    ComponentUtils.cleanContextDeap(breadcrumbItem);

    assertEquals(0, breadcrumbItem.getContext().size());
    assertEquals(0, inputField.getContext().size());
    assertEquals(0, fieldLabel.getContext().size());
    assertEquals(0, labelTootlip.getContext().size());
    assertEquals(0, tooltip.getContext().size());
  }
Esempio n. 12
0
 public void testIsExpressionIsFalseWhenNull() throws Exception {
   assertFalse(ComponentUtils.isExpression(null));
 }
Esempio n. 13
0
 public TagComponent(String xPathExpression) {
   super(xPathExpression, ComponentUtils.emptyElementFilterList());
 }