Table attributes support implemented

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/reports@70977 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2013-03-06 18:42:20 +00:00
parent 00486c87fa
commit ff80982188
4 changed files with 70 additions and 56 deletions

View File

@ -5,18 +5,18 @@ import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.gcube.portlets.d4sreporting.common.shared.ComponentType;
import org.gcube.portlets.d4sreporting.common.shared.Metadata;
import org.gcube.portlets.d4sreporting.common.shared.Attribute;
import org.gcube.portlets.d4sreporting.common.shared.AttributeArea; import org.gcube.portlets.d4sreporting.common.shared.AttributeArea;
import org.gcube.portlets.d4sreporting.common.shared.BasicComponent; import org.gcube.portlets.d4sreporting.common.shared.BasicComponent;
import org.gcube.portlets.d4sreporting.common.shared.ComponentType;
import org.gcube.portlets.d4sreporting.common.shared.Metadata;
import org.gcube.portlets.d4sreporting.common.shared.RepTimeSeries;
import org.gcube.portlets.d4sreporting.common.shared.RepeatableSequence; import org.gcube.portlets.d4sreporting.common.shared.RepeatableSequence;
import org.gcube.portlets.d4sreporting.common.shared.Table; import org.gcube.portlets.d4sreporting.common.shared.Table;
import org.gcube.portlets.d4sreporting.common.shared.RepTimeSeries;
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.targets.AttributeMultiSelection; import org.gcube.portlets.user.reportgenerator.client.targets.AttributeMultiSelection;
import org.gcube.portlets.user.reportgenerator.client.targets.AttributeSingleSelection; import org.gcube.portlets.user.reportgenerator.client.targets.AttributeSingleSelection;
import org.gcube.portlets.user.reportgenerator.client.targets.BasicTextArea; import org.gcube.portlets.user.reportgenerator.client.targets.BasicTextArea;
import org.gcube.portlets.user.reportgenerator.client.targets.ClientRepeatableSequence;
import org.gcube.portlets.user.reportgenerator.client.targets.D4sRichTextarea; import org.gcube.portlets.user.reportgenerator.client.targets.D4sRichTextarea;
import org.gcube.portlets.user.reportgenerator.client.targets.DropImageListener; import org.gcube.portlets.user.reportgenerator.client.targets.DropImageListener;
import org.gcube.portlets.user.reportgenerator.client.targets.DropTSListener; import org.gcube.portlets.user.reportgenerator.client.targets.DropTSListener;
@ -25,16 +25,13 @@ 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.GroupingInnerArea; import org.gcube.portlets.user.reportgenerator.client.targets.GroupingInnerArea;
import org.gcube.portlets.user.reportgenerator.client.targets.ImageArea; import org.gcube.portlets.user.reportgenerator.client.targets.ImageArea;
import org.gcube.portlets.user.reportgenerator.client.targets.ClientRepeatableSequence;
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 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;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.RadioButton;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
@ -411,21 +408,11 @@ public class TemplateComponent {
break; break;
case ATTRIBUTE_MULTI: case ATTRIBUTE_MULTI:
AttributeMultiSelection att = (AttributeMultiSelection) this.content; AttributeMultiSelection att = (AttributeMultiSelection) this.content;
ArrayList<Attribute> values = new ArrayList<Attribute>(); content = att.getSerializable();
for (CheckBox box : att.getBoxes()) {
values.add(new Attribute(box.getText().trim(), box.getValue()));
}
AttributeArea sat= new AttributeArea(att.getAttrName().trim(), values);
content = sat;
break; break;
case ATTRIBUTE_UNIQUE: case ATTRIBUTE_UNIQUE:
AttributeSingleSelection atu = (AttributeSingleSelection) this.content; AttributeSingleSelection atu = (AttributeSingleSelection) this.content;
ArrayList<Attribute> singlevalues = new ArrayList<Attribute>(); content = atu.getSerializable();
for (RadioButton box : atu.getBoxes()) {
singlevalues.add(new Attribute(box.getText().trim(), box.getValue()));
}
AttributeArea satu = new AttributeArea(atu.getAttrName().trim(), singlevalues);
content = satu;
break; break;
case COMMENT: case COMMENT:
content = ((HTML) this.content).getHTML(); content = ((HTML) this.content).getHTML();

View File

@ -1,10 +1,11 @@
package org.gcube.portlets.user.reportgenerator.client.targets; package org.gcube.portlets.user.reportgenerator.client.targets;
import org.gcube.portlets.d4sreporting.common.shared.ComponentType; import java.util.ArrayList;
import org.gcube.portlets.d4sreporting.common.shared.Attribute; import org.gcube.portlets.d4sreporting.common.shared.Attribute;
import org.gcube.portlets.d4sreporting.common.shared.AttributeArea; import org.gcube.portlets.d4sreporting.common.shared.AttributeArea;
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 com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
@ -137,6 +138,13 @@ public class AttributeMultiSelection extends Composite {
return attrName; return attrName;
} }
public AttributeArea getSerializable() {
ArrayList<Attribute> values = new ArrayList<Attribute>();
for (CheckBox box : getBoxes()) {
values.add(new Attribute(box.getText().trim(), box.getValue()));
}
return new AttributeArea(getAttrName().trim(), values);
}
} }

View File

@ -1,12 +1,13 @@
package org.gcube.portlets.user.reportgenerator.client.targets; package org.gcube.portlets.user.reportgenerator.client.targets;
import java.util.ArrayList;
import org.gcube.portlets.d4sreporting.common.shared.Attribute; import org.gcube.portlets.d4sreporting.common.shared.Attribute;
import org.gcube.portlets.d4sreporting.common.shared.AttributeArea; import org.gcube.portlets.d4sreporting.common.shared.AttributeArea;
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 com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.FlowPanel;
@ -22,7 +23,7 @@ import com.google.gwt.user.client.ui.RadioButton;
*/ */
public class AttributeSingleSelection extends Composite { public class AttributeSingleSelection extends Composite {
private final String RADIO_NAME = "radio_unique"; private final String RADIO_NAME = "radio_unique"+(int)(Math.random()*10000);
private HorizontalPanel myPanel; private HorizontalPanel myPanel;
private String attrName; private String attrName;
private RadioButton[] boxes; private RadioButton[] boxes;
@ -122,7 +123,7 @@ public class AttributeSingleSelection extends Composite {
* @return * @return
*/ */
public ComponentType getType() { public ComponentType getType() {
return ComponentType.ATTRIBUTE_MULTI; return ComponentType.ATTRIBUTE_UNIQUE;
} }
/** /**
* *
@ -139,6 +140,13 @@ public class AttributeSingleSelection extends Composite {
return attrName; return attrName;
} }
public AttributeArea getSerializable() {
ArrayList<Attribute> singlevalues = new ArrayList<Attribute>();
for (RadioButton box : getBoxes()) {
singlevalues.add(new Attribute(box.getText().trim(), box.getValue()));
}
return new AttributeArea(getAttrName().trim(), singlevalues);
}
} }

View File

@ -39,30 +39,33 @@ public class GenericTable extends Composite {
public static final int DEFAULT_COLS_NUM = 2; public static final int DEFAULT_COLS_NUM = 2;
private FocusPanel focusPanel = new FocusPanel(); private FocusPanel focusPanel = new FocusPanel();
private VerticalPanel myPanel = new VerticalPanel(); private VerticalPanel myPanel = new VerticalPanel();
private FlexTable myTable; private FlexTable myTable;
Presenter presenter; Presenter presenter;
private int rows; private int rows;
private int cols; private int cols;
private int width; private int width;
private boolean isEditTableMode = false; private boolean isEditTableMode = false;
private AttributeSingleSelection attrSS;
private Button cellMerger = new Button("Merge Cells"); private Button cellMerger = new Button("Merge Cells");
private Button colMerger = new Button("Merge Selected"); private Button colMerger = new Button("Merge Selected");
private Button cancel = new Button("Cancel"); private Button cancel = new Button("Cancel");
private Button resetTabelB = new Button("Reset Table"); private Button resetTabelB = new Button("Reset Table");
private Button addRowB = new Button("Add Row"); private Button addRowB = new Button("Add Row");
private Button addColB = new Button("Add Col"); private Button addColB = new Button("Add Col");
private Button deleteRowB = new Button("Del. Row"); private Button deleteRowB = new Button("Del. Row");
private Button deleteColB = new Button("Del. Col"); private Button deleteColB = new Button("Del. Col");
private TextBox titleTB = new TextBox(); private TextBox titleTB = new TextBox();
private TextBox descTB = new TextBox(); private TextBox descTB = new TextBox();
@ -71,7 +74,7 @@ public class GenericTable extends Composite {
private int cellPadding = 0; private int cellPadding = 0;
private GenTableCell selectedCell = null; private GenTableCell selectedCell = null;
private Table originalTable; private Table originalTable;
/** /**
@ -103,28 +106,28 @@ public class GenericTable extends Composite {
toAdd.addClickHandler(cellClicker); toAdd.addClickHandler(cellClicker);
} }
} }
HorizontalPanel controlPanel = getControlPanel(); HorizontalPanel controlPanel = getControlPanel();
VerticalPanel attributesPanel = getAttributesPanel(); VerticalPanel attributesPanel = getAttributesPanel(sTable);
attributesPanel.setStyleName("tableAttributesPanel"); attributesPanel.setStyleName("tableAttributesPanel");
controlPanel.setStyleName("tableControlPanel"); controlPanel.setStyleName("tableControlPanel");
myPanel.add(controlPanel); myPanel.add(controlPanel);
myPanel.add(myTable); myPanel.add(myTable);
myPanel.add(attributesPanel); myPanel.add(attributesPanel);
myPanel.setStyleName("tablePanel"); myPanel.setStyleName("tablePanel");
for (int i = 0; i < controlPanel.getWidgetCount(); i++) { for (int i = 0; i < controlPanel.getWidgetCount(); i++) {
if (controlPanel.getWidget(i) instanceof Button) { if (controlPanel.getWidget(i) instanceof Button) {
Button b = (Button) controlPanel.getWidget(i); Button b = (Button) controlPanel.getWidget(i);
b.addStyleName("tableButton"); b.addStyleName("tableButton");
} }
} }
focusPanel.add(myPanel); focusPanel.add(myPanel);
initWidget(focusPanel); initWidget(focusPanel);
focusPanel.addMouseOutHandler(new MouseOutHandler() { focusPanel.addMouseOutHandler(new MouseOutHandler() {
@Override @Override
public void onMouseOut(MouseOutEvent event) { public void onMouseOut(MouseOutEvent event) {
@ -132,7 +135,7 @@ public class GenericTable extends Composite {
} }
}); });
} }
private void saveTable(Table sTable) { private void saveTable(Table sTable) {
originalTable = new Table(sTable.getColsNo()); originalTable = new Table(sTable.getColsNo());
originalTable.setTable(sTable.getTable()); originalTable.setTable(sTable.getTable());
@ -161,30 +164,36 @@ public class GenericTable extends Composite {
int cellWidth = width / cols; int cellWidth = width / cols;
return cellWidth; return cellWidth;
} }
private VerticalPanel getAttributesPanel() { private VerticalPanel getAttributesPanel(Table sTable) {
VerticalPanel toReturn = new VerticalPanel(); VerticalPanel toReturn = new VerticalPanel();
HorizontalPanel hp1 = new HorizontalPanel(); HorizontalPanel hp1 = new HorizontalPanel();
HTML title = new HTML("Title: <span style=\"color: red;\">*&nbsp;</span>", true); HTML title = new HTML("Title: <span style=\"color: red;\">*&nbsp;</span>", true);
hp1.add(title); hp1.add(title);
hp1.add(titleTB); hp1.add(titleTB);
titleTB.setWidth("135px"); titleTB.setWidth("135px");
titleTB.setText(sTable.getTitle());
HTML desc = new HTML("&nbsp;Description: <span style=\"color: red;\">*&nbsp;</span>", true); HTML desc = new HTML("&nbsp;Description: <span style=\"color: red;\">*&nbsp;</span>", true);
//desc.setStyleName("attributeArea"); //desc.setStyleName("attributeArea");
hp1.add(desc); hp1.add(desc);
hp1.add(descTB); hp1.add(descTB);
descTB.setWidth("435px"); descTB.setWidth("435px");
descTB.setText(sTable.getDescription());
toReturn.add(hp1); toReturn.add(hp1);
AttributeSingleSelection attrSS = new AttributeSingleSelection(presenter, 0, 0, 700, 0, "DisplayType:Token|Inline|Link|Popup"); if (sTable.getAttrArea() != null) {
attrSS = new AttributeSingleSelection(presenter, 0, 0, 700, 0, sTable.getAttrArea());
}
else
attrSS = new AttributeSingleSelection(presenter, 0, 0, 700, 0, "DisplayType:Token|Inline|Link|Popup");
toReturn.add(attrSS); toReturn.add(attrSS);
return toReturn; return toReturn;
} }
/** /**
* *
* @return * @return
@ -204,7 +213,7 @@ public class GenericTable extends Composite {
resetMe(); resetMe();
} }
}); });
addRowB.addClickHandler(new ClickHandler() { addRowB.addClickHandler(new ClickHandler() {
@Override @Override
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
@ -284,8 +293,8 @@ public class GenericTable extends Composite {
}); });
return toReturn; return toReturn;
} }
/** /**
* *
@ -417,7 +426,10 @@ public class GenericTable extends Composite {
for (int i = 0; i < myTable.getRowCount(); i++) { for (int i = 0; i < myTable.getRowCount(); i++) {
toReturn.addRow(getRow(i)); toReturn.addRow(getRow(i));
} }
toReturn.setTitle(titleTB.getText());
toReturn.setDescription(descTB.getText());
toReturn.setAttrArea(attrSS.getSerializable());
return toReturn; return toReturn;
} }
@ -471,7 +483,7 @@ public class GenericTable extends Composite {
deleteRow(rows-1); deleteRow(rows-1);
rows--; rows--;
} }
private void deleteLastColumn() { private void deleteLastColumn() {
deleteColumn(cols-1); deleteColumn(cols-1);
} }
@ -561,7 +573,7 @@ public class GenericTable extends Composite {
Info.display("Info", "Table Row removed successfully"); Info.display("Info", "Table Row removed successfully");
} }
} }
/** /**
* delete the colIndex column from the table * delete the colIndex column from the table
*/ */
@ -589,17 +601,16 @@ public class GenericTable extends Composite {
//Info.display("Info", "Table Column removed successfully"); //Info.display("Info", "Table Column removed successfully");
} }
} }
protected void resetMe() { protected void resetMe() {
myTable.clear(); myTable.removeAllRows();
/** /**
* construct the table * construct the table
*/ */
for (int i = 0; i < originalTable.getRowCount(); i++) { for (int i = 0; i < originalTable.getRowCount(); i++) {
for (int j = 0; j < originalTable.getColsNo(); j++) { for (int j = 0; j < originalTable.getColsNo(); j++) {
TableCell toPut = new TableCell(""); int cellWidth = getCellWidth(originalTable.getColsNo());
int cellWidth = toPut.getCellWidth();
GenTableCell toAdd = new GenTableCell(i, j, cellWidth, 1); GenTableCell toAdd = new GenTableCell(i, j, cellWidth, 1);
toAdd.setText(""); toAdd.setText("");
toAdd.setStyleName("tableBorder"); toAdd.setStyleName("tableBorder");