Exemplo n.º 1
0
  public Component buildRelatedTableStep() throws Exception {
    VerticalLayout layout = new VerticalLayout();
    FormLayout formLayout = new FormLayout();
    formLayout.setSpacing(true);
    formLayout.setReadOnly(true);
    layout.addComponent(formLayout);

    if (ReportModelPool.findReportModelByCurrentUser(user) == null) {
      throw new Exception("Error occurs when initialing the related data");
    }

    if (relateReportTables == null || relateReportTables.size() == 0) {
      relateReportTables = new ArrayList<ReportTable>();
      for (ReportTable r : ReportModelPool.findReportModelByCurrentUser(user).getReportTables()) {
        if (r.getType() != null
            && r.getType().toString().equals(ReportConfiguration.ReportType.SubTable.toString())) {
          if (relateReportTables != null) {
            relateReportTables.add(r);
          }
        }
      }
    }
    ReportTableEditor editor =
        new ReportTableEditor(
            getRelateTableModel(), ReportConfiguration.ReportType.SubTable.toString());
    formLayout.addComponent(editor);
    return layout;
  }
Exemplo n.º 2
0
    public void attach() {
      this.addStyleName("custom-report-step-caption");
      Label caption = new Label("Select Reference Table");
      caption.setStyleName("caption");
      this.addComponent(caption);
      box.setWidth(fieldWidth);
      box.setImmediate(true);
      box.addStyleName("custom-report-step-box");
      BeanItemContainer<ReportModel> container =
          new BeanItemContainer<ReportModel>(ReportModel.class);
      container.addAll(getReportModels());
      box.setContainerDataSource(container);
      box.setItemCaptionPropertyId("tableLabel");
      box.addListener(this);
      this.addComponent(box);
      columnLayout.setSpacing(true);
      columnLayout.setVisible(false);

      //			List<ReportTable> relateReportTables=null;
      //			if(getEditableReportTable()!=null){
      //				for(Iterator<ReportModel> it=container.getItemIds().iterator();it.hasNext();){
      //					rm=(ReportModel) it.next();
      //					if(rm.getTableName().equals(getEditableReportTable().getTableName())){
      //						box.setValue(rm);
      //						mainReportTable=rm.getReportTables().iterator().next();
      //						relateReportTables=buildEditableRelatedTableInfo();
      //						break;
      //					}
      //				}
      //				box.setValue(getEditableReportTable().getTableName());
      //				rm.getReportTables().addAll(relateReportTables);
      //			}

      if (relateReportTables != null && isEditableFlg) {
        columnLayout.setVisible(true);
        columnLayout.setImmediate(true);
        //				columnLayout.addComponent(gridLayout);

        //				box.setValue(getEditableReportTable().getTableName());
        //				rm.getReportTables().addAll(relateReportTables);

        for (ReportTable relateRT : relateReportTables) {
          for (Iterator<ReportModel> it = container.getItemIds().iterator(); it.hasNext(); ) {
            ReportModel tempRm = it.next();
            if (tempRm.getTableName().equals(relateRT.getTableName())) {
              box.setValue(tempRm);
              break;
            }
          }
          List<ReportColumn> columnFields = relateRT.getReportColumns();

          for (final ReportColumn columnField : columnFields) {
            if (columnField.getColumnLabel() != null) {
              ReportColumnCard reportColumnCard =
                  new ReportColumnCard(columnField) {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public void layoutClick(LayoutClickEvent event) {
                      ReportColumn reportColumn = columnField;
                      reportColumn.setColumnUseMode(
                          ReportConfiguration.ReportColumnType.OutputColumn.toString());
                      rm.getSubTableSelectedColumns().add(reportColumn);
                    }
                  };

              for (ReportColumn rc : relateRT.getReportColumns()) {
                if (rc.getColumnUseMode() != null
                    && rc.getColumnUseMode()
                        .equals(ReportConfiguration.ReportColumnType.OutputColumn.toString())) {
                  if (rc.getColumnName().equals(columnField.getColumnName())) {
                    reportColumnCard.getCheckBox().setValue(true);
                  }
                }
              }

              gridLayout.addComponent(reportColumnCard);
            }
          }
        }
      }

      this.addComponent(columnLayout);
      reportColumnLabel.setStyleName("custom-report-step-column-caption");
      reportColumnLabel.setVisible(false);
      reportColumnStepDesc.setStyleName("custom-report-step-column-desc");
      reportColumnStepDesc.setVisible(false);
      this.addComponent(reportColumnLabel);
      this.addComponent(reportColumnStepDesc);
      gridLayout.setSizeFull();
      gridLayout.setImmediate(true);
      gridLayout.addStyleName("custom-report-step-column-gridlayout");
      this.addComponent(gridLayout);
    }