2013-02-06 23:25:43 +01:00
|
|
|
package org.gcube.portlets.user.reportgenerator.client.model;
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2013-03-01 19:42:50 +01:00
|
|
|
import org.gcube.portlets.d4sreporting.common.shared.AttributeArea;
|
|
|
|
import org.gcube.portlets.d4sreporting.common.shared.BasicComponent;
|
2013-03-06 19:42:20 +01:00
|
|
|
import org.gcube.portlets.d4sreporting.common.shared.ComponentType;
|
|
|
|
import org.gcube.portlets.d4sreporting.common.shared.Metadata;
|
|
|
|
import org.gcube.portlets.d4sreporting.common.shared.RepTimeSeries;
|
2013-03-01 19:42:50 +01:00
|
|
|
import org.gcube.portlets.d4sreporting.common.shared.RepeatableSequence;
|
|
|
|
import org.gcube.portlets.d4sreporting.common.shared.Table;
|
2013-02-06 23:25:43 +01:00
|
|
|
import org.gcube.portlets.user.reportgenerator.client.Presenter.Presenter;
|
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;
|
2013-03-06 19:42:20 +01:00
|
|
|
import org.gcube.portlets.user.reportgenerator.client.targets.ClientRepeatableSequence;
|
2013-02-06 23:25:43 +01:00
|
|
|
import org.gcube.portlets.user.reportgenerator.client.targets.D4sRichTextarea;
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.targets.DropTSListener;
|
|
|
|
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;
|
|
|
|
import org.gcube.portlets.user.reportgenerator.client.targets.GroupingInnerArea;
|
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-02-06 23:25:43 +01:00
|
|
|
|
|
|
|
import com.google.gwt.core.client.GWT;
|
|
|
|
import com.google.gwt.dom.client.Style.Unit;
|
|
|
|
import com.google.gwt.user.client.ui.HTML;
|
|
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* This class represent all the possible template components IN THE MODEL
|
|
|
|
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
|
|
|
|
*/
|
|
|
|
public class TemplateComponent {
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2013-03-07 16:03:01 +01:00
|
|
|
public final static String DEFAULT_IMAGE_NAME= "image_placeholder.png";
|
|
|
|
public final static String DEFAULT_IMAGE_PATH= GWT.getModuleBaseURL() + "../images/" + DEFAULT_IMAGE_NAME;
|
2013-02-06 23:25:43 +01:00
|
|
|
|
|
|
|
private int x;
|
|
|
|
private int y;
|
|
|
|
private int width;
|
|
|
|
private int height;
|
|
|
|
private TemplateModel myModel;
|
|
|
|
private int templatePage;
|
|
|
|
private String idInBasket = null;
|
|
|
|
|
|
|
|
|
|
|
|
private ComponentType type;
|
|
|
|
|
|
|
|
private boolean locked;
|
|
|
|
|
|
|
|
private boolean doubleColLayout;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* holds the metadata(s) for the sections
|
|
|
|
*/
|
|
|
|
private List<Metadata> metadata;
|
|
|
|
/**
|
|
|
|
* the paramName for assigning it a value when exporting to pdf, valid only for Dynamic Content
|
|
|
|
*/
|
|
|
|
private String paramName;
|
|
|
|
|
|
|
|
//what is in the template component may vary depending on its type
|
|
|
|
private Widget content;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a empty TemplateComponent
|
|
|
|
*/
|
|
|
|
public TemplateComponent() {
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a TemplateComponent with the given charactheristics in double column
|
|
|
|
*
|
|
|
|
* @param myModel .
|
|
|
|
* @param x .
|
|
|
|
* @param y .
|
|
|
|
* @param width .
|
|
|
|
* @param height .
|
|
|
|
* @param templatePage .
|
|
|
|
* @param content the inserted widget
|
|
|
|
* @param type the type of the inserted widget
|
|
|
|
* @param paramName for assigning it a value when exporting to pdf, valid only for Dynamic Content
|
|
|
|
* @param doubleColLayout to specify that its layout is double columned
|
|
|
|
*/
|
|
|
|
public TemplateComponent(TemplateModel myModel, int x, int y, int width, int height, int templatePage, ComponentType type, String paramName, Widget content, boolean doubleColLayout) {
|
|
|
|
this.myModel = myModel;
|
|
|
|
this.x = x;
|
|
|
|
this.y = y;
|
|
|
|
this.width = width;
|
|
|
|
this.height = height;
|
|
|
|
this.templatePage = templatePage;
|
|
|
|
this.content = content;
|
|
|
|
this.type = type;
|
|
|
|
this.paramName = paramName;
|
|
|
|
this.doubleColLayout = doubleColLayout;
|
|
|
|
this.metadata = new LinkedList<Metadata>();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Creates a TemplateComponent with the given charactheristics and single column
|
|
|
|
*
|
|
|
|
* @param myModel .
|
|
|
|
* @param x .
|
|
|
|
* @param y .
|
|
|
|
* @param width .
|
|
|
|
* @param height .
|
|
|
|
* @param templatePage .
|
|
|
|
* @param content the inserted widget
|
|
|
|
* @param type the type of the inserted widget
|
|
|
|
* @param paramName for assigning it a value when exporting to pdf, valid only for Dynamic Content
|
|
|
|
*/
|
|
|
|
public TemplateComponent(TemplateModel myModel, int x, int y, int width, int height, int templatePage, ComponentType type, String paramName, Widget content) {
|
|
|
|
this.myModel = myModel;
|
|
|
|
this.x = x;
|
|
|
|
this.y = y;
|
|
|
|
this.width = width;
|
|
|
|
this.height = height;
|
|
|
|
this.templatePage = templatePage;
|
|
|
|
this.content = content;
|
|
|
|
this.type = type;
|
|
|
|
this.paramName = paramName;
|
|
|
|
this.doubleColLayout = false;
|
|
|
|
this.metadata = new LinkedList<Metadata>();
|
|
|
|
}
|
2013-03-12 18:10:16 +01:00
|
|
|
|
2013-02-06 23:25:43 +01:00
|
|
|
/**
|
|
|
|
* create a template component which is displayable (create an actual Widget in the content field)
|
|
|
|
* @param myModel the model
|
|
|
|
* @param sc the serialiazble to convert
|
|
|
|
* @param presenter .
|
2013-03-12 18:10:16 +01:00
|
|
|
* @param showClose
|
|
|
|
* @param owner needed only for the TextTableImage case and because im in hurry
|
2013-02-06 23:25:43 +01:00
|
|
|
*/
|
2013-03-12 18:10:16 +01:00
|
|
|
public TemplateComponent(TemplateModel myModel, BasicComponent sc, Presenter presenter, boolean showClose, TextTableImage owner) {
|
2013-02-06 23:25:43 +01:00
|
|
|
this.myModel = myModel;
|
|
|
|
//
|
|
|
|
//Coords start = new Coords(x, y);
|
|
|
|
int width = sc.getWidth();
|
|
|
|
int height = sc.getHeight();
|
|
|
|
this.x = sc.getX();
|
|
|
|
this.y = sc.getY();
|
|
|
|
this.width = sc.getWidth();
|
|
|
|
this.height = sc.getHeight();
|
|
|
|
this.templatePage = sc.getTemplatePage();
|
|
|
|
this.type = sc.getType();
|
|
|
|
this.paramName = sc.getParamName();
|
|
|
|
this.doubleColLayout = sc.isDoubleColLayout();
|
|
|
|
this.locked = sc.isLocked();
|
|
|
|
this.metadata = sc.getMetadata();
|
2013-03-12 18:10:16 +01:00
|
|
|
|
2013-02-06 23:25:43 +01:00
|
|
|
switch (sc.getType()) {
|
|
|
|
case DYNA_IMAGE:
|
2013-03-13 11:06:47 +01:00
|
|
|
ClientImage dp = new ClientImage(sc, presenter, sc.getWidth(), sc.getHeight(), showClose, owner);
|
2013-03-08 15:49:26 +01:00
|
|
|
this.content = dp;
|
2013-02-06 23:25:43 +01:00
|
|
|
break;
|
|
|
|
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 (sc.isLocked()) {
|
|
|
|
HTML area = new HTML();
|
|
|
|
area.setStyleName("report-ui-component");
|
|
|
|
area.addStyleName(getStyle(sc.getType()));
|
|
|
|
area.getElement().getStyle().setMarginTop(5, Unit.PX);
|
|
|
|
area.setPixelSize(width, 18);
|
|
|
|
area.setText((String) sc.getPossibleContent());
|
|
|
|
this.content = area;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
HeadingTextArea bToAdd = new HeadingTextArea(sc.getType(), presenter, sc.getX(), sc.getY(), width, 25, getUserComments() != null, showClose);
|
|
|
|
bToAdd.setText((String) sc.getPossibleContent());
|
|
|
|
this.content = bToAdd;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BODY_NOT_FORMATTED:
|
2013-02-06 23:25:43 +01:00
|
|
|
if (sc.isLocked()) {
|
2013-02-14 19:17:45 +01:00
|
|
|
HTML area = new HTML();
|
|
|
|
area.setStyleName("report-ui-component");
|
|
|
|
area.addStyleName(getStyle(sc.getType()));
|
|
|
|
area.getElement().getStyle().setMarginTop(5, Unit.PX);
|
|
|
|
area.setPixelSize(width, 18);
|
2013-02-06 23:25:43 +01:00
|
|
|
area.setText((String) sc.getPossibleContent());
|
|
|
|
this.content = area;
|
|
|
|
}
|
|
|
|
else {
|
2013-03-12 18:10:16 +01:00
|
|
|
BasicTextArea bToAdd = new BasicTextArea(sc.getType(), presenter, sc.getX(), sc.getY(), width, 25, getUserComments() != null, showClose);
|
2013-02-06 23:25:43 +01:00
|
|
|
bToAdd.setText((String) sc.getPossibleContent());
|
|
|
|
this.content = bToAdd;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BODY:
|
|
|
|
if (sc.isLocked()) {
|
|
|
|
HTML area = new HTML();
|
|
|
|
area.setStyleName("d4sFrame");
|
|
|
|
area.addStyleName("fixedTextArea");
|
|
|
|
area.addStyleName("hasRichTextToolbar");
|
|
|
|
area.setPixelSize(width, height);
|
|
|
|
area.setHTML((String) sc.getPossibleContent());
|
|
|
|
this.content = area;
|
|
|
|
}
|
|
|
|
else {
|
2013-02-14 19:27:15 +01:00
|
|
|
height = 40;
|
2013-03-12 18:10:16 +01:00
|
|
|
D4sRichTextarea ta = new D4sRichTextarea(sc.getType(), presenter, sc.getX(), sc.getY(),width, height, getUserComments() != null, showClose, owner);
|
2013-02-06 23:25:43 +01:00
|
|
|
ta.setHTML((String) sc.getPossibleContent());
|
|
|
|
//ta.setStyleName("cw-RichText");
|
|
|
|
ta.setPixelSize(width, height);
|
|
|
|
this.content = ta;
|
|
|
|
}
|
|
|
|
this.setLocked(sc.isLocked());
|
|
|
|
break;
|
|
|
|
case TOC:
|
2013-03-12 18:10:16 +01:00
|
|
|
ReportTextArea dp2 = new ReportTextArea(sc.getType(), presenter, sc.getX(), sc.getY(), width, height, getUserComments() != null, showClose);
|
2013-02-06 23:25:43 +01:00
|
|
|
dp2.addStyleName("tocArea");
|
|
|
|
this.content = dp2;
|
|
|
|
break;
|
|
|
|
case BIBLIO:
|
2013-03-12 18:10:16 +01:00
|
|
|
ReportTextArea dp3 = new ReportTextArea(sc.getType(), presenter, sc.getX(), sc.getY(), width, height, getUserComments() != null, showClose);
|
2013-02-06 23:25:43 +01:00
|
|
|
dp3.addStyleName("biblioArea");
|
|
|
|
this.content = dp3;
|
|
|
|
break;
|
|
|
|
case PAGEBREAK:
|
2013-03-12 18:10:16 +01:00
|
|
|
ReportTextArea dp4 = new ReportTextArea(sc.getType(), presenter, sc.getX(), sc.getY(), width, height, getUserComments() != null, showClose);
|
2013-02-06 23:25:43 +01:00
|
|
|
dp4.addStyleName("pagebreak");
|
|
|
|
this.content = dp4;
|
|
|
|
break;
|
|
|
|
case FLEX_TABLE:
|
2013-03-01 19:42:50 +01:00
|
|
|
Table st = (Table) sc.getPossibleContent();
|
2013-03-12 19:22:45 +01:00
|
|
|
GenericTable table = new GenericTable(st, presenter, sc.getX(), sc.getY(), TemplateModel.TEMPLATE_WIDTH - 50, 200, sc.isLocked(), showClose, owner);
|
2013-02-06 23:25:43 +01:00
|
|
|
this.content = table;
|
|
|
|
break;
|
2013-02-26 19:44:48 +01:00
|
|
|
case ATTRIBUTE_MULTI:
|
2013-03-05 15:26:22 +01:00
|
|
|
AttributeMultiSelection ta = null;
|
2013-03-01 19:42:50 +01:00
|
|
|
if (sc.getPossibleContent() instanceof AttributeArea) {
|
|
|
|
AttributeArea sata = (AttributeArea) sc.getPossibleContent();
|
2013-03-05 15:26:22 +01:00
|
|
|
ta = new AttributeMultiSelection(presenter, sc.getX(), sc.getY(), width, height, sata);
|
2013-02-06 23:25:43 +01:00
|
|
|
}
|
|
|
|
else {
|
2013-03-05 15:26:22 +01:00
|
|
|
ta = new AttributeMultiSelection(presenter, sc.getX(), sc.getY(), width, height, sc.getPossibleContent().toString());
|
2013-02-06 23:25:43 +01:00
|
|
|
}
|
|
|
|
this.content = ta;
|
|
|
|
break;
|
2013-03-05 15:26:22 +01:00
|
|
|
case ATTRIBUTE_UNIQUE:
|
|
|
|
AttributeSingleSelection atu = null;
|
|
|
|
if (sc.getPossibleContent() instanceof AttributeArea) {
|
|
|
|
AttributeArea sata = (AttributeArea) sc.getPossibleContent();
|
|
|
|
atu = new AttributeSingleSelection(presenter, sc.getX(), sc.getY(), width, height, sata);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
atu = new AttributeSingleSelection(presenter, sc.getX(), sc.getY(), width, height, sc.getPossibleContent().toString());
|
|
|
|
}
|
|
|
|
this.content = atu;
|
|
|
|
break;
|
2013-02-06 23:25:43 +01:00
|
|
|
case COMMENT:
|
|
|
|
HTML comment = new HTML();
|
|
|
|
comment.setStyleName("commentArea");
|
|
|
|
comment.setHTML((String) sc.getPossibleContent());
|
|
|
|
this.content = comment;
|
|
|
|
break;
|
|
|
|
case INSTRUCTION:
|
|
|
|
HTML instr = new HTML();
|
|
|
|
instr.setStyleName("instructionArea");
|
|
|
|
instr.setHTML((String) sc.getPossibleContent());
|
|
|
|
this.content = instr;
|
|
|
|
break;
|
|
|
|
case TIME_SERIES:
|
|
|
|
TSArea tsa;
|
2013-03-01 19:42:50 +01:00
|
|
|
RepTimeSeries sts = null;
|
2013-02-06 23:25:43 +01:00
|
|
|
try {
|
2013-03-01 19:42:50 +01:00
|
|
|
sts = ((RepTimeSeries) sc.getPossibleContent());
|
2013-02-06 23:25:43 +01:00
|
|
|
} catch (ClassCastException e) {
|
|
|
|
|
|
|
|
}
|
|
|
|
//need to reset the filter when loading a TS
|
|
|
|
sts.setFilter(null);
|
|
|
|
tsa = new TSArea(presenter, width, 155, sts);
|
|
|
|
|
|
|
|
tsa.setPixelSize(width, 155);
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
DropTSListener dropTSListener = new DropTSListener(tsa);
|
|
|
|
|
|
|
|
this.content = tsa;
|
|
|
|
break;
|
2013-02-13 18:26:22 +01:00
|
|
|
case REPEAT_SEQUENCE_DELIMITER:
|
|
|
|
GroupingDelimiterArea gp = new GroupingDelimiterArea();
|
|
|
|
this.content = gp;
|
|
|
|
break;
|
|
|
|
case REPEAT_SEQUENCE_INNER:
|
|
|
|
GroupingInnerArea spacer = new GroupingInnerArea();
|
|
|
|
this.content = spacer;
|
|
|
|
break;
|
|
|
|
case REPEAT_SEQUENCE:
|
|
|
|
GWT.log("FOUND SEQUENCE trying getGroup");
|
2013-03-01 19:42:50 +01:00
|
|
|
RepeatableSequence repeatableSequence = (RepeatableSequence) sc.getPossibleContent();
|
2013-03-12 18:10:16 +01:00
|
|
|
|
2013-03-01 19:42:50 +01:00
|
|
|
GWT.log("getGroup: " + repeatableSequence.toString());
|
2013-03-12 18:10:16 +01:00
|
|
|
|
2013-03-01 19:42:50 +01:00
|
|
|
ClientRepeatableSequence rps = new ClientRepeatableSequence(presenter, repeatableSequence);
|
2013-02-13 18:26:22 +01:00
|
|
|
this.content = rps;
|
2013-02-14 15:08:18 +01:00
|
|
|
break;
|
2013-03-12 18:10:16 +01:00
|
|
|
case BODY_TABLE_IMAGE:
|
|
|
|
TextTableImage tti = null;
|
|
|
|
if (sc.getPossibleContent() == null) { //is is a template
|
|
|
|
tti = new TextTableImage(presenter, true);
|
|
|
|
} else {
|
|
|
|
RepeatableSequence seq = (RepeatableSequence) sc.getPossibleContent();
|
|
|
|
tti = new TextTableImage(presenter, seq);
|
|
|
|
}
|
|
|
|
this.content = tti;
|
|
|
|
break;
|
2013-02-06 23:25:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param type
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
private String getStyle(ComponentType type) {
|
|
|
|
switch (type) {
|
|
|
|
case TITLE:
|
2013-02-14 19:17:45 +01:00
|
|
|
return "title-font";
|
2013-02-06 23:25:43 +01:00
|
|
|
case HEADING_1:
|
2013-02-14 19:17:45 +01:00
|
|
|
return "heading1-label";
|
2013-02-06 23:25:43 +01:00
|
|
|
case HEADING_2:
|
2013-02-14 19:17:45 +01:00
|
|
|
return "heading2-label";
|
2013-02-06 23:25:43 +01:00
|
|
|
case HEADING_3:
|
2013-02-14 19:17:45 +01:00
|
|
|
return "heading3-label";
|
2013-02-13 18:26:22 +01:00
|
|
|
case HEADING_4:
|
2013-02-14 19:17:45 +01:00
|
|
|
return "heading4-label";
|
2013-02-13 18:26:22 +01:00
|
|
|
case HEADING_5:
|
2013-02-14 19:17:45 +01:00
|
|
|
return "heading5-label";
|
2013-02-06 23:25:43 +01:00
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* return a template Component which is serializable
|
|
|
|
* @return .
|
|
|
|
*/
|
2013-03-01 19:42:50 +01:00
|
|
|
public BasicComponent getSerializable() {
|
2013-02-06 23:25:43 +01:00
|
|
|
Serializable content = "";
|
|
|
|
String id = "";
|
|
|
|
switch (this.getType()) {
|
|
|
|
case DYNA_IMAGE:
|
2013-03-07 16:03:01 +01:00
|
|
|
ClientImage da = (ClientImage) this.content;
|
2013-02-06 23:25:43 +01:00
|
|
|
content = da.getDroppedImage().getUrl();
|
|
|
|
id = da.getIdInBasket();
|
|
|
|
idInBasket = id;
|
|
|
|
if (((String) content).compareTo("") == 0)
|
|
|
|
content = DEFAULT_IMAGE_PATH;
|
2013-03-07 18:59:50 +01:00
|
|
|
metadata = da.getMetadata();
|
2013-03-07 19:22:29 +01:00
|
|
|
width = da.getImageWidth();
|
|
|
|
height = da.getImageHeight();
|
2013-02-06 23:25:43 +01:00
|
|
|
break;
|
|
|
|
case BODY:
|
|
|
|
if (this.isLocked()) {
|
|
|
|
content = ((HTML) this.content).getHTML();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
content = ((D4sRichTextarea) this.content).getHTML();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case HEADING_1:
|
|
|
|
case HEADING_2:
|
|
|
|
case HEADING_3:
|
2013-02-14 15:08:18 +01:00
|
|
|
case HEADING_4:
|
|
|
|
case HEADING_5:
|
2013-02-06 23:25:43 +01:00
|
|
|
case TITLE:
|
|
|
|
if (this.isLocked()) {
|
|
|
|
content = ((HTML) this.content).getText();
|
2013-03-12 18:10:16 +01:00
|
|
|
|
2013-03-13 11:06:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
content = ((HeadingTextArea) this.content).getText();
|
|
|
|
break;
|
|
|
|
case BODY_NOT_FORMATTED:
|
|
|
|
if (this.isLocked()) {
|
|
|
|
content = ((HTML) this.content).getText();
|
|
|
|
|
2013-02-06 23:25:43 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
content = ((BasicTextArea) this.content).getText();
|
|
|
|
break;
|
|
|
|
case TIME_SERIES:
|
|
|
|
GWT.log("Found Time Series", null);
|
|
|
|
TSArea tsa = (TSArea) this.content;
|
|
|
|
content = tsa.getSts();
|
|
|
|
break;
|
|
|
|
case FLEX_TABLE:
|
|
|
|
GenericTable gt = (GenericTable) this.content;
|
2013-03-01 19:42:50 +01:00
|
|
|
Table st = gt.getSerializable();
|
2013-02-06 23:25:43 +01:00
|
|
|
content = st;
|
|
|
|
break;
|
2013-02-26 19:44:48 +01:00
|
|
|
case ATTRIBUTE_MULTI:
|
2013-03-05 15:26:22 +01:00
|
|
|
AttributeMultiSelection att = (AttributeMultiSelection) this.content;
|
2013-03-06 19:42:20 +01:00
|
|
|
content = att.getSerializable();
|
2013-02-06 23:25:43 +01:00
|
|
|
break;
|
2013-03-05 15:26:22 +01:00
|
|
|
case ATTRIBUTE_UNIQUE:
|
|
|
|
AttributeSingleSelection atu = (AttributeSingleSelection) this.content;
|
2013-03-06 19:42:20 +01:00
|
|
|
content = atu.getSerializable();
|
2013-03-05 15:26:22 +01:00
|
|
|
break;
|
2013-02-06 23:25:43 +01:00
|
|
|
case COMMENT:
|
|
|
|
content = ((HTML) this.content).getHTML();
|
|
|
|
break;
|
|
|
|
case INSTRUCTION:
|
|
|
|
content = ((HTML) this.content).getHTML();
|
|
|
|
break;
|
2013-02-14 15:08:18 +01:00
|
|
|
case REPEAT_SEQUENCE:
|
2013-03-01 19:42:50 +01:00
|
|
|
ClientRepeatableSequence repSeq = (ClientRepeatableSequence) this.content;
|
|
|
|
RepeatableSequence toStore = new RepeatableSequence(getSerializableSequence(repSeq), height);
|
2013-02-14 15:08:18 +01:00
|
|
|
content = toStore;
|
|
|
|
break;
|
2013-03-12 18:10:16 +01:00
|
|
|
case BODY_TABLE_IMAGE:
|
|
|
|
TextTableImage tti = (TextTableImage) this.content;
|
|
|
|
RepeatableSequence toSave = new RepeatableSequence(getSerializableSequence(tti), height);
|
|
|
|
content = toSave;
|
|
|
|
break;
|
2013-02-06 23:25:43 +01:00
|
|
|
}
|
2013-03-01 19:42:50 +01:00
|
|
|
return new BasicComponent(x, y, width, height, templatePage, type, idInBasket, "param empty", content, this.doubleColLayout, isLocked(), metadata);
|
2013-02-06 23:25:43 +01:00
|
|
|
}
|
|
|
|
|
2013-02-14 15:08:18 +01:00
|
|
|
/**
|
2013-03-12 18:10:16 +01:00
|
|
|
* this method constructs a RepeatableSequence sequence that can be serializable from the ClientRepeatableSequence
|
2013-02-14 15:08:18 +01:00
|
|
|
* @param repSeq
|
|
|
|
* @return
|
|
|
|
*/
|
2013-03-01 19:42:50 +01:00
|
|
|
private ArrayList<BasicComponent> getSerializableSequence(ClientRepeatableSequence repSeq) {
|
|
|
|
ArrayList<BasicComponent> sComps = new ArrayList<BasicComponent>();
|
2013-02-14 15:08:18 +01:00
|
|
|
for (TemplateComponent tc : repSeq.getGroupedComponents()) {
|
|
|
|
sComps.add(tc.getSerializable());
|
|
|
|
}
|
|
|
|
return sComps;
|
|
|
|
}
|
2013-03-12 18:10:16 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* this method constructs a Sequence that can be serializable from the TextTableImage Widget
|
|
|
|
* @param repSeq
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
private ArrayList<BasicComponent> getSerializableSequence(TextTableImage seq) {
|
|
|
|
ArrayList<BasicComponent> sComps = new ArrayList<BasicComponent>();
|
|
|
|
for (TemplateComponent tc : seq.getAddedComponents()) {
|
|
|
|
sComps.add(tc.getSerializable());
|
|
|
|
}
|
|
|
|
return sComps;
|
|
|
|
}
|
2013-02-06 23:25:43 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return .
|
|
|
|
*/
|
|
|
|
public int getHeight() {return height;}
|
|
|
|
/**
|
|
|
|
* @param height .
|
|
|
|
*/
|
|
|
|
public void setHeight(int height) { this.height = height; }
|
|
|
|
/**
|
|
|
|
* @return .
|
|
|
|
*/
|
|
|
|
public ComponentType getType() {return type;}
|
|
|
|
/**
|
|
|
|
* @param type .
|
|
|
|
*/
|
|
|
|
public void setType(ComponentType type) { this.type = type;}
|
|
|
|
/**
|
|
|
|
* @return .
|
|
|
|
*/
|
|
|
|
public int getWidth() { return width;}
|
|
|
|
/**
|
|
|
|
* @param width .
|
|
|
|
*/
|
|
|
|
public void setWidth(int width) {this.width = width;}
|
|
|
|
/**
|
|
|
|
* @return .
|
|
|
|
*/
|
|
|
|
public int getX() { return x;}
|
|
|
|
/**
|
|
|
|
* @param x .
|
|
|
|
*/
|
|
|
|
public void setX(int x) {this.x = x;}
|
|
|
|
/**
|
|
|
|
* @return .
|
|
|
|
*/
|
|
|
|
public int getY() {return y;}
|
|
|
|
/**
|
|
|
|
* @param y .
|
|
|
|
*/
|
|
|
|
public void setY(int y) {this.y = y;}
|
|
|
|
/**
|
|
|
|
* @return .
|
|
|
|
*/
|
|
|
|
public int getTemplatePage() { return templatePage; }
|
|
|
|
/**
|
|
|
|
* @param templatePage .
|
|
|
|
*/
|
|
|
|
public void setTemplatePage(int templatePage) { this.templatePage = templatePage;}
|
|
|
|
/**
|
|
|
|
* @return .
|
|
|
|
*/
|
|
|
|
public Widget getContent() {return content; }
|
|
|
|
/**
|
|
|
|
* @param content .
|
|
|
|
*/
|
|
|
|
public void setContent(Widget content) {
|
|
|
|
this.content = content;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @return .
|
|
|
|
*/
|
|
|
|
public String getParamName() {
|
|
|
|
return paramName;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param paramName .
|
|
|
|
*/
|
|
|
|
public void setParamName(String paramName) {
|
|
|
|
this.paramName = paramName;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @return .
|
|
|
|
*/
|
|
|
|
public boolean isLocked() {
|
|
|
|
return locked;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param locked .
|
|
|
|
*/
|
|
|
|
public void setLocked(boolean locked) {
|
|
|
|
this.locked = locked;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param attr .
|
|
|
|
* @param value .
|
|
|
|
*/
|
|
|
|
public void addMetadata(String attr, String value) {
|
|
|
|
if (attr != null && value != null) {
|
|
|
|
metadata.add(new Metadata(attr, value));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
throw new NullPointerException();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @return .
|
|
|
|
*/
|
|
|
|
public List<Metadata> getAllMetadata() {
|
|
|
|
if (metadata == null) {
|
|
|
|
new LinkedList<Metadata>();
|
|
|
|
}
|
|
|
|
return metadata;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String getUserComments() {
|
|
|
|
if (metadata == null) return null;
|
|
|
|
for (Metadata md : metadata) {
|
|
|
|
if (md.getAttribute().equals(TemplateModel.USER_COMMENT))
|
|
|
|
return md.getValue();
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @return .
|
|
|
|
*/
|
|
|
|
public String getIdInBasket() {
|
|
|
|
return idInBasket;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param idInBasket .
|
|
|
|
*/
|
|
|
|
public void setIdInBasket(String idInBasket) {
|
|
|
|
this.idInBasket = idInBasket;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @return .
|
|
|
|
*/
|
|
|
|
public boolean isDoubleColLayout() {
|
|
|
|
return doubleColLayout;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|