diff --git a/pom.xml b/pom.xml
index 4a72d10..ce8d947 100644
--- a/pom.xml
+++ b/pom.xml
@@ -110,8 +110,14 @@
gxt
3.0.1
-
-
+
+
+ com.sencha.gxt
+ gxt-chart
+ 3.0.1
+
+
+
org.gcube.portlets.user
@@ -119,7 +125,7 @@
[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)
provided
-
+
org.gcube.portlets.user
@@ -127,7 +133,7 @@
[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)
provided
-
+
org.gcube.portlets.user
@@ -135,7 +141,7 @@
[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)
provided
-
+
org.gcube.portlets.widgets
@@ -154,9 +160,9 @@
gcube-widgets
provided
-
-
-
+
+
+
com.allen-sauer.gwt.log
diff --git a/src/main/java/org/gcube/portlets/user/td/resourceswidget/ColumnWidget.gwt.xml b/src/main/java/org/gcube/portlets/user/td/resourceswidget/ColumnWidget.gwt.xml
index 40997a7..b71fc8d 100644
--- a/src/main/java/org/gcube/portlets/user/td/resourceswidget/ColumnWidget.gwt.xml
+++ b/src/main/java/org/gcube/portlets/user/td/resourceswidget/ColumnWidget.gwt.xml
@@ -1,31 +1,36 @@
-
-
-
-
-
-
+
+
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
diff --git a/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/ResourcesPanel.java b/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/ResourcesPanel.java
index 2c4291b..1c02884 100644
--- a/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/ResourcesPanel.java
+++ b/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/ResourcesPanel.java
@@ -18,6 +18,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.StringResourceT
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.gwtservice.shared.user.UserInfo;
+import org.gcube.portlets.user.td.resourceswidget.client.charts.ChartDialog;
import org.gcube.portlets.user.td.resourceswidget.client.properties.ResourceTDDescriptorProperties;
import org.gcube.portlets.user.td.resourceswidget.client.resources.ResourceBundle;
import org.gcube.portlets.user.td.resourceswidget.client.save.SaveResourceWizard;
@@ -454,6 +455,8 @@ public class ResourcesPanel extends FramedPanel {
switch (resourceTDType) {
case CHART:
contextMenu.clear();
+ openItem.setIcon(ResourceBundle.INSTANCE.chart());
+ contextMenu.add(openItem);
contextMenu.add(saveItem);
contextMenu.add(removeItem);
grid.setContextMenu(contextMenu);
@@ -509,7 +512,7 @@ public class ResourcesPanel extends FramedPanel {
protected void requestSave(ResourceTDDescriptor resourceTDDescriptor) {
switch (resourceTDDescriptor.getResourceType()) {
case CHART:
- requestSaveResource(resourceTDDescriptor, ".png", "image/png");
+ requestSaveResource(resourceTDDescriptor, ".jpg", "image/jpeg");
break;
case CODELIST:
break;
@@ -637,6 +640,7 @@ public class ResourcesPanel extends FramedPanel {
protected void requestOpen(ResourceTDDescriptor resourceTDDescriptor) {
switch (resourceTDDescriptor.getResourceType()) {
case CHART:
+ repquestOpenChart(resourceTDDescriptor);
break;
case CODELIST:
break;
@@ -658,6 +662,12 @@ public class ResourcesPanel extends FramedPanel {
}
+ private void repquestOpenChart(ResourceTDDescriptor resourceTDDescriptor) {
+ ChartDialog chartDialog=new ChartDialog(resourceTDDescriptor, trId, eventBus);
+ chartDialog.show();
+
+ }
+
protected void requestOpenMap(
final ResourceTDDescriptor resourceTDDescriptor) {
ResourceTD resource = resourceTDDescriptor.getResourceTD();
diff --git a/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/charts/ChartDialog.java b/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/charts/ChartDialog.java
new file mode 100644
index 0000000..67337aa
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/charts/ChartDialog.java
@@ -0,0 +1,60 @@
+package org.gcube.portlets.user.td.resourceswidget.client.charts;
+
+import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDDescriptor;
+import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
+
+import com.google.web.bindery.event.shared.EventBus;
+import com.sencha.gxt.widget.core.client.Window;
+import com.sencha.gxt.widget.core.client.event.SelectEvent;
+import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
+
+/**
+ * Delete Column Dialog
+ *
+ * @author "Giancarlo Panichi"
+ * g.panichi@isti.cnr.it
+ *
+ */
+public class ChartDialog extends Window {
+ private static final String WIDTH = "822px";
+ private static final String HEIGHT = "420px";
+
+ public ChartDialog(ResourceTDDescriptor resourceTDDescriptor, TRId trId, EventBus eventBus) {
+ initWindow();
+
+ ChartPanel chartPanel= new ChartPanel(this, resourceTDDescriptor, trId, eventBus);
+ add(chartPanel);
+ }
+
+ protected void initWindow() {
+ setWidth(WIDTH);
+ setHeight(HEIGHT);
+ setBodyBorder(false);
+ setResizable(false);
+ setHeadingText("Chart");
+ //getHeader().setIcon(Resources.IMAGES.side_list());
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void initTools() {
+ super.initTools();
+
+ closeBtn.addSelectHandler(new SelectHandler() {
+
+ public void onSelect(SelectEvent event) {
+ close();
+ }
+ });
+
+ }
+
+ public void close() {
+ hide();
+
+ }
+
+}
diff --git a/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/charts/ChartPanel.java b/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/charts/ChartPanel.java
new file mode 100644
index 0000000..b47fd76
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/charts/ChartPanel.java
@@ -0,0 +1,175 @@
+package org.gcube.portlets.user.td.resourceswidget.client.charts;
+
+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.resourceswidget.client.utils.UtilsGXT3;
+import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.resources.client.ImageResource;
+import com.google.gwt.safehtml.shared.SafeUri;
+import com.google.gwt.safehtml.shared.UriUtils;
+import com.google.gwt.user.client.ui.Image;
+import com.google.web.bindery.event.shared.EventBus;
+import com.sencha.gxt.chart.client.draw.DrawComponent;
+import com.sencha.gxt.chart.client.draw.sprite.ImageSprite;
+import com.sencha.gxt.widget.core.client.FramedPanel;
+import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
+import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
+
+/**
+ *
+ * ResourcesPanel shows the resources
+ *
+ *
+ * @author "Giancarlo Panichi" g.panichi@isti.cnr.it
+ *
+ */
+public class ChartPanel extends FramedPanel {
+ private static final String RETRIEVE_CHART_FILE_SERVLET = "RetrieveChartFileServlet";
+ private static final String ATTRIBUTE_STORAGE_URI = "storageURI";
+
+ private static final String WIDTH = "800px";
+ private static final String HEIGHT = "400px";
+
+ private ChartDialog parent;
+ private ResourceTDDescriptor resourceTDDescriptor;
+ private ImageResource chartImageResource;
+
+ public ChartPanel(ChartDialog parent,
+ ResourceTDDescriptor resourceTDDescriptor, TRId trId,
+ EventBus eventBus) {
+ super();
+ this.parent = parent;
+ this.resourceTDDescriptor = resourceTDDescriptor;
+ forceLayoutOnResize = true;
+ retrieveChart();
+ draw();
+ }
+
+ protected void retrieveChart() {
+ InternalURITD internalURITD;
+ ResourceTD resource = resourceTDDescriptor.getResourceTD();
+ if (resource instanceof InternalURITD) {
+ internalURITD = (InternalURITD) resource;
+ } else {
+ UtilsGXT3.alert("Attention",
+ "This resource does not have valid internal URI!");
+ Log.debug("Attention, this resource does not have valid Internal URI!");
+ close();
+ return;
+ }
+ Log.debug("InteranlURI: " + internalURITD);
+ final String storageURI=internalURITD.getUri();
+
+ final String path = GWT.getModuleBaseURL() + RETRIEVE_CHART_FILE_SERVLET;
+
+ //SafeUri uri = UriUtils.fromSafeConstant(path + "?"
+ // + ATTRIBUTE_STORAGE_URI + "=" + storageURI);
+
+ //chartImage = new Image(uri.asString());
+
+
+ chartImageResource=new ImageResource(){
+
+ @Override
+ public String getName() {
+ return "image";
+ }
+
+
+ @Override
+ public int getHeight() {
+ return 2000;
+ }
+
+ @Override
+ public int getLeft() {
+ return 0;
+ }
+
+ @Override
+ public SafeUri getSafeUri() {
+ SafeUri uri = UriUtils.fromSafeConstant(path + "?"
+ + ATTRIBUTE_STORAGE_URI + "=" + storageURI);
+ Log.debug("Image uri:"+uri.asString());
+ return UriUtils.fromTrustedString(uri.asString());
+ }
+
+
+ @Override
+ public int getTop() {
+ return 0;
+ }
+
+
+ @Override
+ public String getURL() {
+ return this.getSafeUri().asString();
+ }
+
+
+ @Override
+ public int getWidth() {
+ return 1000;
+ }
+
+
+ @Override
+ public boolean isAnimated() {
+ return false;
+ }
+
+ };
+
+ }
+
+ protected void draw(){
+ init();
+ create();
+ }
+
+
+ protected void init() {
+ setWidth(WIDTH);
+ setHeight(HEIGHT);
+ setHeaderVisible(false);
+ setBodyBorder(false);
+ setResize(true);
+
+ }
+
+ protected void create() {
+ //DrawComponent paint = new DrawComponent();
+
+ VerticalLayoutContainer layout = new VerticalLayoutContainer();
+ add(layout);
+
+ //int offsetHeight=paint.getOffsetHeight(true);
+ //int offsetWidth=paint.getOffsetWidth(true);
+
+ //ImageSprite imageSprite = new ImageSprite(chartImageResource);
+ //imageSprite.setX(0);
+ //imageSprite.setY(0);
+ //imageSprite.setScaling(new Scaling(new Double(800)/2000,new Double(400)/1000));
+ //paint.addSprite(imageSprite);
+
+
+ //paint.setLayoutData(new VerticalLayoutData(1, 1));
+ Image image=new Image(chartImageResource.getSafeUri());
+ layout.add(image);
+
+ forceLayout();
+ }
+
+ protected void close() {
+ if (parent != null) {
+ parent.close();
+ }
+
+ }
+
+}
diff --git a/src/main/resources/org/gcube/portlets/user/td/resourceswidget/ResourcesWidget.gwt.xml b/src/main/resources/org/gcube/portlets/user/td/resourceswidget/ResourcesWidget.gwt.xml
index 331e887..b1c3e8d 100644
--- a/src/main/resources/org/gcube/portlets/user/td/resourceswidget/ResourcesWidget.gwt.xml
+++ b/src/main/resources/org/gcube/portlets/user/td/resourceswidget/ResourcesWidget.gwt.xml
@@ -1,32 +1,37 @@
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index c890b91..9a44c5c 100644
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -11,6 +11,12 @@
org.gcube.portlets.user.td.gwtservice.server.TDGWTServiceImpl
+
+
+ RetrieveChartFileServlet
+ org.gcube.portlets.user.td.gwtservice.server.RetrieveChartFileServlet
+
+
jUnitHostImpl
com.google.gwt.junit.server.JUnitHostImpl
@@ -19,11 +25,19 @@
TDGWTService
- ResourcesWidget/TDGWTService
+ /ResourcesWidget/TDGWTService
+
+
+
+ RetrieveChartFileServlet
+ /ResourcesWidget/RetrieveChartFileServlet
+
+
+
jUnitHostImpl
- ResourcesWidget/junithost/*
+ /ResourcesWidget/junithost/*