partially implement text table image

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/reports@71268 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2013-03-12 17:10:16 +00:00
parent a9165be746
commit f159ee4eaa
22 changed files with 368 additions and 144 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.0.3-SNAPSHOT/WEB-INF/classes" path="src/main/java"> <classpathentry kind="src" output="target/reports-4.0.4-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
@ -30,5 +30,5 @@
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/> <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="output" path="target/reports-4.0.3-SNAPSHOT/WEB-INF/classes"/> <classpathentry kind="output" path="target/reports-4.0.4-SNAPSHOT/WEB-INF/classes"/>
</classpath> </classpath>

View File

@ -1,5 +1,5 @@
#Thu Mar 07 19:02:40 CET 2013 #Tue Mar 12 17:50:07 CET 2013
eclipse.preferences.version=1 eclipse.preferences.version=1
lastWarOutDir=/Users/massi/Documents/workspace/reports/target/reports-4.0.3-SNAPSHOT lastWarOutDir=/Users/massi/Documents/workspace/reports/target/reports-4.0.4-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.0.3-SNAPSHOT</version> <version>4.0.4-SNAPSHOT</version>
<name>gCube Reports Portlet</name> <name>gCube Reports Portlet</name>
<description> <description>
gCube Reports Portlet. gCube Reports Portlet.

View File

@ -44,6 +44,7 @@ import org.gcube.portlets.user.reportgenerator.client.targets.GenericTable;
import org.gcube.portlets.user.reportgenerator.client.targets.GroupingDelimiterArea; import org.gcube.portlets.user.reportgenerator.client.targets.GroupingDelimiterArea;
import org.gcube.portlets.user.reportgenerator.client.targets.ReportTextArea; import org.gcube.portlets.user.reportgenerator.client.targets.ReportTextArea;
import org.gcube.portlets.user.reportgenerator.client.targets.TSArea; import org.gcube.portlets.user.reportgenerator.client.targets.TSArea;
import org.gcube.portlets.user.reportgenerator.client.targets.TextTableImage;
import org.gcube.portlets.user.reportgenerator.shared.SessionInfo; import org.gcube.portlets.user.reportgenerator.shared.SessionInfo;
import org.gcube.portlets.user.reportgenerator.shared.UserBean; import org.gcube.portlets.user.reportgenerator.shared.UserBean;
@ -1048,6 +1049,10 @@ public class Presenter {
ClientRepeatableSequence rps = (ClientRepeatableSequence) component.getContent(); ClientRepeatableSequence rps = (ClientRepeatableSequence) component.getContent();
wp.addComponentToLayout(rps, component.isDoubleColLayout()); wp.addComponentToLayout(rps, component.isDoubleColLayout());
break; break;
case BODY_TABLE_IMAGE:
TextTableImage tti = (TextTableImage) component.getContent();
wp.addComponentToLayout(tti, component.isDoubleColLayout());
break;
} }
} }
} }

View File

@ -135,7 +135,7 @@ public class ReportGenerator implements EntryPoint {
mainLayout.add(cellPanel); mainLayout.add(cellPanel);
divHidden.setStyleName("d4sFrame"); divHidden.setStyleName("d4sFrame");
divHidden.setWidth("500"); divHidden.setWidth("750px");
divHidden.setStyleName("d4sRichTextArea"); divHidden.setStyleName("d4sRichTextArea");
divHidden.addStyleName("setVisibilityOff"); divHidden.addStyleName("setVisibilityOff");
divHidden.addStyleName("hasRichTextToolbar"); divHidden.addStyleName("hasRichTextToolbar");

View File

@ -25,6 +25,7 @@ import org.gcube.portlets.user.reportgenerator.client.targets.GroupingDelimiterA
import org.gcube.portlets.user.reportgenerator.client.targets.GroupingInnerArea; import org.gcube.portlets.user.reportgenerator.client.targets.GroupingInnerArea;
import org.gcube.portlets.user.reportgenerator.client.targets.ReportTextArea; import org.gcube.portlets.user.reportgenerator.client.targets.ReportTextArea;
import org.gcube.portlets.user.reportgenerator.client.targets.TSArea; import org.gcube.portlets.user.reportgenerator.client.targets.TSArea;
import org.gcube.portlets.user.reportgenerator.client.targets.TextTableImage;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.Unit;
@ -138,14 +139,16 @@ public class TemplateComponent {
this.doubleColLayout = false; this.doubleColLayout = false;
this.metadata = new LinkedList<Metadata>(); this.metadata = new LinkedList<Metadata>();
} }
/** /**
* create a template component which is displayable (create an actual Widget in the content field) * create a template component which is displayable (create an actual Widget in the content field)
* @param myModel the model * @param myModel the model
* @param sc the serialiazble to convert * @param sc the serialiazble to convert
* @param presenter . * @param presenter .
* @param showClose
* @param owner needed only for the TextTableImage case and because im in hurry
*/ */
public TemplateComponent(TemplateModel myModel, BasicComponent sc, Presenter presenter) { public TemplateComponent(TemplateModel myModel, BasicComponent sc, Presenter presenter, boolean showClose, TextTableImage owner) {
this.myModel = myModel; this.myModel = myModel;
// //
//Coords start = new Coords(x, y); //Coords start = new Coords(x, y);
@ -161,7 +164,7 @@ public class TemplateComponent {
this.doubleColLayout = sc.isDoubleColLayout(); this.doubleColLayout = sc.isDoubleColLayout();
this.locked = sc.isLocked(); this.locked = sc.isLocked();
this.metadata = sc.getMetadata(); this.metadata = sc.getMetadata();
switch (sc.getType()) { switch (sc.getType()) {
case DYNA_IMAGE: case DYNA_IMAGE:
ClientImage dp = new ClientImage(sc, presenter, sc.getWidth(), sc.getHeight()); ClientImage dp = new ClientImage(sc, presenter, sc.getWidth(), sc.getHeight());
@ -184,7 +187,7 @@ public class TemplateComponent {
this.content = area; this.content = area;
} }
else { else {
BasicTextArea bToAdd = new BasicTextArea(sc.getType(), presenter, sc.getX(), sc.getY(), width, 25, getUserComments() != null); BasicTextArea bToAdd = new BasicTextArea(sc.getType(), presenter, sc.getX(), sc.getY(), width, 25, getUserComments() != null, showClose);
bToAdd.setText((String) sc.getPossibleContent()); bToAdd.setText((String) sc.getPossibleContent());
this.content = bToAdd; this.content = bToAdd;
} }
@ -201,7 +204,7 @@ public class TemplateComponent {
} }
else { else {
height = 40; height = 40;
D4sRichTextarea ta = new D4sRichTextarea(sc.getType(), presenter, sc.getX(), sc.getY(),width, height, getUserComments() != null); D4sRichTextarea ta = new D4sRichTextarea(sc.getType(), presenter, sc.getX(), sc.getY(),width, height, getUserComments() != null, showClose, owner);
ta.setHTML((String) sc.getPossibleContent()); ta.setHTML((String) sc.getPossibleContent());
//ta.setStyleName("cw-RichText"); //ta.setStyleName("cw-RichText");
ta.setPixelSize(width, height); ta.setPixelSize(width, height);
@ -210,17 +213,17 @@ public class TemplateComponent {
this.setLocked(sc.isLocked()); this.setLocked(sc.isLocked());
break; break;
case TOC: case TOC:
ReportTextArea dp2 = new ReportTextArea(sc.getType(), presenter, sc.getX(), sc.getY(), width, height, getUserComments() != null); ReportTextArea dp2 = new ReportTextArea(sc.getType(), presenter, sc.getX(), sc.getY(), width, height, getUserComments() != null, showClose);
dp2.addStyleName("tocArea"); dp2.addStyleName("tocArea");
this.content = dp2; this.content = dp2;
break; break;
case BIBLIO: case BIBLIO:
ReportTextArea dp3 = new ReportTextArea(sc.getType(), presenter, sc.getX(), sc.getY(), width, height, getUserComments() != null); ReportTextArea dp3 = new ReportTextArea(sc.getType(), presenter, sc.getX(), sc.getY(), width, height, getUserComments() != null, showClose);
dp3.addStyleName("biblioArea"); dp3.addStyleName("biblioArea");
this.content = dp3; this.content = dp3;
break; break;
case PAGEBREAK: case PAGEBREAK:
ReportTextArea dp4 = new ReportTextArea(sc.getType(), presenter, sc.getX(), sc.getY(), width, height, getUserComments() != null); ReportTextArea dp4 = new ReportTextArea(sc.getType(), presenter, sc.getX(), sc.getY(), width, height, getUserComments() != null, showClose);
dp4.addStyleName("pagebreak"); dp4.addStyleName("pagebreak");
this.content = dp4; this.content = dp4;
break; break;
@ -294,12 +297,22 @@ public class TemplateComponent {
case REPEAT_SEQUENCE: case REPEAT_SEQUENCE:
GWT.log("FOUND SEQUENCE trying getGroup"); GWT.log("FOUND SEQUENCE trying getGroup");
RepeatableSequence repeatableSequence = (RepeatableSequence) sc.getPossibleContent(); RepeatableSequence repeatableSequence = (RepeatableSequence) sc.getPossibleContent();
GWT.log("getGroup: " + repeatableSequence.toString()); GWT.log("getGroup: " + repeatableSequence.toString());
ClientRepeatableSequence rps = new ClientRepeatableSequence(presenter, repeatableSequence); ClientRepeatableSequence rps = new ClientRepeatableSequence(presenter, repeatableSequence);
this.content = rps; this.content = rps;
break; break;
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;
} }
} }
/** /**
@ -361,7 +374,7 @@ public class TemplateComponent {
case TITLE: case TITLE:
if (this.isLocked()) { if (this.isLocked()) {
content = ((HTML) this.content).getText(); content = ((HTML) this.content).getText();
} }
else else
content = ((BasicTextArea) this.content).getText(); content = ((BasicTextArea) this.content).getText();
@ -395,12 +408,17 @@ public class TemplateComponent {
RepeatableSequence toStore = new RepeatableSequence(getSerializableSequence(repSeq), height); RepeatableSequence toStore = new RepeatableSequence(getSerializableSequence(repSeq), height);
content = toStore; content = toStore;
break; break;
case BODY_TABLE_IMAGE:
TextTableImage tti = (TextTableImage) this.content;
RepeatableSequence toSave = new RepeatableSequence(getSerializableSequence(tti), height);
content = toSave;
break;
} }
return new BasicComponent(x, y, width, height, templatePage, type, idInBasket, "param empty", content, this.doubleColLayout, isLocked(), metadata); return new BasicComponent(x, y, width, height, templatePage, type, idInBasket, "param empty", content, this.doubleColLayout, isLocked(), metadata);
} }
/** /**
* this method constructs a SerializableRepeatableSequence sequence that can be serializable * this method constructs a RepeatableSequence sequence that can be serializable from the ClientRepeatableSequence
* @param repSeq * @param repSeq
* @return * @return
*/ */
@ -411,6 +429,19 @@ public class TemplateComponent {
} }
return sComps; return sComps;
} }
/**
* 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;
}
/** /**
* @return . * @return .

View File

@ -200,7 +200,7 @@ public class TemplateModel {
BasicComponent references = new BasicComponent(0, 0,TEMPLATE_WIDTH - 50, 35, BasicComponent references = new BasicComponent(0, 0,TEMPLATE_WIDTH - 50, 35,
totalPages, ComponentType.HEADING_2, "", "REFERENCES", false, true, singleSection.getAllMetadata()); totalPages, ComponentType.HEADING_2, "", "REFERENCES", false, true, singleSection.getAllMetadata());
TemplateComponent referencesTC = new TemplateComponent(this, references, presenter); TemplateComponent referencesTC = new TemplateComponent(this, references, presenter, false, null);
singleSection.addComponent(referencesTC); singleSection.addComponent(referencesTC);
sections.put(""+totalPages, singleSection); sections.put(""+totalPages, singleSection);
@ -216,11 +216,11 @@ public class TemplateModel {
TemplateSection singleSection = getSection(totalPages); TemplateSection singleSection = getSection(totalPages);
BasicComponent entry = new BasicComponent(0, 0,TEMPLATE_WIDTH - 50, 35, BasicComponent entry = new BasicComponent(0, 0,TEMPLATE_WIDTH - 50, 35,
totalPages, ComponentType.HEADING_2, "", "Bibliographic Entry", false, true, singleSection.getAllMetadata()); totalPages, ComponentType.HEADING_2, "", "Bibliographic Entry", false, true, singleSection.getAllMetadata());
TemplateComponent entryTC = new TemplateComponent(this, entry, presenter); TemplateComponent entryTC = new TemplateComponent(this, entry, presenter, false, null);
singleSection.addComponent(entryTC); singleSection.addComponent(entryTC);
BasicComponent entryText = new BasicComponent(0, 0,TEMPLATE_WIDTH - 50, 35, BasicComponent entryText = new BasicComponent(0, 0,TEMPLATE_WIDTH - 50, 35,
totalPages, ComponentType.BODY, "", citation, false, false, singleSection.getAllMetadata()); totalPages, ComponentType.BODY, "", citation, false, false, singleSection.getAllMetadata());
TemplateComponent entryTextTC = new TemplateComponent(this, entryText, presenter); TemplateComponent entryTextTC = new TemplateComponent(this, entryText, presenter, false, null);
singleSection.addComponent(entryTextTC); singleSection.addComponent(entryTextTC);
storeInSession(); storeInSession();
} }
@ -295,7 +295,7 @@ public class TemplateModel {
List<TemplateComponent> myTemplateSection = new Vector<TemplateComponent>(); List<TemplateComponent> myTemplateSection = new Vector<TemplateComponent>();
for (BasicComponent sc : serialazableSection.getComponents()) { //for each page component for (BasicComponent sc : serialazableSection.getComponents()) { //for each page component
myTemplateSection.add(new TemplateComponent(this, sc, presenter)); myTemplateSection.add(new TemplateComponent(this, sc, presenter, false, null));
} }
//TODO: load also metadata //TODO: load also metadata
GWT.log("Section Metadata:"+serialazableSection.getMetadata().size(), null); GWT.log("Section Metadata:"+serialazableSection.getMetadata().size(), null);
@ -321,7 +321,7 @@ public class TemplateModel {
BasicSection toImport = toLoad.getSections().get(sectionNoToimport-1); BasicSection toImport = toLoad.getSections().get(sectionNoToimport-1);
List<TemplateComponent> myTemplateSection = new Vector<TemplateComponent>(); List<TemplateComponent> myTemplateSection = new Vector<TemplateComponent>();
for (BasicComponent sc : toImport.getComponents()) { //for each page component for (BasicComponent sc : toImport.getComponents()) { //for each page component
myTemplateSection.add(new TemplateComponent(this, sc, presenter)); myTemplateSection.add(new TemplateComponent(this, sc, presenter, false, null));
} }
//TODO: load also metadata //TODO: load also metadata
GWT.log("Section Metadata:"+toImport.getMetadata().size(), null); GWT.log("Section Metadata:"+toImport.getMetadata().size(), null);

View File

@ -4,14 +4,16 @@ import org.gcube.portlets.d4sreporting.common.shared.ComponentType;
import org.gcube.portlets.user.reportgenerator.client.ReportGenerator; import org.gcube.portlets.user.reportgenerator.client.ReportGenerator;
import org.gcube.portlets.user.reportgenerator.client.Presenter.Presenter; import org.gcube.portlets.user.reportgenerator.client.Presenter.Presenter;
import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.KeyUpEvent; import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler; import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.event.dom.client.MouseDownEvent;
import com.google.gwt.event.dom.client.MouseDownHandler;
import com.google.gwt.event.dom.client.MouseOutEvent; import com.google.gwt.event.dom.client.MouseOutEvent;
import com.google.gwt.event.dom.client.MouseOutHandler; import com.google.gwt.event.dom.client.MouseOutHandler;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasVerticalAlignment; import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.TextArea; import com.google.gwt.user.client.ui.RichTextArea;
import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
/** /**
@ -21,19 +23,21 @@ import com.google.gwt.user.client.ui.Widget;
* @version July 2011 (3.0) * @version July 2011 (3.0)
*/ */
public class BasicTextArea extends ReportTextArea { public class BasicTextArea extends ReportTextArea {
private TextArea textArea = new TextArea(); private RichTextArea textArea = new RichTextArea();
private VerticalPanel myPanel; private VerticalPanel myPanel;
private Presenter presenter;
int currHeight = 0; int currHeight = 0;
public BasicTextArea(ComponentType type, final Presenter presenter, int left, int top, int width, final int height, boolean hasComments) {
super(type, presenter, left, top, width, height, hasComments); public BasicTextArea(ComponentType type, final Presenter presenter, int left, int top, final int width, final int height, boolean hasComments, boolean showClose) {
this.presenter = presenter; super(type, presenter, left, top, width, height, hasComments, showClose);
currHeight = height;
myPanel = getResizablePanel(); myPanel = getResizablePanel();
textArea.setPixelSize(width, height); textArea.setPixelSize(width, height);
textArea.getElement().getStyle().setMarginTop(-4, Unit.PX); //this is needed because the richtextarea has margin 8px and a not able to modify it via css
textArea.addMouseOutHandler(new MouseOutHandler() { textArea.addMouseOutHandler(new MouseOutHandler() {
@ -85,6 +89,33 @@ public class BasicTextArea extends ReportTextArea {
} }
}); });
textArea.addKeyUpHandler(new KeyUpHandler() {
public void onKeyUp(KeyUpEvent event) {
HTML div = ReportGenerator.get().getDivHidden();
div.setHTML(textArea.getHTML());
int newHeight = div.getOffsetHeight();
if (newHeight > currHeight) {
resizePanel(width, newHeight);
presenter.resizeTemplateComponentInModel(myInstance, width, newHeight);
currHeight = newHeight;
}
}
});
textArea.addMouseDownHandler(new MouseDownHandler() {
public void onMouseDown(MouseDownEvent event) {
HTML div = ReportGenerator.get().getDivHidden();
div.setHTML(textArea.getHTML());
int newHeight = div.getOffsetHeight();
if (newHeight > currHeight) {
resizePanel(width, newHeight);
presenter.resizeTemplateComponentInModel(myInstance, width, newHeight);
currHeight = newHeight;
}
}
});
} }
public String getText() { public String getText() {
return textArea.getText(); return textArea.getText();
@ -93,5 +124,19 @@ public class BasicTextArea extends ReportTextArea {
textArea.setText(text); textArea.setText(text);
} }
/**
* used to resize the panel
* @param width w
* @param height h
*/
@Override
public void resizePanel(int width, int height) {
if (height > 25) {
mainPanel.setPixelSize(width, height);
resizablePanel.setPixelSize(width, height);
textArea.setPixelSize(width-4, height);
currHeight = height;
}
}
} }

View File

@ -14,6 +14,7 @@ import com.google.gwt.event.dom.client.MouseDownHandler;
import com.google.gwt.event.dom.client.MouseOutEvent; import com.google.gwt.event.dom.client.MouseOutEvent;
import com.google.gwt.event.dom.client.MouseOutHandler; import com.google.gwt.event.dom.client.MouseOutHandler;
import com.google.gwt.user.client.Event; import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasVerticalAlignment; import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.RichTextArea; import com.google.gwt.user.client.ui.RichTextArea;
@ -48,6 +49,8 @@ public class D4sRichTextarea extends ReportTextArea {
*/ */
public D4sRichTextarea() {} public D4sRichTextarea() {}
private TextTableImage owner;
/** /**
* *
* @param presenter . * @param presenter .
@ -57,8 +60,10 @@ public class D4sRichTextarea extends ReportTextArea {
* @param height . * @param height .
* @param type . * @param type .
*/ */
public D4sRichTextarea(ComponentType type, final Presenter presenter, int left, int top, int width, final int height, boolean hasComments) { public D4sRichTextarea(ComponentType type, final Presenter presenter, int left, int top, final int width,
super(type, presenter, left, top, width, height, hasComments); final int height, boolean hasComments, boolean showClose, TextTableImage owner) {
super(type, presenter, left, top, width, height, hasComments, showClose);
this.owner = owner;
currHeight = height; currHeight = height;
myPanel = getResizablePanel(); myPanel = getResizablePanel();
@ -91,16 +96,16 @@ public class D4sRichTextarea extends ReportTextArea {
presenter.enableTextToolBar(area); presenter.enableTextToolBar(area);
presenter.enableBiblioEntry(area); presenter.enableBiblioEntry(area);
firstClick = false; firstClick = false;
ReportGenerator.get().getDivHidden().setPixelSize(area.getOffsetWidth(), -1); ReportGenerator.get().getDivHidden().setPixelSize(width, -1);
} }
HTML div = ReportGenerator.get().getDivHidden(); HTML div = ReportGenerator.get().getDivHidden();
div.setHTML(area.getHTML()); div.setHTML(area.getHTML());
int newHeight = div.getOffsetHeight()+20 ; int newHeight = div.getOffsetHeight()+20 ;
if (newHeight > height-10 && newHeight != currHeight) { if (newHeight > height-10 && newHeight != currHeight) {
presenter.shiftComponentsByTextArea(myInstance.top, newHeight - currHeight); presenter.shiftComponentsByTextArea(myInstance.top, newHeight - currHeight);
resizePanel(myPanel.getOffsetWidth(), div.getOffsetHeight()); resizePanel(width, div.getOffsetHeight());
//Window.alert("myInstance.top: " + myInstance.top); //Window.alert("myInstance.top: " + myInstance.top);
presenter.resizeTemplateComponentInModel(myInstance, myPanel.getOffsetWidth(), newHeight); presenter.resizeTemplateComponentInModel(myInstance, width, newHeight);
} }
} }
}); });
@ -112,42 +117,7 @@ public class D4sRichTextarea extends ReportTextArea {
} }
}); });
//TODO: aggiorna
// area.addKeyDownHandler(new KeyDownHandler() {
// public void onKeyDown(KeyDownEvent event) {
//// if (event.isAnyModifierKeyDown() && event.getNativeKeyCode() == 86) { //event.getNativeKeyCode() == 86 is the V (to avoid ctrl V or cmd V)
//// MessageBox.show(new MessageBoxConfig() {
//// {
//// setTitle("Paste operation");
//// setMsg("Please enter your text here (PLAIN)");
//// setWidth(500);
//// setButtons(MessageBox.OKCANCEL);
//// setMultiline(true);
//// setCallback(new MessageBox.PromptCallback() {
//// public void execute(String btnID, String text) {
//// if (btnID.compareTo("ok") == 0) {
//// area.setText(text);
////
//// //resize if needed
//// HTML div = ReportGenerator.get().getDivHidden();
//// //GWT.log("element.getHTML():\n" + area.getHTML(), null);
//// div.setHTML(area.getHTML());
//// int newHeight = div.getOffsetHeight()+20 ;
//// if (newHeight > height-10 && newHeight != currHeight) {
//// resizePanel(myPanel.getOffsetWidth(), div.getOffsetHeight());
//// }
//// }
////
//// }
//// });
//// }
//// });
// event.stopPropagation();
// event.preventDefault();
// }
//
// }
// });
area.addKeyUpHandler(new KeyUpHandler() { area.addKeyUpHandler(new KeyUpHandler() {
public void onKeyUp(KeyUpEvent event) { public void onKeyUp(KeyUpEvent event) {
HTML div = ReportGenerator.get().getDivHidden(); HTML div = ReportGenerator.get().getDivHidden();
@ -174,7 +144,7 @@ public class D4sRichTextarea extends ReportTextArea {
mainPanel.setPixelSize(width, height+20); mainPanel.setPixelSize(width, height+20);
resizablePanel.setPixelSize(width, height+20); resizablePanel.setPixelSize(width, height+20);
mainPanel.setWidgetPosition(topPanel, width-30 , 0); mainPanel.setWidgetPosition(topPanel, width-30 , 0);
area.setPixelSize(width-4, height+20); area.setPixelSize(width, height+20);
currHeight = height + 20; currHeight = height + 20;
} }
} }
@ -208,4 +178,12 @@ public class D4sRichTextarea extends ReportTextArea {
public void setFirstClick(boolean firstClick) { public void setFirstClick(boolean firstClick) {
this.firstClick = firstClick; this.firstClick = firstClick;
} }
@Override
public void removeTemplateComponent() {
if (owner != null) {
owner.removeFromParent(this);
removeFromParent();
}
}
} }

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.user.reportgenerator.client.targets; package org.gcube.portlets.user.reportgenerator.client.targets;
import org.gcube.portlets.d4sreporting.common.client.ImageConstants; import org.gcube.portlets.d4sreporting.common.client.ImageConstants;
import org.gcube.portlets.d4sreporting.common.client.uicomponents.ReportUIComponent;
import org.gcube.portlets.d4sreporting.common.shared.ComponentType; import org.gcube.portlets.d4sreporting.common.shared.ComponentType;
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.dialog.CommentDialog; import org.gcube.portlets.user.reportgenerator.client.dialog.CommentDialog;
@ -9,6 +10,7 @@ import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.AbsolutePanel; import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment; import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.Image;
@ -40,14 +42,16 @@ public class ReportTextArea extends Composite {
private Presenter presenter; private Presenter presenter;
private ComponentType type; private ComponentType type;
protected AbsolutePanel mainPanel; protected AbsolutePanel mainPanel;
protected HorizontalPanel topPanel; protected HorizontalPanel topPanel;
protected VerticalPanel resizablePanel; protected VerticalPanel resizablePanel;
protected Image commentImage; protected Image commentImage;
private HTML closeImage = new HTML();
/** /**
* *
* @return . * @return .
@ -74,9 +78,9 @@ public class ReportTextArea extends Composite {
* @param height . * @param height .
* @param type a * @param type a
*/ */
public ReportTextArea(ComponentType type, final Presenter presenter, int left, int top, int width, int height, boolean hasComments) { public ReportTextArea(ComponentType type, final Presenter presenter, int left, int top, int width, int height, boolean hasComments, boolean isRemovable) {
myInstance = this; myInstance = this;
this.type = type; this.type = type;
this.presenter = presenter; this.presenter = presenter;
@ -94,11 +98,11 @@ public class ReportTextArea extends Composite {
topPanel.setPixelSize(30, 15); topPanel.setPixelSize(30, 15);
resizablePanel.setPixelSize(width, height); resizablePanel.setPixelSize(width, height);
commentImage = new Image((hasComments) ? ImageConstants.IMAGE_COMMENTS : ImageConstants.IMAGE_COMMENTS_GRAY); commentImage = new Image((hasComments) ? ImageConstants.IMAGE_COMMENTS : ImageConstants.IMAGE_COMMENTS_GRAY);
commentImage.setTitle("Show user comments"); commentImage.setTitle("Show user comments");
topPanel.add(commentImage); topPanel.add(commentImage);
commentImage.setStyleName("selectable"); commentImage.setStyleName("selectable");
commentImage.addClickHandler(new ClickHandler() { commentImage.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
@ -111,16 +115,33 @@ public class ReportTextArea extends Composite {
dlg.show(); dlg.show();
} }
}); });
topPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); topPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
mainPanel.add(resizablePanel, 0, 0); mainPanel.add(resizablePanel, 0, 0);
mainPanel.add(topPanel, width-18, 0); mainPanel.add(topPanel, width-30, 0);
mainPanel.setStyleName("d4sFrame"); mainPanel.setStyleName("d4sFrame");
initWidget(mainPanel); initWidget(mainPanel);
}
if (isRemovable) {
closeImage.setHeight("15px");
closeImage.setStyleName("closeImage");
closeImage.setTitle("Click to remove");
topPanel.add(closeImage);
}
closeImage.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
remove();
}
});
}
private void remove() {
removeTemplateComponent();
}
public void removeTemplateComponent() { }
/** /**
* *
* @return . * @return .
@ -137,7 +158,7 @@ public class ReportTextArea extends Composite {
this.type = type; this.type = type;
} }
/** /**
* used to resize the panel * used to resize the panel
* @param width w * @param width w
@ -150,8 +171,8 @@ public class ReportTextArea extends Composite {
mainPanel.setWidgetPosition(topPanel, width-15, 0); mainPanel.setWidgetPosition(topPanel, width-15, 0);
} }
} }
/*** /***
* *
* @param height g * @param height g
@ -173,8 +194,8 @@ public class ReportTextArea extends Composite {
public void repositionMyPanel(int left, int top) { public void repositionMyPanel(int left, int top) {
//mainPanel.setWidgetPosition(resizablePanel, left, top); //mainPanel.setWidgetPosition(resizablePanel, left, top);
} }
/** /**
* @return . * @return .
*/ */
@ -215,7 +236,7 @@ public class ReportTextArea extends Composite {
return presenter; return presenter;
} }
/** /**
* *
* @return . * @return .
@ -223,7 +244,7 @@ public class ReportTextArea extends Composite {
public ReportTextArea getMyInstance() { public ReportTextArea getMyInstance() {
return myInstance; return myInstance;
} }
/** /**
* *
* @param myInstance . * @param myInstance .
@ -238,23 +259,23 @@ public class ReportTextArea extends Composite {
public void addCommentView() { public void addCommentView() {
commentImage.setUrl(ImageConstants.IMAGE_COMMENTS); commentImage.setUrl(ImageConstants.IMAGE_COMMENTS);
} }
public void showComment(String comment) { public void showComment(String comment) {
// final Window window = new Window(); // final Window window = new Window();
// window.setTitle(""); // window.setTitle("");
// window.setMaximizable(true); // window.setMaximizable(true);
// window.setResizable(true); // window.setResizable(true);
// window.setLayout(new FitLayout()); // window.setLayout(new FitLayout());
// window.setWidth(200); // window.setWidth(200);
// window.setHeight(100); // window.setHeight(100);
// window.setModal(false); // window.setModal(false);
// //
// Panel windowPanel = new Panel(); // Panel windowPanel = new Panel();
// windowPanel.setBaseCls("comment-popup"); // windowPanel.setBaseCls("comment-popup");
// windowPanel.setHtml(comment); // windowPanel.setHtml(comment);
// windowPanel.setShadow(true); // windowPanel.setShadow(true);
// window.add(windowPanel); // window.add(windowPanel);
// window.setPosition(commentImage.getAbsoluteLeft()+25, commentImage.getAbsoluteTop()); // window.setPosition(commentImage.getAbsoluteLeft()+25, commentImage.getAbsoluteTop());
// window.show(); // window.show();
} }
} }

View File

@ -62,7 +62,7 @@ public class SequenceWidget extends Composite {
sComp.setPossibleContent(""); sComp.setPossibleContent("");
sComp.setMetadata(new ArrayList<Metadata>()); sComp.setMetadata(new ArrayList<Metadata>());
} }
add(new TemplateComponent(p.getModel(), sComp, p)); add(new TemplateComponent(p.getModel(), sComp, p, false, null));
} }
initWidget(myPanel); initWidget(myPanel);

View File

@ -0,0 +1,156 @@
package org.gcube.portlets.user.reportgenerator.client.targets;
import java.util.ArrayList;
import org.gcube.portlets.d4sreporting.common.shared.BasicComponent;
import org.gcube.portlets.d4sreporting.common.shared.ComponentType;
import org.gcube.portlets.d4sreporting.common.shared.RepeatableSequence;
import org.gcube.portlets.user.reportgenerator.client.Presenter.Presenter;
import org.gcube.portlets.user.reportgenerator.client.model.TemplateComponent;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
/**
*
* @author Massimiliano Assante ISTI-CNR
*
*/
public class TextTableImage extends Composite {
public static final int DEFAULT_HEIGHT = 100;
public static final int DEFAULT_WIDTH = 700;
private FocusPanel focusPanel = new FocusPanel();
private VerticalPanel mainPanel = new VerticalPanel();
private HorizontalPanel controlPanel;
private Button addTextB = new Button("Add Text");
private Button addImageB = new Button("Add Image");
private Button addTableB = new Button("Add Table");
private Presenter presenter;
private ArrayList<TemplateComponent> addedComponents = new ArrayList<TemplateComponent>();
/**
* constructor to be used when reading from a template
* @param presenter
*/
public TextTableImage(Presenter presenter, boolean isFromTemplate) {
this.presenter = presenter;
mainPanel.setStyleName("imageTableTextPanel");
controlPanel = getControlPanel();
controlPanel.setStyleName("imageTableTextControlPanel");
mainPanel.add(controlPanel);
focusPanel.add(mainPanel);
initWidget(focusPanel);
if (isFromTemplate) {
int height = 40;
D4sRichTextarea firstText = new D4sRichTextarea(ComponentType.BODY, presenter, 0, 0, DEFAULT_WIDTH, height, false, true, this);
firstText.setPixelSize(DEFAULT_WIDTH, height);
mainPanel.add(firstText);
//construct the first component and add it
TemplateComponent toAdd = new TemplateComponent(presenter.getModel(), 0, 0, DEFAULT_WIDTH, height,
presenter.getModel().getCurrentPage(), ComponentType.BODY, "", firstText);
add(toAdd);
}
}
/**
* constructor to be used when reading from a report
* @param presenter
* @param sRS
*/
public TextTableImage(Presenter presenter, RepeatableSequence sRS) {
this(presenter, false);
if (sRS != null && sRS.getGroupedComponents().size() > 0) {
for (BasicComponent sComp : sRS.getGroupedComponents()) {
add(new TemplateComponent(presenter.getModel(), sComp, presenter, true, this));
}
}
}
public void add(TemplateComponent toAdd) {
addedComponents.add(toAdd);
GWT.log("ToAdd= getType " + toAdd.getType());
mainPanel.add(toAdd.getContent());
}
private void addNewText() {
int height = 40;
D4sRichTextarea text = new D4sRichTextarea(ComponentType.BODY, presenter, 0, 0, DEFAULT_WIDTH, height, false, true, this);
text.setPixelSize(DEFAULT_WIDTH, height);
TemplateComponent toAdd = new TemplateComponent(presenter.getModel(), 0, 0, DEFAULT_WIDTH, height,
presenter.getModel().getCurrentPage(), ComponentType.BODY, "", text);
add(toAdd);
}
private void addNewTable() {
}
/**
*
* @return
*/
private HorizontalPanel getControlPanel() {
final HorizontalPanel toReturn = new HorizontalPanel();
addTextB.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
addNewText();
}
});
addImageB.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
}
});
addTableB.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
}
});
toReturn.setSpacing(3);
toReturn.add(addTextB);
toReturn.add(addTableB);
toReturn.add(addImageB);
//set style for buttons
for (int i = 0; i < toReturn.getWidgetCount(); i++) {
if (toReturn.getWidget(i) instanceof Button) {
Button b = (Button) toReturn.getWidget(i);
b.addStyleName("tableButton");
}
}
return toReturn;
}
public ArrayList<TemplateComponent> getAddedComponents() {
return addedComponents;
}
public void removeFromParent(D4sRichTextarea d4sRichTextarea) {
for (TemplateComponent tc : addedComponents) {
if (tc.getType() == ComponentType.BODY) {
D4sRichTextarea toCheck = (D4sRichTextarea) tc.getContent();
if (toCheck.equals(d4sRichTextarea)) {
addedComponents.remove(tc);
break;
}
}
}
}
}

View File

@ -878,8 +878,6 @@ public class ReportServiceImpl extends RemoteServiceServlet implements ReportSe
ASLSession d4Session = getASLSession(); ASLSession d4Session = getASLSession();
d4Session.setAttribute(CURRENT_REPORT_INSTANCE, model); d4Session.setAttribute(CURRENT_REPORT_INSTANCE, model);
System.out.println("SAVED");
Vector<BasicSection> sections = model.getSections(); Vector<BasicSection> sections = model.getSections();
for (BasicSection section : sections) { for (BasicSection section : sections) {
for (BasicComponent component : section.getComponents()) { for (BasicComponent component : section.getComponents()) {

View File

@ -1,5 +1,21 @@
@import url('reports/old-dialog.css'); @import url('reports/old-dialog.css');
.closeImage {
background: url(images/close.png) 0px 0px no-repeat;
height: 15px;
width: 15px;
}
.closeImage:hover {
background: url(images/close.png) 0px -16px no-repeat;
cursor: pointer;
cursor: hand;
}
.closeImage:active {
background: url(images/close.png) 0px -32px no-repeat;
}
.deleteEntryButton { .deleteEntryButton {
background-image: none !important; background-image: none !important;
background-repeat: none !important; background-repeat: none !important;
@ -40,6 +56,16 @@
width: 600px; width: 600px;
} }
.imageTableTextPanel {
background-color: transparent;
margin: 8px 0px;
}
.imageTableTextControlPanel {
margin-top: 5px;
}
.imageWrapperPanel { .imageWrapperPanel {
background-color: transparent; background-color: transparent;
border-bottom: 2px dashed #FFF; border-bottom: 2px dashed #FFF;
@ -452,8 +478,6 @@ tableBorder td {
.setVisibilityOn { .setVisibilityOn {
margin-top: 1px; margin-top: 1px;
visibility: visible; visibility: visible;
cursor: pointer;
cursor: hand;
} }
.templateFrame { .templateFrame {
@ -662,38 +686,4 @@ gwt-MenuBar {
.cw-RichText { .cw-RichText {
border: 1px solid #BBBBBB; border: 1px solid #BBBBBB;
border-spacing: 0px; border-spacing: 0px;
}
/* *********** FANCY FILE UPLOAD **************/
.fancyfileupload-pending {
font-family: arial;
font-size: 10px;
background: orange;
width: 200px;
}
.fancyfileupload-loading {
font-family: arial;
font-size: 10px;
background: orange;
width: 200px;
}
.fancyfileupload-loaded {
font-family: arial;
font-size: 10px;
background: lightgreen;
width: 200px;
}
.fancyfileupload-failed {
font-family: arial;
font-size: 10px;
background: blue;
width: 200px;
}
/* *********** END FANCY FILE UPLOAD **************/
.droppingArea-Text {
border: 1px inset black;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 715 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1002 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1023 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1021 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1018 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB