コード例 #1
0
ファイル: ListActivity.java プロジェクト: benkonrath/gwt-glom
  @Override
  public void start(final AcceptsOneWidget panel, final EventBus eventBus) {
    if (StringUtils.isEmpty(documentID)) {
      goTo(new DocumentSelectionPlace());
    }

    // register this class as the presenter
    listView.setPresenter(this);

    checkAuthentication(eventBus);

    // set the change handler for the table selection widget
    eventBus.addHandler(
        TableChangeEvent.TYPE,
        new TableChangeEventHandler() {
          @Override
          public void onTableChange(final TableChangeEvent event) {
            goTo(new ListPlace(documentID, event.getNewTableName(), ""));
          }
        });

    // populate the cell table with data
    final AsyncCallback<LayoutGroup> callback =
        new AsyncCallback<LayoutGroup>() {
          @Override
          public void onFailure(final Throwable caught) {
            // TODO: create a way to notify users of asynchronous callback failures
            GWT.log(
                "AsyncCallback Failed: OnlineGlomService.getListViewLayout(): "
                    + caught.getMessage());
          }

          @Override
          public void onSuccess(final LayoutGroup result) {
            // TODO check if result.getTableName() is the same as the tableName field. Update it if
            // it's not the
            // same.
            listView.setCellTable(documentID, tableName, result, quickFind);
          }
        };

    final String localeID = Utils.getCurrentLocaleID();
    OnlineGlomServiceAsync.Util.getInstance()
        .getListViewLayout(documentID, tableName, localeID, callback);

    // TODO: Avoid the code duplication with DetailsActivity.
    // set the change handler for the quickfind text widget
    eventBus.addHandler(
        QuickFindChangeEvent.TYPE,
        new QuickFindChangeEventHandler() {
          @Override
          public void onQuickFindChange(final QuickFindChangeEvent event) {
            // We switch to the List view, to show search results.
            // TODO: Show the details view if there is only one result.
            goTo(new ListPlace(documentID, tableName, event.getNewQuickFindText()));
          }
        });

    // Set the change handler for the table selection widget
    eventBus.addHandler(
        LocaleChangeEvent.TYPE,
        new LocaleChangeEventHandler() {
          @Override
          public void onLocaleChange(final LocaleChangeEvent event) {
            // note the empty primary key item
            goTo(new ListPlace(documentID, tableName, quickFind));
          }
        });

    // indicate that the view is ready to be displayed
    panel.setWidget(listView.asWidget());
  }
コード例 #2
0
ファイル: ListActivity.java プロジェクト: benkonrath/gwt-glom
 @Override
 protected void clearView() {
   super.clearView();
   listView.clear();
 }