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.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.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.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.targets.AttributeMultiSelection;
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.ClientRepeatableSequence;
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.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.GroupingInnerArea;
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.TSArea;
import com.google.gwt.core.client.GWT;
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.Image;
import com.google.gwt.user.client.ui.RadioButton;
import com.google.gwt.user.client.ui.Widget;
@ -411,21 +408,11 @@ public class TemplateComponent {
break;
case ATTRIBUTE_MULTI:
AttributeMultiSelection att = (AttributeMultiSelection) this.content;
ArrayList<Attribute> values = new ArrayList<Attribute>();
for (CheckBox box : att.getBoxes()) {
values.add(new Attribute(box.getText().trim(), box.getValue()));
}
AttributeArea sat= new AttributeArea(att.getAttrName().trim(), values);
content = sat;
content = att.getSerializable();
break;
case ATTRIBUTE_UNIQUE:
AttributeSingleSelection atu = (AttributeSingleSelection) this.content;
ArrayList<Attribute> singlevalues = new ArrayList<Attribute>();
for (RadioButton box : atu.getBoxes()) {
singlevalues.add(new Attribute(box.getText().trim(), box.getValue()));
}
AttributeArea satu = new AttributeArea(atu.getAttrName().trim(), singlevalues);
content = satu;
content = atu.getSerializable();
break;
case COMMENT:
content = ((HTML) this.content).getHTML();

View File

@ -1,10 +1,11 @@
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.AttributeArea;
import org.gcube.portlets.d4sreporting.common.shared.ComponentType;
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.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Composite;
@ -137,6 +138,13 @@ public class AttributeMultiSelection extends Composite {
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;
import java.util.ArrayList;
import org.gcube.portlets.d4sreporting.common.shared.Attribute;
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 com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.Composite;
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 {
private final String RADIO_NAME = "radio_unique";
private final String RADIO_NAME = "radio_unique"+(int)(Math.random()*10000);
private HorizontalPanel myPanel;
private String attrName;
private RadioButton[] boxes;
@ -122,7 +123,7 @@ public class AttributeSingleSelection extends Composite {
* @return
*/
public ComponentType getType() {
return ComponentType.ATTRIBUTE_MULTI;
return ComponentType.ATTRIBUTE_UNIQUE;
}
/**
*
@ -139,6 +140,13 @@ public class AttributeSingleSelection extends Composite {
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;
private FocusPanel focusPanel = new FocusPanel();
private VerticalPanel myPanel = new VerticalPanel();
private FlexTable myTable;
Presenter presenter;
private int rows;
private int cols;
private int width;
private boolean isEditTableMode = false;
private AttributeSingleSelection attrSS;
private Button cellMerger = new Button("Merge Cells");
private Button colMerger = new Button("Merge Selected");
private Button cancel = new Button("Cancel");
private Button resetTabelB = new Button("Reset Table");
private Button addRowB = new Button("Add Row");
private Button addColB = new Button("Add Col");
private Button deleteRowB = new Button("Del. Row");
private Button deleteColB = new Button("Del. Col");
private TextBox titleTB = new TextBox();
private TextBox descTB = new TextBox();
@ -71,7 +74,7 @@ public class GenericTable extends Composite {
private int cellPadding = 0;
private GenTableCell selectedCell = null;
private Table originalTable;
/**
@ -103,28 +106,28 @@ public class GenericTable extends Composite {
toAdd.addClickHandler(cellClicker);
}
}
HorizontalPanel controlPanel = getControlPanel();
VerticalPanel attributesPanel = getAttributesPanel();
VerticalPanel attributesPanel = getAttributesPanel(sTable);
attributesPanel.setStyleName("tableAttributesPanel");
controlPanel.setStyleName("tableControlPanel");
myPanel.add(controlPanel);
myPanel.add(controlPanel);
myPanel.add(myTable);
myPanel.add(attributesPanel);
myPanel.setStyleName("tablePanel");
for (int i = 0; i < controlPanel.getWidgetCount(); i++) {
if (controlPanel.getWidget(i) instanceof Button) {
Button b = (Button) controlPanel.getWidget(i);
b.addStyleName("tableButton");
}
}
focusPanel.add(myPanel);
initWidget(focusPanel);
focusPanel.addMouseOutHandler(new MouseOutHandler() {
@Override
public void onMouseOut(MouseOutEvent event) {
@ -132,7 +135,7 @@ public class GenericTable extends Composite {
}
});
}
private void saveTable(Table sTable) {
originalTable = new Table(sTable.getColsNo());
originalTable.setTable(sTable.getTable());
@ -161,30 +164,36 @@ public class GenericTable extends Composite {
int cellWidth = width / cols;
return cellWidth;
}
private VerticalPanel getAttributesPanel() {
private VerticalPanel getAttributesPanel(Table sTable) {
VerticalPanel toReturn = new VerticalPanel();
HorizontalPanel hp1 = new HorizontalPanel();
HTML title = new HTML("Title: <span style=\"color: red;\">*&nbsp;</span>", true);
hp1.add(title);
hp1.add(titleTB);
titleTB.setWidth("135px");
titleTB.setText(sTable.getTitle());
HTML desc = new HTML("&nbsp;Description: <span style=\"color: red;\">*&nbsp;</span>", true);
//desc.setStyleName("attributeArea");
hp1.add(desc);
hp1.add(descTB);
descTB.setWidth("435px");
descTB.setText(sTable.getDescription());
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);
return toReturn;
}
/**
*
* @return
@ -204,7 +213,7 @@ public class GenericTable extends Composite {
resetMe();
}
});
addRowB.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
@ -284,8 +293,8 @@ public class GenericTable extends Composite {
});
return toReturn;
}
/**
*
@ -417,7 +426,10 @@ public class GenericTable extends Composite {
for (int i = 0; i < myTable.getRowCount(); i++) {
toReturn.addRow(getRow(i));
}
toReturn.setTitle(titleTB.getText());
toReturn.setDescription(descTB.getText());
toReturn.setAttrArea(attrSS.getSerializable());
return toReturn;
}
@ -471,7 +483,7 @@ public class GenericTable extends Composite {
deleteRow(rows-1);
rows--;
}
private void deleteLastColumn() {
deleteColumn(cols-1);
}
@ -561,7 +573,7 @@ public class GenericTable extends Composite {
Info.display("Info", "Table Row removed successfully");
}
}
/**
* delete the colIndex column from the table
*/
@ -589,17 +601,16 @@ public class GenericTable extends Composite {
//Info.display("Info", "Table Column removed successfully");
}
}
protected void resetMe() {
myTable.clear();
myTable.removeAllRows();
/**
* construct the table
*/
for (int i = 0; i < originalTable.getRowCount(); i++) {
for (int j = 0; j < originalTable.getColsNo(); j++) {
TableCell toPut = new TableCell("");
int cellWidth = toPut.getCellWidth();
int cellWidth = getCellWidth(originalTable.getColsNo());
GenTableCell toAdd = new GenTableCell(i, j, cellWidth, 1);
toAdd.setText("");
toAdd.setStyleName("tableBorder");