Ejemplo n.º 1
0
  @Override
  protected void configureDisplay(CellTable<IndexedDIP> display) {

    dateCreated =
        new Column<IndexedDIP, Date>(
            new DateCell(DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_MEDIUM))) {
          @Override
          public Date getValue(IndexedDIP dip) {
            return dip != null ? dip.getDateCreated() : null;
          }
        };

    lastModified =
        new Column<IndexedDIP, Date>(
            new DateCell(DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_MEDIUM))) {
          @Override
          public Date getValue(IndexedDIP dip) {
            return dip != null ? dip.getLastModified() : null;
          }
        };

    titleColumn =
        new TextColumn<IndexedDIP>() {

          @Override
          public String getValue(IndexedDIP dip) {
            return dip != null ? dip.getTitle() : null;
          }
        };

    titleColumn.setSortable(true);
    dateCreated.setSortable(true);
    lastModified.setSortable(true);

    display.addColumn(titleColumn, messages.aipGenericTitle());
    display.addColumn(dateCreated, messages.dipCreatedDate());
    display.addColumn(lastModified, messages.dipLastModified());

    Label emptyInfo = new Label(messages.noItemsToDisplay());
    display.setEmptyTableWidget(emptyInfo);

    // define default sorting
    display.getColumnSortList().push(new ColumnSortInfo(titleColumn, true));

    // display.setColumnWidth(titleColumn, 7.0, Unit.EM);
    display.setColumnWidth(dateCreated, 13.0, Unit.EM);
    display.setColumnWidth(lastModified, 13.0, Unit.EM);

    dateCreated.setCellStyleNames("nowrap");
    lastModified.setCellStyleNames("nowrap");

    addStyleName("my-collections-table");
    emptyInfo.addStyleName("my-collections-empty-info");
  }
Ejemplo n.º 2
0
  private void setWindowTitle(List<String> historyTokens) {
    String tokenI18N = "";
    boolean resolved = false;
    List<String> tokens = historyTokens;

    while (!resolved && tokens.size() > 0) {
      String token = StringUtils.join(tokens, "_");
      tokenI18N = messages.title(token).toUpperCase();

      if (tokenI18N.isEmpty()) {
        tokens = HistoryUtils.removeLast(tokens);
      } else {
        resolved = true;
      }
    }

    if (!resolved) {
      String lastToken = historyTokens.get(historyTokens.size() - 1);

      // TODO generalize suffix approach
      if (lastToken.endsWith(".html")) {
        lastToken = lastToken.substring(0, lastToken.length() - ".html".length());
      }

      // transform camel case to spaces
      lastToken = lastToken.replaceAll("([A-Z])", " $1");

      // upper-case
      lastToken = lastToken.toUpperCase();

      tokenI18N = lastToken;
    }

    // title.setText(tokenI18N);
    Window.setTitle(messages.windowTitle(tokenI18N));
  }
Ejemplo n.º 3
0
  @Override
  protected void configureDisplay(CellTable<Notification> display) {
    fromUser =
        new TextColumn<Notification>() {

          @Override
          public String getValue(Notification notification) {
            return notification != null ? notification.getFromUser() : null;
          }
        };

    sentOn =
        new Column<Notification, Date>(
            new DateCell(DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_MEDIUM))) {
          @Override
          public Date getValue(Notification notification) {
            return notification != null ? notification.getSentOn() : null;
          }
        };

    subject =
        new TextColumn<Notification>() {

          @Override
          public String getValue(Notification notification) {
            return notification != null ? notification.getSubject() : null;
          }
        };

    acknowledged =
        new Column<Notification, SafeHtml>(new SafeHtmlCell()) {
          @Override
          public SafeHtml getValue(Notification notification) {
            SafeHtml ret = null;
            if (notification != null) {
              if (notification.isAcknowledged()) {
                ret =
                    SafeHtmlUtils.fromSafeConstant(
                        "<span class='label-success'>"
                            + messages.showMessageAcknowledged()
                            + "</span>");
              } else {
                ret =
                    SafeHtmlUtils.fromSafeConstant(
                        "<span class='label-danger'>"
                            + messages.showMessageNotAcknowledged()
                            + "</span>");
              }
            }

            return ret;
          }
        };

    state =
        new Column<Notification, SafeHtml>(new SafeHtmlCell()) {
          @Override
          public SafeHtml getValue(Notification notification) {
            SafeHtml ret = null;
            if (notification != null) {
              ret = HtmlSnippetUtils.getNotificationStateHTML(notification.getState());
            }
            return ret;
          }
        };

    fromUser.setSortable(true);
    sentOn.setSortable(true);
    subject.setSortable(true);
    acknowledged.setSortable(true);
    state.setSortable(true);
    // TODO externalize strings into constants

    addColumn(fromUser, messages.notificationFrom(), true, false);
    addColumn(sentOn, messages.notificationSentOn(), true, false, 13);
    addColumn(subject, messages.notificationSubject(), true, false);
    addColumn(state, messages.notificationState(), true, false, 7);
    addColumn(acknowledged, messages.notificationAck(), true, false, 7);

    // default sorting
    display.getColumnSortList().push(new ColumnSortInfo(sentOn, false));

    addStyleName("my-collections-table");
  }