コード例 #1
0
ファイル: SearchPopup.java プロジェクト: HackLinux/openkm
  /** executeSearch */
  private void executeSearch() {
    if (name.getText().length() >= 3) {
      String category = "";

      if (typeList.getSelectedIndex() > 0) {
        category = typeList.getValue(typeList.getSelectedIndex());
      }

      String query = name.getText();
      Dropbox.get().status.setSearch();
      dropboxService.search(
          query,
          category,
          new AsyncCallback<List<GWTDropboxEntry>>() {
            @Override
            public void onSuccess(List<GWTDropboxEntry> result) {
              importButton.setEnabled(false);
              table.removeAllRows();
              data = new HashMap<String, GWTDropboxEntry>();

              for (GWTDropboxEntry gwtDropboxEntry : result) {
                int row = table.getRowCount();

                if (gwtDropboxEntry.isDir()) {
                  if (gwtDropboxEntry.isChildren()) {
                    table.setHTML(row, 0, UtilComunicator.imageItemHTML("img/menuitem_childs.gif"));
                  } else {
                    table.setHTML(row, 0, UtilComunicator.imageItemHTML("img/menuitem_empty.gif"));
                  }

                } else {
                  table.setHTML(
                      row, 0, UtilComunicator.mimeImageHTML(gwtDropboxEntry.getMimeType()));
                }

                table.setHTML(row, 1, gwtDropboxEntry.getPath());
                table.setHTML(row, 2, gwtDropboxEntry.getRev());
                table.getCellFormatter().setWidth(row, 0, "20");
                table.getCellFormatter().setWidth(row, 1, "100%");
                table.getCellFormatter().setHorizontalAlignment(row, 0, HasAlignment.ALIGN_CENTER);
                table.getCellFormatter().setHorizontalAlignment(row, 1, HasAlignment.ALIGN_LEFT);
                table.getCellFormatter().setVisible(row, 2, false);
                data.put(gwtDropboxEntry.getRev(), gwtDropboxEntry);
              }

              Dropbox.get().status.unsetSearch();
            }

            @Override
            public void onFailure(Throwable caught) {
              GeneralComunicator.showError("search", caught);
              Dropbox.get().status.unsetSearch();
            }
          });
    } else {
      table.removeAllRows();
      importButton.setEnabled(false);
    }
  }