Example #1
0
  protected void updateDependancies() {
    if (getOwner() instanceof FIBComponent) {

      if (binding == null) {
        return;
      }

      Vector<Expression> primitives;
      try {
        primitives = Expression.extractPrimitives(binding.getStringRepresentation());

        FIBComponent component = (FIBComponent) getOwner();
        FIBComponent rootComponent = component.getRootComponent();
        Iterator<FIBComponent> subComponents = rootComponent.subComponentIterator();
        while (subComponents.hasNext()) {
          FIBComponent next = subComponents.next();
          if (next != getOwner()) {
            if (next instanceof FIBWidget
                && ((FIBWidget) next).getData() != null
                && ((FIBWidget) next).getData().isSet()) {
              String data = ((FIBWidget) next).getData().toString();
              if (data != null) {
                for (Expression p : primitives) {
                  String primitiveValue = null;
                  if (p instanceof Variable) {
                    primitiveValue = ((Variable) p).getName();
                  }
                  if (p instanceof Function) {
                    primitiveValue = ((Function) p).getName();
                  }
                  if (primitiveValue != null && primitiveValue.startsWith(data)) {
                    try {
                      component.declareDependantOf(next);
                    } catch (DependancyLoopException e) {
                      logger.warning(
                          "DependancyLoopException raised while declaring dependancy (data lookup)"
                              + "in the context of binding: "
                              + binding.getStringRepresentation()
                              + " primitive: "
                              + primitiveValue
                              + " component: "
                              + component
                              + " dependancy: "
                              + next
                              + " data: "
                              + data
                              + " message: "
                              + e.getMessage());
                    }
                  }
                }
              }
            }
            if (next.getName() != null) {
              for (Expression p : primitives) {
                String primitiveValue = null;
                if (p instanceof Variable) {
                  primitiveValue = ((Variable) p).getName();
                }
                if (p instanceof Function) {
                  primitiveValue = ((Function) p).getName();
                }
                if (primitiveValue != null
                    && StringUtils.isNotEmpty(next.getName())
                    && primitiveValue.startsWith(next.getName())) {
                  try {
                    component.declareDependantOf(next);
                  } catch (DependancyLoopException e) {
                    logger.warning(
                        "DependancyLoopException raised while declaring dependancy (name lookup)"
                            + "in the context of binding: "
                            + binding.getStringRepresentation()
                            + " primitive: "
                            + primitiveValue
                            + " component: "
                            + component
                            + " dependancy: "
                            + next
                            + " message: "
                            + e.getMessage());
                  }
                }
              }
            }
          }
        }

      } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (TypeMismatchException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }