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"?>
<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>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
@ -30,5 +30,5 @@
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</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>

View File

@ -1,8 +1,8 @@
#Wed Mar 13 19:15:40 CET 2013
#Thu Mar 14 19:06:34 CET 2013
=\=\=\=\=\=\=
<<<<<<<=.mine
>>>>>>>=.r71295
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
warSrcDirIsOutput=false

View File

@ -12,7 +12,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>reports</artifactId>
<packaging>war</packaging>
<version>4.1.0-SNAPSHOT</version>
<version>4.1.2-SNAPSHOT</version>
<name>gCube Reports Portlet</name>
<description>
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.google.gwt.core.client.GWT;
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.Window;
import com.google.gwt.user.client.ui.CellPanel;
@ -381,7 +376,7 @@ public class Headerbar extends Composite{
};
Command showReportStructure = new Command() {
public void execute() {
public void execute() {
presenter.showReportStructure();
}
};
@ -646,12 +641,9 @@ public class Headerbar extends Composite{
}
};
Command generateEncryptedModel = new Command() {
Command generateEncryptedModel = new Command() {
@Override
public void execute() {
public void execute() {
GWT.runAsync(WorkspaceLightTreeLoadPopup.class, new RunAsyncCallback() {
public void onSuccess() {
WorkspaceLightTreeLoadPopup wpTreepopup = new WorkspaceLightTreeLoadPopup("Select the Report (or Template) to encrypt ", true, true);
@ -692,7 +684,18 @@ public class Headerbar extends Composite{
//************** COMMANDS ********************************////
Command addBiblioEntryCommand = new Command() {
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() {
public void execute() {
int left = mainLayout.getAbsoluteLeft() + 50;
int top = mainLayout.getAbsoluteTop() + 25;
GCubeDialog dlg = new GCubeDialog(true);
dlg.setText("Report Metadata:");
int pageNo = presenter.getModel().getCurrentPage();
List<Metadata> metadatas = presenter.getModel().getSection(pageNo).getAllMetadata();
int nRows = metadatas.size();
Grid metadataGrid = new Grid(nRows, 2);
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++;
}
GWT.runAsync(new RunAsyncCallback() {
@Override
public void onSuccess() {
int left = mainLayout.getAbsoluteLeft() + 50;
int top = mainLayout.getAbsoluteTop() + 25;
GCubeDialog dlg = new GCubeDialog(true);
dlg.setText("Report Metadata:");
int pageNo = presenter.getModel().getCurrentPage();
List<Metadata> metadatas = presenter.getModel().getSection(pageNo).getAllMetadata();
int nRows = metadatas.size();
Grid metadataGrid = new Grid(nRows, 2);
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.setPopupPosition(left, top);
dlg.setAnimationEnabled(true);
dlg.show();
dlg.setWidget(metadataGrid);
dlg.setPopupPosition(left, top);
dlg.setAnimationEnabled(true);
dlg.show();
}
@Override
public void onFailure(Throwable reason) {}
});
}
};
@ -734,32 +748,40 @@ public class Headerbar extends Composite{
dlg.show();
}
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;
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);
wpTreepopup.addPopupHandler(new PopupHandler() {
public void onPopup(PopupEvent event) {
if (! event.isCanceled()) {
if (event.getSelectedItem() != null) {
int left = mainLayout.getAbsoluteLeft() + 50;
int top = mainLayout.getAbsoluteTop() + 25;
ImporterDialog dlg = new ImporterDialog(event.getSelectedItem(), presenter);
dlg.setPopupPosition(left, top);
dlg.setAnimationEnabled(true);
dlg.show();
}
presenter.getHeader().enableExports();
}
wpTreepopup.addPopupHandler(new PopupHandler() {
public void onPopup(PopupEvent event) {
if (! event.isCanceled()) {
if (event.getSelectedItem() != null) {
int left = mainLayout.getAbsoluteLeft() + 50;
int top = mainLayout.getAbsoluteTop() + 25;
ImporterDialog dlg = new ImporterDialog(event.getSelectedItem(), presenter);
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.layout.FitLayout;
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.HandlerManager;
import com.google.gwt.event.shared.SimpleEventBus;
@ -629,40 +630,6 @@ public class Presenter {
* @param 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 .
*/
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?");
// }
GWT.runAsync(ReportExporterPopup.class, new RunAsyncCallback() {
@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() {
ReportStructureDialog panel = new ReportStructureDialog(eventBus, model.getSerializableModel(), ToolboxPanel.TOOLBOX_WIDTH+"px", ToolboxPanel.TOOLBOX_HEIGHT+"px");
final com.extjs.gxt.ui.client.widget.Window window = new com.extjs.gxt.ui.client.widget.Window();
window.setTitle("Report Structure");
window.setClosable(true);
window.setResizable(false);
window.setWidth(ToolboxPanel.TOOLBOX_WIDTH);
window.setHeight(ToolboxPanel.TOOLBOX_HEIGHT);
window.setPlain(true);
window.setLayout(new FitLayout());
window.add(panel);
panel.getElement().getStyle().setBackgroundColor("#FFF");
window.setPosition(0, this.getToolBoxPanel().getAbsoluteTop());
window.show();
GWT.runAsync(ReportStructureDialog.class, new RunAsyncCallback() {
@Override
public void onSuccess() {
ReportStructureDialog panel = new ReportStructureDialog(eventBus, model.getSerializableModel(), ToolboxPanel.TOOLBOX_WIDTH+"px", ToolboxPanel.TOOLBOX_HEIGHT+"px");
final com.extjs.gxt.ui.client.widget.Window window = new com.extjs.gxt.ui.client.widget.Window();
window.setTitle("Report Structure");
window.setClosable(true);
window.setResizable(false);
window.setWidth(ToolboxPanel.TOOLBOX_WIDTH);
window.setHeight(ToolboxPanel.TOOLBOX_HEIGHT);
window.setPlain(true);
window.setLayout(new FitLayout());
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.util.encryption.EncryptionUtil;
@SuppressWarnings("serial")
public class DownloadEncryptedReport extends HttpServlet {