Example #1
0
 public Object getValue() {
   if (!ValueUtil.isEmpty(expression)) {
     ExpressionResolver er = ClientContext.getCurrentContext().getExpressionResolver();
     return er.evaluate(binding.getBean(), expression);
   } else if (!ValueUtil.isEmpty(getName())) return UIControlUtil.getBeanValue(this);
   else return super.getText();
 }
Example #2
0
  public String getText() {
    if (Beans.isDesignTime()) {
      if (!ValueUtil.isEmpty(expression)) return expression;
      else if (!ValueUtil.isEmpty(getName())) return getName();
      else return super.getText();

    } else {
      return super.getText();
    }
  }
Example #3
0
    public void propertyChange(PropertyChangeEvent evt) {
      String propName = evt.getPropertyName();
      Object value = evt.getNewValue();

      if ("caption".equals(propName)) {
        String text = (value == null) ? "" : value + "";
        formatText(text, activeProperty.isRequired());

      } else if ("captionMnemonic".equals(propName)) {
        setDisplayedMnemonic((value + "").charAt(0));
        formatText(activeProperty.getCaption(), activeProperty.isRequired());

      } else if ("required".equals(propName)) {
        boolean req = Boolean.parseBoolean(value + "");
        formatText(activeProperty.getCaption(), req);

      } else if ("errorMessage".equals(propName)) {
        String message = (value != null) ? value + "" : null;
        boolean error = !ValueUtil.isEmpty(message);
        if (error) {
          oldFg = getForeground();
          setForeground(Color.RED);
        } else {
          setForeground(oldFg);
        }
        setToolTipText(message);
        if (activeComponent != null) {
          activeComponent.setToolTipText(message);
        }
      }
    }
Example #4
0
 public void load() {
   if (!ValueUtil.isEmpty(labelFor)) {
     UIControl c = binding.find(labelFor);
     if (c == null) return;
     if (c instanceof JComponent) {
       this.setLabelFor((JComponent) c);
     }
   }
 }
Example #5
0
  public void refresh() {
    try {
      Object value = null;
      if (!ValueUtil.isEmpty(expression)) {
        value = UIControlUtil.evaluateExpr(binding.getBean(), expression);
      } else if (!ValueUtil.isEmpty(getName())) {
        value = UIControlUtil.getBeanValue(this);
        if (value != null && format != null) {
          value = format.format(value);
        }
      } else {
        value = super.getText();
      }

      super.setText((value != null ? value + "" : ""));

    } catch (Exception e) {
      super.setText("");

      if (ClientContext.getCurrentContext().isDebugMode()) {
        e.printStackTrace();
      }
    }
  }
Example #6
0
  public void setLabelFor(Component c) {
    activeComponent = (JComponent) c;
    if (c instanceof ActiveControl) {
      ActiveControl ac = (ActiveControl) c;
      activeProperty = ac.getControlProperty();
      String acCaption = activeProperty.getCaption();
      if (forceUseActiveCaption
          || (!ValueUtil.isEmpty(acCaption) && !acCaption.equals("Caption"))) {
        setName(null);
        setExpression(null);
        formatText(activeProperty.getCaption(), activeProperty.isRequired());
        super.setDisplayedMnemonic(activeProperty.getCaptionMnemonic());
      }

      activeControlSupport = new ActiveControlSupport();
      activeProperty.addPropertyChangeListener(activeControlSupport);
    }
    super.setLabelFor(c);
  }
Example #7
0
  private void formatText(String text, boolean required) {
    StringBuffer sb = new StringBuffer(text);
    if (addCaptionColon && !ValueUtil.isEmpty(text)) {
      sb.append(" :");
    }
    if (required) {
      int mnem = getDisplayedMnemonic();
      int idx = findDisplayedMnemonicIndex(sb, mnem);
      if (idx != -1) {
        sb.replace(idx, idx + 1, "<u>" + sb.charAt(idx) + "</u>");
      }

      sb.insert(0, "<html>");
      sb.append(" <font color=\"red\">*</font>");
      sb.append("</html>");
    }

    super.setText(sb.toString());
  }