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

@ -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;
}
}

View File

@ -101,5 +101,7 @@ public class TabularDataXController {
{
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.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"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author "Giancarlo Panichi" <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 {
@ -78,11 +78,10 @@ public class TabularDataXGridPanel extends ContentPanel {
protected EventBus eventBus;
protected List<MenuItem> headerColumnMenuItems;
protected List<MenuItem> headerColumnMenuItems;
protected com.google.web.bindery.event.shared.EventBus externalBus;
protected Grid<DataRow> grid;
protected VerticalLayoutContainer container;
@ -132,7 +131,7 @@ public class TabularDataXGridPanel extends ContentPanel {
public Grid<DataRow> 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<Row> when multiple selection is enable
*/
public List<Row> getSelectedRows() {
if (grid != null && grid.getSelectionModel()!=null) {
if (grid != null && grid.getSelectionModel() != null) {
List<DataRow> dataRows = grid.getSelectionModel()
.getSelectedItems();
List<Row> rows = new ArrayList<Row>();
@ -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<MenuItem> items,
public void addGridHeaderContextMenuItems(final List<MenuItem> 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<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;
}
}