Ejemplo n.º 1
0
  /** Actually load the history data, as demanded. */
  protected void loadHistoryData() {

    AssetServiceAsync assetService = GWT.create(AssetService.class);
    assetService.loadItemHistory(
        this.uuid,
        new GenericCallback<TableDataResult>() {

          public void onSuccess(TableDataResult table) {
            if (table == null || table.data.length == 0) {
              layout.setWidget(1, 0, new Label(constants.NoHistory()));
              showStaticIcon();
              return;
            }
            TableDataRow[] rows = table.data;
            Arrays.sort(
                rows,
                new Comparator<TableDataRow>() {
                  public int compare(TableDataRow r1, TableDataRow r2) {
                    Integer v2 = Integer.valueOf(r2.values[0]);
                    Integer v1 = Integer.valueOf(r1.values[0]);

                    return v2.compareTo(v1);
                  }
                });

            final ListBox history = new ListBox(true);

            for (TableDataRow row : rows) {
              String s =
                  constants.property0ModifiedOn1By23(
                      row.values[0], row.values[2], row.values[4], row.values[1]);
              history.addItem(s, row.id);
            }

            layout.setWidget(1, 0, history);
            FlexCellFormatter formatter = layout.getFlexCellFormatter();

            formatter.setColSpan(1, 0, 2);

            Button open = new Button(constants.View());

            open.addClickHandler(
                new ClickHandler() {

                  public void onClick(ClickEvent event) {
                    showVersion(history.getValue(history.getSelectedIndex()));
                  }
                });

            layout.setWidget(2, 0, open);
            formatter.setColSpan(2, 1, 3);
            formatter.setHorizontalAlignment(2, 1, HasHorizontalAlignment.ALIGN_CENTER);

            showStaticIcon();
          }
        });
  }