Added getSelectedRowAsRaw()
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-widgetx@95692 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
8ffe18e775
commit
513bfc920b
|
@ -12,6 +12,7 @@ import java.util.Map;
|
|||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.GridHeaderColumnMenuItemEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.GridHeaderColumnMenuItemType;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.CellData;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.grid.model.RowRaw;
|
||||
import org.gcube.portlets.user.tdwx.client.config.GridAndCellSelectionModel;
|
||||
import org.gcube.portlets.user.tdwx.client.config.Row;
|
||||
import org.gcube.portlets.user.tdwx.client.config.TableViewConfig;
|
||||
|
@ -101,6 +102,7 @@ public class TabularDataXGridPanel extends ContentPanel {
|
|||
protected ToolBar toolBar;
|
||||
// protected GridInlineEditing<DataRow> editing;
|
||||
protected TableDefinition tableDefinition;
|
||||
|
||||
protected VerticalLayoutContainer container;
|
||||
|
||||
protected ExtendedLiveGridView liveGridView;
|
||||
|
@ -172,6 +174,15 @@ public class TabularDataXGridPanel extends ContentPanel {
|
|||
this.contextMenu = contextMenu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return table definition
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public TableDefinition getTableDefinition() {
|
||||
return tableDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the selected row.
|
||||
*
|
||||
|
@ -228,6 +239,65 @@ public class TabularDataXGridPanel extends ContentPanel {
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return Selected Row as RowRaw
|
||||
*/
|
||||
public RowRaw getSelectedRowAsRaw() {
|
||||
if (grid != null && grid.getSelectionModel() != null) {
|
||||
List<DataRow> dataRows = grid.getSelectionModel()
|
||||
.getSelectedItems();
|
||||
List<Row> rows = new ArrayList<Row>();
|
||||
for (DataRow dataRow : dataRows) {
|
||||
if (dataRow != null) {
|
||||
rows.add(new Row(dataRow, keys));
|
||||
}
|
||||
}
|
||||
|
||||
RowRaw r = null;
|
||||
|
||||
if (rows.size() > 0) {
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
ColumnModel<DataRow> columnModel = grid.getColumnModel();
|
||||
List<ColumnConfig<DataRow, ?>> columns = columnModel
|
||||
.getColumns();
|
||||
Row rowFirst = rows.get(0);
|
||||
DataRowColumnConfig<?> columnDataRow = null;
|
||||
String rowId=null;
|
||||
for (ColumnConfig<DataRow, ?> col : columns) {
|
||||
columnDataRow = (DataRowColumnConfig<?>) col;
|
||||
ColumnDefinition colDef = columnDataRow.getDefinition();
|
||||
if (colDef != null) {
|
||||
String value;
|
||||
if (colDef.getColumnDataType()
|
||||
.compareTo("Date") == 0) {
|
||||
value = rowFirst.getFieldAsDate(colDef
|
||||
.getColumnLocalId());
|
||||
} else {
|
||||
value = rowFirst.getFieldAsText(colDef
|
||||
.getColumnLocalId());
|
||||
}
|
||||
map.put(colDef.getColumnLocalId(), value);
|
||||
ColumnType ctype = colDef.getType();
|
||||
if (ctype == ColumnType.COLUMNID) {
|
||||
rowId=value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if(rowId!=null && !rowId.isEmpty() && map.size()>0){
|
||||
r=new RowRaw(rowId,map);
|
||||
}
|
||||
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve selected cell value
|
||||
|
@ -268,16 +338,16 @@ public class TabularDataXGridPanel extends ContentPanel {
|
|||
.getCell());
|
||||
DataRowColumnConfig<?> cSelected = (DataRowColumnConfig<?>) colSelected;
|
||||
ColumnDefinition cdSelected = cSelected.getDefinition();
|
||||
|
||||
|
||||
String cellValue;
|
||||
if(cdSelected.getColumnDataType().compareTo("Date")==0){
|
||||
if (cdSelected.getColumnDataType().compareTo("Date") == 0) {
|
||||
cellValue = row.getFieldAsDate(cdSelected
|
||||
.getColumnLocalId());
|
||||
} else {
|
||||
cellValue = row.getFieldAsText(cdSelected
|
||||
.getColumnLocalId());
|
||||
.getColumnLocalId());
|
||||
}
|
||||
|
||||
|
||||
String columnIdValue = row.getFieldAsText(columnIdSelected
|
||||
.getColumnLocalId());
|
||||
|
||||
|
@ -703,7 +773,7 @@ public class TabularDataXGridPanel extends ContentPanel {
|
|||
|
||||
// TODO workaround: the loader is called only if the scroll bar is
|
||||
// in the middle
|
||||
//if (loader.getOffset() == 0)
|
||||
// if (loader.getOffset() == 0)
|
||||
// loader.load();
|
||||
loader.load(0, liveGridView.getCacheSize());
|
||||
}
|
||||
|
@ -816,8 +886,6 @@ public class TabularDataXGridPanel extends ContentPanel {
|
|||
return columnId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param rows
|
||||
|
|
Loading…
Reference in New Issue