Integrated report-exporter-widget

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/reports@70948 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Antonio Gioia 2013-03-06 14:30:36 +00:00
parent fc3bf84c69
commit 20d91c8e83
7 changed files with 125 additions and 86 deletions

View File

@ -1,6 +1,5 @@
#Tue Feb 26 17:29:33 CET 2013
eclipse.preferences.version=1
jarsExcludedFromWebInfLib=
lastWarOutDir=/Users/massi/Documents/workspace/reports/target/reports-4.0.1-SNAPSHOT
lastWarOutDir=/home/gioia/workspace/reports/target/reports-4.0.1-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

View File

@ -8,6 +8,9 @@
<dependent-module archiveName="gcube-docx-generator-1.2.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-docx-generator/gcube-docx-generator">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="report-exporter-widget-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/report-exporter-widget/report-exporter-widget">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="reports"/>
</wb-module>

View File

@ -156,13 +156,13 @@
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>home-library</artifactId>
<version>4.3.0-SNAPSHOT</version>
<version>[4.3.0-SNAPSHOT,5.0.0-SNAPSHOT)</version>
<scope>${setScope}</scope>
</dependency>
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>home-library-jcr</artifactId>
<version>1.3.0-SNAPSHOT</version>
<version>[1.3.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<classifier>${setClassifier}</classifier>
<scope>${setScope}</scope>
</dependency>
@ -233,6 +233,11 @@
<classifier>sources</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>report-exporter-widget</groupId>
<artifactId>report-exporter-widget</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
</dependencies>
<build>

View File

@ -79,6 +79,8 @@ public class Headerbar extends Composite{
private MenuItem optionHTML;
private MenuItem optionDOCX;
private MenuItem optionPDF;
private MenuItem optionFimes;
@ -323,13 +325,13 @@ public class Headerbar extends Composite{
MenuItem toReturn = new MenuItem("Export", exportsMenu);
optionDOCX = new MenuItem("<font color=\"gray\">"+ EXPORT_OPENXML +"</font>", true, getNullCommand());
// optionPDF = new MenuItem("<font color=\"gray\">Export to PDF</font>", true, getNullCommand());
optionPDF = new MenuItem("<font color=\"gray\">Export to PDF</font>", true, getNullCommand());
optionHTML = new MenuItem("<font color=\"gray\">"+ EXPORT_HTML +"</font>", true, getNullCommand());
optionFimes = new MenuItem("<font color=\"gray\">"+ EXPORT_FIMES +"</font>", true, getNullCommand());
exportsMenu.addItem(optionDOCX);
exportsMenu.addItem(optionHTML);
exportsMenu.addItem(optionPDF);
//optionsMenu.addItem(optionPDF);
//exportsMenu.addItem(optionFimes);
@ -375,8 +377,8 @@ public class Headerbar extends Composite{
optionDOCX.setHTML(EXPORT_OPENXML);
optionDOCX.setCommand(generateDOCX);
// optionPDF.setHTML("Export to PDF");
// optionPDF.setCommand(generatePDF);
optionPDF.setHTML("Export to PDF");
optionPDF.setCommand(generatePDF);
optionHTML.setHTML(EXPORT_HTML);
optionHTML.setCommand(generateHTML);
@ -591,7 +593,7 @@ public class Headerbar extends Composite{
Command generatePDF = new Command() {
public void execute() {
Window.alert("PDF Exporting may not be fully working, you can also generate a PDF using your Word Processor application starting from the docx exported file");
// Window.alert("PDF Exporting may not be fully working, you can also generate a PDF using your Word Processor application starting from the docx exported file");
presenter.generateManifestation(templateModel, ExportManifestationType.PDF);
}
};

View File

@ -7,6 +7,8 @@ import org.gcube.portlets.d4sreporting.common.client.uicomponents.richtext.RichT
import org.gcube.portlets.d4sreporting.common.shared.ComponentType;
import org.gcube.portlets.d4sreporting.common.shared.Metadata;
import org.gcube.portlets.d4sreporting.common.shared.Model;
import org.gcube.portlets.user.exporter.client.ReportExporterPopup;
import org.gcube.portlets.user.exporter.shared.TypeExporter;
import org.gcube.portlets.user.gcubewidgets.client.popup.GCubeDialog;
import org.gcube.portlets.user.reportgenerator.client.Headerbar;
import org.gcube.portlets.user.reportgenerator.client.ReportGenerator;
@ -654,85 +656,103 @@ public class Presenter {
* @param type .
*/
public void generateManifestation(final TemplateModel model, final ExportManifestationType type) {
boolean cont = true;
if (type == ExportManifestationType.HTML && model.containsLargeTS()) {
cont = Window.confirm("Exporting Large Time Series in HTML format can take up to minutes. (about 30 secs for 500 rows)\ndo you want to continue?");
// boolean cont = true;
// if (type == ExportManifestationType.HTML && model.containsLargeTS()) {
// cont = Window.confirm("Exporting Large Time Series in HTML format can take up to minutes. (about 30 secs for 500 rows)\ndo you want to continue?");
// }
ReportExporterPopup popup = new ReportExporterPopup();
Model reportModel = model.getSerializableModel();
switch (type) {
case DOCX:
popup.export(reportModel, TypeExporter.DOCX);
break;
case HTML:
popup.export(reportModel, TypeExporter.HTML);
break;
case PDF:
popup.export(reportModel, TypeExporter.PDF);
break;
}
//continue after warning the user on exporting large TSs
if (cont) {
final int left = Window.getClientWidth() / 2 - 200;
final int top = Window.getClientHeight() / 2 + 100;
final LoadingPopup loading = new LoadingPopup(true);
loading.setPopupPosition(left, top);
//loading.setStyleName("none");
AsyncCallback<Boolean> callback = new AsyncCallback<Boolean>() {
public void onFailure(Throwable caught) {
//MessageBox
MessageBox.alert("", "Failed to export: " + caught.getMessage(), null);
}
public void onSuccess(Boolean result) {
//MessageBox.hide();
if (result) {
refreshWorkspace();
final GCubeDialog popupPanel = new GCubeDialog();
popupPanel.setText("Exporting result");
String exportedName = model.getTemplateName();
exportedName = exportedName.replaceAll(".d4sR", "");
exportedName = exportedName.replaceAll(".d4sT", "");
final String urlToOpen = model.getExportedFileURL(type, exportedName);
VerticalPanel dlgPanel = new VerticalPanel();
dlgPanel.setSpacing(5);
dlgPanel.add(new HTML("The Report " + exportedName + " (" + type +") has been successfully saved <br />in your workspace root folder", true));
CellPanel bPanel = new HorizontalPanel();
Button close = new Button("close");
Button preview = new Button("Open");
bPanel.add(close);
bPanel.add(preview);
bPanel.setWidth("100%");
bPanel.setSpacing(5);
bPanel.setCellWidth(close, "50%");
bPanel.setCellWidth(preview, "50%");
bPanel.setCellHorizontalAlignment(close, HasHorizontalAlignment.ALIGN_CENTER);
bPanel.setCellHorizontalAlignment(preview, HasHorizontalAlignment.ALIGN_CENTER);
close.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
popupPanel.hide();
}
});
preview.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
Window.open(urlToOpen, model.getTemplateName(), "");
}
});
dlgPanel.add(bPanel);
popupPanel.setAnimationEnabled(true);
popupPanel.setPopupPosition(left, top);
popupPanel.setWidget(dlgPanel);
popupPanel.show();
}
else {
MessageBox.alert("", "Server reported errors on exporting Format", null);
}
}
};
Model toSend = model.getSerializableModel();
model.getModelService().generateManifestation(toSend, type, callback);
// //continue after warning the user on exporting large TSs
// if (cont) {
// final int left = Window.getClientWidth() / 2 - 200;
// final int top = Window.getClientHeight() / 2 + 100;
// final LoadingPopup loading = new LoadingPopup(true);
// loading.setPopupPosition(left, top);
// //loading.setStyleName("none");
//
//
// AsyncCallback<Boolean> callback = new AsyncCallback<Boolean>() {
//
// public void onFailure(Throwable caught) {
// //MessageBox
// MessageBox.alert("", "Failed to export: " + caught.getMessage(), null);
//
// }
//
// public void onSuccess(Boolean result) {
// //MessageBox.hide();
// if (result) {
// refreshWorkspace();
//
//
//
// final GCubeDialog popupPanel = new GCubeDialog();
// popupPanel.setText("Exporting result");
// String exportedName = model.getTemplateName();
// exportedName = exportedName.replaceAll(".d4sR", "");
// exportedName = exportedName.replaceAll(".d4sT", "");
//
// final String urlToOpen = model.getExportedFileURL(type, exportedName);
//
// VerticalPanel dlgPanel = new VerticalPanel();
// dlgPanel.setSpacing(5);
// dlgPanel.add(new HTML("The Report " + exportedName + " (" + type +") has been successfully saved <br />in your workspace root folder", true));
// CellPanel bPanel = new HorizontalPanel();
// Button close = new Button("close");
// Button preview = new Button("Open");
// bPanel.add(close);
// bPanel.add(preview);
// bPanel.setWidth("100%");
//
// bPanel.setSpacing(5);
// bPanel.setCellWidth(close, "50%");
// bPanel.setCellWidth(preview, "50%");
// bPanel.setCellHorizontalAlignment(close, HasHorizontalAlignment.ALIGN_CENTER);
// bPanel.setCellHorizontalAlignment(preview, HasHorizontalAlignment.ALIGN_CENTER);
//
// close.addClickHandler(new ClickHandler() {
// public void onClick(ClickEvent event) {
// popupPanel.hide();
// }
// });
// preview.addClickHandler(new ClickHandler() {
// public void onClick(ClickEvent event) {
// Window.open(urlToOpen, model.getTemplateName(), "");
// }
// });
// dlgPanel.add(bPanel);
//
// popupPanel.setAnimationEnabled(true);
// popupPanel.setPopupPosition(left, top);
// popupPanel.setWidget(dlgPanel);
// popupPanel.show();
// }
// else {
// MessageBox.alert("", "Server reported errors on exporting Format", null);
// }
// }
//
// };
//
// Model toSend = model.getSerializableModel();
// model.getModelService().generateManifestation(toSend, type, callback);
//TODO:
// MessageBox.show(new MessageBoxConfig() {
// {
@ -747,7 +767,7 @@ public class Presenter {
// });
// }
// });
}
// }
}
public void openAddCitationDialog() {

View File

@ -13,6 +13,7 @@
<!-- <set-property name="user.agent" value="gecko1_8" /> -->
<inherits name='org.gcube.portlets.user.workspace.lighttree.WorkspacePortletLightTree' />
<inherits name='org.gcube.portlets.user.exporter.Report_exporter_widget' />
<!-- Specify the app entry point class. -->
<entry-point

View File

@ -109,6 +109,15 @@
</servlet> <servlet-mapping> <servlet-name>fileUploaderServlet</servlet-name>
<url-pattern>/reportgenerator/fimesfileuploaderservlet</url-pattern> </servlet-mapping -->
<servlet>
<servlet-name>convertServlet</servlet-name>
<servlet-class>org.gcube.portlets.user.exporter.server.ReportExporterServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>convertServlet</servlet-name>
<url-pattern>/reports/convert</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>DownloadService</servlet-name>