/** executeImport */ private void executeImport() { if (selectedRow >= 0) { GWTDropboxEntry gwtDropboxEntry = data.get(table.getHTML(selectedRow, 2)); // The actual folder selected in navigator view GWTFolder folder = NavigatorComunicator.getFolder(); if (gwtDropboxEntry.isDir()) { Dropbox.get().status.setImporting(); Dropbox.get().startStatusListener(StatusListenerPopup.ACTION_IMPORT); dropboxService.importFolder( gwtDropboxEntry, folder.getPath(), new AsyncCallback<Object>() { @Override public void onSuccess(Object result) { Dropbox.get().status.unsetImporting(); GeneralComunicator.refreshUI(); Dropbox.get().stopStatusListener(); } @Override public void onFailure(Throwable caught) { GeneralComunicator.showError("importFolder", caught); Dropbox.get().status.unsetImporting(); Dropbox.get().stopStatusListener(); } }); } else { Dropbox.get().status.setImporting(); dropboxService.importDocument( gwtDropboxEntry, folder.getPath(), new AsyncCallback<Object>() { @Override public void onSuccess(Object result) { Dropbox.get().status.unsetImporting(); GeneralComunicator.refreshUI(); } @Override public void onFailure(Throwable caught) { GeneralComunicator.showError("importDocument", caught); Dropbox.get().status.unsetImporting(); } }); } } }
/** 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); } }