implemented create scenario

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/reports@87162 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2013-12-18 15:30:32 +00:00
parent 86746daad9
commit b18bea1b92
18 changed files with 145 additions and 17 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.6.17-SNAPSHOT/WEB-INF/classes" path="src/main/java"> <classpathentry kind="src" output="target/reports-4.6.19-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"/>
@ -26,10 +26,10 @@
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/> <classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="output" path="target/reports-4.6.17-SNAPSHOT/WEB-INF/classes"/> <classpathentry kind="output" path="target/reports-4.6.19-SNAPSHOT/WEB-INF/classes"/>
</classpath> </classpath>

View File

@ -2,6 +2,6 @@
<<<<<<<=.mine <<<<<<<=.mine
>>>>>>>=.r71295 >>>>>>>=.r71295
eclipse.preferences.version=1 eclipse.preferences.version=1
lastWarOutDir=/Users/massi/Documents/workspace/reports/target/reports-4.6.17-SNAPSHOT lastWarOutDir=/Users/massi/Documents/workspace/reports/target/reports-4.6.19-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.6.17-SNAPSHOT</version> <version>4.6.19-SNAPSHOT</version>
<name>gCube Reports Manager</name> <name>gCube Reports Manager</name>
<description> <description>
gCube Reports Portlet. gCube Reports Portlet.

View File

@ -186,7 +186,7 @@ public class Headerbar extends Composite{
menuBar.addSeparator(); menuBar.addSeparator();
MenuItem vmeMenuCreate = getVMEMenuFake("Create"); MenuItem vmeMenuCreate = getVMEMenuCreate();
menuBar.addItem(vmeMenuCreate); menuBar.addItem(vmeMenuCreate);
separator4 = menuBar.addSeparator(); separator4 = menuBar.addSeparator();
@ -415,6 +415,52 @@ public class Headerbar extends Composite{
return toReturn; return toReturn;
} }
private MenuItem getVMEMenuCreate() {
MenuBar importMenu = new MenuBar(true);
importMenu.setAnimationEnabled(true);
MenuItem toReturn = new MenuItem("Create VME-DB", importMenu);
toReturn.getElement().getStyle().setWhiteSpace(WhiteSpace.NOWRAP);
MenuItem item = new MenuItem("Create new VME", true, new Command() {
public void execute() {
presenter.importVMETemplate(VMETypeIdentifier.Vme);
}
});
importMenu.addItem(item);
importMenu.addSeparator();
item = new MenuItem("Create new General Measure", true, new Command() {
public void execute() {
presenter.importVMETemplate(VMETypeIdentifier.GeneralMeasure);
}
});
importMenu.addItem(item);
item = new MenuItem("Create new Information Source", true, new Command() {
public void execute() {
presenter.importVMETemplate(VMETypeIdentifier.InformationSource);
}
});
importMenu.addItem(item);
item = new MenuItem("Create new Fishing footprint", true, new Command() {
public void execute() {
presenter.importVMETemplate(VMETypeIdentifier.FisheryAreasHistory);
}
});
importMenu.addItem(item);
item = new MenuItem("Create new Regional History of VMEs", true, new Command() {
public void execute() {
presenter.importVMETemplate(VMETypeIdentifier.VMEsHistory);
}
});
importMenu.addItem(item);
return toReturn;
}
/** /**
* *
* @return * @return

View File

@ -38,6 +38,7 @@ public class CommonCommands {
*/ */
public Command openReport; public Command openReport;
public Command newTemplate; public Command newTemplate;
/** /**
* *
@ -73,7 +74,6 @@ public class CommonCommands {
} }
}; };
openTemplate = new Command() { openTemplate = new Command() {
public void execute() { public void execute() {
final int left = presenter.getHeader().getMainLayout().getAbsoluteLeft() + 50; final int left = presenter.getHeader().getMainLayout().getAbsoluteLeft() + 50;

View File

@ -1208,6 +1208,26 @@ public class Presenter {
dlg.show(); dlg.show();
} }
public void importVMETemplate(final VMETypeIdentifier type) {
showLoading();
reportService.importVMETemplate(type, new AsyncCallback<Model>() {
@Override
public void onFailure(Throwable caught) {
Window.alert("Could not Load Template Model, error on server.: " + caught.getMessage());
}
@Override
public void onSuccess(Model toLoad) {
if (toLoad != null) {
loadModel(toLoad, type == VMETypeIdentifier.Vme);
}
else
Window.alert("Could not Load Template Model, error on server.");
}
});
}
private void importVMEReport(String reportId, String name, final VMETypeIdentifier type) { private void importVMEReport(String reportId, String name, final VMETypeIdentifier type) {
showLoading(); showLoading();
reportService.importVMEReport(reportId, name, type, new AsyncCallback<Model>() { reportService.importVMEReport(reportId, name, type, new AsyncCallback<Model>() {

View File

@ -29,6 +29,8 @@ public interface ReportService extends RemoteService{
Model getVMEReportRef2Associate(String id, VMETypeIdentifier refType); Model getVMEReportRef2Associate(String id, VMETypeIdentifier refType);
Model importVMETemplate(VMETypeIdentifier refType);
String save(String filePath, String workspaceFolderId, String ItemName, String save(String filePath, String workspaceFolderId, String ItemName,
TypeExporter type, boolean overwrite) TypeExporter type, boolean overwrite)
throws SaveReportFileException, SaveReportFileExistException; throws SaveReportFileException, SaveReportFileExistException;

View File

@ -84,4 +84,6 @@ public interface ReportServiceAsync {
AsyncCallback<ArrayList<VMEReportBean>> callback); AsyncCallback<ArrayList<VMEReportBean>> callback);
void getVMEReportRef2Associate(String id, VMETypeIdentifier refType, AsyncCallback<Model> callback); void getVMEReportRef2Associate(String id, VMETypeIdentifier refType, AsyncCallback<Model> callback);
void importVMETemplate(VMETypeIdentifier refType,
AsyncCallback<Model> callback);
} }

View File

@ -50,10 +50,15 @@ public interface Images extends ImageBundle {
* @return . * @return .
*/ */
AbstractImagePrototype justifyRight(); AbstractImagePrototype justifyRight();
/**
* @return .
*/
AbstractImagePrototype closeDoc();
/** /**
* @return . * @return .
*/ */
AbstractImagePrototype newdoc(); AbstractImagePrototype newdoc();
/** /**
* @return . * @return .
*/ */

View File

@ -39,3 +39,4 @@ open_template = Open Template
open_report = Open Report from Workspace open_report = Open Report from Workspace
importing = Import from Template importing = Import from Template
forecolors = Text Color forecolors = Text Color
close_report = Close Report

View File

@ -80,6 +80,8 @@ public class RichTextToolbar extends Composite {
commands.get("save").execute(); commands.get("save").execute();
} else if (sender == newdoc) { } else if (sender == newdoc) {
commands.get("newdoc").execute(); commands.get("newdoc").execute();
}else if (sender == close) {
commands.get("newdoc").execute();
} else if (sender == open_report) { } else if (sender == open_report) {
commands.get("open_report").execute(); commands.get("open_report").execute();
} else if (sender == open_template) { } else if (sender == open_template) {
@ -173,6 +175,7 @@ public class RichTextToolbar extends Composite {
private PushButton justifyRight; private PushButton justifyRight;
private PushButton save; private PushButton save;
private PushButton saveDB; private PushButton saveDB;
private PushButton close;
private PushButton newdoc; private PushButton newdoc;
private PushButton open_template; private PushButton open_template;
private PushButton open_report; private PushButton open_report;
@ -245,6 +248,8 @@ public class RichTextToolbar extends Composite {
} }
//add the save button //add the save button
topPanel.add(save = createPushButton(images.save(), strings.save())); topPanel.add(save = createPushButton(images.save(), strings.save()));
//add the close button
topPanel.add(close = createPushButton(images.closeDoc(), strings.close_report()));
if (isVme) { if (isVme) {
topPanel.add(saveDB = createPushButton(images.db_save(), "Commit current in VME-DB")); topPanel.add(saveDB = createPushButton(images.db_save(), "Commit current in VME-DB"));
saveDB.addClickHandler(new ClickHandler() { saveDB.addClickHandler(new ClickHandler() {
@ -456,6 +461,8 @@ public class RichTextToolbar extends Composite {
*/ */
public interface Strings extends Constants { public interface Strings extends Constants {
String close_report();
String insertImage(); String insertImage();
String importing(); String importing();

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.reportgenerator.client.uibinder;
import org.gcube.portlets.user.reportgenerator.client.Presenter.CommonCommands; import org.gcube.portlets.user.reportgenerator.client.Presenter.CommonCommands;
import org.gcube.portlets.user.reportgenerator.client.Presenter.Presenter; import org.gcube.portlets.user.reportgenerator.client.Presenter.Presenter;
import org.gcube.portlets.user.reportgenerator.client.uibinder.ExportOptions.ExportMode; import org.gcube.portlets.user.reportgenerator.client.uibinder.ExportOptions.ExportMode;
import org.gcube.portlets.user.reportgenerator.shared.VMETypeIdentifier;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
@ -64,7 +65,7 @@ public class OpenOptionsVME extends Composite {
p.showVMEImportDialog(); p.showVMEImportDialog();
break; break;
case OPEN_TEMPLATE: case OPEN_TEMPLATE:
Window.alert("Not yet available"); p.importVMETemplate(VMETypeIdentifier.Vme);
break; break;
case UPLOAD: case UPLOAD:
Window.alert("Not yet available"); Window.alert("Not yet available");

View File

@ -1552,6 +1552,7 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
try { try {
model = new ReportManagerReportBuilder().buildReport(cr); model = new ReportManagerReportBuilder().buildReport(cr);
model.setTemplateName(name); model.setTemplateName(name);
//ReportsReader.readReportStructure(model);
} catch (ReportBuilderException e) { } catch (ReportBuilderException e) {
e.printStackTrace(); e.printStackTrace();
} catch (Exception e) { } catch (Exception e) {
@ -1575,8 +1576,34 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
} }
return model; return model;
} }
@Override
public Model importVMETemplate(VMETypeIdentifier refType) {
RsgService rsgClient = new RsgClient(getRSGWSAddress());
CompiledReport cr = null;
if (refType == VMETypeIdentifier.Vme) {
_log.info("Importing VME Template");
cr = rsgClient.getTemplate(new ReportType(refType.getId()));
}
else {
_log.info("Importing Ref type= " + refType.getId());
cr = rsgClient.getTemplate(new ReportType(refType.getId()));
}
Model model = null;
try {
model = new ReportManagerReportBuilder().buildReport(cr);
model.setTemplateName("New " + refType.getDisplayName());
} catch (ReportBuilderException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return model;
}
/** /**
* this method ch * this method look for a ReportsStoreGateway WS available in the infrastructure
* @return true if an instance of the ReportsStoreGateway is available in the infrastructure * @return true if an instance of the ReportsStoreGateway is available in the infrastructure
*/ */
private boolean isReportsStoreGatewayAvailable() { private boolean isReportsStoreGatewayAvailable() {
@ -1606,4 +1633,5 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
else return false; else return false;
} }
} }

View File

@ -33,6 +33,7 @@ public class ReportsReader {
} }
/** Non Test methods **/ /** Non Test methods **/
/** /**
* ket method whne reading * ket method whne reading
@ -45,16 +46,23 @@ public class ReportsReader {
case HEADING: case HEADING:
case INSTRUCTION: case INSTRUCTION:
case TEXT_INPUT: case TEXT_INPUT:
case HIDDEN:
System.out.println(sep +"Type: " + rc.getType()+"\n\tId: " + rc.getId() + "\tValue: " + rc.getStringValue() + " props="+rc.getProperties().toString()); System.out.println(sep +"Type: " + rc.getType()+"\n\tId: " + rc.getId() + "\tValue: " + rc.getStringValue() + " props="+rc.getProperties().toString());
break; break;
case BOXAREA: case BOXAREA:
BoxesArea ba = (BoxesArea) rc; BoxesArea ba = (BoxesArea) rc;
System.out.println(sep +"Type: " + rc.getType()); System.out.println(sep +"Type: " + rc.getType() + ba.getProperties());
for (ReportComponent rpc : ba.getChildren()) { for (ReportComponent rpc : ba.getChildren()) {
Box attrBox = (Box) rpc; Box attrBox = (Box) rpc;
System.out.println("\t"+attrBox); System.out.println("\t"+attrBox);
} }
break; break;
case SEQUENCE_LIST:
System.out.println(sep +"Type: " + rc.getType());
for (ReportComponent rpc : rc.getChildren()) {
printReportCompomnent(rpc, sep+"\t");
}
break;
case SEQUENCE: case SEQUENCE:
System.out.println(sep +"Type: " + rc.getType()); System.out.println(sep +"Type: " + rc.getType());
for (ReportComponent rpc : rc.getChildren()) { for (ReportComponent rpc : rc.getChildren()) {

View File

@ -1,17 +1,19 @@
package org.gcube.portlets.user.reportgenerator.shared; package org.gcube.portlets.user.reportgenerator.shared;
public enum VMETypeIdentifier { public enum VMETypeIdentifier {
Vme("Vme"), Vme("Vme", "VME"),
GeneralMeasure("GeneralMeasure"), GeneralMeasure("GeneralMeasure", "General Measure"),
InformationSource("InformationSource"), InformationSource("InformationSource", "Information Source"),
FisheryAreasHistory("FisheryAreasHistory"), FisheryAreasHistory("FisheryAreasHistory", "fishing foot print"),
VMEsHistory("VMEsHistory"), VMEsHistory("VMEsHistory", "regional history"),
Rfmo("Rfmo"); Rfmo("Rfmo", "RFMO");
private String _id; private String _id;
private String displayName;
private VMETypeIdentifier(String id) { private VMETypeIdentifier(String id, String _displayName) {
this._id = id; this._id = id;
this.displayName = _displayName;
} }
/** /**
@ -20,4 +22,9 @@ public enum VMETypeIdentifier {
public String getId() { public String getId() {
return this._id; return this._id;
} }
public String getDisplayName() {
return displayName;
}
} }

View File

@ -57,6 +57,7 @@
.optionDeleteVME { .optionDeleteVME {
background: url('images/deleteVME.png') 55% 25px no-repeat; background: url('images/deleteVME.png') 55% 25px no-repeat;
opacity: 0.5;
} }
.exportPanel { .exportPanel {

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB