private void buildColumns() {
   gameResultTable.addGeneratedColumn("Round", GameCoulmnHelper.getRoundColmun());
   gameResultTable.addGeneratedColumn(
       PlayerType.FACTORY.toString() + " order",
       GameCoulmnHelper.getPlayerOrderColumn(PlayerType.FACTORY));
   gameResultTable.addGeneratedColumn(
       PlayerType.FACTORY.toString() + " score",
       GameCoulmnHelper.getPlayerScoreColumn(PlayerType.FACTORY));
   gameResultTable.addGeneratedColumn(
       PlayerType.DISTRIBUTOR.toString() + " order",
       GameCoulmnHelper.getPlayerOrderColumn(PlayerType.DISTRIBUTOR));
   gameResultTable.addGeneratedColumn(
       PlayerType.DISTRIBUTOR.toString() + " score",
       GameCoulmnHelper.getPlayerScoreColumn(PlayerType.DISTRIBUTOR));
   gameResultTable.addGeneratedColumn(
       PlayerType.WHOLESALER.toString() + " order",
       GameCoulmnHelper.getPlayerOrderColumn(PlayerType.WHOLESALER));
   gameResultTable.addGeneratedColumn(
       PlayerType.WHOLESALER.toString() + " score",
       GameCoulmnHelper.getPlayerOrderColumn(PlayerType.WHOLESALER));
   gameResultTable.addGeneratedColumn(
       PlayerType.RETAILER.toString() + " order",
       GameCoulmnHelper.getPlayerOrderColumn(PlayerType.RETAILER));
   gameResultTable.addGeneratedColumn(
       PlayerType.RETAILER.toString() + " score",
       GameCoulmnHelper.getPlayerOrderColumn(PlayerType.RETAILER));
   gameResultTable.addGeneratedColumn("Total score", GameCoulmnHelper.getScoreColumn());
 }
  @Override
  protected Component getChart() {
    List<StockData> data = new LinkedList<StockData>();
    for (int i = 0; i < 200; i++) {
      data.addAll(getStockData());
    }

    Container container = new BeanItemContainer<StockData>(StockData.class, data);

    Table table = new Table();
    table.setContainerDataSource(container);
    table.addGeneratedColumn(
        "values",
        new Table.ColumnGenerator() {
          @Override
          public Object generateCell(Table source, Object itemId, Object columnId) {
            return new Sparkline(
                100, 20, (Number[]) source.getItem(itemId).getItemProperty(columnId).getValue());
          }
        });

    table.setVisibleColumns("month", "values", "latest");
    table.setHeightUndefined();

    return table;
  }
  @SuppressWarnings("serial")
  private Component getTable() {
    List<UserOprYayasan> lm = GenericPersistence.findList(UserOprYayasan.class);

    dashboardPanels = new VerticalLayout();
    dashboardPanels.addStyleName("dashboard-panels");
    Responsive.makeResponsive(dashboardPanels);
    beans.setBeanIdProperty("id");
    beans.removeAllItems();
    if (lm != null) {
      beans.addAll(lm);
    } else {
      beans.addBean(new UserOprYayasan());
    }

    tabel.addGeneratedColumn(
        "aksi",
        new ColumnGenerator() {
          @Override
          public Object generateCell(Table source, Object itemId, Object columnId) {
            HorizontalLayout hl = new HorizontalLayout();
            Button edit = new Button(FontAwesome.EDIT);
            Button hapus = new Button(FontAwesome.TRASH_O);
            edit.addStyleName(ValoTheme.BUTTON_FRIENDLY);
            edit.addStyleName(ValoTheme.BUTTON_SMALL);
            hapus.addStyleName(ValoTheme.BUTTON_FRIENDLY);
            hapus.addStyleName(ValoTheme.BUTTON_SMALL);
            BeanItem<?> i = (BeanItem<?>) source.getContainerDataSource().getItem(itemId);
            final UserOprYayasan o = (UserOprYayasan) i.getBean();
            edit.addClickListener(
                new ClickListener() {
                  @Override
                  public void buttonClick(ClickEvent event) {
                    tambahUserYayasanbaru(o);
                  }
                });
            hl.addComponent(edit);
            hl.addComponent(hapus);
            return hl;
          }
        });
    tabel.setSizeFull();
    tabel.setImmediate(true);
    tabel.setSelectable(true);
    tabel.setContainerDataSource(beans);
    tabel.setRowHeaderMode(Table.RowHeaderMode.INDEX);
    tabel.setColumnHeader("useNnama", "NAMA PENGGUNA");
    tabel.setColumnHeader("nama", "NAMA");
    tabel.setColumnHeader("realName", "NAMA LENGKAP");
    tabel.setColumnHeader("registerDate", "TANGGAL REGISTRASI");
    tabel.setColumnHeader("email", "E-MAIL");
    tabel.setColumnHeader("lastSuccessfulLogin", "TERAKHIR LOGIN");
    tabel.setColumnHeader("aksi", "AKSI");
    tabel.setVisibleColumns(
        "aksi", "nama", "realName", "registerDate", "email", "lastSuccessfulLogin");
    dashboardPanels.addComponent(tabel);
    return dashboardPanels;
  }
 /**
  * Call this method before any of the {@link SelectionNotifier} methods to ensure that the {@link
  * SelectionListener} instances are registered with all of the {@link ColumnGenerator} classes
  * that also implement {@link SelectionNotifier}.
  */
 public void setColumnGenerators(Map generators) {
   for (Object key : generators.keySet()) {
     super.addGeneratedColumn(key, (ColumnGenerator) generators.get(key));
     // If any of the column generators are {@link SelectionNotifier} instances,
     // then register this component as a listener for events that they generate.
     try {
       m_selectionNotifiers.add((SelectionNotifier) generators.get(key));
     } catch (ClassCastException e) {
     }
   }
 }
 @Override
 protected void initView() {
   super.initView();
   processTable = new Table();
   dataSource = new BeanItemContainer<ProcessDefinition>(ProcessDefinition.class);
   processTable.setContainerDataSource(dataSource);
   processTable.setVisibleColumns(
       new String[] {"name", "key", "version", "resourceName", "category"});
   processTable.setSizeFull();
   processTable.addGeneratedColumn("name", createNameColumnGenerator());
   getViewLayout().addComponent(processTable);
   getViewLayout().setExpandRatio(processTable, 1.0F);
 }
Exemple #6
0
  @Override
  /** displays a list of historicProcessInstances */
  protected void initView() {
    super.initView();
    Button refresh = new Button("Refresh");
    refresh.addStyleName(Reindeer.BUTTON_SMALL);
    refresh.addListener(
        new Button.ClickListener() {
          private static final long serialVersionUID = 1L;

          @Override
          public void buttonClick(ClickEvent event) {
            getPresenter().init();
          }
        });

    processTable = new Table();
    dataSource =
        new BeanItemContainer<HistoricProcessInstanceTitle>(HistoricProcessInstanceTitle.class);
    processTable.setContainerDataSource(dataSource);
    processTable.setVisibleColumns(
        new String[] {
          "id",
          "processDefinitionId",
          "title",
          "startUserId",
          "startTime",
          "endTime",
          "durationInMillis"
        });
    processTable.setSizeFull();
    processTable.addGeneratedColumn("id", createNameColumnGenerator());
    processTable.addGeneratedColumn("durationInMillis", new TimeColumnGenerator());
    getViewLayout().addComponent(refresh);
    getViewLayout().addComponent(processTable);
    getViewLayout().setExpandRatio(processTable, 1.0F);
  }
  protected Table createList() {
    groupTable = new Table();

    groupTable.setEditable(false);
    groupTable.setImmediate(true);
    groupTable.setSelectable(true);
    groupTable.setNullSelectionAllowed(false);
    groupTable.setSortDisabled(true);
    groupTable.setSizeFull();

    groupListQuery = new GroupListQuery();
    groupListContainer = new LazyLoadingContainer(groupListQuery, 20);
    groupTable.setContainerDataSource(groupListContainer);

    // Column headers
    groupTable.addGeneratedColumn("icon", new ThemeImageColumnGenerator(Images.GROUP_22));
    groupTable.setColumnWidth("icon", 22);
    groupTable.addContainerProperty("name", String.class, null);
    groupTable.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);

    // Listener to change right panel when clicked on a user
    groupTable.addListener(
        new Property.ValueChangeListener() {
          private static final long serialVersionUID = 1L;

          public void valueChange(ValueChangeEvent event) {
            Item item =
                groupTable.getItem(
                    event
                        .getProperty()
                        .getValue()); // the value of the property is the itemId of the table entry
            if (item != null) {
              String groupId = (String) item.getItemProperty("id").getValue();
              setDetailComponent(new GroupDetailPanel(GroupPage.this, groupId));

              // Update URL
              ExplorerApp.get()
                  .setCurrentUriFragment(new UriFragment(GroupNavigator.GROUP_URI_PART, groupId));
            } else {
              // Nothing is selected
              setDetailComponent(null);
              ExplorerApp.get()
                  .setCurrentUriFragment(new UriFragment(GroupNavigator.GROUP_URI_PART, groupId));
            }
          }
        });

    return groupTable;
  }
 @SuppressWarnings("serial")
 public static void addBemerkungColumn(final String columnId, final Table table) {
   table.addGeneratedColumn(
       columnId,
       new Table.ColumnGenerator() {
         @Override
         public Object generateCell(
             final Table source, final Object itemId, final Object columnId) {
           HorizontalLayout layout = new HorizontalLayout();
           ReservationStellplatz reservation = (ReservationStellplatz) itemId;
           if (StringUtils.isNotBlank(reservation.getBemerkung())) {
             Label labelBemerkung =
                 new Label(Utility.cropString(reservation.getBemerkung(), 5) + " (...)");
             labelBemerkung.setDescription("<h2>" + reservation.getBemerkung() + "</h2>");
             layout.addComponent(labelBemerkung);
           }
           return layout;
         }
       });
 }
  public WindowManagerTeacher() {

    setCaption("quan ly bo mon "); // Constants.USER_CAPTION) ;

    mainLayout = new HorizontalLayout();
    mainLayout.setImmediate(false);
    mainLayout.setWidth(Constants.WIDTH_MAX, Sizeable.UNITS_PIXELS);
    mainLayout.setMargin(false);
    mainLayout.setSpacing(true);

    mainLayout.addComponent(new leftSide());

    rContentList = new VerticalLayout();
    rContentList.setWidth("100%");
    mainLayout.addComponent(rContentList);
    mainLayout.setExpandRatio(rContentList, 1.0f);

    rContentModify = new rightContentAddNewTeacher(1);
    rContentModify.setWidth("100%");

    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setStyleName("bl-mainContent");
    v.addComponent(mainLayout);
    v.setComponentAlignment(mainLayout, Alignment.MIDDLE_CENTER);

    addComponent(new topLogin());
    addComponent(new topPanel());
    addComponent(new mainMenu());
    addComponent(v);
    addComponent(new bottom());

    // --------------------bl
    Label title = new Label("<center><h1>Danh sách giang vien<h1></center>", Label.CONTENT_XHTML);

    table = new Table();
    table.setWidth("100%");
    table.setPageLength(20);

    rContentList.addComponent(title);
    rContentList.addComponent(table);

    Connection conn = null;
    Statement stmt = null;

    try {
      JDBCConnectionPool pool =
          new SimpleJDBCConnectionPool(
              JDBC_DRIVER,
              DB_URL + QlgiangvienApplication.DB_DBNAME,
              QlgiangvienApplication.DB_USER,
              QlgiangvienApplication.DB_PASS);

      String mysql = "SELECT * from GiangVien";

      TableQuery query = new TableQuery("GiangVien", pool);
      query.setVersionColumn("OPTLOCK");

      SQLContainer container = new SQLContainer(query);
      container.setAutoCommit(true);
      //          container.re
      table.setContainerDataSource(container);

      //           FreeformQuery query = new FreeformQuery(mysql, pool, "MaGV") ;

      //           container = new SQLContainer(query);

      //           table.setContainerDataSource(container) ;

      table.addGeneratedColumn(
          "Chinh Sua",
          new Table.ColumnGenerator() {
            public Component generateCell(Table source, Object itemId, Object columnId) {
              final Item item = table.getItem(itemId);

              Button btnModify =
                  new Button(
                      "Chinh Sua",
                      new Button.ClickListener() {
                        @Override
                        public void buttonClick(ClickEvent event) {

                          //              				rContentList.setVisible(false);
                          //              				rContentModify.setVisible(true);
                          System.out.println(item.toString());
                          rContentModify.setUpdateData(
                              item.getItemProperty("MaGV").getValue().toString());
                          mainLayout.removeComponent(rContentList);
                          mainLayout.addComponent(rContentModify);
                          mainLayout.setExpandRatio(rContentModify, 1.0f);
                        }
                      });

              return btnModify;
            }
          });
      confirmDelete();
      table.addGeneratedColumn(
          "Xoa",
          new Table.ColumnGenerator() {
            public Component generateCell(Table source, Object itemId, Object columnId) {

              //            	   Item item = table.getItem(itemId);

              Button btnModify =
                  new Button(
                      "Xoa",
                      new Button.ClickListener() {
                        @Override
                        public void buttonClick(ClickEvent event) {

                          if (subwindow.getParent() == null) {

                            getWindow().addWindow(subwindow);
                          }
                        }
                      });

              return btnModify;
            }
          });

    } catch (Exception e) {
      System.out.println("in right COntent: " + e.toString());
    }
  } // end of container
Exemple #10
0
  private DataBinder<MarathonData> showPhaseData(final FormLayout layout, final Phase phase) {
    layout.setMargin(true);
    final BeanFieldGroup<PhaseDataCompetition> binder =
        new BeanFieldGroup<PhaseDataCompetition>(PhaseDataCompetition.class);
    final DurationFieldFactory fieldFactory = new DurationFieldFactory();
    binder.setFieldFactory(fieldFactory);

    // layout.addComponent(binder.buildAndBind("geplante Startzeit", "startTime"));
    // layout.addComponent(binder.buildAndBind("Maximale Zeit", "maxTime"));
    // layout.addComponent(binder.buildAndBind("Minimale Zeit", "minTime"));
    layout.addComponent(binder.buildAndBind("Name der Phase", "phaseName"));
    layout.addComponent(binder.buildAndBind("Länge in m", "length"));
    // layout.addComponent(binder.buildAndBind("Geschwindigkeit im m/s", "velocity"));
    // layout.addComponent(binder.buildAndBind("Tabelle", "entries"));

    final BeanItemContainer<Entry<String, PhaseDataCategory>> categoryTimesItemContainer =
        new BeanItemContainer<Map.Entry<String, PhaseDataCategory>>(Map.Entry.class);
    final Table timesTable = new Table("Zeiten");
    timesTable.setContainerDataSource(categoryTimesItemContainer);
    timesTable.setHeight("8em");
    timesTable.removeContainerProperty("key");
    timesTable.removeContainerProperty("value");
    timesTable.addGeneratedColumn(
        "Kategorie",
        new ColumnGenerator() {

          @Override
          public Object generateCell(
              final Table source, final Object itemId, final Object columnId) {
            @SuppressWarnings("unchecked")
            final Entry<String, PhaseDataCategory> entry =
                (Entry<String, PhaseDataCategory>) itemId;
            return new Label(entry.getKey());
          }
        });
    timesTable.addGeneratedColumn(
        "Min. Zeit",
        new ColumnGenerator() {

          @Override
          public Object generateCell(
              final Table source, final Object itemId, final Object columnId) {
            @SuppressWarnings("unchecked")
            final Entry<String, PhaseDataCategory> entry =
                (Entry<String, PhaseDataCategory>) itemId;
            final TextField field = fieldFactory.createField(Duration.class, TextField.class);
            final PhaseDataCategory phaseDataCategory = entry.getValue();
            final ObjectProperty<Duration> property =
                new ObjectProperty<Duration>(
                    defaultIfNull(phaseDataCategory.getMinTime(), new Duration(0)));
            field.setPropertyDataSource(property);
            property.addValueChangeListener(
                new ValueChangeListener() {

                  @Override
                  public void valueChange(final ValueChangeEvent event) {
                    phaseDataCategory.setMinTime(property.getValue());
                  }
                });
            return field;
          }
        });
    timesTable.addGeneratedColumn(
        "Max. Zeit",
        new ColumnGenerator() {

          @Override
          public Object generateCell(
              final Table source, final Object itemId, final Object columnId) {
            @SuppressWarnings("unchecked")
            final Entry<String, PhaseDataCategory> entry =
                (Entry<String, PhaseDataCategory>) itemId;
            final TextField field = fieldFactory.createField(Duration.class, TextField.class);
            final PhaseDataCategory phaseDataCategory = entry.getValue();
            final ObjectProperty<Duration> property =
                new ObjectProperty<Duration>(
                    defaultIfNull(phaseDataCategory.getMaxTime(), new Duration(0)));
            field.setPropertyDataSource(property);
            property.addValueChangeListener(
                new ValueChangeListener() {

                  @Override
                  public void valueChange(final ValueChangeEvent event) {
                    phaseDataCategory.setMaxTime(property.getValue());
                  }
                });
            return field;
          }
        });
    timesTable.addGeneratedColumn(
        "Geschw.",
        new ColumnGenerator() {

          @Override
          public Object generateCell(
              final Table source, final Object itemId, final Object columnId) {
            @SuppressWarnings("unchecked")
            final Entry<String, PhaseDataCategory> entry =
                (Entry<String, PhaseDataCategory>) itemId;
            final PhaseDataCategory phaseDataCategory = entry.getValue();
            phaseDataCategory.getVelocity();
            final TextField field = fieldFactory.createField(Double.class, TextField.class);
            final ObjectProperty<Double> property =
                new ObjectProperty<Double>(
                    defaultIfNull(phaseDataCategory.getVelocity(), Double.valueOf(0)));
            field.setPropertyDataSource(property);
            property.addValueChangeListener(
                new ValueChangeListener() {

                  @Override
                  public void valueChange(final ValueChangeEvent event) {
                    phaseDataCategory.setVelocity(property.getValue());
                  }
                });
            return field;
          }
        });

    layout.addComponent(timesTable);

    final BeanItemContainer<TimeEntry> timeEntryItemContainer =
        new BeanItemContainer<TimeEntry>(TimeEntry.class);

    final Table table = new Table("Strecke");
    table.setContainerDataSource(timeEntryItemContainer);
    table.setEditable(true);
    table.setSortEnabled(false);
    table.setNullSelectionAllowed(true);
    layout.addComponent(table);
    table.setDragMode(TableDragMode.ROW);
    table.setDropHandler(
        new DropHandler() {

          @Override
          public void drop(final DragAndDropEvent dropEvent) {
            final DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable();
            final TimeEntry sourceItemId = (TimeEntry) t.getItemId(); // returns our Bean

            final AbstractSelectTargetDetails dropData =
                ((AbstractSelectTargetDetails) dropEvent.getTargetDetails());
            final TimeEntry targetItemId = (TimeEntry) dropData.getItemIdOver(); // returns our Bean

            // No move if source and target are the same, or there is no target
            if (sourceItemId == targetItemId || targetItemId == null) return;

            // Let's remove the source of the drag so we can add it back where requested...
            timeEntryItemContainer.removeItem(sourceItemId);

            if (dropData.getDropLocation() == VerticalDropLocation.BOTTOM) {
              timeEntryItemContainer.addItemAfter(targetItemId, sourceItemId);
            } else {
              final Object prevItemId = timeEntryItemContainer.prevItemId(targetItemId);
              timeEntryItemContainer.addItemAfter(prevItemId, sourceItemId);
            }
          }

          @Override
          public AcceptCriterion getAcceptCriterion() {
            return new SourceIs(table);
          }
        });
    table.addGeneratedColumn(
        "",
        new ColumnGenerator() {

          @Override
          public Object generateCell(
              final Table source, final Object itemId, final Object columnId) {
            final Button button = new Button("Löschen");
            button.addClickListener(
                new ClickListener() {
                  @Override
                  public void buttonClick(final ClickEvent event) {
                    source.getContainerDataSource().removeItem(itemId);
                  }
                });
            return button;
          }
        });
    final TableFieldFactory tableFieldFactory =
        new TableFieldFactory() {

          @Override
          public Field<?> createField(
              final Container container,
              final Object itemId,
              final Object propertyId,
              final Component uiContext) {
            final Class<?> type = container.getType(propertyId);
            final Field field = fieldFactory.createField(type, Field.class);
            if (field instanceof AbstractTextField) {
              final AbstractTextField abstractTextField = (AbstractTextField) field;
              abstractTextField.setNullRepresentation("");
              abstractTextField.setValidationVisible(true);
            }
            return field;
          }
        };
    table.setTableFieldFactory(tableFieldFactory);

    layout.addComponent(
        new Button(
            "Neuer Steckenpunkt",
            new ClickListener() {

              @Override
              public void buttonClick(final ClickEvent event) {
                timeEntryItemContainer.addBean(new TimeEntry());
              }
            }));

    final DataBinder<MarathonData> phaseDataBinder =
        new DataBinder<MarathonData>() {

          private MarathonData data;

          @Override
          public void bindData(final MarathonData phaseData) {
            this.data = phaseData;
            final PhaseDataCompetition dataCompetition = data.getCompetitionPhases().get(phase);
            binder.setItemDataSource(dataCompetition);
            timeEntryItemContainer.removeAllItems();
            timeEntryItemContainer.addAll(dataCompetition.getEntries());
            categoryTimesItemContainer.removeAllItems();
            final Map<String, PhaseDataCategory> categoryTimes = dataCompetition.getCategoryTimes();
            for (final String category : data.getCategories()) {
              if (!categoryTimes.containsKey(category)) {
                categoryTimes.put(category, new PhaseDataCategory());
              }
              categoryTimesItemContainer.addBean(
                  new Entry<String, PhaseDataCategory>() {

                    @Override
                    public String getKey() {
                      return category;
                    }

                    @Override
                    public PhaseDataCategory getValue() {
                      return categoryTimes.get(category);
                    }

                    @Override
                    public PhaseDataCategory setValue(final PhaseDataCategory value) {
                      return categoryTimes.put(category, value);
                    }
                  });
            }
          }

          @Override
          public void commitHandler() {
            try {
              binder.commit();
              final PhaseDataCompetition dataCompetition = data.getCompetitionPhases().get(phase);
              container2Model(timeEntryItemContainer, dataCompetition);
              for (final Entry<String, PhaseDataCategory> entry :
                  categoryTimesItemContainer.getItemIds()) {
                dataCompetition.getCategoryTimes().put(entry.getKey(), entry.getValue());
              }
            } catch (final CommitException e) {
              throw new RuntimeException("Cannot commit", e);
            }
          }

          @Override
          public MarathonData getCurrentData() {
            return data;
          }
        };
    layout.addComponent(
        new Button(
            "Reset Strecke",
            new ClickListener() {

              @Override
              public void buttonClick(final ClickEvent event) {
                phaseDataBinder.commitHandler();

                final PhaseDataCompetition phaseData =
                    phaseDataBinder.getCurrentData().getCompetitionPhases().get(phase);
                phaseData.setDefaultPoints();

                model2Container(phaseData, timeEntryItemContainer);
                System.out.println(phaseData);
              }
            }));
    return phaseDataBinder;
  }
Exemple #11
0
  private DataBinder<MarathonData> showOverviewData(final FormLayout layout) {
    layout.setMargin(true);
    final BeanFieldGroup<MarathonData> binder =
        new BeanFieldGroup<MarathonData>(MarathonData.class);
    layout.addComponent(binder.buildAndBind("Veranstaltung", "marathonName"));
    final BeanItemContainer<String> categoryListContainer =
        new BeanItemContainer<String>(String.class);

    final ListSelect categoryListSelect = new ListSelect("Kategorieen", categoryListContainer);
    categoryListSelect.setNewItemsAllowed(true);
    categoryListSelect.setNullSelectionAllowed(false);
    categoryListSelect.setMultiSelect(false);
    layout.addComponent(categoryListSelect);
    final Button removeItemButton = new Button("Kategorie löschen");
    layout.addComponent(removeItemButton);
    removeItemButton.addClickListener(
        new ClickListener() {

          @Override
          public void buttonClick(final ClickEvent event) {
            categoryListContainer.removeItem(categoryListSelect.getValue());
          }
        });
    // final ListSelect categoryList = new ListSelect("Kategorieen");
    // layout.addComponent(categoryList);

    final BeanItemContainer<DriverData> driverContainer =
        new BeanItemContainer<DriverData>(DriverData.class);

    final Table table = new Table("Fahrer");
    table.setContainerDataSource(driverContainer);
    table.removeContainerProperty("smallSheets");
    table.removeContainerProperty("startTimes");
    table.removeContainerProperty("category");
    table.addGeneratedColumn(
        "Kategorie",
        new ColumnGenerator() {

          @Override
          public Object generateCell(
              final Table source, final Object itemId, final Object columnId) {
            final ComboBox comboBox = new ComboBox();
            comboBox.setContainerDataSource(categoryListContainer);
            final DriverData driverData = (DriverData) itemId;
            final String category =
                driverData.getCategory() == null ? "" : driverData.getCategory();

            final ObjectProperty<String> property = new ObjectProperty<String>(category);
            comboBox.setPropertyDataSource(property);
            property.addValueChangeListener(
                new ValueChangeListener() {

                  @Override
                  public void valueChange(final ValueChangeEvent event) {
                    driverData.setCategory(property.getValue());
                  }
                });
            return comboBox;
          }
        });
    table.addGeneratedColumn(
        "Generieren",
        new ColumnGenerator() {

          @Override
          public Object generateCell(
              final Table source, final Object itemId, final Object columnId) {
            final DriverData driverData = (DriverData) itemId;
            final Button button = new Button("PDF");
            button.addClickListener(
                new ClickListener() {
                  @Override
                  public void buttonClick(final ClickEvent event) {
                    // showPdfHandler.showPdf(driverData.getName());
                  }
                });
            return button;
          }
        });
    table.addGeneratedColumn("Phase A Zettel", createPhaseCheckbox(Phase.A));
    table.addGeneratedColumn("Phase D Zettel", createPhaseCheckbox(Phase.D));
    table.addGeneratedColumn("Phase E Zettel", createPhaseCheckbox(Phase.E));
    final DurationFieldFactory fieldFactory = new DurationFieldFactory();
    table.addGeneratedColumn("Phase A Start", createPhaseStartInput(fieldFactory, Phase.A));
    table.addGeneratedColumn("Phase D Start", createPhaseStartInput(fieldFactory, Phase.D));
    table.addGeneratedColumn("Phase E Start", createPhaseStartInput(fieldFactory, Phase.E));
    table.addGeneratedColumn(
        "Fahrer Löschen",
        new ColumnGenerator() {

          @Override
          public Object generateCell(
              final Table source, final Object itemId, final Object columnId) {
            final Button button = new Button("-");
            button.addClickListener(
                new ClickListener() {

                  @Override
                  public void buttonClick(final ClickEvent event) {
                    driverContainer.removeItem(itemId);
                  }
                });
            return button;
          }
        });

    table.setEditable(true);
    table.setSortEnabled(false);
    // table.setNullSelectionAllowed(true);
    layout.addComponent(table);
    final Button addDriverButton = new Button("Neuer Fahrer");
    addDriverButton.addClickListener(
        new ClickListener() {

          @Override
          public void buttonClick(final ClickEvent event) {
            final DriverData driver = new DriverData();
            driver.setName("Fahrer - " + driverContainer.size());
            driverContainer.addBean(driver);
          }
        });
    layout.addComponent(addDriverButton);

    return new DataBinder<MarathonData>() {

      private MarathonData data;

      @Override
      public void bindData(final MarathonData data) {
        this.data = data;
        binder.setItemDataSource(data);
        categoryListContainer.removeAllItems();
        for (final String category : data.getCategories()) {
          categoryListContainer.addBean(category);
        }
        driverContainer.removeAllItems();
        for (final DriverData driver : data.getDrivers().values()) {
          driverContainer.addBean(driver);
        }
      }

      @Override
      public void commitHandler() {
        try {
          binder.commit();
          final List<String> categories = data.getCategories();
          categories.clear();
          categories.addAll(categoryListContainer.getItemIds());
          final Map<String, DriverData> drivers = data.getDrivers();
          drivers.clear();
          for (final DriverData driver : driverContainer.getItemIds()) {
            drivers.put(driver.getName(), driver);
          }
        } catch (final CommitException e) {
          throw new RuntimeException("Cannot commit", e);
        }
      }

      @Override
      public MarathonData getCurrentData() {
        return data;
      }
    };
  }
Exemple #12
0
  protected Component createMainArea() {
    layout = new VerticalLayout();

    layout.setSpacing(true);
    layout.setMargin(true);
    layout.setSizeFull();

    HorizontalLayout filterLine = new HorizontalLayout();

    TextField filterBox = new TextField();
    filterBox.addStyleName(JabylonStyle.SEARCH_FIELD.getCSSName());
    filterBox.addListener(
        new TextChangeListener() {

          @Override
          public void textChange(TextChangeEvent event) {
            propertyFilter.setFilterText(event.getText());
            propertyPairContainer.addContainerFilter(propertyFilter);
          }
        });
    filterBox.setInputPrompt(
        Messages.getString("PropertiesEditor_FILTER_INPUT_PROMPT")); // $NON-NLS-1$
    filterLine.addComponent(filterBox);

    final CheckBox untranslatedBox =
        new CheckBox(
            Messages.getString(
                "PropertiesEditor_SHOW_ONLY_UNTRANSLATED_BUTTON_CAPTION")); //$NON-NLS-1$
    untranslatedBox.addListener(
        new ClickListener() {

          @Override
          public void buttonClick(ClickEvent event) {
            propertyPairContainer.removeContainerFilter(untranslatedFilter);
            if (untranslatedBox.getValue().equals(Boolean.TRUE))
              propertyPairContainer.addContainerFilter(untranslatedFilter);
          }
        });
    untranslatedBox.setImmediate(true);
    filterLine.addComponent(untranslatedBox);

    layout.addComponent(filterLine);
    layout.setExpandRatio(filterLine, 0);

    table = new Table();
    table.addStyleName(JabylonStyle.TABLE_STRIPED.getCSSName());
    table.setSizeFull();
    target = descriptor.loadProperties();
    source = descriptor.getMaster().loadProperties();

    propertyPairContainer = new PropertyPairContainer(source, target);
    table.setContainerDataSource(propertyPairContainer);
    table.setVisibleColumns(
        propertyPairContainer.getContainerPropertyIds().subList(0, 2).toArray());
    table.setWidth(100, Table.UNITS_PERCENTAGE);
    table.addGeneratedColumn(
        Messages.getString("PropertiesEditor_PROBLEMS_COLUMN_HEADER"),
        new ColumnGenerator() { //$NON-NLS-1$

          @Override
          public Object generateCell(Table source, Object itemId, Object columnId) {

            if (reviews.containsKey(itemId)) {
              Embedded embedded = new Embedded("", ImageConstants.IMAGE_ERROR); // $NON-NLS-1$

              Review review = reviews.get((String) itemId).iterator().next();
              // TODO: this can't be the right way to refresh?
              if (review.cdoInvalid()) {
                reviews.remove(itemId, review); // the review is
                // no
                // longer valid
                embedded.setIcon(ImageConstants.IMAGE_OK);
                embedded.setDescription(""); // $NON-NLS-1$
              } else {
                embedded.setDescription(review.getMessage());
              }

              return embedded;
            } else return new Embedded("", ImageConstants.IMAGE_OK); // $NON-NLS-1$
          }
        });

    table.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_EXPLICIT);

    table.setColumnHeaders(
        new String[] {
          Messages.getString("PropertiesEditor_ORIGINAL_COLUMN_HEADER"),
          Messages.getString("PropertiesEditor_TRANSLATED_COLUMN_HEADER"),
          Messages.getString("PropertiesEditor_PROBLEMS_COLUMN_HEADER")
        }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    table.setColumnExpandRatio(propertyPairContainer.getContainerPropertyIds().get(0), 1.0f);
    table.setColumnExpandRatio(propertyPairContainer.getContainerPropertyIds().get(1), 1.0f);
    table.setColumnExpandRatio(
        Messages.getString("PropertiesEditor_PROBLEMS_COLUMN_HEADER"), 0.0f); // $NON-NLS-1$

    table.setEditable(false);
    table.setWriteThrough(false);

    table.setSelectable(true);
    table.setMultiSelect(false);
    table.setImmediate(true); // react at once when something is selected
    table.addListener(this);

    layout.addComponent(table);

    layout.setExpandRatio(table, 2);
    createEditorArea();
    return layout;
  }