added asyncs

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/reports@71411 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2013-03-15 10:37:45 +00:00
parent 8949e29c02
commit e564b5546d
6 changed files with 129 additions and 217 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" output="target/reports-4.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java"> <classpathentry kind="src" output="target/reports-4.1.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
@ -30,5 +30,5 @@
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/> <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="output" path="target/reports-4.1.0-SNAPSHOT/WEB-INF/classes"/> <classpathentry kind="output" path="target/reports-4.1.1-SNAPSHOT/WEB-INF/classes"/>
</classpath> </classpath>

View File

@ -1,8 +1,8 @@
#Wed Mar 13 19:15:40 CET 2013 #Thu Mar 14 19:06:34 CET 2013
=\=\=\=\=\=\= =\=\=\=\=\=\=
<<<<<<<=.mine <<<<<<<=.mine
>>>>>>>=.r71295 >>>>>>>=.r71295
eclipse.preferences.version=1 eclipse.preferences.version=1
lastWarOutDir=/Users/massi/Documents/workspace/reports/target/reports-4.1.0-SNAPSHOT lastWarOutDir=/Users/massi/Documents/workspace/reports/target/reports-4.1.1-SNAPSHOT
warSrcDir=src/main/webapp warSrcDir=src/main/webapp
warSrcDirIsOutput=false warSrcDirIsOutput=false

View File

@ -12,7 +12,7 @@
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
<artifactId>reports</artifactId> <artifactId>reports</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<version>4.1.0-SNAPSHOT</version> <version>4.1.2-SNAPSHOT</version>
<name>gCube Reports Portlet</name> <name>gCube Reports Portlet</name>
<description> <description>
gCube Reports Portlet. gCube Reports Portlet.

View File

@ -19,11 +19,6 @@ import org.gcube.portlets.user.workspace.lighttree.client.load.WorkspaceLightTre
import com.extjs.gxt.ui.client.widget.MessageBox; import com.extjs.gxt.ui.client.widget.MessageBox;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.RunAsyncCallback; import com.google.gwt.core.client.RunAsyncCallback;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;
import com.google.gwt.user.client.Command; import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Window; import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.CellPanel; import com.google.gwt.user.client.ui.CellPanel;
@ -381,7 +376,7 @@ public class Headerbar extends Composite{
}; };
Command showReportStructure = new Command() { Command showReportStructure = new Command() {
public void execute() { public void execute() {
presenter.showReportStructure(); presenter.showReportStructure();
} }
}; };
@ -646,12 +641,9 @@ public class Headerbar extends Composite{
} }
}; };
Command generateEncryptedModel = new Command() { Command generateEncryptedModel = new Command() {
@Override @Override
public void execute() { public void execute() {
GWT.runAsync(WorkspaceLightTreeLoadPopup.class, new RunAsyncCallback() { GWT.runAsync(WorkspaceLightTreeLoadPopup.class, new RunAsyncCallback() {
public void onSuccess() { public void onSuccess() {
WorkspaceLightTreeLoadPopup wpTreepopup = new WorkspaceLightTreeLoadPopup("Select the Report (or Template) to encrypt ", true, true); WorkspaceLightTreeLoadPopup wpTreepopup = new WorkspaceLightTreeLoadPopup("Select the Report (or Template) to encrypt ", true, true);
@ -692,7 +684,18 @@ public class Headerbar extends Composite{
//************** COMMANDS ********************************//// //************** COMMANDS ********************************////
Command addBiblioEntryCommand = new Command() { Command addBiblioEntryCommand = new Command() {
public void execute() { public void execute() {
presenter.openAddCitationDialog(); GWT.runAsync(new RunAsyncCallback() {
@Override
public void onSuccess() {
presenter.openAddCitationDialog();
}
@Override
public void onFailure(Throwable reason) {
}
});
} }
}; };
@ -701,25 +704,36 @@ public class Headerbar extends Composite{
*/ */
Command openMetadata = new Command() { Command openMetadata = new Command() {
public void execute() { public void execute() {
int left = mainLayout.getAbsoluteLeft() + 50; GWT.runAsync(new RunAsyncCallback() {
int top = mainLayout.getAbsoluteTop() + 25;
GCubeDialog dlg = new GCubeDialog(true); @Override
dlg.setText("Report Metadata:"); public void onSuccess() {
int pageNo = presenter.getModel().getCurrentPage(); int left = mainLayout.getAbsoluteLeft() + 50;
List<Metadata> metadatas = presenter.getModel().getSection(pageNo).getAllMetadata(); int top = mainLayout.getAbsoluteTop() + 25;
int nRows = metadatas.size(); GCubeDialog dlg = new GCubeDialog(true);
Grid metadataGrid = new Grid(nRows, 2); dlg.setText("Report Metadata:");
int i = 0; int pageNo = presenter.getModel().getCurrentPage();
for (Metadata md : metadatas) { List<Metadata> metadatas = presenter.getModel().getSection(pageNo).getAllMetadata();
metadataGrid.setWidget(i, 0, new HTML("<b>" + md.getAttribute() + ": </b>")); int nRows = metadatas.size();
metadataGrid.setWidget(i, 1, new HTML(md.getValue())); Grid metadataGrid = new Grid(nRows, 2);
i++; int i = 0;
} for (Metadata md : metadatas) {
metadataGrid.setWidget(i, 0, new HTML("<b>" + md.getAttribute() + ": </b>"));
metadataGrid.setWidget(i, 1, new HTML(md.getValue()));
i++;
}
dlg.setWidget(metadataGrid); dlg.setWidget(metadataGrid);
dlg.setPopupPosition(left, top); dlg.setPopupPosition(left, top);
dlg.setAnimationEnabled(true); dlg.setAnimationEnabled(true);
dlg.show(); dlg.show();
}
@Override
public void onFailure(Throwable reason) {}
});
} }
}; };
@ -734,32 +748,40 @@ public class Headerbar extends Composite{
dlg.show(); dlg.show();
} }
else { else {
GWT.runAsync(new RunAsyncCallback() {
@Override
public void onSuccess() {
int left = mainLayout.getAbsoluteLeft() + 50;
int top = mainLayout.getAbsoluteTop() + 25;
WorkspaceLightTreeLoadPopup wpTreepopup = new WorkspaceLightTreeLoadPopup("Pick the item you want to import from", true, true);
wpTreepopup.setShowableTypes(ItemType.REPORT_TEMPLATE, ItemType.REPORT);
int left = mainLayout.getAbsoluteLeft() + 50; wpTreepopup.addPopupHandler(new PopupHandler() {
int top = mainLayout.getAbsoluteTop() + 25; public void onPopup(PopupEvent event) {
WorkspaceLightTreeLoadPopup wpTreepopup = new WorkspaceLightTreeLoadPopup("Pick the item you want to import from", true, true); if (! event.isCanceled()) {
wpTreepopup.setShowableTypes(ItemType.REPORT_TEMPLATE, ItemType.REPORT); if (event.getSelectedItem() != null) {
int left = mainLayout.getAbsoluteLeft() + 50;
wpTreepopup.addPopupHandler(new PopupHandler() { int top = mainLayout.getAbsoluteTop() + 25;
public void onPopup(PopupEvent event) { ImporterDialog dlg = new ImporterDialog(event.getSelectedItem(), presenter);
if (! event.isCanceled()) { dlg.setPopupPosition(left, top);
if (event.getSelectedItem() != null) { dlg.setAnimationEnabled(true);
int left = mainLayout.getAbsoluteLeft() + 50; dlg.show();
int top = mainLayout.getAbsoluteTop() + 25; }
ImporterDialog dlg = new ImporterDialog(event.getSelectedItem(), presenter); presenter.getHeader().enableExports();
dlg.setPopupPosition(left, top); }
dlg.setAnimationEnabled(true);
dlg.show();
}
presenter.getHeader().enableExports();
}
}
});
wpTreepopup.setPopupPosition(left, top);
wpTreepopup.show();
}
@Override
public void onFailure(Throwable reason) {
} }
}); });
wpTreepopup.setPopupPosition(left, top);
wpTreepopup.show();
} }
} }
}; };

View File

@ -52,6 +52,7 @@ import org.gcube.portlets.user.reportgenerator.shared.UserBean;
import com.extjs.gxt.ui.client.widget.MessageBox; import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.layout.FitLayout; import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.RunAsyncCallback;
import com.google.gwt.event.shared.EventBus; import com.google.gwt.event.shared.EventBus;
import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.event.shared.SimpleEventBus; import com.google.gwt.event.shared.SimpleEventBus;
@ -629,40 +630,6 @@ public class Presenter {
* @param model * @param model
*/ */
public void generateFiMES(final TemplateModel model) { public void generateFiMES(final TemplateModel model) {
// GWT.log("generateFiMES");
// MessageBox.show(new MessageBoxConfig() { {
// setMsg("Processing report, please wait ...");
// setProgressText("pre-processining phase");
// setWidth(300);
// setWait(true);
// setWaitConfig(new WaitConfig() {
// {
// setInterval(500);
// }
// });
// }
// });
// final SerializableModel toSend = model.getSerializableModel();
//
// model.getModelService().generateTempDocx(toSend, new AsyncCallback<String>() {
// public void onFailure(Throwable caught) {
// MessageBox.hide();
// MessageBox.alert("There were problems on Server: " + caught.getMessage());
// }
//
// public void onSuccess(String result) {
// MessageBox.hide();
// if (result.compareTo("ERROR") == 0)
// MessageBox.alert("There were problems on Server, conversion failed");
// else {
// MessageBox.hide();
// String filename = toSend.getTemplateName().replaceAll(".d4sR", "");
// GWT.log("____>>>>>"+filename);
// final FimesExporterPopup pp = new FimesExporterPopup(eventBus, result, filename);
// GWT.log("____>>>>>pp.isFinished()="+pp.isFinished());
// }
// }
// });
} }
/** /**
* *
@ -670,120 +637,33 @@ public class Presenter {
* @param type . * @param type .
*/ */
public void generateManifestation(final TemplateModel model, final ExportManifestationType type) { public void generateManifestation(final TemplateModel model, final ExportManifestationType type) {
// boolean cont = true; GWT.runAsync(ReportExporterPopup.class, new RunAsyncCallback() {
// 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?"); @Override
// } public void onSuccess() {
ReportExporterPopup popup = new ReportExporterPopup(eventBus);
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;
case XML:
popup.export(reportModel, TypeExporter.XML);
break;
}
}
@Override
public void onFailure(Throwable reason) {
}
});
ReportExporterPopup popup = new ReportExporterPopup(eventBus);
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;
case XML:
popup.export(reportModel, TypeExporter.XML);
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);
//TODO:
// MessageBox.show(new MessageBoxConfig() {
// {
// setMsg("Processing report, please wait ...");
// setProgressText("exporting ...");
// setWidth(300);
// setWait(true);
// setWaitConfig(new WaitConfig() {
// {
// setInterval(1000);
// }
// });
// }
// });
// }
} }
@ -1225,19 +1105,28 @@ public class Presenter {
public void showReportStructure() { public void showReportStructure() {
ReportStructureDialog panel = new ReportStructureDialog(eventBus, model.getSerializableModel(), ToolboxPanel.TOOLBOX_WIDTH+"px", ToolboxPanel.TOOLBOX_HEIGHT+"px"); GWT.runAsync(ReportStructureDialog.class, new RunAsyncCallback() {
final com.extjs.gxt.ui.client.widget.Window window = new com.extjs.gxt.ui.client.widget.Window(); @Override
window.setTitle("Report Structure"); public void onSuccess() {
window.setClosable(true); ReportStructureDialog panel = new ReportStructureDialog(eventBus, model.getSerializableModel(), ToolboxPanel.TOOLBOX_WIDTH+"px", ToolboxPanel.TOOLBOX_HEIGHT+"px");
window.setResizable(false); final com.extjs.gxt.ui.client.widget.Window window = new com.extjs.gxt.ui.client.widget.Window();
window.setWidth(ToolboxPanel.TOOLBOX_WIDTH); window.setTitle("Report Structure");
window.setHeight(ToolboxPanel.TOOLBOX_HEIGHT); window.setClosable(true);
window.setPlain(true); window.setResizable(false);
window.setLayout(new FitLayout()); window.setWidth(ToolboxPanel.TOOLBOX_WIDTH);
window.add(panel); window.setHeight(ToolboxPanel.TOOLBOX_HEIGHT);
panel.getElement().getStyle().setBackgroundColor("#FFF"); window.setPlain(true);
window.setPosition(0, this.getToolBoxPanel().getAbsoluteTop()); window.setLayout(new FitLayout());
window.show(); window.add(panel);
panel.getElement().getStyle().setBackgroundColor("#FFF");
window.setPosition(0, getToolBoxPanel().getAbsoluteTop());
window.show();
}
@Override
public void onFailure(Throwable reason) {
}
});
} }

View File

@ -24,6 +24,7 @@ import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.Report;
import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ReportTemplate; import org.gcube.portlets.user.homelibrary.home.workspace.folder.items.ReportTemplate;
import org.gcube.portlets.user.homelibrary.util.encryption.EncryptionUtil; import org.gcube.portlets.user.homelibrary.util.encryption.EncryptionUtil;
@SuppressWarnings("serial")
public class DownloadEncryptedReport extends HttpServlet { public class DownloadEncryptedReport extends HttpServlet {