コード例 #1
0
ファイル: ViewDwr.java プロジェクト: mlavelle42/mango
  private List<ViewComponentState> getViewPointData(User user, View view, boolean edit) {
    WebContext webContext = WebContextFactory.get();
    HttpServletRequest request = webContext.getHttpServletRequest();
    List<ViewComponentState> states = new ArrayList<ViewComponentState>();
    Map<String, Object> model = new HashMap<String, Object>();
    RuntimeManager rtm = Common.ctx.getRuntimeManager();

    for (ViewComponent viewComponent : view.getViewComponents()) {
      if (viewComponent.isCompoundComponent() && (edit || viewComponent.isVisible())) {
        CompoundComponent compoundComponent = (CompoundComponent) viewComponent;

        boolean imageChart = compoundComponent instanceof ImageChartComponent;

        // Add states for each of the children
        for (CompoundChild child : compoundComponent.getChildComponents())
          addPointComponentState(
              child.getViewComponent(), rtm, model, request, view, user, states, edit, !imageChart);

        // Add a state for the compound component.
        ViewComponentState state = new ViewComponentState();
        state.setId(compoundComponent.getId());

        model.clear();
        model.put("compoundComponent", compoundComponent);

        List<Map<String, Object>> childData = new ArrayList<Map<String, Object>>();
        for (CompoundChild child : compoundComponent.getChildComponents()) {
          if (child.getViewComponent().isPointComponent()) {
            DataPointVO point = ((PointComponent) child.getViewComponent()).tgetDataPoint();
            if (point != null) {
              Map<String, Object> map = new HashMap<String, Object>();
              if (imageChart) map.put("name", point.getName());
              else map.put("name", getMessage(child.getDescription()));
              map.put("point", point);
              map.put("pointValue", point.lastValue());
              childData.add(map);
            }
          }
        }
        model.put("childData", childData);

        if (compoundComponent.hasInfo())
          state.setInfo(generateContent(request, "compoundInfoContent.jsp", model));

        if (imageChart)
          state.setContent(
              ((ImageChartComponent) compoundComponent).getImageChartData(getResourceBundle()));
        else if (!edit) state.setChart(compoundComponent.getImageChartData(getResourceBundle()));

        states.add(state);
      } else
        addPointComponentState(viewComponent, rtm, model, request, view, user, states, edit, true);
    }

    return states;
  }
コード例 #2
0
ファイル: ViewDwr.java プロジェクト: mlavelle42/mango
 private ViewComponent getViewComponent(View view, String viewComponentId) {
   for (ViewComponent viewComponent : view.getViewComponents()) {
     if (viewComponent.getId().equals(viewComponentId)) return viewComponent;
   }
   return null;
 }