added table support
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/reports@70976 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
20d91c8e83
commit
00486c87fa
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/reports-4.0.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/reports-4.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
|
@ -30,5 +30,5 @@
|
|||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/reports-4.0.1-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/reports-4.1.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#Wed Mar 06 18:58:12 CET 2013
|
||||
eclipse.preferences.version=1
|
||||
jarsExcludedFromWebInfLib=
|
||||
lastWarOutDir=/home/gioia/workspace/reports/target/reports-4.0.1-SNAPSHOT
|
||||
lastWarOutDir=/Users/massi/Documents/workspace/reports/target/reports-4.1.0-SNAPSHOT
|
||||
warSrcDir=src/main/webapp
|
||||
warSrcDirIsOutput=false
|
||||
|
|
|
@ -5,12 +5,6 @@
|
|||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
||||
<dependent-module archiveName="gcube-docx-generator-1.2.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-docx-generator/gcube-docx-generator">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module archiveName="report-exporter-widget-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/report-exporter-widget/report-exporter-widget">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
|
||||
<property name="context-root" value="reports"/>
|
||||
</wb-module>
|
||||
|
|
4
pom.xml
4
pom.xml
|
@ -12,7 +12,7 @@
|
|||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>reports</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>4.0.1-SNAPSHOT</version>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<name>gCube Reports Portlet</name>
|
||||
<description>
|
||||
gCube Reports Portlet.
|
||||
|
@ -133,7 +133,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>gcube-docx-generator</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<version>[1.2.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.gcube.portlets.user.reportgenerator.client.ToolboxPanel;
|
|||
import org.gcube.portlets.user.reportgenerator.client.WorkspacePanel;
|
||||
import org.gcube.portlets.user.reportgenerator.client.dialog.AddBiblioEntryDialog;
|
||||
import org.gcube.portlets.user.reportgenerator.client.dialog.DeleteCitationsDialog;
|
||||
import org.gcube.portlets.user.reportgenerator.client.dialog.FimesReportTreePanel;
|
||||
import org.gcube.portlets.user.reportgenerator.client.dialog.ReportStructureDialog;
|
||||
import org.gcube.portlets.user.reportgenerator.client.dialog.LoadingPopup;
|
||||
import org.gcube.portlets.user.reportgenerator.client.events.AddBiblioEvent;
|
||||
import org.gcube.portlets.user.reportgenerator.client.events.AddBiblioEventHandler;
|
||||
|
@ -166,8 +166,8 @@ public class Presenter {
|
|||
// });
|
||||
|
||||
eventBus.addHandler(ItemSelectionEvent.TYPE, new ItemSelectionEventHandler() {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void onItemSelected(ItemSelectionEvent event) {
|
||||
// TODO Auto-generated method stub
|
||||
HashMap<String,Object> map = event.getItemSelected();
|
||||
int sectionIndex = 0, compIndex = 0;
|
||||
if (map != null) {
|
||||
|
@ -179,7 +179,7 @@ public class Presenter {
|
|||
sectionIndex = Integer.parseInt((String) ((HashMap<String, Object>) map.get("parent")).get("index"));
|
||||
seekSection(sectionIndex+1);
|
||||
int top = getModel().getSectionComponent(sectionIndex+1).get(compIndex).getContent().getAbsoluteTop();
|
||||
ReportGenerator.get().getScrollerPanel().setScrollPosition(top);
|
||||
ReportGenerator.get().getScrollerPanel().setVerticalScrollPosition(top);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1189,7 +1189,7 @@ public class Presenter {
|
|||
|
||||
|
||||
public void showReportStructure() {
|
||||
FimesReportTreePanel panel = new FimesReportTreePanel(eventBus, model.getSerializableModel(), ToolboxPanel.TOOLBOX_WIDTH+"px", ToolboxPanel.TOOLBOX_HEIGHT+"px");
|
||||
ReportStructureDialog panel = new ReportStructureDialog(eventBus, model.getSerializableModel(), ToolboxPanel.TOOLBOX_WIDTH+"px", ToolboxPanel.TOOLBOX_HEIGHT+"px");
|
||||
final com.extjs.gxt.ui.client.widget.Window window = new com.extjs.gxt.ui.client.widget.Window();
|
||||
window.setTitle("Report Structure");
|
||||
window.setClosable(true);
|
||||
|
|
|
@ -23,9 +23,9 @@ import com.google.gwt.user.client.ui.TreeItem;
|
|||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
|
||||
public class FimesReportTreePanel extends ScrollPanel{
|
||||
public class ReportStructureDialog extends ScrollPanel{
|
||||
|
||||
public FimesReportTreePanel(final HandlerManager eventBus, final Model report,
|
||||
public ReportStructureDialog(final HandlerManager eventBus, final Model report,
|
||||
final String height, final String width) {
|
||||
|
||||
this.setWidth(width);
|
|
@ -257,7 +257,7 @@ public class TemplateComponent {
|
|||
break;
|
||||
case FLEX_TABLE:
|
||||
Table st = (Table) sc.getPossibleContent();
|
||||
GenericTable table = new GenericTable(st, presenter, sc.getX(), sc.getY(), TemplateModel.TEMPLATE_WIDTH - 50, 200);
|
||||
GenericTable table = new GenericTable(st, presenter, sc.getX(), sc.getY(), TemplateModel.TEMPLATE_WIDTH - 50, 200, sc.isLocked());
|
||||
this.content = table;
|
||||
break;
|
||||
case ATTRIBUTE_MULTI:
|
||||
|
|
|
@ -5,6 +5,7 @@ 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.ReportGenerator;
|
||||
import org.gcube.portlets.user.reportgenerator.client.Presenter.Presenter;
|
||||
import org.gcube.portlets.user.reportgenerator.client.model.TemplateComponent;
|
||||
|
||||
|
@ -31,7 +32,7 @@ public class ClientRepeatableSequence extends Composite {
|
|||
this.p = p;
|
||||
this.repSequence = sRS;
|
||||
this.originalSequence = extractOriginalSequence(sRS);
|
||||
SequenceWidget seqW = new SequenceWidget(p, this, originalSequence, true);
|
||||
SequenceWidget seqW = new SequenceWidget(p, this, originalSequence, true, false);
|
||||
myPanel.add(seqW);
|
||||
|
||||
for (RepeatableSequence repeatSeq : getRepeats()) {
|
||||
|
@ -102,7 +103,12 @@ public class ClientRepeatableSequence extends Composite {
|
|||
}
|
||||
|
||||
protected void addAnother(RepeatableSequence sRS) {
|
||||
SequenceWidget seqW = new SequenceWidget(p, this, sRS, false);
|
||||
SequenceWidget seqW = new SequenceWidget(p, this, sRS, false, false);
|
||||
myPanel.add(seqW);
|
||||
}
|
||||
|
||||
protected void addNew(RepeatableSequence sRS) {
|
||||
SequenceWidget seqW = new SequenceWidget(p, this, sRS, false, true);
|
||||
myPanel.add(seqW);
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -1,24 +1,46 @@
|
|||
package org.gcube.portlets.user.reportgenerator.client.targets;
|
||||
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.d4sreporting.common.shared.Table;
|
||||
import org.gcube.portlets.d4sreporting.common.shared.TableCell;
|
||||
import org.gcube.portlets.user.reportgenerator.client.Presenter.Presenter;
|
||||
|
||||
import com.extjs.gxt.ui.client.event.Listener;
|
||||
import com.extjs.gxt.ui.client.event.MessageBoxEvent;
|
||||
import com.extjs.gxt.ui.client.widget.Info;
|
||||
import com.extjs.gxt.ui.client.widget.MessageBox;
|
||||
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.event.dom.client.MouseOutEvent;
|
||||
import com.google.gwt.event.dom.client.MouseOutHandler;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.FlexTable;
|
||||
import com.google.gwt.user.client.ui.FocusPanel;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante ISTI-CNR
|
||||
* @version 1.0
|
||||
*
|
||||
*/
|
||||
public class GenericTable extends Composite {
|
||||
private VerticalPanel myPanel;
|
||||
|
||||
public static final int DEFAULT_HEIGHT = 200;
|
||||
|
||||
public static final int DEFAULT_ROWS_NUM = 5;
|
||||
public static final int DEFAULT_COLS_NUM = 2;
|
||||
|
||||
private FocusPanel focusPanel = new FocusPanel();
|
||||
|
||||
private VerticalPanel myPanel = new VerticalPanel();
|
||||
private FlexTable myTable;
|
||||
|
||||
Presenter presenter;
|
||||
|
@ -26,21 +48,42 @@ public class GenericTable extends Composite {
|
|||
private int rows;
|
||||
private int cols;
|
||||
|
||||
private int width;
|
||||
|
||||
private boolean isEditTableMode = false;
|
||||
|
||||
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();
|
||||
|
||||
private int cellWidth;
|
||||
private int cellSpacing = 1;
|
||||
private int cellPadding = 0;
|
||||
|
||||
private GenTableCell selectedCell = null;
|
||||
|
||||
private Table originalTable;
|
||||
|
||||
/**
|
||||
* constructor called when reading the model
|
||||
* @param sTable
|
||||
*/
|
||||
public GenericTable(Table sTable, Presenter presenter, int top, int left, int width, int height) {
|
||||
|
||||
public GenericTable(Table sTable, Presenter presenter, int top, int left, int width, int height, boolean isLocked) {
|
||||
saveTable(sTable);
|
||||
commonConstructorCode(presenter);
|
||||
this.rows = sTable.getRowCount();
|
||||
this.cols = sTable.getColsNo();
|
||||
this.width = width;
|
||||
|
||||
/**
|
||||
* construct the table
|
||||
|
@ -49,7 +92,7 @@ public class GenericTable extends Composite {
|
|||
for (int j = 0; j < sTable.getCellCount(i); j++) {
|
||||
TableCell toPut = sTable.getValue(i, j);
|
||||
int cellWidth = toPut.getCellWidth();
|
||||
int cellHeight = toPut.getCellHeight();
|
||||
//int cellHeight = toPut.getCellHeight();
|
||||
int colspan = toPut.getColspan();
|
||||
GenTableCell toAdd = new GenTableCell(i, j, cellWidth, colspan);
|
||||
toAdd.setText(toPut.getContent());
|
||||
|
@ -57,14 +100,46 @@ public class GenericTable extends Composite {
|
|||
toAdd.setWidth(""+cellWidth+"px");
|
||||
myTable.setWidget(i, j, toAdd);
|
||||
myTable.getFlexCellFormatter().setColSpan(i, j, colspan);
|
||||
toAdd.addClickHandler(cellClicker);
|
||||
}
|
||||
}
|
||||
|
||||
myPanel = new VerticalPanel();
|
||||
myPanel.setWidth(width+"px");
|
||||
myPanel.setStyleName("d4sFrame");
|
||||
HorizontalPanel controlPanel = getControlPanel();
|
||||
VerticalPanel attributesPanel = getAttributesPanel();
|
||||
attributesPanel.setStyleName("tableAttributesPanel");
|
||||
|
||||
controlPanel.setStyleName("tableControlPanel");
|
||||
myPanel.add(controlPanel);
|
||||
myPanel.add(myTable);
|
||||
initWidget(myPanel);
|
||||
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) {
|
||||
saveStatus();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void saveTable(Table sTable) {
|
||||
originalTable = new Table(sTable.getColsNo());
|
||||
originalTable.setTable(sTable.getTable());
|
||||
}
|
||||
|
||||
private void saveStatus() {
|
||||
presenter.storeChangeInSession(this);
|
||||
}
|
||||
/**
|
||||
* common Constructors Code
|
||||
|
@ -77,6 +152,236 @@ public class GenericTable extends Composite {
|
|||
myTable.setCellPadding(cellPadding);
|
||||
|
||||
}
|
||||
/**
|
||||
* calculate the cell width
|
||||
* @param cols
|
||||
* @return
|
||||
*/
|
||||
private int getCellWidth(int cols) {
|
||||
int cellWidth = width / cols;
|
||||
return cellWidth;
|
||||
}
|
||||
|
||||
private VerticalPanel getAttributesPanel() {
|
||||
VerticalPanel toReturn = new VerticalPanel();
|
||||
|
||||
HorizontalPanel hp1 = new HorizontalPanel();
|
||||
HTML title = new HTML("Title: <span style=\"color: red;\">* </span>", true);
|
||||
hp1.add(title);
|
||||
hp1.add(titleTB);
|
||||
titleTB.setWidth("135px");
|
||||
|
||||
HTML desc = new HTML(" Description: <span style=\"color: red;\">* </span>", true);
|
||||
//desc.setStyleName("attributeArea");
|
||||
|
||||
hp1.add(desc);
|
||||
hp1.add(descTB);
|
||||
descTB.setWidth("435px");
|
||||
toReturn.add(hp1);
|
||||
|
||||
AttributeSingleSelection attrSS = new AttributeSingleSelection(presenter, 0, 0, 700, 0, "DisplayType:Token|Inline|Link|Popup");
|
||||
toReturn.add(attrSS);
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private HorizontalPanel getControlPanel() {
|
||||
final HorizontalPanel toReturn = new HorizontalPanel();
|
||||
|
||||
final Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() {
|
||||
public void handleEvent(MessageBoxEvent ce) {
|
||||
Info.display("Info", "Table Edit Mode Enabled");
|
||||
}
|
||||
};
|
||||
|
||||
resetTabelB.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
resetMe();
|
||||
}
|
||||
});
|
||||
|
||||
addRowB.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
addRow();
|
||||
}
|
||||
});
|
||||
|
||||
deleteRowB.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
deleteLastRow();
|
||||
}
|
||||
});
|
||||
|
||||
addColB.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
addColumn();
|
||||
}
|
||||
});
|
||||
|
||||
deleteColB.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
deleteLastColumn();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
cellMerger.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (! isEditTableMode) {
|
||||
isEditTableMode = true;
|
||||
MessageBox.alert("Table Edit Mode Enabled", "Click on the cells you want to merge", null);
|
||||
myTable.addStyleName("highlight_background");
|
||||
cellMerger.setEnabled(false);
|
||||
|
||||
//rowMerger.setVisible(true);
|
||||
colMerger.setVisible(true);
|
||||
cancel.setVisible(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//the control buttons
|
||||
toReturn.add(resetTabelB);
|
||||
toReturn.add(addRowB);
|
||||
toReturn.add(addColB);
|
||||
toReturn.add(deleteRowB);
|
||||
toReturn.add(deleteColB);
|
||||
|
||||
toReturn.add(cellMerger);
|
||||
toReturn.add(colMerger);
|
||||
toReturn.add(cancel);
|
||||
|
||||
colMerger.setVisible(false);
|
||||
cancel.setVisible(false);
|
||||
|
||||
toReturn.setSpacing(3);
|
||||
|
||||
|
||||
cancel.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
endEditMode();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
colMerger.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
mergeSelectedCols();
|
||||
endEditMode();
|
||||
}
|
||||
});
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* End the edit mode
|
||||
*/
|
||||
private void endEditMode() {
|
||||
isEditTableMode = false;
|
||||
myTable.removeStyleName("highlight_background");
|
||||
cellMerger.setEnabled(true);
|
||||
colMerger.setVisible(false);
|
||||
cancel.setVisible(false);
|
||||
for (int i = 0; i < rows; i++) {
|
||||
for (int j = 0; j < cols; j++) {
|
||||
try {
|
||||
GenTableCell tc = (GenTableCell) myTable.getWidget(i, j);
|
||||
if (tc.isSelected()) {
|
||||
tc.selected = false;
|
||||
tc.removeStyleName("selectedCell");
|
||||
}
|
||||
}catch (IndexOutOfBoundsException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* merges the contiguos cols per row
|
||||
*/
|
||||
private void mergeSelectedCols() {
|
||||
for_i: for (int i = 0; i < rows; i++) {
|
||||
for (int j = 0; j < cols; j++) {
|
||||
try {
|
||||
GenTableCell tc = (GenTableCell) myTable.getWidget(i, j);
|
||||
if (tc.isSelected()) {
|
||||
int nToMerge = checkContiguosColsPerRows(i, j);
|
||||
if (nToMerge > 1) {
|
||||
//myTable.removeCells(i, j+1, nToMerge-1);
|
||||
int cellsData[] = deleteCells(i, j+1, nToMerge-1);
|
||||
int colSpanDeleted = cellsData[0];
|
||||
int deletedCellWidth = cellsData[1];
|
||||
tc.setColspan(tc.getColspan()+colSpanDeleted);
|
||||
GWT.log("i=" + i + " j=" +j + " nTomerge" + nToMerge + " COLSPAN: " + tc.getColspan());
|
||||
myTable.getFlexCellFormatter().setColSpan(i, j, tc.getColspan());
|
||||
int newWidth = (tc.getWidth() + deletedCellWidth + cellSpacing * tc.getColspan() + tc.getColspan());
|
||||
tc.setWidth(newWidth+"px");
|
||||
tc.setCellWidth(newWidth);
|
||||
tc.removeStyleName("selectedCell");
|
||||
continue for_i;
|
||||
}
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param row the row of the cells to be removed
|
||||
* @column the column of the first cell to be removed
|
||||
* @num the number of cells to be removed
|
||||
* @return the total colspan of the cells in [0] is deleting, the total width of cells deleted in [1]
|
||||
*/
|
||||
private int[] deleteCells(int row, int col, int num) {
|
||||
int[] toReturn = new int[2];
|
||||
toReturn[0] = 0;
|
||||
toReturn[1] = 0;
|
||||
for (int j = col; j < (col+num); j++) {
|
||||
toReturn[0] += ((GenTableCell) myTable.getWidget(row, j)).getColspan();
|
||||
toReturn[1] += ((GenTableCell) myTable.getWidget(row, j)).getCellWidth();
|
||||
}
|
||||
myTable.removeCells(row, col, num);
|
||||
GWT.log("REMOVED CELL from" + col + " to " + (col+num));
|
||||
return toReturn;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int checkContiguosColsPerRows(int i, int j) {
|
||||
int counter = 1;
|
||||
GenTableCell next = (GenTableCell) myTable.getWidget(i, j);
|
||||
j++;
|
||||
while (j < myTable.getCellCount(i)) {
|
||||
next = (GenTableCell) myTable.getWidget(i, j);
|
||||
if (next.isSelected())
|
||||
counter++;
|
||||
else
|
||||
break;
|
||||
j++;
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
|
||||
|
||||
public FlexTable getMyTable() {
|
||||
|
@ -127,19 +432,181 @@ public class GenericTable extends Composite {
|
|||
return toReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
ClickHandler cellClicker = new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
GenTableCell toSelect = (GenTableCell) event.getSource();
|
||||
setSelected(toSelect);
|
||||
if (isEditTableMode) {
|
||||
|
||||
if (! toSelect.isSelected()) {
|
||||
toSelect.addStyleName("selectedCell");
|
||||
toSelect.setSelected(true);
|
||||
}
|
||||
else {
|
||||
toSelect.setSelected(false);
|
||||
toSelect.removeStyleName("selectedCell");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* tells the presenter this tableb is selected
|
||||
*/
|
||||
private void setSelected(GenTableCell tc) {
|
||||
selectedCell = tc;
|
||||
}
|
||||
|
||||
public GenTableCell getSelectedCell() {
|
||||
return selectedCell;
|
||||
}
|
||||
|
||||
/**
|
||||
* adda a column at the left of the selected cell of the selected table
|
||||
* delete the selected row from the table
|
||||
*/
|
||||
public void deleteLastRow() {
|
||||
deleteRow(rows-1);
|
||||
rows--;
|
||||
}
|
||||
|
||||
private void deleteLastColumn() {
|
||||
deleteColumn(cols-1);
|
||||
}
|
||||
/**
|
||||
* adda a row at the bottom of the tableb
|
||||
*/
|
||||
public void addRow() {
|
||||
|
||||
Table sTable = getSerializable();
|
||||
//Window.alert("Adding row Above: " + rowIndex + " cells no: " + sTable.getCellCount(rowIndex));
|
||||
int rowIndex = myTable.getRowCount();
|
||||
for (int j = 0; j < myTable.getCellCount(rowIndex-1); j++) {
|
||||
TableCell toPut = sTable.getValue(rowIndex-1, j);
|
||||
int cellWidth = toPut.getCellWidth();
|
||||
int cellHeight = toPut.getCellHeight();
|
||||
int colspan = toPut.getColspan();
|
||||
GenTableCell toAdd = new GenTableCell(rowIndex, j, cellWidth, colspan);
|
||||
toAdd.setText(toPut.getContent());
|
||||
toAdd.setStyleName("tableBorder");
|
||||
toAdd.setWidth(""+cellWidth+"px");
|
||||
myTable.setWidget(rowIndex, j, toAdd);
|
||||
myTable.getFlexCellFormatter().setColSpan(rowIndex, j, colspan);
|
||||
toAdd.addClickHandler(cellClicker);
|
||||
}
|
||||
rows += 1;
|
||||
Info.display("Info", "Table Row added successfully");
|
||||
}
|
||||
/**
|
||||
* add a column next to the last onw
|
||||
*/
|
||||
public void addColumn() {
|
||||
int colIndex = cols;
|
||||
int cellWidth = getCellWidth(cols+1);
|
||||
|
||||
for (int i = 0; i < rows; i++) {
|
||||
GenTableCell toAdd = new GenTableCell(i, colIndex, cellWidth, 1);
|
||||
toAdd.setStyleName("tableBorder");
|
||||
GWT.log("Width=" + cellWidth);
|
||||
myTable.setWidget(i, colIndex, toAdd);
|
||||
toAdd.addClickHandler(cellClicker);
|
||||
}
|
||||
cols++;
|
||||
updateCellsWidth(getCellWidth(cols));
|
||||
Info.display("Info", "Table Column added successfully");
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void updateCellsWidth(int newWidth) {
|
||||
Table sTable = getSerializable();
|
||||
/**
|
||||
* construct the table
|
||||
*/
|
||||
for (int i = 0; i < rows; i++) {
|
||||
for (int j = 0; j < sTable.getCellCount(i); j++) {
|
||||
TableCell toPut = sTable.getValue(i, j);
|
||||
int cellWidth = newWidth;
|
||||
//int cellHeight = toPut.getCellHeight();
|
||||
int colspan = toPut.getColspan();
|
||||
GenTableCell toAdd = new GenTableCell(i, j, cellWidth, colspan);
|
||||
toAdd.setText(toPut.getContent());
|
||||
toAdd.setStyleName("tableBorder");
|
||||
toAdd.setWidth(""+cellWidth+"px");
|
||||
myTable.setWidget(i, j, toAdd);
|
||||
myTable.getFlexCellFormatter().setColSpan(i, j, colspan);
|
||||
toAdd.addClickHandler(cellClicker);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* adda a column at the left of the selected cell of the selected tableb
|
||||
* TODO: next version
|
||||
*/
|
||||
public void addColumnLeft(int colindex) {
|
||||
// myTable.insertCell(beforeRow, beforeColumn)
|
||||
}
|
||||
/**
|
||||
* delete the rowIndex row from the table
|
||||
*/
|
||||
public void deleteRow(int rowIndex) {
|
||||
GWT.log("Removing row: " + rowIndex);
|
||||
if (rows == 1) {
|
||||
Info.display("Error", "Only one row left, delete the table");
|
||||
} else {
|
||||
myTable.removeRow(rowIndex);
|
||||
Info.display("Info", "Table Row removed successfully");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* delete the colIndex column from the table
|
||||
*/
|
||||
public void deleteColumn(int colIndex) {
|
||||
GWT.log("Removing column: " + colIndex);
|
||||
if (cols <= 1) {
|
||||
Info.display("Error", "Only one column left, delete the table");
|
||||
} else {
|
||||
//check if the column has all rows
|
||||
for (int i = 0; i < rows; i++) {
|
||||
try {
|
||||
myTable.getWidget(i, colIndex);
|
||||
}
|
||||
catch (IndexOutOfBoundsException e) {
|
||||
Info.display("Error", "Table Column cannot be removed as at least one row has merged cells");
|
||||
return;
|
||||
}
|
||||
}
|
||||
// at this point you are sure there are no merged cells in the column to be deleted (last one)
|
||||
for (int i = 0; i < rows; i++) {
|
||||
myTable.removeCell(i, colIndex);
|
||||
}
|
||||
cols--;
|
||||
updateCellsWidth(getCellWidth(cols));
|
||||
//Info.display("Info", "Table Column removed successfully");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void resetMe() {
|
||||
myTable.clear();
|
||||
/**
|
||||
* 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();
|
||||
GenTableCell toAdd = new GenTableCell(i, j, cellWidth, 1);
|
||||
toAdd.setText("");
|
||||
toAdd.setStyleName("tableBorder");
|
||||
toAdd.setWidth(""+cellWidth+"px");
|
||||
myTable.setWidget(i, j, toAdd);
|
||||
toAdd.addClickHandler(cellClicker);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public class SequenceWidget extends Composite {
|
|||
private RepeatableSequence repSequence;
|
||||
private ArrayList<TemplateComponent> seqGroupedComponents = new ArrayList<TemplateComponent>();
|
||||
|
||||
public SequenceWidget(Presenter p, ClientRepeatableSequence owner, RepeatableSequence repSequence, boolean isFirst) {
|
||||
public SequenceWidget(Presenter p, ClientRepeatableSequence owner, RepeatableSequence repSequence, boolean isFirst, boolean isNew) {
|
||||
this.p = p;
|
||||
this.owner = owner;
|
||||
this.repSequence = repSequence;
|
||||
|
@ -53,6 +53,10 @@ public class SequenceWidget extends Composite {
|
|||
|
||||
buttonPanel.add(buttonsWrapperPanel);
|
||||
}
|
||||
//if isNew and is not locked and is of type BODY then put fields to blank
|
||||
if (isNew && (!sComp.isLocked()) && (sComp.getType() == ComponentType.BODY || sComp.getType() == ComponentType.BODY_NOT_FORMATTED) ) {
|
||||
sComp.setPossibleContent("");
|
||||
}
|
||||
add(new TemplateComponent(p.getModel(), sComp, p));
|
||||
}
|
||||
initWidget(myPanel);
|
||||
|
@ -100,11 +104,10 @@ public class SequenceWidget extends Composite {
|
|||
}
|
||||
|
||||
private void addAnother() {
|
||||
owner.addAnother(repSequence);
|
||||
owner.addNew(repSequence);
|
||||
}
|
||||
|
||||
private void removeMe() {
|
||||
owner.removeSeqWidget(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<inherits name='org.gcube.portlets.user.guidedtour.GuidedTour' />
|
||||
|
||||
<!-- To Comment out -->
|
||||
<!-- <set-property name="user.agent" value="gecko1_8" /> -->
|
||||
<set-property name="user.agent" value="gecko1_8" />
|
||||
|
||||
<inherits name='org.gcube.portlets.user.workspace.lighttree.WorkspacePortletLightTree' />
|
||||
<inherits name='org.gcube.portlets.user.exporter.Report_exporter_widget' />
|
||||
|
|
|
@ -40,6 +40,23 @@
|
|||
width: 600px;
|
||||
}
|
||||
|
||||
.tablePanel {
|
||||
border-bottom: 2px dashed #FFF;
|
||||
background-color: transparent;
|
||||
margin: 8px 0px;
|
||||
}
|
||||
|
||||
.tableControlPanel {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.tableAttributesPanel {
|
||||
margin: 8px 0px;
|
||||
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
|
||||
font-size: 14px;
|
||||
color: #336699;
|
||||
}
|
||||
|
||||
.tableBorder {
|
||||
border: 1px solid #CCC;
|
||||
height: 30px;
|
||||
|
@ -48,6 +65,14 @@
|
|||
color: #333;
|
||||
}
|
||||
|
||||
.tableButton {
|
||||
background-image: none !important;
|
||||
background-repeat: none !important;
|
||||
background-color: #fff !important;
|
||||
color: #666 !important;
|
||||
margin-right: 10px !important;
|
||||
}
|
||||
|
||||
.selectable {
|
||||
cursor: pointer;
|
||||
cursor: hand;
|
||||
|
@ -83,7 +108,7 @@
|
|||
}
|
||||
|
||||
tableBorder td {
|
||||
border: 2px solid #BBBBBB;
|
||||
border: 1px solid #BBBBBB;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
|
|
Reference in New Issue