Minor update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-widgetx@102121 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-12-15 18:00:18 +00:00 committed by Giancarlo Panichi
parent 46aa37e9df
commit 8a13cc5c89
3 changed files with 84 additions and 105 deletions

View File

@ -447,7 +447,7 @@ public class TabularDataXGridPanel extends ContentPanel {
List<ColumnConfig<DataRow, ?>> columns = columnModel.getColumns();
List<ColumnConfig<DataRow, ?>> columnsNew = new ArrayList<ColumnConfig<DataRow, ?>>();
// Retrive Column with conlumnLocalId
// Retrieve Column with conlumnLocalId
DataRowColumnConfig<?> columnTarget = null;
// boolean columnTargetRetrieved = false;
for (ColumnConfig<DataRow, ?> col : columns) {
@ -485,7 +485,7 @@ public class TabularDataXGridPanel extends ContentPanel {
List<ColumnConfig<DataRow, ?>> columns = columnModel.getColumns();
// Retrive Column with conlumnLocalId
// Retrieve Column with conlumnLocalId
DataRowColumnConfig<?> columnTarget = null;
boolean columnTargetRetrieved = false;
for (ColumnConfig<DataRow, ?> col : columns) {
@ -561,11 +561,11 @@ public class TabularDataXGridPanel extends ContentPanel {
rows.add(rowS);
}
} else {
Log.debug("no selected rows retrived");
Log.debug("no selected rows retrieved");
}
return rows;
} else {
Log.debug("no COLUMNID retrived");
Log.debug("no COLUMNID retrieved");
return null;
}

View File

@ -94,35 +94,7 @@ public class GridAndCellSelectionModel<M> extends GridSelectionModel<M> {
}
}
/*
* Old GXT 2.5.1 if (Element.is(event.getEvent().getEventTarget()) &&
* !grid.getView().isSelectableTarget(
* Element.as(event.getEvent().getEventTarget()))) { return; } if
* (isLocked()) { return; }
*
* if (fireSelectionChangeOnClick) { fireSelectionChange();
* fireSelectionChangeOnClick = false; }
*
* XEvent xe = event.getEvent().<XEvent> cast();
*
* int rowIndex = event.getRowIndex(); int colIndex =
* event.getColumnIndex(); if (rowIndex == -1) { deselectAll(); return;
* }
*
*
*
* // we only handle multi select with control key here if
* (selectionMode == SelectionMode.MULTI) { M sel =
* listStore.get(rowIndex); cellSelected = new CellSelection<M>(sel,
* rowIndex, colIndex); if (xe.getCtrlOrMetaKey() && isSelected(sel)) {
* doDeselect(Collections.singletonList(sel), false); } else if
* (xe.getCtrlOrMetaKey()) { grid.getView().focusCell(rowIndex,
* colIndex, false); doSelect(Collections.singletonList(sel), true,
* false); } else if (isSelected(sel) && !event.getEvent().getShiftKey()
* && !xe.getCtrlOrMetaKey() && selected.size() > 1) {
* grid.getView().focusCell(rowIndex, colIndex, false);
* doSelect(Collections.singletonList(sel), false, false); } }
*/
}
/**
@ -240,78 +212,7 @@ public class GridAndCellSelectionModel<M> extends GridSelectionModel<M> {
mouseDown = false;
/* GXT 3.0.1
if (Element.is(event.getEvent().getEventTarget())
&& !grid.getView().isSelectableTarget(
Element.as(event.getEvent().getEventTarget()))) {
return;
}
if (isLocked()) {
return;
}
int rowIndex = event.getRowIndex();
int colIndex = event.getColumnIndex();
if (rowIndex == -1) {
return;
}
mouseDown = true;
XEvent e = event.getEvent().<XEvent> cast();
if (event.getEvent().getButton() == Event.BUTTON_RIGHT) {
if (selectionMode != SelectionMode.SINGLE
&& isSelected(listStore.get(rowIndex))) {
M sel = listStore.get(rowIndex);
cellSelected = new CellSelection<M>(sel, rowIndex, colIndex);
return;
}
M sel = listStore.get(rowIndex);
cellSelected = new CellSelection<M>(sel, rowIndex, colIndex);
grid.getView().focusCell(rowIndex, colIndex, false);
select(rowIndex, false);
} else {
M sel = listStore.get(rowIndex);
if (selectionMode == SelectionMode.SIMPLE) {
if (!isSelected(sel)) {
grid.getView().focusCell(rowIndex, colIndex, false);
cellSelected = new CellSelection<M>(sel, rowIndex, colIndex);
select(sel, true);
}
} else if (selectionMode == SelectionMode.SINGLE) {
if (e.getCtrlOrMetaKey() && isSelected(sel)) {
deselect(sel);
} else if (!isSelected(sel)) {
grid.getView().focusCell(rowIndex, colIndex, false);
cellSelected = new CellSelection<M>(sel, rowIndex, colIndex);
select(sel, false);
}
} else if (!e.getCtrlOrMetaKey()) {
if (event.getEvent().getShiftKey() && lastSelected != null) {
int last = listStore.indexOf(lastSelected);
int index = rowIndex;
grid.getView().focusCell(index, colIndex, false);
select(last, index, e.getCtrlOrMetaKey());
} else if (!isSelected(sel)) {
grid.getView().focusCell(rowIndex, colIndex, false);
cellSelected = new CellSelection<M>(sel, rowIndex, colIndex);
doSelect(Collections.singletonList(sel), false, false);
}
} else {
// EXTGWT-2019 when inline editing for grid and tree grid with
// row based
// selection model focus is not
// being moved to grid when clicking on another cell in same row
// as
// active edit and therefore
// field is not bluring and firing change event
grid.getView().focus();
}
}
mouseDown = false;
*/
}
public CellSelection<M> getCellSelected() {

View File

@ -0,0 +1,78 @@
package org.gcube.portlets.user.tdwx.client.config;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.event.shared.HandlerRegistration;
import com.sencha.gxt.widget.core.client.event.LiveGridViewUpdateEvent;
import com.sencha.gxt.widget.core.client.event.LiveGridViewUpdateEvent.LiveGridViewUpdateHandler;
import com.sencha.gxt.widget.core.client.grid.Grid;
import com.sencha.gxt.widget.core.client.grid.GridSelectionModel;
import com.sencha.gxt.widget.core.client.grid.LiveGridView;
import com.sencha.gxt.widget.core.client.grid.LiveToolItem;
import com.sencha.gxt.widget.core.client.selection.SelectionChangedEvent;
import com.sencha.gxt.widget.core.client.selection.SelectionChangedEvent.SelectionChangedHandler;
/**
* Extend LiveToolItem adding selected rows
*
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class TDXLiveToolItem extends LiveToolItem {
private HandlerRegistration handlerRegistration;
public TDXLiveToolItem(Grid<?> grid) {
super(grid);
}
@Override
protected void onUpdate(LiveGridViewUpdateEvent be) {
int pageSize = be.getRowCount();
int viewIndex = be.getViewIndex();
int totalCount = be.getTotalCount();
int i = pageSize + viewIndex;
if (i > totalCount) {
i = totalCount;
}
setLabel(getMessages().displayMessage(
totalCount == 0 ? 0 : viewIndex + 1, i, (int) totalCount));
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void bindGrid(Grid<?> grid) {
if (handlerRegistration != null) {
handlerRegistration.removeHandler();
handlerRegistration = null;
}
if (grid != null) {
LiveGridView<?> view = (LiveGridView<?>) grid.getView();
view.addLiveGridViewUpdateHandler(new LiveGridViewUpdateHandler() {
@Override
public void onUpdate(LiveGridViewUpdateEvent event) {
TDXLiveToolItem.this.onUpdate(event);
}
});
GridSelectionModel<?> selectionModel = (GridSelectionModel<?>)grid.getSelectionModel();
selectionModel.addSelectionChangedHandler(new SelectionChangedHandler(){
@Override
public void onSelectionChanged(
SelectionChangedEvent event) {
if(event.getSelection()!=null){
Log.debug("Selected List Items: "+event.getSelection().size());
} else {
}
}});
}
}
}