Updated Chart open
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-resources-widget@101604 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
a0f42ede05
commit
6619aa1440
6
pom.xml
6
pom.xml
|
@ -111,6 +111,12 @@
|
|||
<version>3.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sencha.gxt</groupId>
|
||||
<artifactId>gxt-chart</artifactId>
|
||||
<version>3.0.1</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- tabular-data-widget-common-event -->
|
||||
<dependency>
|
||||
|
|
|
@ -16,12 +16,17 @@
|
|||
|
||||
<!-- Other module inherits -->
|
||||
<inherits name='com.sencha.gxt.ui.GXT' />
|
||||
|
||||
<!-- Add this for using GXT charts -->
|
||||
<inherits name='com.sencha.gxt.chart.Chart' />
|
||||
|
||||
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
|
||||
<inherits name='org.gcube.portlets.user.td.gwtservice.TDGWTService' />
|
||||
<inherits name='org.gcube.portlets.user.td.wizardwidget.Wizard' />
|
||||
|
||||
<!-- Specify the app entry point class. -->
|
||||
<!-- <entry-point class='org.gcube.portlets.user.td.resourceswidget.client.ResourcesWidgetEntry' /> -->
|
||||
<!-- <entry-point class='org.gcube.portlets.user.td.resourceswidget.client.ResourcesWidgetEntry'
|
||||
/> -->
|
||||
|
||||
<!-- Specify the paths for translatable code -->
|
||||
<source path='client' />
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -17,12 +17,17 @@
|
|||
|
||||
<!-- Other module inherits -->
|
||||
<inherits name='com.sencha.gxt.ui.GXT' />
|
||||
|
||||
<!-- Add this for using GXT charts -->
|
||||
<inherits name='com.sencha.gxt.chart.Chart' />
|
||||
|
||||
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
|
||||
<inherits name='org.gcube.portlets.user.td.gwtservice.TDGWTService' />
|
||||
<inherits name='org.gcube.portlets.user.td.wizardwidget.Wizard' />
|
||||
|
||||
<!-- Specify the app entry point class. -->
|
||||
<!-- <entry-point class='org.gcube.portlets.user.td.resourceswidget.client.ResourcesWidgetEntry' /> -->
|
||||
<!-- <entry-point class='org.gcube.portlets.user.td.resourceswidget.client.ResourcesWidgetEntry'
|
||||
/> -->
|
||||
|
||||
<!-- Specify the paths for translatable code -->
|
||||
<source path='client' />
|
||||
|
|
|
@ -11,6 +11,12 @@
|
|||
<servlet-class>org.gcube.portlets.user.td.gwtservice.server.TDGWTServiceImpl</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<!-- Retrieve Chart File Servlet -->
|
||||
<servlet>
|
||||
<servlet-name>RetrieveChartFileServlet</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.user.td.gwtservice.server.RetrieveChartFileServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>jUnitHostImpl</servlet-name>
|
||||
<servlet-class>com.google.gwt.junit.server.JUnitHostImpl</servlet-class>
|
||||
|
@ -19,11 +25,19 @@
|
|||
<!-- Servlets Mapping -->
|
||||
<servlet-mapping>
|
||||
<servlet-name>TDGWTService</servlet-name>
|
||||
<url-pattern>ResourcesWidget/TDGWTService</url-pattern>
|
||||
<url-pattern>/ResourcesWidget/TDGWTService</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- Retrieve Chart File Servlet -->
|
||||
<servlet-mapping>
|
||||
<servlet-name>RetrieveChartFileServlet</servlet-name>
|
||||
<url-pattern>/ResourcesWidget/RetrieveChartFileServlet</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>jUnitHostImpl</servlet-name>
|
||||
<url-pattern>ResourcesWidget/junithost/*</url-pattern>
|
||||
<url-pattern>/ResourcesWidget/junithost/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue