Пример #1
0
  @SuppressWarnings("unchecked")
  public Object evaluate() throws com.dexels.navajo.parser.TMLExpressionException {
    if (getOperands().size() != 1) {
      throw new TMLExpressionException(this, "Invalid function call, need one parameter");
    }
    Object o = getOperand(0);
    if (o == null) {
      throw new TMLExpressionException(
          this, "Invalid function call in GetSelectedName: Parameter null");
    }

    if (o instanceof Property) {
      Property p = (Property) o;
      if (p.getSelected() != null) {
        return (p.getAllSelectedSelections().size() > 0 ? p.getSelected().getName() : null);
      } else {
        return null;
      }
    }

    if (!(o instanceof List)) {
      throw new TMLExpressionException(
          this, "Invalid function call in GetSelectedName: Not a selection property");
    }
    List<Selection> l = (List<Selection>) o;
    for (Selection selection : l) {
      if (selection.isSelected()) {
        return selection.getName();
      }
    }
    return null;
  }
Пример #2
0
 public Object getComponentValue(String name) {
   if (myProperty != null) {
     logger.info("myProperty:" + myProperty.getName() + " value: " + myProperty.getValue());
   }
   if ("propertyname".equals(name)) {
     if (myProperty != null && myProperty.getType().equals(Property.SELECTION_PROPERTY)) {
       try {
         Selection s = myProperty.getSelected();
         if (s != null) {
           return s.getName();
         } else {
           return myPropertyName;
         }
       } catch (Exception e) {
         return myPropertyName;
       }
     }
     return myPropertyName;
   }
   //      if ("use_checkbox".equals(name)) {
   //        return new Boolean("checkbox".equals(selectionType));
   //      }
   //      if ("selectiontype".equals(name)) {
   //        return selectionType;
   //      }
   //      if ("showlabel".equals(name)) {
   //        return new Boolean(isLabelVisible());
   //      }
   //      if ("label_valign".equals(name)) {
   //        return vAlign;
   //      }
   //      if ("enabled".equals(name)) {
   //          if (myEnableState!=null) {
   //              return new Boolean(myEnableState.booleanValue());
   //          } else {
   //              return new Boolean( ( (GenericPropertyComponent) getContainer()).isEnabled());
   //          }
   //        }
   //      if ("visible".equals(name)) {
   //        return new Boolean( ( (GenericPropertyComponent) getContainer()).isVisible());
   //      }
   //      if ("label_halign".equals(name)) {
   //        return hAlign;
   //      }
   //      if ("label_indent".equals(name)) {
   //        return new Integer( ( (GenericPropertyComponent) getContainer()).getLabelIndent());
   //      }
   //      if ("capitalization".equals(name)) {
   //        return myCapitalization;
   //      }
   if ("propertyValue".equals(name)) {
     if (myProperty != null) {
       if (myProperty.getType().equals(Property.SELECTION_PROPERTY)) {
         try {
           Selection s = myProperty.getSelected();
           if (s != null) {
             return s.getValue();
           } else {
             return "" + myProperty.getTypedValue();
           }
         } catch (Exception e) {
           return "" + myProperty.getTypedValue();
         }
       }
       if (myProperty.getType().equals(Property.BINARY_PROPERTY)) {
         return myProperty.getTypedValue();
       }
       return "" + myProperty.getTypedValue();
     }
   }
   return super.getComponentValue(name);
 }