From 0a9b87cfcf8294862ce55f371ab8ec724139b4bf Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Fri, 20 Dec 2013 14:47:53 +0000 Subject: [PATCH] git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-widgetx@87261 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../user/tdwx/client/TabularDataX.java | 14 +++ .../tdwx/client/TabularDataXController.java | 2 + .../tdwx/client/TabularDataXGridPanel.java | 106 ++++++++++-------- 3 files changed, 75 insertions(+), 47 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/tdwx/client/TabularDataX.java b/src/main/java/org/gcube/portlets/user/tdwx/client/TabularDataX.java index 9e9df94..2a5d92e 100644 --- a/src/main/java/org/gcube/portlets/user/tdwx/client/TabularDataX.java +++ b/src/main/java/org/gcube/portlets/user/tdwx/client/TabularDataX.java @@ -144,5 +144,19 @@ public class TabularDataX { } 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; + } } diff --git a/src/main/java/org/gcube/portlets/user/tdwx/client/TabularDataXController.java b/src/main/java/org/gcube/portlets/user/tdwx/client/TabularDataXController.java index a2e97a8..55b688a 100644 --- a/src/main/java/org/gcube/portlets/user/tdwx/client/TabularDataXController.java +++ b/src/main/java/org/gcube/portlets/user/tdwx/client/TabularDataXController.java @@ -101,5 +101,7 @@ public class TabularDataXController { { service.getTableDefinition(tableId, callback); } + + } 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 9e81b9b..d185914 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 @@ -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.TableReadyEvent; 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.DataRowPagingReader; 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.TableDefinition; - import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; @@ -66,11 +66,11 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar; /** * - * @author "Giancarlo Panichi" - * g.panichi@isti.cnr.it + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + * Defines the panel that will contain the grid * - * Defines the panel that will contain the grid - * */ public class TabularDataXGridPanel extends ContentPanel { @@ -78,11 +78,10 @@ public class TabularDataXGridPanel extends ContentPanel { protected EventBus eventBus; - protected List headerColumnMenuItems; - + protected List headerColumnMenuItems; + protected com.google.web.bindery.event.shared.EventBus externalBus; - - + protected Grid grid; protected VerticalLayoutContainer container; @@ -132,7 +131,7 @@ public class TabularDataXGridPanel extends ContentPanel { public Grid getGrid() { return grid; } - + /** * Return the context menu of grid * @@ -166,34 +165,33 @@ public class TabularDataXGridPanel extends ContentPanel { } /** - * * - * Set SelectionMode * - * The selection model supports 3 different selection modes: SINGLE - * - Only single selections allowed SIMPLE - Multiple selections - * without having to use the control and shift keys MULTI - Multiple - * selections + * Set SelectionMode + * + * The selection model supports 3 different selection modes: SINGLE - Only + * single selections allowed SIMPLE - Multiple selections without having to + * use the control and shift keys MULTI - Multiple selections * * * @param mode */ public void setSelectionModel(SelectionMode mode) { - if (grid != null && grid.getSelectionModel()!=null) { + if (grid != null && grid.getSelectionModel() != null) { grid.getSelectionModel().setSelectionMode(mode); } } /** - * * - * getSelectedRows + * + * getSelectedRows * * @return List when multiple selection is enable */ public List getSelectedRows() { - if (grid != null && grid.getSelectionModel()!=null) { + if (grid != null && grid.getSelectionModel() != null) { List dataRows = grid.getSelectionModel() .getSelectedItems(); List rows = new ArrayList(); @@ -225,7 +223,6 @@ public class TabularDataXGridPanel extends ContentPanel { eventBus.addHandler(CloseTableEvent.TYPE, new CloseTableEventHandler() { - public void onCloseTable(CloseTableEvent event) { doCloseTable(); } @@ -324,7 +321,6 @@ public class TabularDataXGridPanel extends ContentPanel { Scheduler.get().scheduleDeferred(new ScheduledCommand() { - public void execute() { container.forceLayout(); } @@ -358,14 +354,13 @@ public class TabularDataXGridPanel extends ContentPanel { grid.setContextMenu(contextMenu); } else grid.setContextMenu(null); - - if(headerColumnMenuItems!=null){ - setHeaderContextMenuHandler(); - } - + + if (headerColumnMenuItems != null) { + setHeaderContextMenuHandler(); + } + } - - + /** * * Add Items to menu of Columns @@ -373,21 +368,20 @@ public class TabularDataXGridPanel extends ContentPanel { * @param items * @param externalBus */ - public void addGridHeaderContextMenuItems(final List items, + public void addGridHeaderContextMenuItems(final List items, com.google.web.bindery.event.shared.EventBus externalBus) { this.headerColumnMenuItems = items; - this.externalBus=externalBus; + this.externalBus = externalBus; } - + /** - * Set Items on Menu of Columns + * Set Items on Menu of Columns * */ - protected void setHeaderContextMenuHandler(){ - - HeaderContextMenuHandler headerContextMenuHandler=new HeaderContextMenuEvent.HeaderContextMenuHandler() { - - + protected void setHeaderContextMenuHandler() { + + HeaderContextMenuHandler headerContextMenuHandler = new HeaderContextMenuEvent.HeaderContextMenuHandler() { + public void onHeaderContextMenu(HeaderContextMenuEvent event) { Log.debug("Header Menu"); final Menu menu = event.getMenu(); @@ -403,16 +397,17 @@ public class TabularDataXGridPanel extends ContentPanel { .getSelectedItem(); if (headerColumnMenuItems.contains(menuItem)) { Log.debug("Event Fire on EventBus"); - externalBus.fireEvent(new GridHeaderColumnMenuItemEvent( - GridHeaderColumnMenuItemType.SELECTED, - menuItem.getId(), colIndex)); - + externalBus + .fireEvent(new GridHeaderColumnMenuItemEvent( + GridHeaderColumnMenuItemType.SELECTED, + menuItem.getId(), colIndex)); + menu.hide(); } } } }; - + menu.addSelectionHandler(handlerHeaderContextMenu); Log.debug("Adding Items to menu"); @@ -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 columnModel = grid.getColumnModel(); + List> columns = columnModel.getColumns(); + + DataRowColumnConfig dc = (DataRowColumnConfig) columns.get(i); + + columnId = dc.getDefinition().getId(); + Log.debug("Column - Definition: Id: " + columnId); + + } + return columnId; + } + }