protected void refreshPatternBar() {
    patternBar.removeAllComponents();

    final Collection<NType> allPatterns = app.getTypes(null);

    patternBar.setColumns(patternColumns);
    patternBar.setRows((int) Math.ceil(allPatterns.size() / patternColumns));

    // 1. add all non-present patterns to 'patternMenu'
    for (final NType pattern : allPatterns) {
      String pName = pattern.getName();

      final PushButton pButton =
          new PushButton(pName, detail.getTypes().contains(pattern)) {

            @Override
            public void setPushed(boolean b) {
              super.setPushed(b);
              if (isPushed()) {
                addNewPattern(pattern.getId());
              } else {
                removePattern(pattern.getId());
              }
            }
          };
      pButton.setWidth("100%");
      pButton.setHeight("100%");
      // pButton.setIcon(new ThemeResource(pattern.getIconURL()));

      patternBar.addComponent(pButton);
    }
    //        patternMenu.addSeparator();
    //        patternMenu.addItem("New Pattern...", new Command() {
    //
    //            @Override
    //            public void menuSelected(MenuItem selectedItem) {
    //                createNewPattern();
    //            }
    //        });

    //        //2. add all present patterns to 'patternBar' as menus
    //        for (final String p : presentPatterns) {
    //            Pattern pattern = schema.getPatterns().get(p);
    //            int total = getPropertiesTotal(pattern);
    //            MenuItem i = patternBar.addItem(pattern.getName() + " (" + (total -
    // getPropertiesNotPresent(pattern)) + "/" + total + ")", null, null);
    //
    //            for (String property : pattern.keySet()) {
    //                if (supportsAnotherProperty(property)) {
    //                    final Property pr = schema.getProperty(property);
    //                    i.addItem(pr.getName(), new Command() {
    //
    //                        @Override
    //                        public void menuSelected(MenuItem selectedItem) {
    //                            addProperty(pr.getID());
    //                        }
    //                    });
    //                }
    //            }
    //
    //            i.addSeparator();
    //
    //            //move left (more important)
    //            //move right (less important)
    //
    //            i.addItem("Remove", new Command() {
    //
    //                @Override
    //                public void menuSelected(MenuItem selectedItem) {
    //                    removePattern(p);
    //                }
    //            });
    //        }
  }
示例#2
0
    @Override
    public void valueChange(ValueChangeEvent event) {
      rm = (ReportModel) box.getValue();
      if (rm != null) {
        columnLayout.setVisible(true);
        columnLayout.setImmediate(true);
        reportColumnStepDesc.setVisible(true);
        List<ReportColumn> columnFields = rm.getReportTables().iterator().next().getReportColumns();
        gridLayout.removeAllComponents();
        gridLayout.requestRepaintAll();
        gridLayout.setRows(columnFields.size());
        gridLayout.setSpacing(true);

        for (final ReportColumn columnField : columnFields) {
          if (columnField.getColumnLabel() != null) {
            ReportColumnCard reportColumnCard =
                new ReportColumnCard(columnField) {
                  @Override
                  public void layoutClick(LayoutClickEvent event) {
                    if (clearDuplicateRelateColumnResult(columnField)) {
                      System.out.println(
                          "User click related column: " + columnField.getColumnLabel());
                      ReportColumn reportColumn = new ReportColumn();
                      reportColumn.setColumnName(columnField.getColumnName());
                      reportColumn.setColumnLabel(columnField.getColumnLabel());
                      reportColumn.setColumnUseMode(
                          ReportConfiguration.ReportColumnType.OutputColumn.toString());
                      if (ReportModelPool.findReportModelByCurrentUser(user)
                              .getSubTableSelectedColumns()
                          == null) {
                        HashSet<ReportColumn> reportColumns = new HashSet<ReportColumn>();
                        reportColumns.add(reportColumn);
                        ReportModelPool.findReportModelByCurrentUser(user)
                            .setSubTableSelectedColumns(reportColumns);
                      } else {
                        ReportModelPool.findReportModelByCurrentUser(user)
                            .getSubTableSelectedColumns()
                            .add(reportColumn);
                      }
                    }
                  }
                };
            gridLayout.addComponent(reportColumnCard);
          }
        }
        this.addComponent(columnLayout);
        ReportTable selectSubReportTable = rm.getReportTables().iterator().next();
        ReportModelPool.findReportModelByCurrentUser(user)
            .getReportTables()
            .add(selectSubReportTable);
        boolean removeStepflg = false;
        for (WizardStep step : w.getSteps()) {
          if (step.getCaption() != null) {
            if (step.getCaption().equals("Report Filter Step")) {
              removeStepflg = true;
            }
          }
        }
        if (removeStepflg) {
          w.removeStep("Report Filter Step");
        }
        w.removeStep("Preview Step");
        w.addStep(new ReportFilterStep(w, user), "Report Filter Step");
        w.addStep(new PreviewStep(w, user), "Preview Step");
      }
    }