Minor Update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-widgetx@93006 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
90982cda43
commit
62a697a5a5
|
@ -115,7 +115,7 @@ public class TabularDataXGridPanel extends ContentPanel {
|
|||
this.eventBus = eventBus;
|
||||
bindEventBus();
|
||||
container = new VerticalLayoutContainer();
|
||||
|
||||
|
||||
setWidget(container);
|
||||
}
|
||||
|
||||
|
@ -214,6 +214,60 @@ public class TabularDataXGridPanel extends ContentPanel {
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* getSelectedRowsId
|
||||
*
|
||||
* @return List<String> list of identifiers of the selected rows
|
||||
*/
|
||||
public ArrayList<String> getSelectedRowsId() {
|
||||
if (grid != null) {
|
||||
ColumnModel<DataRow> columnModel = grid
|
||||
.getColumnModel();
|
||||
|
||||
List<ColumnConfig<DataRow, ?>> columns = columnModel
|
||||
.getColumns();
|
||||
DataRowColumnConfig<?> c = null;
|
||||
boolean columnIdRetrieved = false;
|
||||
for (ColumnConfig<DataRow, ?> col : columns) {
|
||||
c = (DataRowColumnConfig<?>) col;
|
||||
ColumnType ctype = c.getDefinition().getType();
|
||||
if (ctype == ColumnType.COLUMNID) {
|
||||
columnIdRetrieved = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (columnIdRetrieved) {
|
||||
ColumnDefinition cd = c.getDefinition();
|
||||
Log.debug("CD - Definition:" + cd.getId()
|
||||
+ " ColumnLocalId:" + cd.getColumnLocalId()
|
||||
+ " Label:" + cd.getLabel() + " Key:"
|
||||
+ cd.getKey());
|
||||
List<Row> rowsSelected = getSelectedRows();
|
||||
Log.debug("Retriving rows selected");
|
||||
String rowS = "";
|
||||
ArrayList<String> rows = new ArrayList<String>();
|
||||
if (rowsSelected != null) {
|
||||
for (Row row : rowsSelected) {
|
||||
rowS = row.getFieldAsText(cd.getLabel());
|
||||
Log.debug("Selected Row:" + rowS);
|
||||
rows.add(rowS);
|
||||
}
|
||||
} else {
|
||||
Log.debug("no selected rows retrived");
|
||||
}
|
||||
return rows;
|
||||
} else {
|
||||
Log.debug("no COLUMNID retrived");
|
||||
return null;
|
||||
}
|
||||
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void bindEventBus() {
|
||||
eventBus.addHandler(OpenTableEvent.TYPE, new OpenTableEventHandler() {
|
||||
|
@ -262,14 +316,13 @@ public class TabularDataXGridPanel extends ContentPanel {
|
|||
unmask();
|
||||
}
|
||||
|
||||
|
||||
protected void setupGrid(TableDefinition tableDefinition) {
|
||||
this.tableDefinition=tableDefinition;
|
||||
|
||||
this.tableDefinition = tableDefinition;
|
||||
|
||||
ColumnDefinition modelKeyColumn = tableDefinition.getModelKeyColumn();
|
||||
store = new ListStore<DataRow>(
|
||||
new DataRowModelKeyProvider(modelKeyColumn.getKey()));
|
||||
|
||||
store = new ListStore<DataRow>(new DataRowModelKeyProvider(
|
||||
modelKeyColumn.getKey()));
|
||||
|
||||
store.addStoreUpdateHandler(new StoreUpdateEvent.StoreUpdateHandler<DataRow>() {
|
||||
|
||||
@Override
|
||||
|
@ -317,31 +370,30 @@ public class TabularDataXGridPanel extends ContentPanel {
|
|||
|
||||
liveGridView = new ExtendedLiveGridView();
|
||||
liveGridView.setRowHeight(21);
|
||||
|
||||
|
||||
grid = new Grid<DataRow>(store, columnModel);
|
||||
grid.setLoadMask(true);
|
||||
grid.setLoader(loader);
|
||||
grid.setView(liveGridView);
|
||||
|
||||
|
||||
editing = new GridInlineEditing<DataRow>(grid);
|
||||
editing.setClicksToEdit(ClicksToEdit.TWO);
|
||||
|
||||
for(ColumnConfig<DataRow, ?> c:columnsConfig){
|
||||
ColumnConfigGenerator.setEditor(editing, c);
|
||||
|
||||
for (ColumnConfig<DataRow, ?> c : columnsConfig) {
|
||||
ColumnConfigGenerator.setEditor(editing, c);
|
||||
}
|
||||
|
||||
|
||||
// numberer.initPlugin(grid);
|
||||
|
||||
|
||||
container.add(grid, new VerticalLayoutData(1, 1, new Margins(0)));
|
||||
|
||||
|
||||
ToolBar toolBar = new ToolBar();
|
||||
toolBar.add(new LiveToolItem(grid));
|
||||
toolBar.addStyleName(ThemeStyles.getStyle().borderTop());
|
||||
toolBar.getElement().getStyle().setProperty("borderBottom", "none");
|
||||
|
||||
container.add(toolBar, new VerticalLayoutData(1, 25, new Margins(0)));
|
||||
|
||||
|
||||
container.add(toolBar,
|
||||
new VerticalLayoutData(1, 25, new Margins(0)));
|
||||
|
||||
container.forceLayout();
|
||||
|
||||
|
@ -353,7 +405,7 @@ public class TabularDataXGridPanel extends ContentPanel {
|
|||
});
|
||||
|
||||
loader.load(0, liveGridView.getCacheSize());
|
||||
|
||||
|
||||
if (contextMenu != null) {
|
||||
grid.setContextMenu(contextMenu);
|
||||
} else
|
||||
|
@ -362,9 +414,7 @@ public class TabularDataXGridPanel extends ContentPanel {
|
|||
if (headerColumnMenuItems != null) {
|
||||
setHeaderContextMenuHandler();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
// TODO we need to manually reset the sort
|
||||
loader.clearSortInfo();
|
||||
|
@ -372,11 +422,11 @@ public class TabularDataXGridPanel extends ContentPanel {
|
|||
grid.reconfigure(store, columnModel);
|
||||
editing = new GridInlineEditing<DataRow>(grid);
|
||||
editing.setClicksToEdit(ClicksToEdit.TWO);
|
||||
|
||||
for(ColumnConfig<DataRow, ?> c:columnsConfig){
|
||||
ColumnConfigGenerator.setEditor(editing, c);
|
||||
|
||||
for (ColumnConfig<DataRow, ?> c : columnsConfig) {
|
||||
ColumnConfigGenerator.setEditor(editing, c);
|
||||
}
|
||||
|
||||
|
||||
// TODO workaround: the loader is called only if the scroll bar is
|
||||
// in the middle
|
||||
if (loader.getOffset() == 0)
|
||||
|
@ -394,8 +444,6 @@ public class TabularDataXGridPanel extends ContentPanel {
|
|||
grid.getView().setViewConfig(null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -462,7 +510,8 @@ public class TabularDataXGridPanel extends ContentPanel {
|
|||
|
||||
/**
|
||||
*
|
||||
* @param i index of column in ColumnModel
|
||||
* @param i
|
||||
* index of column in ColumnModel
|
||||
* @return id of column and equals to column name on service
|
||||
*/
|
||||
public String getColumnId(int i) {
|
||||
|
@ -482,38 +531,38 @@ public class TabularDataXGridPanel extends ContentPanel {
|
|||
}
|
||||
|
||||
|
||||
|
||||
public void addRow(ArrayList<String> rows){
|
||||
if(grid!=null && editing!=null){
|
||||
List<ColumnKey> keys=tableDefinition.getKeys();
|
||||
|
||||
DataRow dataRow=new DataRow(keys.size());
|
||||
for(ColumnKey key:keys){
|
||||
/**
|
||||
*
|
||||
* @param rows
|
||||
*/
|
||||
public void addRow(ArrayList<String> rows) {
|
||||
if (grid != null && editing != null) {
|
||||
List<ColumnKey> keys = tableDefinition.getKeys();
|
||||
|
||||
DataRow dataRow = new DataRow(keys.size());
|
||||
for (ColumnKey key : keys) {
|
||||
dataRow.set(key, null);
|
||||
}
|
||||
|
||||
editing.cancelEditing();
|
||||
int pos=0;
|
||||
if(rows!=null && rows.size()>0){
|
||||
pos=new Integer(rows.get(0));
|
||||
}
|
||||
|
||||
store.add(pos, dataRow);
|
||||
|
||||
int row = store.indexOf(dataRow);
|
||||
editing.startEditing(new GridCell(row, pos));
|
||||
|
||||
editing.cancelEditing();
|
||||
int pos = 0;
|
||||
if (rows != null && rows.size() > 0) {
|
||||
pos = new Integer(rows.get(0));
|
||||
}
|
||||
|
||||
store.add(pos, dataRow);
|
||||
|
||||
int row = store.indexOf(dataRow);
|
||||
editing.startEditing(new GridCell(row, pos));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected class ExtendedLiveGridView extends LiveGridView<DataRow> {
|
||||
//TODO bug in gxt3 3.0.0 fixed in future
|
||||
/*@Override
|
||||
public void refresh(boolean headerToo) {
|
||||
preventScrollToTopOnRefresh = true;
|
||||
super.refresh(headerToo);
|
||||
}*/
|
||||
// TODO bug in gxt3 3.0.0 fixed in future
|
||||
/*
|
||||
* @Override public void refresh(boolean headerToo) {
|
||||
* preventScrollToTopOnRefresh = true; super.refresh(headerToo); }
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue