Permalink
Browse files

CORE-3119 Added Simple Download to MyDataGrid action menus.

Renamed idrop-lite Download actions to "Bulk Download".
Added some instructions to the SimpleDownloadWindow.
Fixed GwtTestDataUtils::testSupportedActions.
  • Loading branch information...
psarando committed Apr 21, 2012
1 parent 4af58cf commit 61dd15656d0efa4699bdd02887db7027aba4d602
@@ -1172,10 +1172,24 @@
*/
String loadingSessionWaitNotice();
+ /**
+ * Localized display text for bulk download actions.
+ *
+ * @return a string representing the localized text.
+ */
+ String bulkDownload();
+
/**
* Localized display text for simple download actions.
*
* @return a string representing the localized text.
*/
String simpleDownload();
+
+ /**
+ * Localized display text for simple download window instructions.
+ *
+ * @return a string representing the localized text.
+ */
+ String simpleDownloadNotice();
}
@@ -161,4 +161,6 @@ savingSession = Saving Session
savingSessionWaitNotice = Saving current session, please wait...
loadingSession = Loading Session
loadingSessionWaitNotice = Loading last session, please wait...
+bulkDownload = Bulk Download
simpleDownload = Simple Download
+simpleDownloadNotice = Click on the links below to begin a download.
@@ -19,7 +19,7 @@
View(I18N.DISPLAY.view()),
ViewTree(I18N.DISPLAY.viewTreeViewer()),
SimpleDownload(I18N.DISPLAY.simpleDownload()),
- Download(I18N.DISPLAY.download()),
+ BulkDownload(I18N.DISPLAY.bulkDownload()),
Metadata(I18N.DISPLAY.metadata());
private final String displayText;
@@ -75,7 +75,7 @@ public static boolean hasFolders(final List<DiskResource> resources) {
}
}
- ret.add(Action.Download);
+ ret.add(Action.BulkDownload);
ret.add(Action.Delete);
}
}
@@ -16,6 +16,7 @@
import org.iplantc.de.client.Constants;
import org.iplantc.de.client.I18N;
import org.iplantc.de.client.dispatchers.IDropLiteWindowDispatcher;
+import org.iplantc.de.client.dispatchers.SimpleDownloadWindowDispatcher;
import org.iplantc.de.client.events.disk.mgmt.DiskResourceSelectedEvent;
import org.iplantc.de.client.events.disk.mgmt.DiskResourceSelectedEventHandler;
import org.iplantc.de.client.images.Resources;
@@ -93,7 +94,8 @@
private MenuItem itemRenameResource;
private MenuItem itemViewResource;
private MenuItem itemViewTree;
- private MenuItem itemDownloadResource;
+ private MenuItem itemSimpleDownloadResource;
+ private MenuItem itemBulkDownloadResource;
private MenuItem itemDeleteResource;
private MenuItem itemMetaData;
@@ -177,10 +179,15 @@ private Menu buildActionsMenu() {
itemViewTree.setIcon(AbstractImagePrototype.create(Resources.ICONS.fileView()));
itemViewTree.addSelectionListener(new ViewTreeListenerImpl());
- itemDownloadResource = new MenuItem();
- itemDownloadResource.setText(I18N.DISPLAY.download());
- itemDownloadResource.setIcon(AbstractImagePrototype.create(Resources.ICONS.download()));
- itemDownloadResource.addSelectionListener(new DownloadListenerImpl());
+ itemSimpleDownloadResource = new MenuItem();
+ itemSimpleDownloadResource.setText(I18N.DISPLAY.simpleDownload());
+ itemSimpleDownloadResource.setIcon(AbstractImagePrototype.create(Resources.ICONS.download()));
+ itemSimpleDownloadResource.addSelectionListener(new SimpleDownloadListenerImpl());
+
+ itemBulkDownloadResource = new MenuItem();
+ itemBulkDownloadResource.setText(I18N.DISPLAY.bulkDownload());
+ itemBulkDownloadResource.setIcon(AbstractImagePrototype.create(Resources.ICONS.download()));
+ itemBulkDownloadResource.addSelectionListener(new BulkDownloadListenerImpl());
itemDeleteResource = new MenuItem();
itemDeleteResource.setText(I18N.DISPLAY.delete());
@@ -196,9 +203,11 @@ private Menu buildActionsMenu() {
actionMenu.add(itemRenameResource);
actionMenu.add(itemViewResource);
actionMenu.add(itemViewTree);
- actionMenu.add(itemDownloadResource);
+ actionMenu.add(itemSimpleDownloadResource);
+ actionMenu.add(itemBulkDownloadResource);
actionMenu.add(itemDeleteResource);
actionMenu.add(itemMetaData);
+
return actionMenu;
}
@@ -255,9 +264,14 @@ public void showMenu(int x, int y) {
itemViewTree.show();
break;
- case Download:
- itemDownloadResource.enable();
- itemDownloadResource.show();
+ case SimpleDownload:
+ itemSimpleDownloadResource.enable();
+ itemSimpleDownloadResource.show();
+ break;
+
+ case BulkDownload:
+ itemBulkDownloadResource.enable();
+ itemBulkDownloadResource.show();
break;
case Delete:
@@ -550,15 +564,51 @@ public void componentSelected(MenuEvent ce) {
final MetadataEditorPanel mep = new DiskresourceMetadataEditorPanel(dr);
MetadataEditorDialog d = new MetadataEditorDialog(
- I18N.DISPLAY.metadata() + ":" + dr.getId(), mep);
+ I18N.DISPLAY.metadata() + ":" + dr.getId(), mep); //$NON-NLS-1$
d.setSize(500, 300);
d.setResizable(false);
d.show();
}
}
- private class DownloadListenerImpl extends SelectionListener<MenuEvent> {
+ private class SimpleDownloadListenerImpl extends SelectionListener<MenuEvent> {
+ @Override
+ public void componentSelected(MenuEvent ce) {
+
+ List<DiskResource> resources = getSelectionModel().getSelectedItems();
+
+ if (DataUtils.isDownloadable(resources)) {
+ if (resources.size() == 1) {
+ downloadNow(resources.get(0).getId());
+ } else {
+ launchDownloadWindow(resources);
+ }
+ } else {
+ showErrorMsg();
+ }
+ }
+
+ private void downloadNow(String path) {
+ FolderServiceFacade service = new FolderServiceFacade();
+ service.simpleDownload(path);
+ }
+
+ private void launchDownloadWindow(List<DiskResource> resources) {
+ List<String> paths = new ArrayList<String>();
+
+ for (DiskResource resource : resources) {
+ if (resource instanceof File) {
+ paths.add(resource.getId());
+ }
+ }
+
+ SimpleDownloadWindowDispatcher dispatcher = new SimpleDownloadWindowDispatcher();
+ dispatcher.launchDownloadWindow(paths);
+ }
+ }
+
+ private class BulkDownloadListenerImpl extends SelectionListener<MenuEvent> {
@Override
public void componentSelected(MenuEvent ce) {
@@ -104,7 +104,7 @@ private Hyperlink buildLink(final String text, final Listener<ComponentEvent> cl
ret = new SimpleDownloadListenerImpl();
break;
- case Download:
+ case BulkDownload:
ret = new DownloadListenerImpl();
break;
@@ -16,6 +16,7 @@
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.Listener;
+import com.extjs.gxt.ui.client.widget.Label;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.VerticalPanel;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
@@ -49,8 +50,11 @@ private void init() {
// Add window contents container for the simple download links
contents = new LayoutContainer();
+
+ // TODO use a CSS class instead of hard-coding?
contents.setStyleAttribute("padding", "5px"); //$NON-NLS-1$ //$NON-NLS-2$
+ add(new Label(I18N.DISPLAY.simpleDownloadNotice()));
add(contents);
}
@@ -171,34 +171,36 @@ public void testEmptySupportedActions() {
public void testSupportedActions() {
List<Action> actions = DataUtils.getSupportedActions(buildSingleFileList());
assertTrue(actions.contains(Action.Delete));
- assertTrue(actions.contains(Action.Download));
+ assertTrue(actions.contains(Action.SimpleDownload));
+ assertTrue(actions.contains(Action.BulkDownload));
assertTrue(actions.contains(Action.RenameFile));
assertTrue(actions.contains(Action.View));
assertTrue(actions.contains(Action.ViewTree));
assertTrue(actions.contains(Action.Metadata));
- assertEquals(6, actions.size());
+ assertEquals(7, actions.size());
actions = DataUtils.getSupportedActions(buildSingleFolderList());
assertTrue(actions.contains(Action.Delete));
- assertTrue(actions.contains(Action.Download));
+ assertTrue(actions.contains(Action.BulkDownload));
assertTrue(actions.contains(Action.RenameFolder));
assertTrue(actions.contains(Action.Metadata));
assertEquals(4, actions.size());
actions = DataUtils.getSupportedActions(buildFileFolderList());
assertTrue(actions.contains(Action.Delete));
- assertTrue(actions.contains(Action.Download));
+ assertTrue(actions.contains(Action.BulkDownload));
assertEquals(2, actions.size());
actions = DataUtils.getSupportedActions(buildMixedPermissionsFilesList());
assertTrue(actions.contains(Action.Delete));
- assertTrue(actions.contains(Action.Download));
+ assertTrue(actions.contains(Action.SimpleDownload));
+ assertTrue(actions.contains(Action.BulkDownload));
assertTrue(actions.contains(Action.View));
- assertEquals(3, actions.size());
+ assertEquals(4, actions.size());
actions = DataUtils.getSupportedActions(buildReadOnlyFolderList());
assertTrue(actions.contains(Action.Delete));
- assertTrue(actions.contains(Action.Download));
+ assertTrue(actions.contains(Action.BulkDownload));
assertEquals(2, actions.size());
}

0 comments on commit 61dd156

Please sign in to comment.