Minor updated

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-widgetx@86950 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2013-12-16 09:34:50 +00:00 committed by Giancarlo Panichi
parent 227e334756
commit ca6d34fe06
3 changed files with 74 additions and 1 deletions

View File

@ -97,6 +97,13 @@
<scope>test</scope>
</dependency>
<!-- tabular-data-widget-common-event -->
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>tabular-data-widget-common-event</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<!-- LOGGING -->
<dependency>
<groupId>com.allen-sauer.gwt.log</groupId>

View File

@ -9,6 +9,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.GridHeaderColumnMenuItemEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.GridHeaderColumnMenuItemType;
import org.gcube.portlets.user.tdwx.client.config.Row;
import org.gcube.portlets.user.tdwx.client.config.TableViewConfig;
import org.gcube.portlets.user.tdwx.client.config.TabularDataGridViewConfig;
@ -30,10 +32,13 @@ 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;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.http.client.RequestBuilder;
import com.sencha.gxt.core.client.Style.SelectionMode;
@ -46,17 +51,23 @@ import com.sencha.gxt.data.shared.loader.PagingLoader;
import com.sencha.gxt.widget.core.client.ContentPanel;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
import com.sencha.gxt.widget.core.client.event.HeaderContextMenuEvent;
import com.sencha.gxt.widget.core.client.event.HeaderContextMenuEvent.HeaderContextMenuHandler;
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
import com.sencha.gxt.widget.core.client.grid.Grid;
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.menu.Item;
import com.sencha.gxt.widget.core.client.menu.Menu;
import com.sencha.gxt.widget.core.client.menu.MenuItem;
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
/**
* @author "Federico De Faveri defaveri@isti.cnr.it"
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class TabularDataXGridPanel extends ContentPanel {
@ -64,6 +75,11 @@ public class TabularDataXGridPanel extends ContentPanel {
protected EventBus eventBus;
protected List<MenuItem> items;
protected EventBus externalBus;
protected Grid<DataRow> grid;
protected VerticalLayoutContainer container;
@ -327,5 +343,53 @@ public class TabularDataXGridPanel extends ContentPanel {
} else
grid.setContextMenu(null);
}
/**
*
*/
public void setHeaderContextMenuItems(final List<MenuItem> items, EventBus externalBus) {
this.items = items;
this.externalBus=externalBus;
grid.addHeaderContextMenuHandler(new HeaderContextMenuHandler() {
public void onHeaderContextMenu(HeaderContextMenuEvent event) {
final Menu menu = event.getMenu();
Log.debug("Header Menu add");
final int colIndex = event.getColumnIndex();
final SelectionHandler<Item> handlerHeaderContextMenu = new SelectionHandler<Item>() {
public void onSelection(SelectionEvent<Item> event) {
Log.debug("Selected: "
+ event.getSelectedItem().getId());
if (event.getSelectedItem() instanceof MenuItem) {
Log.debug("Event instanceof MenuItem");
MenuItem menuItem = (MenuItem) event
.getSelectedItem();
if (items.contains(menuItem)) {
Log.debug("Event Fire on EventBus");
eventBus.fireEvent(new GridHeaderColumnMenuItemEvent(
GridHeaderColumnMenuItemType.SELECTED,
menuItem.getId(), colIndex));
menu.hide();
}
}
}
};
menu.addSelectionHandler(handlerHeaderContextMenu);
Log.debug("Adding Items to menu");
for (MenuItem m : items) {
menu.add(m);
}
menu.show();
}
});
}
}

View File

@ -8,6 +8,8 @@
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
<inherits name='org.gcube.portlets.user.td.widgetcommonevent.WidgetCommonEvent' />
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />