diff --git a/src/main/java/org/gcube/portlets/user/tdwx/client/TabularDataXGridPanel.java b/src/main/java/org/gcube/portlets/user/tdwx/client/TabularDataXGridPanel.java index 544d038..7738f5d 100644 --- a/src/main/java/org/gcube/portlets/user/tdwx/client/TabularDataXGridPanel.java +++ b/src/main/java/org/gcube/portlets/user/tdwx/client/TabularDataXGridPanel.java @@ -721,7 +721,7 @@ public class TabularDataXGridPanel extends ContentPanel { }); if (grid == null) { - + Log.debug("Setup grid null"); reader = new DataRowPagingReader(tableDefinition); String path = GWT.getModuleBaseURL() + "tdwxdata"; @@ -824,6 +824,7 @@ public class TabularDataXGridPanel extends ContentPanel { } } else { + Log.debug("Setup grid not null"); // TODO we need to manually reset the sort loader.clearSortInfo(); reader.setDefinition(tableDefinition); diff --git a/src/main/java/org/gcube/portlets/user/tdwx/client/config/GridAndCellSelectionModel.java b/src/main/java/org/gcube/portlets/user/tdwx/client/config/GridAndCellSelectionModel.java index c76d221..aca8e28 100644 --- a/src/main/java/org/gcube/portlets/user/tdwx/client/config/GridAndCellSelectionModel.java +++ b/src/main/java/org/gcube/portlets/user/tdwx/client/config/GridAndCellSelectionModel.java @@ -1,18 +1,13 @@ package org.gcube.portlets.user.tdwx.client.config; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.dom.client.Element; -import com.google.gwt.event.logical.shared.BeforeSelectionEvent; -import com.google.gwt.event.logical.shared.SelectionEvent; import com.google.gwt.user.client.Event; import com.sencha.gxt.core.client.Style.SelectionMode; -import com.sencha.gxt.data.shared.ListStore; import com.sencha.gxt.data.shared.ModelKeyProvider; -import com.sencha.gxt.data.shared.TreeStore; import com.sencha.gxt.data.shared.event.StoreClearEvent; import com.sencha.gxt.widget.core.client.event.RowClickEvent; import com.sencha.gxt.widget.core.client.event.RowMouseDownEvent; @@ -34,7 +29,7 @@ public class GridAndCellSelectionModel extends GridSelectionModel { private CellSelection cellSelected; private boolean focusCellCalled; private int indexOnSelectNoShift; - private List totalSelected = new ArrayList(); + //private List totalSelected = new ArrayList(); public GridAndCellSelectionModel() { @@ -237,173 +232,26 @@ public class GridAndCellSelectionModel extends GridSelectionModel { @Override public void refresh() { Log.debug("Selection Model Called Refresh()"); - selected.clear(); - selected.addAll(totalSelected); - - - if (!selected.isEmpty()) { - setLastFocused(selected.get(selected.size() - 1)); - doSelect(selected, false, true); - } } - @Override - protected void doDeselect(List models, boolean suppressEvent) { - if (locked) - return; - boolean change = false; - for (M m : models) { - totalSelected.remove(m); - if (selected.remove(m)) { - if (lastSelected == m) { - lastSelected = selected.size() > 0 ? selected.get(selected - .size() - 1) : null; - } - onSelectChange(m, false); - change = true; - } - } - if (!suppressEvent && change) { - fireSelectionChange(); - } - } - - @Override - protected void doMultiSelect(List models, boolean keepExisting, - boolean suppressEvent) { - if (locked) - return; - boolean change = false; - if (!keepExisting && selected.size() > 0) { - change = true; - doDeselect(new ArrayList(selected), true); - } - for (M m : models) { - boolean isSelected = isSelected(m); - if (!suppressEvent && !isSelected) { - BeforeSelectionEvent evt = BeforeSelectionEvent - .fire(this, m); - if (evt != null && evt.isCanceled()) { - continue; - } - } - - change = true; - lastSelected = m; - - totalSelected.add(m); - selected.add(m); - setLastFocused(lastSelected); - - if (!isSelected) { - onSelectChange(m, true); - if (!suppressEvent) { - SelectionEvent.fire(this, m); - } - } - } - - if (change && !suppressEvent) { - fireSelectionChange(); - } - } - - @Override - protected void doSelect(List models, boolean keepExisting, - boolean suppressEvent) { - if (locked) - return; - if (selectionMode == SelectionMode.SINGLE) { - M m = models.size() > 0 ? models.get(0) : null; - if (m != null) { - doSingleSelect(m, suppressEvent); - } - } else { - doMultiSelect(models, keepExisting, suppressEvent); - } - } - - @Override - protected void doSingleSelect(M model, boolean suppressEvent) { - if (locked) - return; - - int index = -1; - if (store instanceof ListStore) { - ListStore ls = (ListStore) store; - index = ls.indexOf(model); - } - if (store instanceof TreeStore) { - TreeStore ls = (TreeStore) store; - index = ls.indexOf(model); - } - if (index == -1 || isSelected(model)) { - return; - } else { - if (!suppressEvent) { - BeforeSelectionEvent evt = BeforeSelectionEvent.fire(this, - model); - if (evt != null && evt.isCanceled()) { - return; - } - } - } - - boolean change = false; - if (selected.size() > 0 && !isSelected(model)) { - doDeselect(Collections.singletonList(lastSelected), true); - change = true; - } - if (selected.size() == 0) { - change = true; - } - totalSelected.add(model); - selected.add(model); - lastSelected = model; - onSelectChange(model, true); - setLastFocused(lastSelected); - - if (!suppressEvent) { - SelectionEvent.fire(this, model); - } - - if (change && !suppressEvent) { - fireSelectionChange(); - } - } @Override protected void onClear(StoreClearEvent event) { Log.debug("Selection Model Called OnClear()"); - /*int oldSize = selected.size(); - selected.clear(); - totalSelected.clear(); - lastSelected = null; - setLastFocused(null); - if (oldSize > 0) - fireSelectionChange();*/ + } @Override - protected void onRemove(M model) { - ModelKeyProvider mod = grid.getStore().getKeyProvider(); - - Log.debug("Selection Model Called OnRemove(): "+mod.getKey(model)); + protected void onRemove(M model) { + Log.debug("Selection Model Called OnRemove(): "); } @Override protected void onAdd(List models) { - ModelKeyProvider mod = grid.getStore().getKeyProvider(); - for(M m:models){ - Log.debug("Selection Model Called OnAdd(): "+mod.getKey(m)); - } super.onAdd(models); - - selected.clear(); - selected.addAll(totalSelected); - - - for(M item: totalSelected){ + + ModelKeyProvider mod = grid.getStore().getKeyProvider(); + for(M item: selected){ Log.debug("Selected: "+mod.getKey(item)); } @@ -413,7 +261,7 @@ public class GridAndCellSelectionModel extends GridSelectionModel { boolean notChanged; for (M model : gridView.getCacheStore().getAll()) { notChanged=true; - for (M item : totalSelected) { + for (M item : selected) { if (mod.getKey(model).compareTo(mod.getKey(item)) == 0) { onSelectChange(model, true); notChanged=false; diff --git a/src/main/java/org/gcube/portlets/user/tdwx/client/config/TDXLiveToolItem.java b/src/main/java/org/gcube/portlets/user/tdwx/client/config/TDXLiveToolItem.java index 5fd3f0a..f78b63e 100644 --- a/src/main/java/org/gcube/portlets/user/tdwx/client/config/TDXLiveToolItem.java +++ b/src/main/java/org/gcube/portlets/user/tdwx/client/config/TDXLiveToolItem.java @@ -2,9 +2,6 @@ package org.gcube.portlets.user.tdwx.client.config; import java.util.List; -import org.gcube.portlets.user.tdwx.client.model.grid.DataRowModelKeyProvider; -import org.gcube.portlets.user.tdwx.shared.model.DataRow; - import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.event.shared.HandlerRegistration; import com.sencha.gxt.widget.core.client.event.LiveGridViewUpdateEvent; @@ -130,7 +127,7 @@ public class TDXLiveToolItem extends LiveToolItem { if (grid != null) { ExtendedLiveGridView view = (ExtendedLiveGridView) grid .getView(); - final DataRowModelKeyProvider modelKeyProvider = (DataRowModelKeyProvider)grid.getStore().getKeyProvider(); + //final DataRowModelKeyProvider modelKeyProvider = (DataRowModelKeyProvider)grid.getStore().getKeyProvider(); view.addLiveGridViewUpdateHandler(new LiveGridViewUpdateHandler() { @Override @@ -138,10 +135,7 @@ public class TDXLiveToolItem extends LiveToolItem { ExtendedLiveGridView source = (ExtendedLiveGridView) event .getSource(); Log.debug("CacheStore List Items: " + source.getCacheSize()); - for (DataRow dataRow : (List) source.getCacheStore() - .getAll()) { - //Log.debug("Item:" + modelKeyProvider.getKey(dataRow)); - } + TDXLiveToolItem.this.onUpdate(event); } }); @@ -159,10 +153,6 @@ public class TDXLiveToolItem extends LiveToolItem { if (event.getSelection() != null) { Log.debug("Selected List Items: " + event.getSelection().size()); - for (DataRow dataRow : (List) event.getSelection()) { - //Log.debug("Item:" + modelKeyProvider.getKey(dataRow)); - } - lastSelected = event.getSelection(); setLabel(getMessages().displayMessage(