diff --git a/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewDetail.css b/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewDetail.css deleted file mode 100644 index 54d9095..0000000 --- a/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewDetail.css +++ /dev/null @@ -1,26 +0,0 @@ -@CHARSET "UTF-8"; - -.details { - padding: 10px; - text-align: center; -} - -.detailsInfo { - border-top: 1px solid #ccc; - font: 11px Arial, Helvetica, sans-serif; - margin-top: 5px; - padding-top: 5px; - text-align: left; -} - -.detailsTable { - border: none; -} - -.detailsHead { - font-weight: bold; -} - -.detailsData { - padding-left: 5px; -} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewDetail.html b/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewDetail.html deleted file mode 100644 index 3995886..0000000 --- a/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewDetail.html +++ /dev/null @@ -1,13 +0,0 @@ -
- -
- - - - - - - -
Name:
{resourceTDDescriptor.name}
Description:
{resourceTDDescriptor.description}
Creation Date:
{resourceTDDescriptor.creationDate}
-
-
\ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewDetailPanel.java b/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewDetailPanel.java index 1e70ab4..260430b 100644 --- a/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewDetailPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewDetailPanel.java @@ -3,6 +3,7 @@ package org.gcube.portlets.user.td.resourceswidget.client; import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.InternalURITD; import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTD; import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDDescriptor; +import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDType; import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.StringResourceTD; import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.TableResourceTD; import org.gcube.portlets.user.td.resourceswidget.client.resources.ResourceBundle; @@ -10,14 +11,19 @@ import org.gcube.portlets.user.td.resourceswidget.client.resources.ResourceBundl import com.google.gwt.safehtml.shared.SafeUri; import com.google.gwt.safehtml.shared.UriUtils; import com.google.gwt.user.client.ui.Image; +import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign; import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode; import com.sencha.gxt.core.client.resources.ThemeStyles; import com.sencha.gxt.core.client.util.Margins; +import com.sencha.gxt.widget.core.client.button.TextButton; +import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData; import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack; import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer; import com.sencha.gxt.widget.core.client.container.SimpleContainer; import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData; +import com.sencha.gxt.widget.core.client.event.SelectEvent; +import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; import com.sencha.gxt.widget.core.client.form.FieldLabel; import com.sencha.gxt.widget.core.client.form.FormPanel.LabelAlign; import com.sencha.gxt.widget.core.client.form.TextArea; @@ -30,32 +36,48 @@ import com.sencha.gxt.widget.core.client.form.TextField; * */ public class ResourcesListViewDetailPanel extends SimpleContainer { + private static final String THUMBNAIL_WIDTH = "160px"; + private static final String THUMBNAIL_HEIGHT = "160px"; private static final String DESCRIPTION_HEIGHT = "70px"; - private Image thumbnail; private TextField name; private TextArea description; private TextField creationDate; private VerticalLayoutContainer v; - public ResourcesListViewDetailPanel() { + private ResourceTDDescriptor descriptor; + + private TextButton removeButton; + + private TextButton saveButton; + + private TextButton openButton; + + private ResourcesListViewPanel parent; + + private HBoxLayoutContainer buttonMenu; + + public ResourcesListViewDetailPanel(ResourcesListViewPanel parent) { super(); + this.parent = parent; init(); - + } - protected void init(){ + + protected void init() { addStyleName(ThemeStyles.get().style().border()); - getElement().getStyle().setBackgroundColor("white"); - + // getElement().getStyle().setBackgroundColor("white"); + } - - public void setDescriptor(ResourceTDDescriptor descriptor){ - if(v!=null){ + + public void setDescriptor(ResourceTDDescriptor descriptor) { + this.descriptor = descriptor; + if (v != null) { remove(v); } - - if(descriptor==null){ + + if (descriptor == null) { forceLayout(); return; } @@ -81,48 +103,173 @@ public class ResourcesListViewDetailPanel extends SimpleContainer { } } } - - - thumbnail=new Image(); - - - name=new TextField(); - FieldLabel nameLabel=new FieldLabel(name, "Name"); + + thumbnail = new Image(); + thumbnail.setWidth(THUMBNAIL_WIDTH); + thumbnail.setHeight(THUMBNAIL_HEIGHT); + + name = new TextField(); + FieldLabel nameLabel = new FieldLabel(name, "Name"); nameLabel.setLabelAlign(LabelAlign.TOP); - - description=new TextArea(); + + description = new TextArea(); description.setHeight(DESCRIPTION_HEIGHT); - FieldLabel descriptionLabel=new FieldLabel(description, "Description"); + FieldLabel descriptionLabel = new FieldLabel(description, "Description"); descriptionLabel.setLabelAlign(LabelAlign.TOP); - - creationDate=new TextField(); - FieldLabel creationDateLabel=new FieldLabel(creationDate, "Creation Date"); + + creationDate = new TextField(); + FieldLabel creationDateLabel = new FieldLabel(creationDate, + "Creation Date"); creationDateLabel.setLabelAlign(LabelAlign.TOP); - - v=new VerticalLayoutContainer(); + + v = new VerticalLayoutContainer(); v.setScrollMode(ScrollMode.AUTO); - - HBoxLayoutContainer h=new HBoxLayoutContainer(); + + HBoxLayoutContainer h = new HBoxLayoutContainer(); h.setPack(BoxLayoutPack.CENTER); h.add(thumbnail); - - v.add(h, new VerticalLayoutData(1,-1, new Margins(20,0,10,0))); + + createMenu(); + + v.add(h, new VerticalLayoutData(1, -1, new Margins(20, 0, 10, 0))); v.add(nameLabel, new VerticalLayoutData(1, -1, new Margins(1))); v.add(descriptionLabel, new VerticalLayoutData(1, -1, new Margins(1))); v.add(creationDateLabel, new VerticalLayoutData(1, -1, new Margins(1))); - - + v.add(buttonMenu, new VerticalLayoutData(1, -1, new Margins(0))); + thumbnail.setUrl(thumbnailPath); name.setValue(descriptor.getName()); description.setValue(descriptor.getDescription()); creationDate.setValue(descriptor.getCreationDate()); add(v); - + forceLayout(); - + + } + + protected void createMenu() { + if (descriptor == null || descriptor.getResourceType() == null) { + return; + } + + openButton = new TextButton("Open"); + openButton.setIcon(ResourceBundle.INSTANCE.resources()); + openButton.setIconAlign(IconAlign.RIGHT); + openButton.setToolTip("Open"); + SelectHandler openHandler = new SelectHandler() { + + public void onSelect(SelectEvent event) { + requestOpen(); + + } + }; + openButton.addSelectHandler(openHandler); + + saveButton = new TextButton("Save"); + saveButton.setIcon(ResourceBundle.INSTANCE.save()); + saveButton.setIconAlign(IconAlign.RIGHT); + saveButton.setToolTip("Save"); + SelectHandler saveHandler = new SelectHandler() { + + public void onSelect(SelectEvent event) { + requestSave(); + + } + }; + saveButton.addSelectHandler(saveHandler); + + removeButton = new TextButton("Delete"); + removeButton.setIcon(ResourceBundle.INSTANCE.delete()); + removeButton.setIconAlign(IconAlign.RIGHT); + removeButton.setToolTip("Save"); + SelectHandler removeHandler = new SelectHandler() { + + public void onSelect(SelectEvent event) { + requestRemove(); + + } + }; + removeButton.addSelectHandler(removeHandler); + + ResourceTDType resourceTDType = descriptor.getResourceType(); + switch (resourceTDType) { + case CHART: + openButton.setIcon(ResourceBundle.INSTANCE.chart()); + openButton.setVisible(true); + saveButton.setVisible(true); + removeButton.setVisible(true); + break; + case CODELIST: + openButton.setVisible(false); + saveButton.setVisible(false); + removeButton.setVisible(true); + break; + case CSV: + openButton.setVisible(false); + saveButton.setVisible(true); + removeButton.setVisible(true); + break; + case GENERIC_FILE: + openButton.setIcon(ResourceBundle.INSTANCE.file()); + openButton.setVisible(true); + saveButton.setVisible(true); + removeButton.setVisible(true); + break; + case GENERIC_TABLE: + openButton.setVisible(false); + saveButton.setVisible(false); + removeButton.setVisible(true); + break; + case GUESSER: + openButton.setVisible(false); + saveButton.setVisible(false); + removeButton.setVisible(true); + break; + case JSON: + openButton.setVisible(false); + saveButton.setVisible(true); + removeButton.setVisible(true); + break; + case MAP: + openButton.setIcon(ResourceBundle.INSTANCE.gis()); + openButton.setVisible(true); + saveButton.setVisible(false); + removeButton.setVisible(true); + break; + case SDMX: + openButton.setVisible(false); + saveButton.setVisible(false); + removeButton.setVisible(true); + break; + default: + openButton.setVisible(false); + saveButton.setVisible(false); + removeButton.setVisible(true); + break; + + } + + buttonMenu = new HBoxLayoutContainer(); + buttonMenu.setPack(BoxLayoutPack.CENTER); + buttonMenu.add(openButton, new BoxLayoutData(new Margins(5, 2, 5, 2))); + buttonMenu.add(saveButton, new BoxLayoutData(new Margins(5, 2, 5, 2))); + buttonMenu + .add(removeButton, new BoxLayoutData(new Margins(5, 2, 5, 2))); + + } + + private void requestOpen() { + parent.requestOpen(descriptor); + } + + private void requestSave() { + parent.requestSave(descriptor); + + } + + private void requestRemove() { + parent.requestRemove(descriptor); + } - - - } diff --git a/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewPanel.java b/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewPanel.java index f6bb63a..ba28c90 100644 --- a/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewPanel.java @@ -9,18 +9,28 @@ import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.InternalURITD; +import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.RemoveResourceSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTD; import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDDescriptor; +import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDType; +import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.SaveResourceSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.StringResourceTD; import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.TableResourceTD; +import org.gcube.portlets.user.td.gwtservice.shared.uriresolver.UriResolverSession; +import org.gcube.portlets.user.td.resourceswidget.client.charts.ChartViewerDialog; import org.gcube.portlets.user.td.resourceswidget.client.resources.ResourceBundle; +import org.gcube.portlets.user.td.resourceswidget.client.save.SaveResourceWizard; import org.gcube.portlets.user.td.resourceswidget.client.utils.UtilsGXT3; import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; +import org.gcube.portlets.user.td.widgetcommonevent.shared.mime.MimeTypeSupport; +import org.gcube.portlets.user.td.widgetcommonevent.shared.uriresolver.ApplicationType; +import org.gcube.portlets.user.td.wizardwidget.client.WizardListener; import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.core.client.GWT; +import com.google.gwt.core.client.RunAsyncCallback; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.event.logical.shared.SelectionEvent; @@ -32,6 +42,7 @@ import com.google.gwt.safehtml.shared.SafeHtmlBuilder; import com.google.gwt.safehtml.shared.SafeUri; import com.google.gwt.safehtml.shared.UriUtils; import com.google.gwt.text.shared.AbstractSafeHtmlRenderer; +import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.web.bindery.event.shared.EventBus; import com.sencha.gxt.cell.core.client.SimpleSafeHtmlCell; @@ -53,9 +64,6 @@ import com.sencha.gxt.data.shared.SortDir; import com.sencha.gxt.data.shared.Store; import com.sencha.gxt.data.shared.Store.StoreSortInfo; import com.sencha.gxt.data.shared.StringLabelProvider; -import com.sencha.gxt.data.shared.loader.ListLoadConfig; -import com.sencha.gxt.data.shared.loader.ListLoadResult; -import com.sencha.gxt.data.shared.loader.ListLoader; import com.sencha.gxt.data.shared.loader.ListStoreBinding; import com.sencha.gxt.data.shared.loader.Loader; import com.sencha.gxt.theme.base.client.listview.ListViewCustomAppearance; @@ -66,8 +74,13 @@ import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.BorderL import com.sencha.gxt.widget.core.client.container.MarginData; import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData; +import com.sencha.gxt.widget.core.client.event.BeforeShowContextMenuEvent; +import com.sencha.gxt.widget.core.client.event.BeforeShowContextMenuEvent.BeforeShowContextMenuHandler; import com.sencha.gxt.widget.core.client.form.SimpleComboBox; import com.sencha.gxt.widget.core.client.form.StoreFilterField; +import com.sencha.gxt.widget.core.client.menu.Item; +import com.sencha.gxt.widget.core.client.menu.Menu; +import com.sencha.gxt.widget.core.client.menu.MenuItem; import com.sencha.gxt.widget.core.client.selection.SelectionChangedEvent; import com.sencha.gxt.widget.core.client.selection.SelectionChangedEvent.SelectionChangedHandler; import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem; @@ -88,19 +101,7 @@ public class ResourcesListViewPanel extends FramedPanel { private static final String HEIGHT = "470px"; private static final String WIDTH = "630px"; - public interface DetailRenderer extends XTemplates { - @XTemplate(source = "ResourcesListViewDetail.html") - public SafeHtml render(ResourceTDDescriptor resourceTDDescriptor, - SafeUri thumbnailPath, ResourceListViewDetailCSS style); - } - - public interface DetailRendererBundle extends ClientBundle { - public static final DetailRendererBundle INSTANCE = GWT - .create(DetailRendererBundle.class); - - @Source("ResourcesListViewDetail.css") - ResourceListViewDetailCSS css(); - } + @FormatterFactories(@FormatterFactory(factory = ShortenFactory.class, name = "shorten")) public interface Renderer extends XTemplates { @@ -117,18 +118,7 @@ public class ResourcesListViewPanel extends FramedPanel { ResourceListViewCSS css(); } - public interface ResourceListViewDetailCSS extends CssResource { - String details(); - - String detailsInfo(); - - String detailsTable(); - - String detailsHead(); - - String detailsData(); - - } + public interface ResourceListViewCSS extends CssResource { String over(); @@ -198,20 +188,24 @@ public class ResourcesListViewPanel extends FramedPanel { } - // private Dialog chooser; - // private HTML details; + private ResourcesListViewDetailPanel details; - // private static DetailRenderer detailRenderer; - // private static ResourceListViewDetailCSS detailStyle; - + private TRId trId; private EventBus eventBus; private ListStore store; - private ListLoader> loader; - - private ListView view; + //private ListLoader> loader; + private Loader> loader; + + private ListView listView; private SimpleComboBox comboSort; + private Menu contextMenu; + private MenuItem openItem; + private MenuItem saveItem; + private MenuItem removeItem; + private RemoveResourceSession removeResourceSession; + private SaveResourceSession saveResourceSession; public ResourcesListViewPanel(EventBus eventBus) { super(); @@ -228,7 +222,7 @@ public class ResourcesListViewPanel extends FramedPanel { details.setDescriptor(null); forceLayout(); } catch (Throwable e) { - Log.error("Error open resources: "+e.getLocalizedMessage()); + Log.error("Error open resources: " + e.getLocalizedMessage()); e.printStackTrace(); } } @@ -244,14 +238,6 @@ public class ResourcesListViewPanel extends FramedPanel { protected void create() { Log.debug("Create Resource List View"); - - /* - * DetailRendererBundle.INSTANCE.css().ensureInjected(); detailStyle = - * DetailRendererBundle.INSTANCE.css(); - * - * detailRenderer = GWT.create(DetailRenderer.class); - */ - RpcProxy> proxy = new RpcProxy>() { @Override public void load(Object loadConfig, @@ -288,7 +274,7 @@ public class ResourcesListViewPanel extends FramedPanel { } }, SortDir.ASC)); - final Loader> loader = new Loader>( + loader = new Loader>( proxy); loader.addLoadHandler(new ListStoreBinding>( store)); @@ -310,7 +296,7 @@ public class ResourcesListViewPanel extends FramedPanel { @Override protected void onFilter() { super.onFilter(); - view.getSelectionModel().select(0, false); + listView.getSelectionModel().select(0, false); } }; filterField.setWidth(100); @@ -367,7 +353,7 @@ public class ResourcesListViewPanel extends FramedPanel { } }; - view = new ListView(store, + listView = new ListView(store, new IdentityValueProvider() { @Override public void setValue(ResourceTDDescriptor object, @@ -388,8 +374,8 @@ public class ResourcesListViewPanel extends FramedPanel { } }; - view.setLoader(loader); - view.setCell(new SimpleSafeHtmlCell( + listView.setLoader(loader); + listView.setCell(new SimpleSafeHtmlCell( new AbstractSafeHtmlRenderer() { @Override public SafeHtml render(ResourceTDDescriptor descriptor) { @@ -421,8 +407,8 @@ public class ResourcesListViewPanel extends FramedPanel { style); } })); - view.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); - view.getSelectionModel().addSelectionChangedHandler( + listView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); + listView.getSelectionModel().addSelectionChangedHandler( new SelectionChangedHandler() { @Override public void onSelectionChanged( @@ -430,16 +416,18 @@ public class ResourcesListViewPanel extends FramedPanel { ResourcesListViewPanel.this.onSelectionChange(event); } }); - view.setBorders(false); + listView.setBorders(false); + + createContextMenu(); VerticalLayoutContainer main = new VerticalLayoutContainer(); main.setScrollMode(ScrollMode.AUTO); // main.setAdjustForScroll(true); main.setBorders(true); main.add(toolbar, new VerticalLayoutData(1, -1)); - main.add(view, new VerticalLayoutData(1, 1)); + main.add(listView, new VerticalLayoutData(1, 1)); - details = new ResourcesListViewDetailPanel(); + details = new ResourcesListViewDetailPanel(this); BorderLayoutData centerData = new BorderLayoutData(); centerData.setMinSize(330); @@ -459,33 +447,10 @@ public class ResourcesListViewPanel extends FramedPanel { SelectionChangedEvent se) { if (se.getSelection().size() > 0) { ResourceTDDescriptor descriptor = se.getSelection().get(0); - /* - * @SuppressWarnings("unused") SafeUri thumbnailPath = - * ResourceBundle.INSTANCE.resources32() .getSafeUri(); ResourceTD - * resourceTD = descriptor.getResourceTD(); - * - * if (resourceTD instanceof InternalURITD) { InternalURITD - * internalURITD = (InternalURITD) resourceTD; if - * (internalURITD.getThumbnailTD() != null && - * internalURITD.getThumbnailTD().getUrl() != null) { thumbnailPath - * = UriUtils.fromTrustedString(internalURITD - * .getThumbnailTD().getUrl()); } } else { if (resourceTD instanceof - * StringResourceTD) { thumbnailPath = - * ResourceBundle.INSTANCE.resources32() .getSafeUri(); } else { if - * (resourceTD instanceof TableResourceTD) { thumbnailPath = - * ResourceBundle.INSTANCE.resources32() .getSafeUri(); } } } - */ - details.setDescriptor(descriptor); - /* - * details.setHTML(detailRenderer.render(descriptor, thumbnailPath, - * detailStyle).asString()); - */ - // chooser.getButton(PredefinedButton.OK).enable(); } else { details.setDescriptor(null); - // chooser.getButton(PredefinedButton.OK).disable(); - // setHTML(""); + } } @@ -531,5 +496,419 @@ public class ResourcesListViewPanel extends FramedPanel { }); } } + + + protected void createContextMenu() { + contextMenu = new Menu(); + openItem = new MenuItem(); + openItem.setText("Open"); + openItem.setIcon(ResourceBundle.INSTANCE.resources()); + openItem.addSelectionHandler(new SelectionHandler() { + + @Override + public void onSelection(SelectionEvent event) { + ResourceTDDescriptor selected = listView.getSelectionModel() + .getSelectedItem(); + Log.debug("selected: " + selected); + requestOpen(selected); + } + + }); + + saveItem = new MenuItem(); + saveItem.setText("Save"); + saveItem.setIcon(ResourceBundle.INSTANCE.save()); + saveItem.addSelectionHandler(new SelectionHandler() { + + @Override + public void onSelection(SelectionEvent event) { + ResourceTDDescriptor selected = listView.getSelectionModel() + .getSelectedItem(); + Log.debug("selected: " + selected); + requestSave(selected); + } + + }); + + removeItem = new MenuItem(); + removeItem.setText("Delete"); + removeItem.setIcon(ResourceBundle.INSTANCE.delete()); + removeItem.addSelectionHandler(new SelectionHandler() { + + @Override + public void onSelection(SelectionEvent event) { + ResourceTDDescriptor selected = listView.getSelectionModel() + .getSelectedItem(); + Log.debug("selected: " + selected); + requestRemove(selected); + } + + }); + + listView.setContextMenu(contextMenu); + + listView.addBeforeShowContextMenuHandler(new BeforeShowContextMenuHandler() { + + @Override + public void onBeforeShowContextMenu(BeforeShowContextMenuEvent event) { + Menu contextMenu = event.getMenu(); + + ResourceTDDescriptor selected = listView.getSelectionModel() + .getSelectedItem(); + ResourceTDType resourceTDType = selected.getResourceType(); + switch (resourceTDType) { + case CHART: + contextMenu.clear(); + openItem.setIcon(ResourceBundle.INSTANCE.chart()); + contextMenu.add(openItem); + contextMenu.add(saveItem); + contextMenu.add(removeItem); + listView.setContextMenu(contextMenu); + break; + case CODELIST: + contextMenu.clear(); + contextMenu.add(removeItem); + listView.setContextMenu(contextMenu); + break; + case CSV: + contextMenu.clear(); + contextMenu.add(saveItem); + contextMenu.add(removeItem); + listView.setContextMenu(contextMenu); + break; + case GUESSER: + contextMenu.clear(); + contextMenu.add(removeItem); + listView.setContextMenu(contextMenu); + break; + case JSON: + contextMenu.clear(); + contextMenu.add(saveItem); + contextMenu.add(removeItem); + listView.setContextMenu(contextMenu); + break; + case MAP: + contextMenu.clear(); + openItem.setIcon(ResourceBundle.INSTANCE.gis()); + contextMenu.add(openItem); + contextMenu.add(removeItem); + listView.setContextMenu(contextMenu); + break; + case SDMX: + contextMenu.clear(); + contextMenu.add(removeItem); + listView.setContextMenu(contextMenu); + break; + case GENERIC_FILE: + contextMenu.clear(); + openItem.setIcon(ResourceBundle.INSTANCE.file()); + contextMenu.add(openItem); + contextMenu.add(saveItem); + contextMenu.add(removeItem); + listView.setContextMenu(contextMenu); + break; + case GENERIC_TABLE: + contextMenu.clear(); + contextMenu.add(removeItem); + listView.setContextMenu(contextMenu); + break; + default: + contextMenu.clear(); + contextMenu.add(removeItem); + listView.setContextMenu(contextMenu); + event.setCancelled(true); + break; + + } + + } + }); + + } + + + protected void requestSave(ResourceTDDescriptor resourceTDDescriptor) { + switch (resourceTDDescriptor.getResourceType()) { + case CHART: + requestSaveResource(resourceTDDescriptor, MimeTypeSupport._jpg); + break; + case CODELIST: + break; + case CSV: + requestSaveResource(resourceTDDescriptor, MimeTypeSupport._csv); + break; + case GUESSER: + break; + case JSON: + requestSaveResource(resourceTDDescriptor, MimeTypeSupport._json); + break; + case MAP: + break; + case SDMX: + break; + case GENERIC_FILE: + requestSaveResource(resourceTDDescriptor, MimeTypeSupport._unknow); + break; + case GENERIC_TABLE: + // requestSaveResource(resourceTDDescriptor, MimeTypeSupport._csv); + break; + default: + break; + + } + + } + + protected void requestSaveResource( + ResourceTDDescriptor resourceTDDescriptor, MimeTypeSupport mime) { + + saveResourceSession = new SaveResourceSession(); + saveResourceSession.setResourceTDDescriptor(resourceTDDescriptor); + saveResourceSession.setMime(mime); + saveResourceSession.setFileName(resourceTDDescriptor.getName()); + saveResourceSession.setFileDescription(resourceTDDescriptor + .getDescription()); + + GWT.runAsync(new RunAsyncCallback() { + + public void onSuccess() { + + SaveResourceWizard saveResourceWizard = new SaveResourceWizard( + saveResourceSession, "Save Resource", eventBus); + + saveResourceWizard.addListener(new WizardListener() { + + public void failed(String title, String message, + String details, Throwable throwable) { + Log.debug(title + ", " + message + " " + details); + } + + public void completed(TRId id) { + Log.debug("Save Resource Completed"); + + } + + @Override + public void putInBackground() { + Log.debug("PutInBakground"); + } + + public void aborted() { + Log.debug("Save Resource Aborted"); + } + }); + + saveResourceWizard.show(); + } + + public void onFailure(Throwable reason) { + Log.error("Async code loading failed", reason); + eventBus.fireEvent(new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } + }); + } + + protected void requestRemove(ResourceTDDescriptor resourceTDDescriptor) { + + removeResourceSession = new RemoveResourceSession(trId, + resourceTDDescriptor); + + TDGWTServiceAsync.INSTANCE.removeResource(removeResourceSession, + new AsyncCallback() { + + public void onFailure(Throwable caught) { + if (caught instanceof TDGWTSessionExpiredException) { + eventBus.fireEvent(new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + if (caught instanceof TDGWTIsLockedException) { + Log.error(caught.getLocalizedMessage()); + UtilsGXT3.alert("Error Locked", + caught.getLocalizedMessage()); + } else { + Log.error("Error removing the resource: " + + caught.getLocalizedMessage()); + UtilsGXT3.alert("Error", + "Error removing the resource: " + + caught.getLocalizedMessage()); + } + } + } + + public void onSuccess(Void v) { + Log.debug("Resource removed"); + loader.load(); + details.setDescriptor(null); + forceLayout(); + // UtilsGXT3.info("Resource", "Resource Removed!"); + } + + }); + + } + + protected void requestOpen(ResourceTDDescriptor resourceTDDescriptor) { + switch (resourceTDDescriptor.getResourceType()) { + case CHART: + repquestOpenChart(resourceTDDescriptor); + break; + case CODELIST: + break; + case CSV: + break; + case GUESSER: + break; + case JSON: + break; + case MAP: + requestOpenMap(resourceTDDescriptor); + break; + case SDMX: + break; + case GENERIC_FILE: + requestOpenGenericFile(resourceTDDescriptor); + break; + case GENERIC_TABLE: + break; + default: + break; + + } + + } + + private void repquestOpenChart(ResourceTDDescriptor resourceTDDescriptor) { + ChartViewerDialog chartDialog = new ChartViewerDialog( + resourceTDDescriptor, trId, eventBus); + chartDialog.show(); + + } + + protected void requestOpenMap( + final ResourceTDDescriptor resourceTDDescriptor) { + ResourceTD resource = resourceTDDescriptor.getResourceTD(); + if (resource instanceof StringResourceTD) { + StringResourceTD stringResourceTD = (StringResourceTD) resource; + UriResolverSession uriResolverSession = new UriResolverSession( + stringResourceTD.getValue(), ApplicationType.GIS); + + TDGWTServiceAsync.INSTANCE.getUriFromResolver(uriResolverSession, + new AsyncCallback() { + + public void onFailure(Throwable caught) { + if (caught instanceof TDGWTSessionExpiredException) { + eventBus.fireEvent(new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + Log.error("Error with uri resolver: " + + caught.getLocalizedMessage()); + UtilsGXT3.alert("Error", + "Error retrieving uri from resolver"); + } + } + + public void onSuccess(String link) { + Log.debug("Retrieved link: " + link); + Window.open(link, resourceTDDescriptor.getName(), + ""); + } + + }); + + } else { + if (resource instanceof InternalURITD) { + InternalURITD internalURITD = (InternalURITD) resource; + UriResolverSession uriResolverSession = new UriResolverSession( + internalURITD.getId(), ApplicationType.GIS); + + TDGWTServiceAsync.INSTANCE.getUriFromResolver( + uriResolverSession, new AsyncCallback() { + + public void onFailure(Throwable caught) { + if (caught instanceof TDGWTSessionExpiredException) { + eventBus.fireEvent(new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + Log.error("Error with uri resolver: " + + caught.getLocalizedMessage()); + UtilsGXT3 + .alert("Error", + "Error retrieving uri from resolver"); + } + } + + public void onSuccess(String link) { + Log.debug("Retrieved link: " + link); + Window.open(link, + resourceTDDescriptor.getName(), ""); + } + + }); + + } else { + if (resource instanceof TableResourceTD) { + + } else { + Log.error("Error with resource: no valid resource"); + UtilsGXT3.alert("Error with resource", + "Error no valid InternalUri"); + + } + + } + } + } + + protected void requestOpenGenericFile( + final ResourceTDDescriptor resourceTDDescriptor) { + ResourceTD resource = resourceTDDescriptor.getResourceTD(); + if (resource instanceof InternalURITD) { + InternalURITD genericFileResourceTD = (InternalURITD) resource; + UriResolverSession uriResolverSession = new UriResolverSession( + genericFileResourceTD.getId(), ApplicationType.SMP_ID, + resourceTDDescriptor.getName(), + genericFileResourceTD.getMimeType()); + + TDGWTServiceAsync.INSTANCE.getUriFromResolver(uriResolverSession, + new AsyncCallback() { + + public void onFailure(Throwable caught) { + if (caught instanceof TDGWTSessionExpiredException) { + eventBus.fireEvent(new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + Log.error("Error with uri resolver: " + + caught.getLocalizedMessage()); + UtilsGXT3.alert("Error", + "Error retrieving uri from resolver"); + } + } + + public void onSuccess(String link) { + Log.debug("Retrieved link: " + link); + Window.open(link, resourceTDDescriptor.getName(), + ""); + } + + }); + } else { + if (resource instanceof InternalURITD) { + + } else { + if (resource instanceof TableResourceTD) { + + } else { + Log.error("Error with resource: no valid resource"); + UtilsGXT3.alert("Error with resource", + "Error no valid InternalUri"); + + } + + } + } + } + + } diff --git a/src/main/resources/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewDetail.css b/src/main/resources/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewDetail.css deleted file mode 100644 index 54d9095..0000000 --- a/src/main/resources/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewDetail.css +++ /dev/null @@ -1,26 +0,0 @@ -@CHARSET "UTF-8"; - -.details { - padding: 10px; - text-align: center; -} - -.detailsInfo { - border-top: 1px solid #ccc; - font: 11px Arial, Helvetica, sans-serif; - margin-top: 5px; - padding-top: 5px; - text-align: left; -} - -.detailsTable { - border: none; -} - -.detailsHead { - font-weight: bold; -} - -.detailsData { - padding-left: 5px; -} \ No newline at end of file diff --git a/src/main/resources/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewDetail.html b/src/main/resources/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewDetail.html deleted file mode 100644 index 3995886..0000000 --- a/src/main/resources/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewDetail.html +++ /dev/null @@ -1,13 +0,0 @@ -
- -
- - - - - - - -
Name:
{resourceTDDescriptor.name}
Description:
{resourceTDDescriptor.description}
Creation Date:
{resourceTDDescriptor.creationDate}
-
-
\ No newline at end of file