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;
@ -647,11 +642,8 @@ 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,8 +684,19 @@ public class Headerbar extends Composite{
//************** COMMANDS ********************************//// //************** COMMANDS ********************************////
Command addBiblioEntryCommand = new Command() { Command addBiblioEntryCommand = new Command() {
public void execute() { public void execute() {
GWT.runAsync(new RunAsyncCallback() {
@Override
public void onSuccess() {
presenter.openAddCitationDialog(); presenter.openAddCitationDialog();
} }
@Override
public void onFailure(Throwable reason) {
}
});
}
}; };
/** /**
@ -701,6 +704,10 @@ public class Headerbar extends Composite{
*/ */
Command openMetadata = new Command() { Command openMetadata = new Command() {
public void execute() { public void execute() {
GWT.runAsync(new RunAsyncCallback() {
@Override
public void onSuccess() {
int left = mainLayout.getAbsoluteLeft() + 50; int left = mainLayout.getAbsoluteLeft() + 50;
int top = mainLayout.getAbsoluteTop() + 25; int top = mainLayout.getAbsoluteTop() + 25;
GCubeDialog dlg = new GCubeDialog(true); GCubeDialog dlg = new GCubeDialog(true);
@ -721,6 +728,13 @@ public class Headerbar extends Composite{
dlg.setAnimationEnabled(true); dlg.setAnimationEnabled(true);
dlg.show(); dlg.show();
} }
@Override
public void onFailure(Throwable reason) {}
});
}
}; };
Command importModelOrReport = new Command() { Command importModelOrReport = new Command() {
@ -734,7 +748,9 @@ 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 left = mainLayout.getAbsoluteLeft() + 50;
int top = mainLayout.getAbsoluteTop() + 25; int top = mainLayout.getAbsoluteTop() + 25;
WorkspaceLightTreeLoadPopup wpTreepopup = new WorkspaceLightTreeLoadPopup("Pick the item you want to import from", true, true); WorkspaceLightTreeLoadPopup wpTreepopup = new WorkspaceLightTreeLoadPopup("Pick the item you want to import from", true, true);
@ -756,11 +772,17 @@ public class Headerbar extends Composite{
} }
}); });
wpTreepopup.setPopupPosition(left, top); wpTreepopup.setPopupPosition(left, top);
wpTreepopup.show(); wpTreepopup.show();
} }
@Override
public void onFailure(Throwable reason) {
}
});
}
} }
}; };
/** /**

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,15 +637,12 @@ 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); ReportExporterPopup popup = new ReportExporterPopup(eventBus);
Model reportModel = model.getSerializableModel(); Model reportModel = model.getSerializableModel();
switch (type) { switch (type) {
case DOCX: case DOCX:
popup.export(reportModel, TypeExporter.DOCX); popup.export(reportModel, TypeExporter.DOCX);
@ -693,97 +657,13 @@ public class Presenter {
popup.export(reportModel, TypeExporter.XML); popup.export(reportModel, TypeExporter.XML);
break; break;
} }
}
@Override
public void onFailure(Throwable reason) {
}
});
// //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,6 +1105,9 @@ public class Presenter {
public void showReportStructure() { public void showReportStructure() {
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"); 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(); final com.extjs.gxt.ui.client.widget.Window window = new com.extjs.gxt.ui.client.widget.Window();
window.setTitle("Report Structure"); window.setTitle("Report Structure");
@ -1236,9 +1119,15 @@ public class Presenter {
window.setLayout(new FitLayout()); window.setLayout(new FitLayout());
window.add(panel); window.add(panel);
panel.getElement().getStyle().setBackgroundColor("#FFF"); panel.getElement().getStyle().setBackgroundColor("#FFF");
window.setPosition(0, this.getToolBoxPanel().getAbsoluteTop()); window.setPosition(0, getToolBoxPanel().getAbsoluteTop());
window.show(); 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 {