This commit is contained in:
Giancarlo Panichi 2013-12-20 14:47:53 +00:00 committed by Giancarlo Panichi
parent 4a241c3af3
commit 0a9b87cfcf
3 changed files with 75 additions and 47 deletions

View File

@ -145,4 +145,18 @@ public class TabularDataX {
return new TableId(defaultDataSourceFactoryName, tableKey); return new TableId(defaultDataSourceFactoryName, tableKey);
} }
/**
*
* @param i index of column in ColumnModel
* @return id of column and equals to column name on service
*/
public String getColumnId(int i){
String columnId=null;
if(gridPanel!=null){
columnId=gridPanel.getColumnId(i);
}
return columnId;
}
} }

View File

@ -102,4 +102,6 @@ public class TabularDataXController {
service.getTableDefinition(tableId, callback); service.getTableDefinition(tableId, callback);
} }
} }

View File

@ -20,6 +20,7 @@ import org.gcube.portlets.user.tdwx.client.event.OpenTableEvent;
import org.gcube.portlets.user.tdwx.client.event.OpenTableEventHandler; import org.gcube.portlets.user.tdwx.client.event.OpenTableEventHandler;
import org.gcube.portlets.user.tdwx.client.event.TableReadyEvent; import org.gcube.portlets.user.tdwx.client.event.TableReadyEvent;
import org.gcube.portlets.user.tdwx.client.event.TableReadyEventHandler; import org.gcube.portlets.user.tdwx.client.event.TableReadyEventHandler;
import org.gcube.portlets.user.tdwx.client.model.grid.DataRowColumnConfig;
import org.gcube.portlets.user.tdwx.client.model.grid.DataRowModelKeyProvider; import org.gcube.portlets.user.tdwx.client.model.grid.DataRowModelKeyProvider;
import org.gcube.portlets.user.tdwx.client.model.grid.DataRowPagingReader; import org.gcube.portlets.user.tdwx.client.model.grid.DataRowPagingReader;
import org.gcube.portlets.user.tdwx.client.model.util.ColumnConfigGenerator; import org.gcube.portlets.user.tdwx.client.model.util.ColumnConfigGenerator;
@ -32,7 +33,6 @@ import org.gcube.portlets.user.tdwx.shared.model.ColumnType;
import org.gcube.portlets.user.tdwx.shared.model.DataRow; import org.gcube.portlets.user.tdwx.shared.model.DataRow;
import org.gcube.portlets.user.tdwx.shared.model.TableDefinition; import org.gcube.portlets.user.tdwx.shared.model.TableDefinition;
import com.allen_sauer.gwt.log.client.Log; import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler;
@ -66,10 +66,10 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
/** /**
* *
* @author "Giancarlo Panichi" * @author "Giancarlo Panichi" <a
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
* Defines the panel that will contain the grid * Defines the panel that will contain the grid
* *
*/ */
public class TabularDataXGridPanel extends ContentPanel { public class TabularDataXGridPanel extends ContentPanel {
@ -82,7 +82,6 @@ public class TabularDataXGridPanel extends ContentPanel {
protected com.google.web.bindery.event.shared.EventBus externalBus; protected com.google.web.bindery.event.shared.EventBus externalBus;
protected Grid<DataRow> grid; protected Grid<DataRow> grid;
protected VerticalLayoutContainer container; protected VerticalLayoutContainer container;
@ -168,18 +167,17 @@ public class TabularDataXGridPanel extends ContentPanel {
/** /**
* *
* *
* Set SelectionMode * Set SelectionMode
* *
* The selection model supports 3 different selection modes: SINGLE * The selection model supports 3 different selection modes: SINGLE - Only
* - Only single selections allowed SIMPLE - Multiple selections * single selections allowed SIMPLE - Multiple selections without having to
* without having to use the control and shift keys MULTI - Multiple * use the control and shift keys MULTI - Multiple selections
* selections
* *
* *
* @param mode * @param mode
*/ */
public void setSelectionModel(SelectionMode mode) { public void setSelectionModel(SelectionMode mode) {
if (grid != null && grid.getSelectionModel()!=null) { if (grid != null && grid.getSelectionModel() != null) {
grid.getSelectionModel().setSelectionMode(mode); grid.getSelectionModel().setSelectionMode(mode);
} }
} }
@ -187,13 +185,13 @@ public class TabularDataXGridPanel extends ContentPanel {
/** /**
* *
* *
* getSelectedRows * getSelectedRows
* *
* @return List<Row> when multiple selection is enable * @return List<Row> when multiple selection is enable
*/ */
public List<Row> getSelectedRows() { public List<Row> getSelectedRows() {
if (grid != null && grid.getSelectionModel()!=null) { if (grid != null && grid.getSelectionModel() != null) {
List<DataRow> dataRows = grid.getSelectionModel() List<DataRow> dataRows = grid.getSelectionModel()
.getSelectedItems(); .getSelectedItems();
List<Row> rows = new ArrayList<Row>(); List<Row> rows = new ArrayList<Row>();
@ -225,7 +223,6 @@ public class TabularDataXGridPanel extends ContentPanel {
eventBus.addHandler(CloseTableEvent.TYPE, new CloseTableEventHandler() { eventBus.addHandler(CloseTableEvent.TYPE, new CloseTableEventHandler() {
public void onCloseTable(CloseTableEvent event) { public void onCloseTable(CloseTableEvent event) {
doCloseTable(); doCloseTable();
} }
@ -324,7 +321,6 @@ public class TabularDataXGridPanel extends ContentPanel {
Scheduler.get().scheduleDeferred(new ScheduledCommand() { Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() { public void execute() {
container.forceLayout(); container.forceLayout();
} }
@ -359,13 +355,12 @@ public class TabularDataXGridPanel extends ContentPanel {
} else } else
grid.setContextMenu(null); grid.setContextMenu(null);
if(headerColumnMenuItems!=null){ if (headerColumnMenuItems != null) {
setHeaderContextMenuHandler(); setHeaderContextMenuHandler();
} }
} }
/** /**
* *
* Add Items to menu of Columns * Add Items to menu of Columns
@ -376,17 +371,16 @@ public class TabularDataXGridPanel extends ContentPanel {
public void addGridHeaderContextMenuItems(final List<MenuItem> items, public void addGridHeaderContextMenuItems(final List<MenuItem> items,
com.google.web.bindery.event.shared.EventBus externalBus) { com.google.web.bindery.event.shared.EventBus externalBus) {
this.headerColumnMenuItems = items; this.headerColumnMenuItems = items;
this.externalBus=externalBus; this.externalBus = externalBus;
} }
/** /**
* Set Items on Menu of Columns * Set Items on Menu of Columns
* *
*/ */
protected void setHeaderContextMenuHandler(){ protected void setHeaderContextMenuHandler() {
HeaderContextMenuHandler headerContextMenuHandler=new HeaderContextMenuEvent.HeaderContextMenuHandler() {
HeaderContextMenuHandler headerContextMenuHandler = new HeaderContextMenuEvent.HeaderContextMenuHandler() {
public void onHeaderContextMenu(HeaderContextMenuEvent event) { public void onHeaderContextMenu(HeaderContextMenuEvent event) {
Log.debug("Header Menu"); Log.debug("Header Menu");
@ -403,9 +397,10 @@ public class TabularDataXGridPanel extends ContentPanel {
.getSelectedItem(); .getSelectedItem();
if (headerColumnMenuItems.contains(menuItem)) { if (headerColumnMenuItems.contains(menuItem)) {
Log.debug("Event Fire on EventBus"); Log.debug("Event Fire on EventBus");
externalBus.fireEvent(new GridHeaderColumnMenuItemEvent( externalBus
GridHeaderColumnMenuItemType.SELECTED, .fireEvent(new GridHeaderColumnMenuItemEvent(
menuItem.getId(), colIndex)); GridHeaderColumnMenuItemType.SELECTED,
menuItem.getId(), colIndex));
menu.hide(); menu.hide();
} }
@ -428,8 +423,25 @@ public class TabularDataXGridPanel extends ContentPanel {
} }
/**
*
* @param i index of column in ColumnModel
* @return id of column and equals to column name on service
*/
public String getColumnId(int i) {
Log.debug("Retrive Column Id of column:" + i);
String columnId = null;
if (grid != null) {
ColumnModel<DataRow> columnModel = grid.getColumnModel();
List<ColumnConfig<DataRow, ?>> columns = columnModel.getColumns();
DataRowColumnConfig<?> dc = (DataRowColumnConfig<?>) columns.get(i);
columnId = dc.getDefinition().getId();
Log.debug("Column - Definition: Id: " + columnId);
}
return columnId;
}
} }