2013-02-06 23:25:43 +01:00
|
|
|
|
package org.gcube.portlets.user.reportgenerator.client.Presenter;
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
2013-11-14 16:26:26 +01:00
|
|
|
|
import org.gcube.portlets.d4sreporting.common.shared.BasicSection;
|
2013-02-06 23:25:43 +01:00
|
|
|
|
import org.gcube.portlets.d4sreporting.common.shared.Metadata;
|
2013-03-01 19:42:50 +01:00
|
|
|
|
import org.gcube.portlets.d4sreporting.common.shared.Model;
|
2013-11-18 18:25:49 +01:00
|
|
|
|
import org.gcube.portlets.d4sreporting.common.shared.ReportReferences;
|
2013-12-17 19:19:51 +01:00
|
|
|
|
import org.gcube.portlets.d4sreporting.common.shared.Tuple;
|
2013-02-06 23:25:43 +01:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.Headerbar;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.ReportGenerator;
|
2013-03-15 19:06:43 +01:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.ReportService;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.ReportServiceAsync;
|
2013-11-22 18:28:12 +01:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.ReportStructurePanel;
|
2013-02-06 23:25:43 +01:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.TitleBar;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.ToolboxPanel;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.WorkspacePanel;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.dialog.AddBiblioEntryDialog;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.dialog.DeleteCitationsDialog;
|
2013-11-25 17:12:01 +01:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.dialog.ImportVMEReportDialog;
|
2013-05-06 18:54:25 +02:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.dialog.WaitingOperationDialog;
|
2013-02-06 23:25:43 +01:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.events.AddBiblioEvent;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.events.AddBiblioEventHandler;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.events.AddCommentEvent;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.events.AddCommentEventHandler;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.events.ItemSelectionEvent;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.events.ItemSelectionEventHandler;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.events.RemovedCitationEvent;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.events.RemovedCitationEventHandler;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.events.RemovedUserCommentEvent;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.events.RemovedUserCommentEventHandler;
|
2013-11-25 17:12:01 +01:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.events.SelectedReportEvent;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.events.SelectedReportEventHandler;
|
2013-02-06 23:25:43 +01:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.model.ExportManifestationType;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.model.TemplateComponent;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.model.TemplateModel;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.model.TemplateSection;
|
2013-03-05 15:26:22 +01:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.targets.AttributeMultiSelection;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.targets.AttributeSingleSelection;
|
2013-02-06 23:25:43 +01:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.targets.BasicTextArea;
|
2013-03-07 16:03:01 +01:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.targets.ClientImage;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.targets.ClientRepeatableSequence;
|
2013-11-14 17:57:40 +01:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.targets.ClientReportReference;
|
2013-11-18 18:25:49 +01:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.targets.ClientSequence;
|
2013-02-06 23:25:43 +01:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.targets.Coords;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.targets.D4sRichTextarea;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.targets.GenericTable;
|
2013-02-13 18:26:22 +01:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.targets.GroupingDelimiterArea;
|
2013-03-13 11:06:47 +01:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.targets.HeadingTextArea;
|
2013-02-06 23:25:43 +01:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.targets.ReportTextArea;
|
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.targets.TSArea;
|
2013-03-12 18:10:16 +01:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.targets.TextTableImage;
|
2013-12-17 19:19:51 +01:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.toolbar.RichTextToolbar;
|
2013-03-15 19:06:43 +01:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.uibinder.ExportOptions;
|
2013-02-06 23:25:43 +01:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.shared.SessionInfo;
|
2013-03-05 15:26:22 +01:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.shared.UserBean;
|
2013-11-13 18:56:13 +01:00
|
|
|
|
import org.gcube.portlets.user.reportgenerator.shared.VMETypeIdentifier;
|
2013-11-07 19:00:34 +01:00
|
|
|
|
import org.gcube.portlets.widgets.exporter.client.ReportExporterPopup;
|
|
|
|
|
import org.gcube.portlets.widgets.exporter.client.event.ExportingCompletedEvent;
|
|
|
|
|
import org.gcube.portlets.widgets.exporter.client.event.ExportingCompletedEventHandler;
|
|
|
|
|
import org.gcube.portlets.widgets.exporter.client.event.ReportExporterEvent;
|
|
|
|
|
import org.gcube.portlets.widgets.exporter.client.event.ReportExporterEventHandler;
|
|
|
|
|
import org.gcube.portlets.widgets.exporter.shared.TypeExporter;
|
2013-02-06 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
import com.extjs.gxt.ui.client.widget.MessageBox;
|
|
|
|
|
import com.google.gwt.core.client.GWT;
|
2013-03-15 11:37:45 +01:00
|
|
|
|
import com.google.gwt.core.client.RunAsyncCallback;
|
2013-02-06 23:25:43 +01:00
|
|
|
|
import com.google.gwt.event.shared.HandlerManager;
|
|
|
|
|
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;
|
2013-03-15 19:06:43 +01:00
|
|
|
|
import com.google.gwt.user.client.ui.HorizontalPanel;
|
2013-02-06 23:25:43 +01:00
|
|
|
|
import com.google.gwt.user.client.ui.RichTextArea;
|
|
|
|
|
import com.google.gwt.user.client.ui.SimplePanel;
|
|
|
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public class Presenter {
|
2013-03-15 19:06:43 +01:00
|
|
|
|
private ReportServiceAsync reportService = (ReportServiceAsync) GWT.create(ReportService.class);
|
2013-02-06 23:25:43 +01:00
|
|
|
|
/**
|
|
|
|
|
* View part
|
|
|
|
|
*/
|
|
|
|
|
private WorkspacePanel wp;
|
|
|
|
|
|
|
|
|
|
private Headerbar header;
|
|
|
|
|
|
|
|
|
|
private ToolboxPanel toolBoxPanel;
|
|
|
|
|
|
|
|
|
|
private TitleBar titleBar;
|
2013-05-06 17:38:24 +02:00
|
|
|
|
|
2013-03-15 19:06:43 +01:00
|
|
|
|
private HorizontalPanel exportsPanel;
|
2013-02-06 23:25:43 +01:00
|
|
|
|
|
2013-05-06 18:54:25 +02:00
|
|
|
|
private final WaitingOperationDialog dlg = new WaitingOperationDialog();
|
2013-05-06 17:38:24 +02:00
|
|
|
|
|
2013-03-05 15:26:22 +01:00
|
|
|
|
private UserBean currentUser;
|
2013-02-06 23:25:43 +01:00
|
|
|
|
private String currentScope;
|
|
|
|
|
/**
|
|
|
|
|
* Model
|
|
|
|
|
*/
|
|
|
|
|
private TemplateModel model;
|
|
|
|
|
|
2013-05-06 17:38:24 +02:00
|
|
|
|
private String location;
|
|
|
|
|
|
2013-02-06 23:25:43 +01:00
|
|
|
|
private int currFocus;
|
2013-11-14 16:26:26 +01:00
|
|
|
|
/**
|
|
|
|
|
* this is needed to know on which client sequence the user is operating
|
|
|
|
|
*/
|
|
|
|
|
private ClientSequence clientSeqSelected = null;
|
2013-02-06 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
RichTextToolbar currentSelectedToolbar;
|
|
|
|
|
|
|
|
|
|
RichTextArea areaForBiblio;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
private CommonCommands commonCommands;
|
|
|
|
|
|
|
|
|
|
private boolean menuForWorkflowDocument = false;
|
2013-12-17 19:19:51 +01:00
|
|
|
|
|
|
|
|
|
private boolean isVME = false;
|
2013-02-06 23:25:43 +01:00
|
|
|
|
/**
|
|
|
|
|
* eventbus events handler
|
|
|
|
|
*/
|
|
|
|
|
HandlerManager eventBus = new HandlerManager(null);
|
|
|
|
|
|
|
|
|
|
public HandlerManager getEventBus() {
|
|
|
|
|
return eventBus;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-14 16:26:26 +01:00
|
|
|
|
|
2013-02-06 23:25:43 +01:00
|
|
|
|
private void handleEvents() {
|
2013-11-14 16:26:26 +01:00
|
|
|
|
|
2013-11-25 17:12:01 +01:00
|
|
|
|
eventBus.addHandler(SelectedReportEvent.TYPE, new SelectedReportEventHandler() {
|
2013-11-13 18:56:13 +01:00
|
|
|
|
@Override
|
2013-11-25 17:12:01 +01:00
|
|
|
|
public void onReportSelected(SelectedReportEvent event) {
|
2013-11-26 18:37:13 +01:00
|
|
|
|
if (event.isAssociation()) {
|
2013-11-14 16:26:26 +01:00
|
|
|
|
try {
|
2013-11-25 17:12:01 +01:00
|
|
|
|
associateVMRReportRef(event.getType(), event.getId());
|
2013-11-14 16:26:26 +01:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
2013-11-25 17:12:01 +01:00
|
|
|
|
}
|
2013-11-26 18:37:13 +01:00
|
|
|
|
else {
|
2013-12-04 23:21:12 +01:00
|
|
|
|
importVMEReport(event.getId(), event.getName(), event.getType());
|
2013-11-26 18:37:13 +01:00
|
|
|
|
}
|
2013-11-13 18:56:13 +01:00
|
|
|
|
}
|
|
|
|
|
});
|
2013-05-06 17:38:24 +02:00
|
|
|
|
|
2013-03-15 19:06:43 +01:00
|
|
|
|
eventBus.addHandler(ExportingCompletedEvent.TYPE, new ExportingCompletedEventHandler() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onExportFinished(ExportingCompletedEvent event) {
|
2013-05-06 18:54:25 +02:00
|
|
|
|
int top = 0;
|
|
|
|
|
ReportGenerator.get().getScrollerPanel().setVerticalScrollPosition(top);
|
2013-03-15 19:06:43 +01:00
|
|
|
|
showExportSaveOptions(event.getFilePath(), event.getItemName(), event.getType());
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-05-06 17:38:24 +02:00
|
|
|
|
|
2013-02-06 23:25:43 +01:00
|
|
|
|
eventBus.addHandler(AddBiblioEvent.TYPE, new AddBiblioEventHandler() {
|
|
|
|
|
public void onAddCitation(AddBiblioEvent event) {
|
|
|
|
|
addCitation(event.getCitekey(), event.getCitetext());
|
|
|
|
|
String keyToAdd = " (" + event.getCitekey() +") ";
|
|
|
|
|
String currHTML = areaForBiblio.getHTML();
|
|
|
|
|
if (currHTML.endsWith("<br>"))
|
|
|
|
|
currHTML = currHTML.substring(0, currHTML.length()-4);
|
|
|
|
|
areaForBiblio.setHTML(currHTML+keyToAdd);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
eventBus.addHandler(RemovedCitationEvent.TYPE, new RemovedCitationEventHandler() {
|
|
|
|
|
public void onRemovedCitation(RemovedCitationEvent event) {
|
|
|
|
|
removeCitation(event.getCitekey());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2013-03-07 12:00:21 +01:00
|
|
|
|
eventBus.addHandler(ReportExporterEvent.TYPE, new ReportExporterEventHandler() {
|
2013-05-06 17:38:24 +02:00
|
|
|
|
|
2013-03-07 12:00:21 +01:00
|
|
|
|
@Override
|
|
|
|
|
public void onCompletedExport(ReportExporterEvent event) {
|
2013-05-06 17:38:24 +02:00
|
|
|
|
|
2013-03-14 18:05:59 +01:00
|
|
|
|
switch (event.getOperationResult()) {
|
|
|
|
|
case SAVED:
|
2013-11-26 18:37:13 +01:00
|
|
|
|
//refreshWorkspace();
|
2013-03-14 18:05:59 +01:00
|
|
|
|
break;
|
|
|
|
|
case SAVED_OPEN:
|
2013-11-26 18:37:13 +01:00
|
|
|
|
// refreshWorkspace();
|
2013-03-14 18:05:59 +01:00
|
|
|
|
toolBoxPanel.showExportedVersion(event.getItemId(), event.getItemId());
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2013-05-06 17:38:24 +02:00
|
|
|
|
|
2013-03-07 12:00:21 +01:00
|
|
|
|
}
|
|
|
|
|
});
|
2013-02-06 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
eventBus.addHandler(AddCommentEvent.TYPE, new AddCommentEventHandler() {
|
|
|
|
|
public void onAddComment(AddCommentEvent event) {
|
|
|
|
|
model.addCommentToComponent(event.getSourceComponent(), event.getComment(), event.getAreaHeight());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
eventBus.addHandler(RemovedUserCommentEvent.TYPE, new RemovedUserCommentEventHandler() {
|
|
|
|
|
public void onRemovedComment(RemovedUserCommentEvent event) {
|
|
|
|
|
model.removeComment(event.getSourceComponent());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
eventBus.addHandler(ItemSelectionEvent.TYPE, new ItemSelectionEventHandler() {
|
2013-03-06 19:06:42 +01:00
|
|
|
|
@SuppressWarnings("unchecked")
|
2013-02-06 23:25:43 +01:00
|
|
|
|
public void onItemSelected(ItemSelectionEvent event) {
|
|
|
|
|
HashMap<String,Object> map = event.getItemSelected();
|
|
|
|
|
int sectionIndex = 0, compIndex = 0;
|
|
|
|
|
if (map != null) {
|
|
|
|
|
if (map.get("item").equals("Section")) {
|
|
|
|
|
sectionIndex = Integer.parseInt((String) map.get("index"));
|
|
|
|
|
seekSection(sectionIndex+1);
|
|
|
|
|
} else {
|
|
|
|
|
compIndex = Integer.parseInt((String) map.get("index"));
|
|
|
|
|
sectionIndex = Integer.parseInt((String) ((HashMap<String, Object>) map.get("parent")).get("index"));
|
|
|
|
|
seekSection(sectionIndex+1);
|
|
|
|
|
int top = getModel().getSectionComponent(sectionIndex+1).get(compIndex).getContent().getAbsoluteTop();
|
2013-03-06 19:06:42 +01:00
|
|
|
|
ReportGenerator.get().getScrollerPanel().setVerticalScrollPosition(top);
|
2013-02-06 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-05-06 17:38:24 +02:00
|
|
|
|
|
2013-02-06 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* constructor
|
|
|
|
|
*/
|
|
|
|
|
public Presenter() {
|
|
|
|
|
model = new TemplateModel(this);
|
|
|
|
|
|
|
|
|
|
titleBar = ReportGenerator.get().getTitleHeader();
|
2013-05-06 18:54:25 +02:00
|
|
|
|
dlg.center();
|
|
|
|
|
dlg.show();
|
2013-02-06 23:25:43 +01:00
|
|
|
|
handleEvents();
|
|
|
|
|
AsyncCallback<SessionInfo> callback = new AsyncCallback<SessionInfo>() {
|
|
|
|
|
public void onFailure(Throwable caught) {}
|
|
|
|
|
|
|
|
|
|
public void onSuccess(final SessionInfo sessionInfo) {
|
|
|
|
|
currentUser = sessionInfo.getUsername();
|
|
|
|
|
currentScope = sessionInfo.getScope();
|
2013-12-17 19:19:51 +01:00
|
|
|
|
isVME = sessionInfo.isVME();
|
|
|
|
|
addTextToolBar(true);
|
2013-02-06 23:25:43 +01:00
|
|
|
|
if (sessionInfo.isWorkflowDocument()) {
|
2013-03-01 19:42:50 +01:00
|
|
|
|
model.getModelService().getWorkflowDocumentFromDocumentLibrary(new AsyncCallback<Model>() {
|
2013-02-06 23:25:43 +01:00
|
|
|
|
|
2013-05-06 18:54:25 +02:00
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
dlg.hide();
|
|
|
|
|
}
|
2013-02-06 23:25:43 +01:00
|
|
|
|
|
2013-03-01 19:42:50 +01:00
|
|
|
|
public void onSuccess(Model wfReport) {
|
2013-05-06 18:54:25 +02:00
|
|
|
|
dlg.hide();
|
2013-11-26 18:37:13 +01:00
|
|
|
|
loadModel(wfReport, true);
|
2013-02-06 23:25:43 +01:00
|
|
|
|
header.setMenuForWorkflowDocument(sessionInfo.isEditable());
|
2013-05-31 18:14:48 +02:00
|
|
|
|
titleBar.addWorkflowButtons(true);
|
2013-02-06 23:25:43 +01:00
|
|
|
|
pollServiceForLockRenewal();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-12-17 19:19:51 +01:00
|
|
|
|
else { //not in workflow mode check if a report was open
|
2013-03-01 19:42:50 +01:00
|
|
|
|
model.getModelService().readTemplateFromSession(new AsyncCallback<Model>() {
|
2013-05-06 18:54:25 +02:00
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
dlg.hide();
|
|
|
|
|
}
|
2013-05-31 18:14:48 +02:00
|
|
|
|
public void onSuccess(Model result) {
|
2013-12-17 19:19:51 +01:00
|
|
|
|
dlg.hide();
|
|
|
|
|
if (result != null) { //there was one report open in session
|
2013-11-26 18:37:13 +01:00
|
|
|
|
loadModel(result, true);
|
2013-02-06 23:25:43 +01:00
|
|
|
|
header.enableExports();
|
2013-12-17 19:19:51 +01:00
|
|
|
|
} else
|
2013-05-06 18:54:25 +02:00
|
|
|
|
commonCommands.newTemplate.execute();
|
2013-02-06 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
model.getModelService().getSessionInfo(getHost(), callback);
|
|
|
|
|
commonCommands = new CommonCommands(this);
|
|
|
|
|
//importDlg = new FimesFileUploadWindow(eventBus);
|
|
|
|
|
}
|
2013-05-06 17:38:24 +02:00
|
|
|
|
|
2013-11-14 16:26:26 +01:00
|
|
|
|
public void setClientSequenceSelected(ClientSequence toSet) {
|
|
|
|
|
this.clientSeqSelected = toSet;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-30 16:16:20 +02:00
|
|
|
|
public void showOpenOptions() {
|
|
|
|
|
wp.showOpenOptions();
|
2013-02-06 23:25:43 +01:00
|
|
|
|
}
|
2013-05-06 17:38:24 +02:00
|
|
|
|
|
2013-05-02 17:00:36 +02:00
|
|
|
|
public void showLoading() {
|
|
|
|
|
wp.showLoading();
|
|
|
|
|
}
|
2013-05-06 17:38:24 +02:00
|
|
|
|
|
2013-05-02 17:00:36 +02:00
|
|
|
|
/**
|
|
|
|
|
* load the template to edit in the MODEL and in the VIEW
|
|
|
|
|
* @param templateToOpen the name of the template to open without extension nor path
|
|
|
|
|
* @param templateObjectID the id in the folder of the template to open
|
|
|
|
|
* @param isTemplate true if you are opening a template false if you are opening a report
|
|
|
|
|
*/
|
|
|
|
|
public void openTemplate(String templateToOpen, String templateObjectID, final boolean isTemplate) {
|
|
|
|
|
showLoading();
|
|
|
|
|
//will asyncrously return a Serializable Model instance read from disk
|
|
|
|
|
model.getModelService().readModel(templateToOpen, templateObjectID, isTemplate, false, new AsyncCallback<Model>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Model toLoad) {
|
|
|
|
|
if (toLoad != null)
|
2013-11-26 18:37:13 +01:00
|
|
|
|
loadModel(toLoad, true);
|
2013-05-02 17:00:36 +02:00
|
|
|
|
else
|
|
|
|
|
Window.alert("Could not Load template, error on server: ");
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
Window.alert("Could not Load template, please try again later: " + caught.getMessage());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-02-06 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* called when a citation is added
|
|
|
|
|
* @param citekey .
|
|
|
|
|
* @param text .
|
|
|
|
|
*/
|
|
|
|
|
public void addCitation(String citekey, String text) {
|
|
|
|
|
if (! hasBibliography()) {
|
|
|
|
|
MessageBox.alert("Warning", "Bibliography will be added as last section of this report", null);
|
|
|
|
|
model.insertBiblioSection();
|
|
|
|
|
}
|
|
|
|
|
model.addCitation(citekey, text);
|
2013-11-07 19:00:34 +01:00
|
|
|
|
titleBar.getSectionSwitchPanel().setPageDisplayer(model.getCurrentPage(), model.getTotalPages());
|
2013-02-06 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean removeCitation(String citekey) {
|
|
|
|
|
boolean toReturn = model.removeCitation(citekey);
|
|
|
|
|
if (toReturn) { //if has been removed from the model
|
|
|
|
|
if (model.getCurrentPage() == model.getTotalPages()) { //if the view is displaying the bibliography, need to refresh it
|
|
|
|
|
seekSection(model.getTotalPages());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return toReturn;
|
|
|
|
|
}
|
2013-05-06 17:38:24 +02:00
|
|
|
|
|
2013-02-06 23:25:43 +01:00
|
|
|
|
/**
|
|
|
|
|
* look if a section with a specific metadata (that indicate sit is a biblio section)
|
|
|
|
|
* exists in the current report model:
|
|
|
|
|
* check whether the last section has Metadata "isBiblio" = "true" or false
|
|
|
|
|
* @return true if bibliography is present yet false otherwise
|
|
|
|
|
*/
|
|
|
|
|
public boolean hasBibliography() {
|
|
|
|
|
for (Metadata metadata : model.getSection(model.getTotalPages()).getAllMetadata())
|
|
|
|
|
if (metadata.getAttribute().equals(TemplateModel.BIBLIO_SECTION)) return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* look if a comment with a specific metadata (that indicate sit is a comment)
|
|
|
|
|
* exists in the current report model:
|
|
|
|
|
* @return true if comment is present yet false otherwise
|
|
|
|
|
*/
|
|
|
|
|
public boolean hasComments(Widget toCheck) {
|
|
|
|
|
TemplateSection currSection = model.getSection(model.getCurrentPage());
|
|
|
|
|
return currSection.hasComments(toCheck);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* look if a comment with a specific metadata (that indicate sit is a comment)
|
|
|
|
|
* exists in the current report model:
|
|
|
|
|
* @return true if comment is present yet false otherwise
|
|
|
|
|
*/
|
|
|
|
|
public AddCommentEvent getComponentComments(Widget toCheck) {
|
|
|
|
|
TemplateSection currSection = model.getSection(model.getCurrentPage());
|
|
|
|
|
return currSection.getComponentComments(toCheck);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
private void pollServiceForLockRenewal() {
|
|
|
|
|
final int fourteenMinutes = 840000;
|
|
|
|
|
final Timer t = new Timer() {
|
|
|
|
|
public void run() {
|
|
|
|
|
model.getModelService().renewLock(new AsyncCallback<Void>() {
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
}
|
|
|
|
|
public void onSuccess(Void result) {
|
|
|
|
|
schedule(fourteenMinutes);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
t.schedule(fourteenMinutes);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* put the commands in the hashmap
|
|
|
|
|
*/
|
|
|
|
|
private HashMap<String, Command> getCommands() {
|
|
|
|
|
/**
|
|
|
|
|
* commands to pass to the toolbar
|
|
|
|
|
*/
|
|
|
|
|
HashMap<String, Command> toReturn = new HashMap<String, Command>();
|
|
|
|
|
|
|
|
|
|
toReturn.put("save", commonCommands.saveTemplate);
|
2013-04-30 16:16:20 +02:00
|
|
|
|
toReturn.put("newdoc", commonCommands.newTemplate);
|
2013-03-16 18:14:36 +01:00
|
|
|
|
toReturn.put("open_report", commonCommands.openReport);
|
2013-02-06 23:25:43 +01:00
|
|
|
|
toReturn.put("open_template", commonCommands.openTemplate);
|
|
|
|
|
toReturn.put("importing", commonCommands.importTemplateCommand);
|
|
|
|
|
toReturn.put("insertImage", commonCommands.insertImage);
|
|
|
|
|
toReturn.put("pickColor", commonCommands.pickColor);
|
|
|
|
|
|
|
|
|
|
return toReturn;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* to remove the current displayed section
|
|
|
|
|
*/
|
|
|
|
|
public void discardCurrentSection() {
|
|
|
|
|
if (model.getTotalPages() == 1)
|
|
|
|
|
Window.alert("Cannot discard section, need ad least 2");
|
|
|
|
|
else {
|
|
|
|
|
boolean result = Window.confirm("Are you sure you want to discard section number " + model.getCurrentPage() + "?");
|
|
|
|
|
if (result) {
|
|
|
|
|
TemplateSection removed = model.discardSection(model.getCurrentPage());
|
|
|
|
|
if (removed == null)
|
|
|
|
|
GWT.log("REMOVED NOTHING", null);
|
|
|
|
|
else
|
|
|
|
|
GWT.log("REMOVED " + removed.getAllComponents().size(), null);
|
|
|
|
|
loadFirstSection();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param titleBar ,
|
|
|
|
|
*/
|
|
|
|
|
public void setTitleBar(TitleBar titleBar) {
|
|
|
|
|
this.titleBar = titleBar;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @return .
|
|
|
|
|
*/
|
|
|
|
|
public String getHost() {
|
|
|
|
|
return GWT.getHostPageBaseURL() + "../../";
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-26 18:37:13 +01:00
|
|
|
|
|
2013-02-06 23:25:43 +01:00
|
|
|
|
/**
|
|
|
|
|
* remove the user-added components from the workspace, and from the model
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public void cleanAll() {
|
|
|
|
|
// reset the model
|
|
|
|
|
model = new TemplateModel(this);
|
|
|
|
|
|
|
|
|
|
//reset the UI
|
|
|
|
|
|
|
|
|
|
//give the new model instance
|
|
|
|
|
header.setModel(model);
|
|
|
|
|
wp.setModel(model);
|
|
|
|
|
|
|
|
|
|
cleanWorkspace();
|
2013-11-07 19:00:34 +01:00
|
|
|
|
titleBar.getSectionSwitchPanel().hideNextButton();
|
|
|
|
|
titleBar.getSectionSwitchPanel().hidePrevButton();
|
2013-02-06 23:25:43 +01:00
|
|
|
|
titleBar.setTemplateName(model.getTemplateName());
|
2013-11-07 19:00:34 +01:00
|
|
|
|
titleBar.getSectionSwitchPanel().setPageDisplayer(model.getCurrentPage(), model.getTotalPages());
|
|
|
|
|
titleBar.getSectionSwitchPanel().setVisible(false);
|
2013-02-06 23:25:43 +01:00
|
|
|
|
resizeWorkingArea(model.getPageWidth(), model.getPageHeight());
|
2013-11-26 18:37:13 +01:00
|
|
|
|
|
2013-11-25 17:12:01 +01:00
|
|
|
|
toolBoxPanel.clear();
|
|
|
|
|
toolBoxPanel.collapse();
|
2013-02-06 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/**
|
2013-04-30 16:16:20 +02:00
|
|
|
|
* remove the user-added components from the workspace (in the current page) but not from the model
|
|
|
|
|
*
|
2013-02-06 23:25:43 +01:00
|
|
|
|
*/
|
2013-04-30 16:16:20 +02:00
|
|
|
|
public void cleanWorkspace() {
|
|
|
|
|
wp.getMainLayout().clear();
|
|
|
|
|
ReportGenerator.get().getScrollerPanel().setScrollPosition(0);
|
2013-02-06 23:25:43 +01:00
|
|
|
|
}
|
2013-05-06 17:38:24 +02:00
|
|
|
|
|
2013-02-06 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Save the current report
|
|
|
|
|
* @param folderid the id where to save the report
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public void saveReport(String folderid, String name) {
|
2013-05-06 17:38:24 +02:00
|
|
|
|
dlg.center();
|
|
|
|
|
dlg.show();
|
|
|
|
|
Model toSave = model.getSerializableModel();
|
|
|
|
|
reportService.saveReport(toSave, folderid, name, new AsyncCallback<Void>() {
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
dlg.hide();
|
|
|
|
|
MessageBox.alert("Warning","Report Not Saved: " + caught.getMessage(), null);
|
|
|
|
|
}
|
|
|
|
|
public void onSuccess(Void result) {
|
|
|
|
|
dlg.hide();
|
|
|
|
|
MessageBox.info("Saving Operation","Report Saved Successfully", null);
|
|
|
|
|
refreshWorkspace();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2013-02-06 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Save the current report in a given folder
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public void saveReport() {
|
2013-05-06 17:38:24 +02:00
|
|
|
|
dlg.center();
|
|
|
|
|
dlg.show();
|
|
|
|
|
Model toSave = model.getSerializableModel();
|
|
|
|
|
reportService.saveReport(toSave, new AsyncCallback<Void>() {
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
dlg.hide();
|
|
|
|
|
MessageBox.alert("Warning","Report Not Saved: " + caught.getMessage(), null);
|
|
|
|
|
}
|
|
|
|
|
public void onSuccess(Void result) {
|
|
|
|
|
dlg.hide();
|
|
|
|
|
MessageBox.info("Saving Operation","Report Saved Successfully", null);
|
|
|
|
|
refreshWorkspace();
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-02-06 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Save the current report in a given folder
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public void updateWorkflowDocument(boolean update) {
|
2013-05-06 17:38:24 +02:00
|
|
|
|
dlg.center();
|
|
|
|
|
dlg.show();
|
|
|
|
|
Model toSave = model.getSerializableModel();
|
|
|
|
|
reportService.updateWorkflowDocument(toSave, update, new AsyncCallback<Void>() {
|
|
|
|
|
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
dlg.hide();
|
|
|
|
|
Window.alert("failed to update workflow document");
|
|
|
|
|
}
|
|
|
|
|
public void onSuccess(Void result) {
|
|
|
|
|
dlg.hide();
|
|
|
|
|
loadWorkflowLibraryApp();
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-02-06 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*@param templateName .
|
|
|
|
|
*/
|
|
|
|
|
public void changeTemplateName(String templateName) {
|
|
|
|
|
//initialize the template
|
|
|
|
|
titleBar.setTemplateName(templateName);
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-06 17:38:24 +02:00
|
|
|
|
/**
|
|
|
|
|
* Redirect to VRE Deployer Portlet
|
|
|
|
|
*/
|
|
|
|
|
private void loadWorkflowLibraryApp(){
|
|
|
|
|
getUrl();
|
|
|
|
|
location += "/../my-workflow-documents";
|
|
|
|
|
Window.open(location, "_self", "");
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Get URL from browser
|
|
|
|
|
*/
|
|
|
|
|
public native void getUrl()/*-{
|
|
|
|
|
this.@org.gcube.portlets.user.reportgenerator.client.Presenter.Presenter::location = $wnd.location.href;
|
|
|
|
|
}-*/;
|
|
|
|
|
|
2013-02-06 23:25:43 +01:00
|
|
|
|
/**
|
|
|
|
|
* Import a Section in the View and in the Model
|
|
|
|
|
* @param toLoad the SerializableModel instance where toget the section
|
|
|
|
|
* @param sectionNoToimport section to import 0 -> n-1
|
|
|
|
|
* @param beforeSection say where to import this section (before)
|
|
|
|
|
* @param asLastSection say to import this section as last section in the curren template / report
|
|
|
|
|
*/
|
2013-03-01 19:42:50 +01:00
|
|
|
|
public void importSection(Model toLoad, int sectionNoToimport, int beforeSection, boolean asLastSection) {
|
2013-02-06 23:25:43 +01:00
|
|
|
|
model.importSectionInModel(toLoad, sectionNoToimport, beforeSection, asLastSection);
|
|
|
|
|
if (asLastSection)
|
|
|
|
|
seekLastPage();
|
|
|
|
|
else
|
|
|
|
|
seekSection(beforeSection);
|
|
|
|
|
Window.alert("Importing Complete");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* in case someone imported a new section
|
|
|
|
|
*/
|
|
|
|
|
public void seekLastPage() {
|
|
|
|
|
while (! (model.getCurrentPage() == model.getTotalPages()) )
|
|
|
|
|
nextPageButtonClicked();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* in case someone imported a new section
|
|
|
|
|
* @param sect2Seek .
|
|
|
|
|
*/
|
|
|
|
|
public void seekSection(int sect2Seek) {
|
|
|
|
|
loadFirstSection();
|
|
|
|
|
while (! ( model.getCurrentPage() == sect2Seek) )
|
|
|
|
|
nextPageButtonClicked();
|
|
|
|
|
}
|
2013-11-26 18:37:13 +01:00
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public void addTextToolBar(boolean enableCommands) {
|
2013-12-17 19:19:51 +01:00
|
|
|
|
RichTextToolbar rtbar = new RichTextToolbar(new RichTextArea(), getCommands(), isVME);
|
2013-11-26 18:37:13 +01:00
|
|
|
|
rtbar.enableCommands(enableCommands);
|
2013-02-06 23:25:43 +01:00
|
|
|
|
|
2013-11-26 18:37:13 +01:00
|
|
|
|
currentSelectedToolbar = rtbar;
|
|
|
|
|
SimplePanel deco = new SimplePanel();
|
|
|
|
|
rtbar.setEnabled(false);
|
|
|
|
|
deco.add(rtbar);
|
|
|
|
|
deco.setSize("100%", "25");
|
|
|
|
|
rtbar.setWidth("100%");
|
|
|
|
|
ReportGenerator.get().getToolbarPanel().clear();
|
|
|
|
|
ReportGenerator.get().getToolbarPanel().add(deco);
|
|
|
|
|
}
|
2013-02-06 23:25:43 +01:00
|
|
|
|
/**
|
|
|
|
|
* enable the format text toolbar for the given Rich Textarea passed as argument
|
|
|
|
|
* @param d4sArea the enabled text area
|
|
|
|
|
*/
|
|
|
|
|
public void enableTextToolBar(RichTextArea d4sArea) {
|
|
|
|
|
|
2013-12-17 19:19:51 +01:00
|
|
|
|
RichTextToolbar rtbar = new RichTextToolbar(d4sArea, getCommands(), isVME);
|
2013-02-06 23:25:43 +01:00
|
|
|
|
if (menuForWorkflowDocument) //disable open and save buttons from the toolbar
|
|
|
|
|
rtbar.enableCommands(false);
|
|
|
|
|
currentSelectedToolbar = rtbar;
|
|
|
|
|
rtbar.setEnabled(true);
|
|
|
|
|
ReportGenerator.get().getToolbarPanel().clear();
|
|
|
|
|
SimplePanel deco = new SimplePanel();
|
|
|
|
|
deco.add(rtbar);
|
|
|
|
|
deco.setSize("100%", "25");
|
|
|
|
|
rtbar.setWidth("100%");
|
|
|
|
|
ReportGenerator.get().getToolbarPanel().add(deco);
|
|
|
|
|
}
|
2013-11-26 18:37:13 +01:00
|
|
|
|
|
2013-02-06 23:25:43 +01:00
|
|
|
|
/**
|
|
|
|
|
* enable the format text toolbar for the given Rich Textarea passed as argument
|
|
|
|
|
* @param d4sArea the enabled text area
|
|
|
|
|
*/
|
|
|
|
|
public void enableBiblioEntry(RichTextArea d4sArea) {
|
|
|
|
|
ReportGenerator.get().getHeader().enableBiblioEntry(d4sArea);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* generate the docx to be passed to the fimesExporter
|
|
|
|
|
* @param model
|
|
|
|
|
*/
|
|
|
|
|
public void generateFiMES(final TemplateModel model) {
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param model .
|
|
|
|
|
* @param type .
|
|
|
|
|
*/
|
|
|
|
|
public void generateManifestation(final TemplateModel model, final ExportManifestationType type) {
|
2013-03-15 11:37:45 +01:00
|
|
|
|
GWT.runAsync(ReportExporterPopup.class, new RunAsyncCallback() {
|
2013-05-06 17:38:24 +02:00
|
|
|
|
|
2013-11-25 17:12:01 +01:00
|
|
|
|
@SuppressWarnings("incomplete-switch")
|
2013-03-15 11:37:45 +01:00
|
|
|
|
@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;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-05-06 17:38:24 +02:00
|
|
|
|
|
2013-03-15 11:37:45 +01:00
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable reason) {
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-05-06 17:38:24 +02:00
|
|
|
|
|
2013-02-06 23:25:43 +01:00
|
|
|
|
}
|
2013-05-06 17:38:24 +02:00
|
|
|
|
|
|
|
|
|
|
2013-02-06 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
public void openAddCitationDialog() {
|
|
|
|
|
AddBiblioEntryDialog dlg = new AddBiblioEntryDialog(eventBus);
|
|
|
|
|
dlg.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void openManageCitationsDialog() {
|
|
|
|
|
DeleteCitationsDialog dlg = new DeleteCitationsDialog(eventBus, model.getSection(model.getTotalPages()));
|
|
|
|
|
dlg.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @return .
|
|
|
|
|
*/
|
|
|
|
|
public Headerbar getHeader() {
|
|
|
|
|
return header;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @return .
|
|
|
|
|
*/
|
|
|
|
|
public TemplateModel getModel() {
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @return .
|
|
|
|
|
*/
|
|
|
|
|
public ToolboxPanel getToolBoxPanel() {
|
|
|
|
|
return toolBoxPanel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @return .
|
|
|
|
|
*/
|
|
|
|
|
public WorkspacePanel getWp() {
|
|
|
|
|
return wp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* called when nextPage Button is Clicked
|
|
|
|
|
*/
|
|
|
|
|
public void nextPageButtonClicked() {
|
|
|
|
|
cleanWorkspace();
|
|
|
|
|
//refresh the current page in the model
|
|
|
|
|
model.setCurrentPage(model.getCurrentPage() + 1);
|
|
|
|
|
|
|
|
|
|
//refresh the current page in the UI
|
2013-11-07 19:00:34 +01:00
|
|
|
|
titleBar.getSectionSwitchPanel().setPageDisplayer(model.getCurrentPage(), model.getTotalPages());
|
2013-02-06 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
//read the previous user added elements to the template page from the model and place them back in the UI
|
|
|
|
|
placeTemplatePageElements(model.getCurrentPage());
|
|
|
|
|
|
|
|
|
|
if (model.getCurrentPage() == model.getTotalPages())
|
2013-11-07 19:00:34 +01:00
|
|
|
|
titleBar.getSectionSwitchPanel().hideNextButton();
|
2013-02-06 23:25:43 +01:00
|
|
|
|
else
|
2013-11-07 19:00:34 +01:00
|
|
|
|
titleBar.getSectionSwitchPanel().showNextButton();
|
2013-02-06 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
if (model.getCurrentPage() == 1)
|
2013-11-07 19:00:34 +01:00
|
|
|
|
titleBar.getSectionSwitchPanel().hidePrevButton();
|
2013-02-06 23:25:43 +01:00
|
|
|
|
else
|
2013-11-07 19:00:34 +01:00
|
|
|
|
titleBar.getSectionSwitchPanel().showPrevButton();
|
2013-02-06 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param toLoad
|
|
|
|
|
*/
|
2013-11-26 18:37:13 +01:00
|
|
|
|
private void loadModel(Model toLoad, boolean savingEnabled) {
|
2013-02-06 23:25:43 +01:00
|
|
|
|
//reset the UI
|
|
|
|
|
cleanAllNotSession();
|
|
|
|
|
|
|
|
|
|
//load the serializable model in my Model
|
|
|
|
|
model.loadModel(toLoad, this);
|
|
|
|
|
|
|
|
|
|
wp.setModel(model);
|
|
|
|
|
|
|
|
|
|
titleBar.setTemplateName(model.getTemplateName());
|
2013-11-07 19:00:34 +01:00
|
|
|
|
titleBar.getSectionSwitchPanel().setPageDisplayer(model.getCurrentPage(), model.getTotalPages());
|
|
|
|
|
titleBar.getSectionSwitchPanel().setVisible(true);
|
2013-02-06 23:25:43 +01:00
|
|
|
|
resizeWorkingArea(model.getPageWidth(), model.getPageHeight());
|
|
|
|
|
|
2013-11-26 18:37:13 +01:00
|
|
|
|
addTextToolBar(savingEnabled);
|
2013-02-06 23:25:43 +01:00
|
|
|
|
int currPage = model.getCurrentPage();
|
|
|
|
|
//load the UI components of the current page
|
|
|
|
|
GWT.log("READ CURR PAGE"+currPage, null);
|
|
|
|
|
placeTemplatePageElements(currPage);
|
|
|
|
|
|
|
|
|
|
//if there is more than one page place in the UI the next page button
|
|
|
|
|
if (currPage < model.getTotalPages()) {
|
2013-11-07 19:00:34 +01:00
|
|
|
|
titleBar.getSectionSwitchPanel().showNextButton();
|
2013-02-06 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
if (currPage > 1)
|
2013-11-07 19:00:34 +01:00
|
|
|
|
titleBar.getSectionSwitchPanel().showPrevButton();
|
2013-11-26 18:37:13 +01:00
|
|
|
|
|
2013-11-22 18:28:12 +01:00
|
|
|
|
//show the structure
|
|
|
|
|
showReportStructure();
|
2013-04-30 16:16:20 +02:00
|
|
|
|
}
|
2013-05-06 17:38:24 +02:00
|
|
|
|
|
2013-04-30 16:16:20 +02:00
|
|
|
|
/**
|
|
|
|
|
* just clean the page
|
|
|
|
|
*/
|
|
|
|
|
public void cleanAllNotSession() {
|
|
|
|
|
// reset the model
|
|
|
|
|
model = new TemplateModel(this);
|
|
|
|
|
|
|
|
|
|
//reset the UI
|
2013-02-06 23:25:43 +01:00
|
|
|
|
|
2013-04-30 16:16:20 +02:00
|
|
|
|
//give the new model instance
|
|
|
|
|
header.setModel(model);
|
|
|
|
|
wp.setModel(model);
|
|
|
|
|
|
|
|
|
|
cleanWorkspace();
|
2013-11-07 19:00:34 +01:00
|
|
|
|
titleBar.getSectionSwitchPanel().hideNextButton();
|
|
|
|
|
titleBar.getSectionSwitchPanel().hidePrevButton();
|
2013-04-30 16:16:20 +02:00
|
|
|
|
titleBar.setTemplateName(model.getTemplateName());
|
2013-11-07 19:00:34 +01:00
|
|
|
|
titleBar.getSectionSwitchPanel().setPageDisplayer(model.getCurrentPage(), model.getTotalPages());
|
|
|
|
|
titleBar.getSectionSwitchPanel().setVisible(false);
|
2013-04-30 16:16:20 +02:00
|
|
|
|
resizeWorkingArea(model.getPageWidth(), model.getPageHeight());
|
2013-02-06 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void loadFirstSection() {
|
|
|
|
|
//reset the UI
|
|
|
|
|
cleanWorkspace();
|
2013-11-07 19:00:34 +01:00
|
|
|
|
titleBar.getSectionSwitchPanel().hideNextButton();
|
|
|
|
|
titleBar.getSectionSwitchPanel().hidePrevButton();
|
2013-02-06 23:25:43 +01:00
|
|
|
|
model.setCurrentPage(1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
titleBar.setTemplateName(model.getTemplateName());
|
2013-11-07 19:00:34 +01:00
|
|
|
|
titleBar.getSectionSwitchPanel().setPageDisplayer(model.getCurrentPage(), model.getTotalPages());
|
|
|
|
|
titleBar.getSectionSwitchPanel().setVisible(true);
|
2013-11-26 18:37:13 +01:00
|
|
|
|
addTextToolBar(true);
|
2013-02-06 23:25:43 +01:00
|
|
|
|
int currPage = model.getCurrentPage();
|
|
|
|
|
//load the UI components of the current page
|
|
|
|
|
GWT.log("READ CURR PAGE"+currPage, null);
|
|
|
|
|
placeTemplatePageElements(currPage);
|
|
|
|
|
|
|
|
|
|
//if there is more than one page place in the UI the next page button
|
|
|
|
|
if (currPage < model.getTotalPages()) {
|
2013-11-07 19:00:34 +01:00
|
|
|
|
titleBar.getSectionSwitchPanel().showNextButton();
|
2013-02-06 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
if (currPage > 1)
|
2013-11-07 19:00:34 +01:00
|
|
|
|
titleBar.getSectionSwitchPanel().showPrevButton();
|
2013-02-06 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* It places back the user added widgets (TemplateComponents) in the page
|
|
|
|
|
*
|
|
|
|
|
* @param section . the section number of the wanted TemplateComponent(s)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public void placeTemplatePageElements(int section) {
|
|
|
|
|
if (! (model.getSectionComponent(section) == null)) {
|
|
|
|
|
List<TemplateComponent> pageElems = model.getSectionComponent(section);
|
|
|
|
|
|
|
|
|
|
for (TemplateComponent component : pageElems) {
|
|
|
|
|
int uiX = component.getX();
|
|
|
|
|
int uiY= component.getY();
|
|
|
|
|
switch (component.getType()) {
|
|
|
|
|
case HEADING_1:
|
|
|
|
|
case HEADING_2:
|
2013-02-13 18:26:22 +01:00
|
|
|
|
case HEADING_3:
|
|
|
|
|
case HEADING_4:
|
2013-03-04 19:15:59 +01:00
|
|
|
|
case HEADING_5:
|
2013-02-06 23:25:43 +01:00
|
|
|
|
case TITLE:
|
2013-03-13 11:06:47 +01:00
|
|
|
|
if (component.isLocked()) {
|
|
|
|
|
HTML text = (HTML) component.getContent();
|
|
|
|
|
wp.addComponentToLayout(text, component.isDoubleColLayout());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
HeadingTextArea textArea = (HeadingTextArea) component.getContent();
|
|
|
|
|
textArea.getMyInstance().setTop(uiY);
|
|
|
|
|
textArea.getMyInstance().setLeft(uiX);
|
|
|
|
|
wp.addComponentToLayout(textArea, component.isDoubleColLayout());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case BODY_NOT_FORMATTED:
|
2013-02-06 23:25:43 +01:00
|
|
|
|
if (component.isLocked()) {
|
|
|
|
|
HTML text = (HTML) component.getContent();
|
2013-10-30 18:50:22 +01:00
|
|
|
|
text.addStyleName("readOnlyText");
|
2013-02-06 23:25:43 +01:00
|
|
|
|
wp.addComponentToLayout(text, component.isDoubleColLayout());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BasicTextArea textArea = (BasicTextArea) component.getContent();
|
|
|
|
|
wp.addComponentToLayout(textArea, component.isDoubleColLayout());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case BODY:
|
|
|
|
|
if (component.isLocked()) {
|
|
|
|
|
HTML text = (HTML) component.getContent();
|
|
|
|
|
wp.addComponentToLayout(text, component.isDoubleColLayout());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
D4sRichTextarea textArea = (D4sRichTextarea) component.getContent();
|
|
|
|
|
textArea.getMyInstance().setTop(uiY);
|
|
|
|
|
textArea.getMyInstance().setLeft(uiX);
|
|
|
|
|
wp.addComponentToLayout(textArea, component.isDoubleColLayout());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case DYNA_IMAGE:
|
2013-03-07 16:03:01 +01:00
|
|
|
|
ClientImage imageDropping = (ClientImage) component.getContent();
|
2013-02-06 23:25:43 +01:00
|
|
|
|
wp.addComponentToLayout(imageDropping, component.isDoubleColLayout());
|
|
|
|
|
break;
|
|
|
|
|
case FAKE_TEXTAREA:
|
|
|
|
|
break;
|
|
|
|
|
case TOC:
|
|
|
|
|
ReportTextArea dp = (ReportTextArea) component.getContent();
|
|
|
|
|
wp.addComponentToLayout(dp, component.isDoubleColLayout());
|
|
|
|
|
setCurrCursorPos(uiY);
|
|
|
|
|
break;
|
|
|
|
|
case BIBLIO:
|
|
|
|
|
ReportTextArea dp2 = (ReportTextArea) component.getContent();
|
|
|
|
|
wp.addComponentToLayout(dp2, component.isDoubleColLayout());
|
|
|
|
|
setCurrCursorPos(uiY);
|
|
|
|
|
break;
|
|
|
|
|
case PAGEBREAK:
|
|
|
|
|
ReportTextArea dp3 = (ReportTextArea) component.getContent();
|
|
|
|
|
wp.addComponentToLayout(dp3, component.isDoubleColLayout());
|
|
|
|
|
setCurrCursorPos(uiY);
|
|
|
|
|
break;
|
|
|
|
|
case TIME_SERIES:
|
|
|
|
|
TSArea dp5 = (TSArea) component.getContent();
|
|
|
|
|
wp.addComponentToLayout(dp5, component.isDoubleColLayout());
|
|
|
|
|
setCurrCursorPos(uiY);
|
|
|
|
|
break;
|
|
|
|
|
case FLEX_TABLE:
|
|
|
|
|
GenericTable gt = (GenericTable) component.getContent();
|
|
|
|
|
GWT.log("Reading TABLE rows: " + gt.getRowsNo() + " cols: " + gt.getCols());
|
|
|
|
|
wp.addComponentToLayout(gt, component.isDoubleColLayout());
|
|
|
|
|
break;
|
2013-02-26 19:44:48 +01:00
|
|
|
|
case ATTRIBUTE_MULTI:
|
2013-03-05 15:26:22 +01:00
|
|
|
|
AttributeMultiSelection at = (AttributeMultiSelection) component.getContent();
|
2013-02-06 23:25:43 +01:00
|
|
|
|
wp.addComponentToLayout(at, component.isDoubleColLayout());
|
|
|
|
|
setCurrCursorPos(uiY);
|
|
|
|
|
break;
|
2013-03-05 15:26:22 +01:00
|
|
|
|
case ATTRIBUTE_UNIQUE:
|
|
|
|
|
AttributeSingleSelection atu = (AttributeSingleSelection) component.getContent();
|
|
|
|
|
wp.addComponentToLayout(atu, component.isDoubleColLayout());
|
|
|
|
|
setCurrCursorPos(uiY);
|
|
|
|
|
break;
|
2013-02-06 23:25:43 +01:00
|
|
|
|
case COMMENT:
|
|
|
|
|
HTML text = (HTML) component.getContent();
|
|
|
|
|
wp.addComponentToLayout(text, component.isDoubleColLayout());
|
|
|
|
|
break;
|
|
|
|
|
case INSTRUCTION:
|
|
|
|
|
HTML instr = (HTML) component.getContent();
|
|
|
|
|
wp.addComponentToLayout(instr, component.isDoubleColLayout());
|
|
|
|
|
break;
|
2013-02-13 18:26:22 +01:00
|
|
|
|
case REPEAT_SEQUENCE_DELIMITER:
|
|
|
|
|
GroupingDelimiterArea gpa = (GroupingDelimiterArea) component.getContent();
|
|
|
|
|
wp.addComponentToLayout(gpa, component.isDoubleColLayout());
|
|
|
|
|
break;
|
|
|
|
|
case REPEAT_SEQUENCE:
|
2013-03-01 19:42:50 +01:00
|
|
|
|
ClientRepeatableSequence rps = (ClientRepeatableSequence) component.getContent();
|
2013-02-13 18:26:22 +01:00
|
|
|
|
wp.addComponentToLayout(rps, component.isDoubleColLayout());
|
|
|
|
|
break;
|
2013-11-14 17:57:40 +01:00
|
|
|
|
case REPORT_REFERENCE:
|
|
|
|
|
ClientReportReference cmSeq = (ClientReportReference) component.getContent();
|
2013-10-30 18:50:22 +01:00
|
|
|
|
wp.addComponentToLayout(cmSeq, component.isDoubleColLayout());
|
|
|
|
|
break;
|
2013-03-12 18:10:16 +01:00
|
|
|
|
case BODY_TABLE_IMAGE:
|
|
|
|
|
TextTableImage tti = (TextTableImage) component.getContent();
|
|
|
|
|
wp.addComponentToLayout(tti, component.isDoubleColLayout());
|
|
|
|
|
break;
|
2013-02-06 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param y .
|
|
|
|
|
*/
|
|
|
|
|
public void setCurrCursorPos(int y) {
|
|
|
|
|
this.currFocus = y;
|
|
|
|
|
}
|
|
|
|
|
public Coords getInsertionPoint() {
|
|
|
|
|
int y = getSelectedIndex();
|
|
|
|
|
return new Coords(25, y);
|
|
|
|
|
}
|
|
|
|
|
public int getSelectedIndex() {
|
|
|
|
|
return currFocus;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* called when prevPage Button is Clicked
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public void prevPageButtonClicked() {
|
|
|
|
|
cleanWorkspace();
|
|
|
|
|
//refresh the current page in the model
|
|
|
|
|
model.setCurrentPage(model.getCurrentPage() - 1);
|
|
|
|
|
|
|
|
|
|
//refresh the current page in the UI
|
2013-11-07 19:00:34 +01:00
|
|
|
|
titleBar.getSectionSwitchPanel().setPageDisplayer(model.getCurrentPage(), model.getTotalPages());
|
2013-02-06 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
//read the previous user added elements to the template page from the model and place them back in the UI
|
|
|
|
|
placeTemplatePageElements(model.getCurrentPage());
|
|
|
|
|
|
|
|
|
|
if (model.getCurrentPage() == model.getTotalPages())
|
2013-11-07 19:00:34 +01:00
|
|
|
|
titleBar.getSectionSwitchPanel().hideNextButton();
|
2013-02-06 23:25:43 +01:00
|
|
|
|
else
|
2013-11-07 19:00:34 +01:00
|
|
|
|
titleBar.getSectionSwitchPanel().showNextButton();
|
2013-02-06 23:25:43 +01:00
|
|
|
|
|
|
|
|
|
if (model.getCurrentPage() == 1)
|
2013-11-07 19:00:34 +01:00
|
|
|
|
titleBar.getSectionSwitchPanel().hidePrevButton();
|
2013-02-06 23:25:43 +01:00
|
|
|
|
else
|
2013-11-07 19:00:34 +01:00
|
|
|
|
titleBar.getSectionSwitchPanel().showPrevButton();
|
2013-02-06 23:25:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Resize the template componet just the model
|
|
|
|
|
*
|
|
|
|
|
* @param toResize .
|
|
|
|
|
* @param newWidth .
|
|
|
|
|
* @param newHeight .
|
|
|
|
|
*/
|
|
|
|
|
public void resizeTemplateComponentInModel(Widget toResize, int newWidth, int newHeight) {
|
|
|
|
|
model.resizeModelComponent(toResize, newWidth, newHeight);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param width .
|
|
|
|
|
* @param height .
|
|
|
|
|
*/
|
|
|
|
|
public void resizeWorkingArea(int width, int height) {
|
|
|
|
|
//save the new state ---> TO MODEL
|
|
|
|
|
model.setPageWidth(width);
|
|
|
|
|
model.setPageHeight(height);
|
|
|
|
|
|
|
|
|
|
//apply the change ---> TO VIEW
|
|
|
|
|
wp.resizeWorkspace(width, height);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param header .
|
|
|
|
|
*/
|
|
|
|
|
public void setHeader(Headerbar header) {
|
|
|
|
|
this.header = header;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param toolBoxPanel It's the tool box panel
|
|
|
|
|
*/
|
|
|
|
|
public void setToolBoxPanel(ToolboxPanel toolBoxPanel) {
|
|
|
|
|
this.toolBoxPanel = toolBoxPanel;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param wp .
|
|
|
|
|
*/
|
|
|
|
|
public void setWp(WorkspacePanel wp) {
|
|
|
|
|
this.wp = wp;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @return the scope in which the application is running on
|
|
|
|
|
*/
|
|
|
|
|
public String getCurrentScope() {
|
|
|
|
|
return currentScope;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @return the user username who is using the application
|
|
|
|
|
*/
|
2013-03-05 15:26:22 +01:00
|
|
|
|
public UserBean getCurrentUser() {
|
2013-02-06 23:25:43 +01:00
|
|
|
|
return currentUser;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @return .
|
|
|
|
|
*/
|
|
|
|
|
public TitleBar getTitleBar() {
|
|
|
|
|
return titleBar;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* refresh the root in the workspace
|
|
|
|
|
*/
|
|
|
|
|
public void refreshWorkspace() {
|
|
|
|
|
toolBoxPanel.refreshRoot();
|
|
|
|
|
}
|
2013-03-07 18:59:50 +01:00
|
|
|
|
/**
|
|
|
|
|
* show the upload file popup
|
|
|
|
|
*/
|
|
|
|
|
public void showUploadFilePopup() {
|
|
|
|
|
toolBoxPanel.showUploadFile();
|
|
|
|
|
}
|
2013-02-06 23:25:43 +01:00
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @return the current selected rich text area
|
|
|
|
|
*/
|
|
|
|
|
public RichTextToolbar getCurrentSelected() {
|
|
|
|
|
return currentSelectedToolbar;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setMenuForWorkflowDocument(boolean enable) {
|
|
|
|
|
menuForWorkflowDocument = enable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean getMenuForWorkflowDocument() {
|
|
|
|
|
return menuForWorkflowDocument;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setAreaForBiblio(RichTextArea d4sArea) {
|
|
|
|
|
areaForBiblio = d4sArea;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void showReportStructure() {
|
2013-11-22 18:28:12 +01:00
|
|
|
|
toolBoxPanel.showStructure(new ReportStructurePanel(eventBus, model.getSerializableModel(), ToolboxPanel.TOOLBOX_WIDTH+"px", ToolboxPanel.TOOLBOX_HEIGHT+"px"));
|
2013-11-26 18:37:13 +01:00
|
|
|
|
}
|
2013-02-06 23:25:43 +01:00
|
|
|
|
|
2013-03-15 19:06:43 +01:00
|
|
|
|
public HorizontalPanel getExportsPanel() {
|
|
|
|
|
return exportsPanel;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-06 23:25:43 +01:00
|
|
|
|
|
2013-03-15 19:06:43 +01:00
|
|
|
|
public void setExportsPanel(HorizontalPanel exportsPanel) {
|
|
|
|
|
this.exportsPanel = exportsPanel;
|
|
|
|
|
}
|
2013-05-06 17:38:24 +02:00
|
|
|
|
|
2013-03-15 19:06:43 +01:00
|
|
|
|
/**
|
|
|
|
|
* 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) {
|
2013-03-19 19:02:28 +01:00
|
|
|
|
clearExportPanel();
|
2013-03-16 02:53:00 +01:00
|
|
|
|
/*
|
|
|
|
|
* I need to save a temp file, in case the user uses the Save & Open.
|
|
|
|
|
* Smart popup blockers will allow a popup if it is directly associated to a user’s action.
|
|
|
|
|
* If it’s delayed in anyway, there’s a good chance it’s going to get blocked. The exported File needs to be there when clicking open.
|
|
|
|
|
*/
|
|
|
|
|
reportService.save(filePath, null, "system.tmp", type, true, new AsyncCallback<String>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(String createdItemId) {
|
|
|
|
|
//here i pass the temp createdItemId
|
|
|
|
|
showExportPanel(filePath, itemName, type, createdItemId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
2013-03-16 18:14:36 +01:00
|
|
|
|
Window.alert("Error while trying exporting this report: " + caught.getMessage());
|
2013-03-16 02:53:00 +01:00
|
|
|
|
}
|
|
|
|
|
});
|
2013-05-06 17:38:24 +02:00
|
|
|
|
|
2013-03-16 02:53:00 +01:00
|
|
|
|
}
|
2013-05-06 17:38:24 +02:00
|
|
|
|
|
2013-03-16 02:53:00 +01:00
|
|
|
|
public void showExportPanel(final String filePath, final String itemName, final TypeExporter type, String tempFileId) {
|
2013-03-16 18:14:36 +01:00
|
|
|
|
final ExportOptions exo = new ExportOptions(this, toolBoxPanel, filePath, itemName, type, reportService, tempFileId);
|
2013-03-15 19:06:43 +01:00
|
|
|
|
exportsPanel.add(exo);
|
2013-03-16 18:14:36 +01:00
|
|
|
|
//needed for applying the css3 transition effect
|
|
|
|
|
final Timer t = new Timer() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
exo.getMainPanel().addStyleName("exportPanel-show");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
t.schedule(10);
|
2013-03-15 19:06:43 +01:00
|
|
|
|
}
|
2013-05-06 17:38:24 +02:00
|
|
|
|
|
2013-03-15 19:06:43 +01:00
|
|
|
|
public void clearExportPanel() {
|
|
|
|
|
exportsPanel.clear();
|
|
|
|
|
}
|
2013-11-13 18:56:13 +01:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public void showVMEImportDialog() {
|
2013-11-26 18:37:13 +01:00
|
|
|
|
ImportVMEReportDialog dlg = new ImportVMEReportDialog(getEventBus(), VMETypeIdentifier.Vme, false);
|
2013-11-25 17:12:01 +01:00
|
|
|
|
dlg.show();
|
2013-11-13 18:56:13 +01:00
|
|
|
|
}
|
2013-11-14 16:26:26 +01:00
|
|
|
|
|
2013-11-26 18:37:13 +01:00
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public void showVMEReportRefImportDialog(VMETypeIdentifier refType) {
|
|
|
|
|
ImportVMEReportDialog dlg = new ImportVMEReportDialog(getEventBus(), refType, false);
|
|
|
|
|
dlg.show();
|
|
|
|
|
}
|
2013-11-13 18:56:13 +01:00
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
public void showVMERefAssociateDialog(VMETypeIdentifier refType) {
|
2013-11-26 18:37:13 +01:00
|
|
|
|
ImportVMEReportDialog dlg = new ImportVMEReportDialog(getEventBus(), refType, true);
|
2013-11-25 19:11:03 +01:00
|
|
|
|
dlg.show();
|
2013-11-13 18:56:13 +01:00
|
|
|
|
}
|
2013-11-14 16:26:26 +01:00
|
|
|
|
|
2013-12-04 23:21:12 +01:00
|
|
|
|
private void importVMEReport(String reportId, String name, final VMETypeIdentifier type) {
|
2013-11-13 18:56:13 +01:00
|
|
|
|
showLoading();
|
2013-12-04 23:21:12 +01:00
|
|
|
|
reportService.importVMEReport(reportId, name, type, new AsyncCallback<Model>() {
|
2013-11-13 18:56:13 +01:00
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
2013-11-14 16:26:26 +01:00
|
|
|
|
Window.alert("Could not Load Report Model, error on server.: " + caught.getMessage());
|
2013-11-13 18:56:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Model toLoad) {
|
2013-12-06 18:23:49 +01:00
|
|
|
|
if (toLoad != null) {
|
2013-11-26 18:37:13 +01:00
|
|
|
|
loadModel(toLoad, type == VMETypeIdentifier.Vme);
|
2013-12-06 18:23:49 +01:00
|
|
|
|
}
|
2013-11-13 18:56:13 +01:00
|
|
|
|
else
|
2013-11-14 16:26:26 +01:00
|
|
|
|
Window.alert("Could not Load Report Model, error on server.");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-25 19:11:03 +01:00
|
|
|
|
private void associateVMRReportRef(VMETypeIdentifier type, String reportId) throws Exception {
|
|
|
|
|
GWT.log("Type="+type);
|
|
|
|
|
GWT.log("Id"+reportId);
|
2013-11-26 18:37:13 +01:00
|
|
|
|
reportService.getVMEReportRef2Associate(reportId, type, new AsyncCallback<Model>() {
|
2013-11-14 16:26:26 +01:00
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
Window.alert("Could not Load Report Model, error on server.: " + caught.getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Model reportRef) {
|
|
|
|
|
if (reportRef != null && reportRef.getSections().size() > 0) {
|
2013-11-18 18:25:49 +01:00
|
|
|
|
//the Repeatable Seq must be in the 1st Section, second component. (because ReportsModeler put it there)
|
2013-11-14 16:26:26 +01:00
|
|
|
|
BasicSection firstSection = reportRef.getSections().get(0);
|
|
|
|
|
if (firstSection.getComponents() != null && firstSection.getComponents().size()==2) {
|
2013-11-18 18:25:49 +01:00
|
|
|
|
ReportReferences toPass = (ReportReferences) firstSection.getComponents().get(1).getPossibleContent();
|
2013-12-17 19:19:51 +01:00
|
|
|
|
GWT.log("Singola?" + toPass.isSingleRelation());
|
|
|
|
|
String refKey = toPass.getTuples().get(0).getKey();
|
|
|
|
|
Tuple ref = toPass.getTuples().get(0);
|
|
|
|
|
clientSeqSelected.add(refKey, ref, toPass.isSingleRelation());
|
2013-11-14 16:26:26 +01:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Window.alert("Sorry, we could not locate the ReportRef correctly in the model instance");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Window.alert("Could not Load Report Model, error on server.");
|
2013-11-13 18:56:13 +01:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-11-14 16:26:26 +01:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* this method translate the VME ReportRef String in an ENUM
|
|
|
|
|
* @param theType
|
|
|
|
|
* @return
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public VMETypeIdentifier getTypeIdFromString(String theType) throws Exception {
|
|
|
|
|
if (theType.equals("GeneralMeasure"))
|
|
|
|
|
return VMETypeIdentifier.GeneralMeasure;
|
|
|
|
|
else if (theType.equals("InformationSource"))
|
|
|
|
|
return VMETypeIdentifier.InformationSource;
|
|
|
|
|
else if (theType.equals("FisheryAreasHistory"))
|
|
|
|
|
return VMETypeIdentifier.FisheryAreasHistory;
|
2013-11-25 17:12:01 +01:00
|
|
|
|
else if (theType.equals("VMEsHistory"))
|
|
|
|
|
return VMETypeIdentifier.VMEsHistory;
|
|
|
|
|
else if (theType.equals("Rfmo"))
|
|
|
|
|
return VMETypeIdentifier.Rfmo;
|
2013-11-14 17:57:40 +01:00
|
|
|
|
throw new Exception("Could not find any valid Report Ref, got " + theType + " should be any of " + VMETypeIdentifier.values().toString());
|
2013-11-13 18:56:13 +01:00
|
|
|
|
}
|
2013-02-06 23:25:43 +01:00
|
|
|
|
}
|