almost warking exports

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/reports@71449 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2013-03-15 18:06:43 +00:00
parent 209d730380
commit 9adc51f0ef
16 changed files with 324 additions and 30 deletions

View File

@ -5,6 +5,9 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
<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

@ -8,11 +8,16 @@ 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.client.ReportExporterServiceAsync;
import org.gcube.portlets.user.exporter.client.event.ExportingCompletedEvent;
import org.gcube.portlets.user.exporter.client.event.ExportingCompletedEventHandler;
import org.gcube.portlets.user.exporter.client.event.ReportExporterEvent;
import org.gcube.portlets.user.exporter.client.event.ReportExporterEventHandler;
import org.gcube.portlets.user.exporter.shared.TypeExporter;
import org.gcube.portlets.user.reportgenerator.client.Headerbar;
import org.gcube.portlets.user.reportgenerator.client.ReportGenerator;
import org.gcube.portlets.user.reportgenerator.client.ReportService;
import org.gcube.portlets.user.reportgenerator.client.ReportServiceAsync;
import org.gcube.portlets.user.reportgenerator.client.TitleBar;
import org.gcube.portlets.user.reportgenerator.client.ToolboxPanel;
import org.gcube.portlets.user.reportgenerator.client.WorkspacePanel;
@ -46,6 +51,7 @@ import org.gcube.portlets.user.reportgenerator.client.targets.HeadingTextArea;
import org.gcube.portlets.user.reportgenerator.client.targets.ReportTextArea;
import org.gcube.portlets.user.reportgenerator.client.targets.TSArea;
import org.gcube.portlets.user.reportgenerator.client.targets.TextTableImage;
import org.gcube.portlets.user.reportgenerator.client.uibinder.ExportOptions;
import org.gcube.portlets.user.reportgenerator.shared.SessionInfo;
import org.gcube.portlets.user.reportgenerator.shared.UserBean;
@ -53,14 +59,13 @@ 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;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.RichTextArea;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
@ -74,6 +79,7 @@ import com.google.gwt.user.client.ui.Widget;
*/
public class Presenter {
private ReportServiceAsync reportService = (ReportServiceAsync) GWT.create(ReportService.class);
/**
* View part
*/
@ -83,10 +89,9 @@ public class Presenter {
private ToolboxPanel toolBoxPanel;
// private FimesFileUploadWindow importDlg;
private TitleBar titleBar;
private HorizontalPanel exportsPanel;
private UserBean currentUser;
private String currentScope;
@ -118,6 +123,14 @@ public class Presenter {
private void handleEvents() {
eventBus.addHandler(ExportingCompletedEvent.TYPE, new ExportingCompletedEventHandler() {
@Override
public void onExportFinished(ExportingCompletedEvent event) {
showExportSaveOptions(event.getFilePath(), event.getItemName(), event.getType());
}
});
eventBus.addHandler(AddBiblioEvent.TYPE, new AddBiblioEventHandler() {
public void onAddCitation(AddBiblioEvent event) {
addCitation(event.getCitekey(), event.getCitetext());
@ -135,11 +148,6 @@ public class Presenter {
}
});
// eventBus.addHandler(ExportFinishedEvent.TYPE, new EsportFinishedEventHandler() {
// public void onFinishedExport(ExportFinishedEvent event) {
// refreshWorkspace();
// }
// });
eventBus.addHandler(ReportExporterEvent.TYPE, new ReportExporterEventHandler() {
@Override
@ -432,15 +440,7 @@ public class Presenter {
//persists the change in the session
model.storeInSession();
}
/**
* when export is done this method is called
* @param filePath
* @param itemName
* @param type
*/
public void showExportSaveOptions(final String filePath, final String itemName, final TypeExporter type) {
}
/**
* just clean the page
*/
@ -1131,5 +1131,27 @@ public class Presenter {
}
public HorizontalPanel getExportsPanel() {
return exportsPanel;
}
public void setExportsPanel(HorizontalPanel exportsPanel) {
this.exportsPanel = exportsPanel;
}
/**
* when export is done this method is called
* @param filePath
* @param itemName
* @param type
*/
public void showExportSaveOptions(final String filePath, final String itemName, final TypeExporter type) {
ExportOptions exo = new ExportOptions(this, toolBoxPanel, filePath, itemName, type, reportService);
exportsPanel.add(exo);
}
public void clearExportPanel() {
exportsPanel.clear();
}
}

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.user.reportgenerator.client;
import org.gcube.portlets.user.exporter.shared.TypeExporter;
import org.gcube.portlets.user.guidedtour.client.GCUBEGuidedTour;
import org.gcube.portlets.user.guidedtour.client.steps.GCUBETemplate1Text1Image;
import org.gcube.portlets.user.guidedtour.client.steps.GCUBETemplate2Text2Image;
@ -34,11 +35,10 @@ import com.google.gwt.user.client.ui.VerticalPanel;
* Entry point classes define <code>onModuleLoad()</code>.
*
*
* <code> ReportGen </code> class is the Entry point class, defines the main layout of the UI
* <code> ReportGeneretor </code> class is the Entry point class, defines the main layout of the UI
*
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
*
* @version June 2011 (3.0)
*/
public class ReportGenerator implements EntryPoint {
@ -86,6 +86,8 @@ public class ReportGenerator implements EntryPoint {
private TitleBar titlebar;
private HorizontalPanel exportResultsPanel = new HorizontalPanel();
private WorkspacePanel workSpacePanel;
private VerticalPanel eastPanel = new VerticalPanel();
@ -116,6 +118,7 @@ public class ReportGenerator implements EntryPoint {
presenter.setTitleBar(titlebar);
presenter.setWp(workSpacePanel);
presenter.setToolBoxPanel(toolBoxPanel);
presenter.setExportsPanel(exportResultsPanel);
mainLayout.add(titlebar);
mainLayout.add(header);
@ -140,6 +143,7 @@ public class ReportGenerator implements EntryPoint {
divHidden.addStyleName("hasRichTextToolbar");
divHidden.addStyleName("setVisibilityOff");
eastPanel.add(exportResultsPanel);
eastPanel.add(workSpacePanel);
eastPanel.add(divHidden);
bottomScrollerPanel.add(eastPanel);
@ -174,6 +178,7 @@ public class ReportGenerator implements EntryPoint {
});
//showGuidedTour() ;
//presenter.showExportSaveOptions("", "", TypeExporter.DOCX, null);
}
private void showGuidedTour() {

View File

@ -1,19 +1,24 @@
package org.gcube.portlets.user.reportgenerator.client;
import org.gcube.portlets.d4sreporting.common.shared.Model;
import org.gcube.portlets.d4sreporting.common.shared.Table;
import org.gcube.portlets.d4sreporting.common.shared.RepTimeSeries;
import org.gcube.portlets.user.reportgenerator.client.model.ExportManifestationType;
import org.gcube.portlets.d4sreporting.common.shared.Table;
import org.gcube.portlets.user.exporter.shared.SaveReportFileException;
import org.gcube.portlets.user.exporter.shared.SaveReportFileExistException;
import org.gcube.portlets.user.exporter.shared.TypeExporter;
import org.gcube.portlets.user.reportgenerator.shared.SessionInfo;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
/**
* Service interface for server communication
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
* @version november 2008 (0.1)
*/
@RemoteServiceRelativePath("ReportServiceImpl")
public interface ReportService extends RemoteService{
String save(String filePath, String workspaceFolderId, String ItemName,
TypeExporter type, boolean overwrite)
throws SaveReportFileException, SaveReportFileExistException;
/**
* return the first ten records of the timeseries having id as param
* @param sTS .

View File

@ -1,9 +1,9 @@
package org.gcube.portlets.user.reportgenerator.client;
import org.gcube.portlets.d4sreporting.common.shared.Model;
import org.gcube.portlets.d4sreporting.common.shared.Table;
import org.gcube.portlets.d4sreporting.common.shared.RepTimeSeries;
import org.gcube.portlets.user.reportgenerator.client.model.ExportManifestationType;
import org.gcube.portlets.d4sreporting.common.shared.Table;
import org.gcube.portlets.user.exporter.shared.TypeExporter;
import org.gcube.portlets.user.reportgenerator.shared.SessionInfo;
import com.google.gwt.user.client.rpc.AsyncCallback;
@ -11,7 +11,6 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
* * Service interface for server Async communication
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
*
* @version november 2011 (3.0)
*/
public interface ReportServiceAsync {
@ -74,4 +73,6 @@ public interface ReportServiceAsync {
void readImportedModel(String tempPath,
AsyncCallback<Model> callback);
void save(String filePath, String workspaceFolderId, String ItemName,
TypeExporter type, boolean overwrite, AsyncCallback<String> callback);
}

View File

@ -8,6 +8,7 @@ import org.gcube.portlets.user.reportgenerator.client.targets.DoubleColumnPanel;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget;
@ -49,7 +50,6 @@ public class WorkspacePanel extends Composite {
public static WorkspacePanel get() {
return singleton;
}
/**
* the panel for the layout of the working space
*/

View File

@ -0,0 +1,84 @@
package org.gcube.portlets.user.reportgenerator.client.uibinder;
import org.gcube.portlets.user.exporter.shared.TypeExporter;
import org.gcube.portlets.user.reportgenerator.client.ReportServiceAsync;
import org.gcube.portlets.user.reportgenerator.client.ToolboxPanel;
import org.gcube.portlets.user.reportgenerator.client.Presenter.Presenter;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
public class ExportOptions extends Composite {
private static ExportOptionsUiBinder uiBinder = GWT
.create(ExportOptionsUiBinder.class);
interface ExportOptionsUiBinder extends UiBinder<Widget, ExportOptions> {
}
enum ExportMode {SAVE_OPEN, SAVE, SAVE_AS }
ToolboxPanel tbp;
@UiField HTML saveOpen;
@UiField HTML save;
@UiField HTML saveAs;
private String filePath;
private String itemName;
private String workspaceFolderId;
private TypeExporter type;
private ReportServiceAsync rpc;
private Presenter p;
public ExportOptions(Presenter p, ToolboxPanel tbp, final String filePath, final String itemName, final TypeExporter type, ReportServiceAsync rpc) {
initWidget(uiBinder.createAndBindUi(this));
this.tbp = tbp;
this.filePath = filePath;
this.itemName = itemName;
this.type= type;
this.rpc = rpc;
this.p = p;
workspaceFolderId = null;
}
@UiHandler("saveOpen")
void onSaveOpenClick(ClickEvent e) {
GWT.log("SaveOPen");
doCallBack(ExportMode.SAVE_OPEN);
}
@UiHandler("save")
void onSaveClick(ClickEvent e) {
doCallBack(ExportMode.SAVE);
}
@UiHandler("saveAs")
void onSaveAs(ClickEvent e) {
doCallBack(ExportMode.SAVE_AS);
}
private void doCallBack(ExportMode mode) {
rpc.save(filePath, workspaceFolderId, itemName, type, true, new AsyncCallback<String>() {
@Override
public void onSuccess(String createdItemId) {
p.clearExportPanel();
tbp.showExportedVersion(createdItemId, itemName);
Window.alert("Success ");
}
@Override
public void onFailure(Throwable caught) {
Window.alert("Error: " + caught.getMessage());
}
});
}
}

View File

@ -0,0 +1,25 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:HTMLPanel styleName="exportPanel">
<table style="width: 700px; text-align: center;">
<tr>
<td colspan="3">
<div class="exportResult">
Exporting Completed Succesfully</div>
</td>
</tr>
<tr>
<td>
<g:HTML ui:field="saveOpen" styleName="exportOption optionSaveOpen">Save &amp; Open</g:HTML>
</td>
<td>
<g:HTML ui:field="save" styleName="exportOption optionSave">Save</g:HTML>
</td>
<td>
<g:HTML ui:field="saveAs" styleName="exportOption optionSaveAs">Save As</g:HTML>
</td>
</tr>
</table>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -47,6 +47,9 @@ import org.gcube.portlets.d4sreporting.common.shared.RepTimeSeries;
import org.gcube.portlets.d4sreporting.common.shared.RepeatableSequence;
import org.gcube.portlets.d4sreporting.common.shared.Table;
import org.gcube.portlets.d4sreporting.common.shared.TableCell;
import org.gcube.portlets.user.exporter.shared.SaveReportFileException;
import org.gcube.portlets.user.exporter.shared.SaveReportFileExistException;
import org.gcube.portlets.user.exporter.shared.TypeExporter;
import org.gcube.portlets.user.homelibrary.home.HomeLibrary;
import org.gcube.portlets.user.homelibrary.home.exceptions.HomeNotFoundException;
import org.gcube.portlets.user.homelibrary.home.exceptions.InternalErrorException;
@ -1651,6 +1654,47 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
}
@Override
public String save(String filePath, String workspaceFolderId, String itemName, TypeExporter type, boolean overwrite) throws SaveReportFileException, SaveReportFileExistException {
try {
File file = new File(filePath);
Workspace workspace = HomeLibrary.getUserWorkspace(getASLSession());
_log.info("Saving in Workspace of " + workspace.getOwner().getPortalLogin());
WorkspaceFolder folder = (workspaceFolderId != null)?
(WorkspaceFolder)workspace.getItem(workspaceFolderId):workspace.getRoot();
if (workspace.exists(itemName, folder.getId())) {
if (overwrite)
workspace.remove(itemName, folder.getId());
else
throw new SaveReportFileException("The item " + itemName + " already exists");
}
switch (type) {
case PDF:
return folder.createExternalPDFFileItem(itemName + "." + type.toString().toLowerCase(),
"", null, new FileInputStream(file)).getId();
case HTML:
return folder.createExternalFileItem(itemName + "." + type.toString().toLowerCase(),
"", "text/html", new FileInputStream(file)).getId();
case DOCX:
return folder.createExternalFileItem(itemName + "." + type.toString().toLowerCase(),
"", "application/msword", new FileInputStream(file)).getId();
case XML:
return folder.createExternalFileItem(itemName + "." + type.toString().toLowerCase(),
"", "application/xml", new FileInputStream(file)).getId();
}
throw new SaveReportFileException("Unknown file type");
} catch (ItemAlreadyExistException e) {
throw new SaveReportFileExistException(e.getMessage());
} catch (Exception e) {
throw new SaveReportFileException(e.getMessage());
}
}

View File

@ -0,0 +1,25 @@
package org.gcube.portlets.user.reportgenerator.shared;
import java.io.Serializable;
public class ReportExporterException extends Exception implements Serializable {
/**
*
*/
private static final long serialVersionUID = -1020757346366625622L;
private String error;
public ReportExporterException() {
}
public ReportExporterException(String error) {
this.error = error;
}
@Override
public String getMessage() {
return error;
}
}

View File

@ -0,0 +1,16 @@
package org.gcube.portlets.user.reportgenerator.shared;
public class SaveReportFileException extends ReportExporterException {
private static final long serialVersionUID = -6674611825830219782L;
public SaveReportFileException() {
}
public SaveReportFileException(String error) {
super(error);
}
}

View File

@ -0,0 +1,18 @@
package org.gcube.portlets.user.reportgenerator.shared;
public class SaveReportFileExistException extends ReportExporterException {
/**
*
*/
private static final long serialVersionUID = 7241356056474394295L;
public SaveReportFileExistException() {
}
public SaveReportFileExistException(String error) {
super(error);
}
}

View File

@ -1,5 +1,51 @@
@import url('reports/old-dialog.css');
.exportPanel {
margin: 10px 5px 5px 20px;
border: 1px solid #e3e8f3;
padding: 10px;
background-color: #FFFFBF;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
width: 775px;
}
.exportResult {
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 18px;
color: #444;
margin-bottom: 20px;
}
.exportOption {
display: block;
height: 148px;
width: 250px;
opacity: 0.8;
text-align: center;
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 18px;
color: #444;
}
.exportOption:hover {
cursor: pointer;
cursor: hand;
opacity: 1.0;
}
.optionSave {
background: url('images/save.png') 55% 25px no-repeat;
}
.optionSaveAs {
background: url('images/save_as.png') 60% 25px no-repeat;
}
.optionSaveOpen {
background: url('images/save_open.png') 55% 25px no-repeat;
}
.closeImage {
background: url(images/close.png) 0px 0px no-repeat;
height: 15px;

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB