Added first events

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-portlet@74917 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Federico De Faveri 2013-05-14 12:24:27 +00:00
parent 4a422f4bda
commit 16fd10f936
6 changed files with 426 additions and 0 deletions

View File

@ -0,0 +1,52 @@
/**
*
*/
package org.gcube.portlets.user.td.client;
import org.gcube.portlets.user.td.client.event.ImportTableEvent;
import org.gcube.portlets.user.td.client.event.ImportTableType;
import com.allen_sauer.gwt.log.client.Log;
import com.google.web.bindery.event.shared.EventBus;
import com.google.web.bindery.event.shared.SimpleEventBus;
import com.sencha.gxt.widget.core.client.info.Info;
/**
* @author "Federico De Faveri defaveri@isti.cnr.it"
*
*/
public class TabularDataController {
protected EventBus eventBus;
public TabularDataController()
{
eventBus = new SimpleEventBus();
bindToEvents();
}
/**
* @return the eventBus
*/
public EventBus getEventBus() {
return eventBus;
}
protected void bindToEvents()
{
eventBus.addHandler(ImportTableEvent.TYPE, new ImportTableEvent.ImportTableHandler() {
@Override
public void onImportTable(ImportTableEvent event) {
doImportTable(event.getImportType());
}
});
}
public void doImportTable(ImportTableType importType)
{
Log.trace("doImportTable importType: "+importType);
Info.display("ImportTableEvent", "importType: "+importType);
}
}

View File

@ -0,0 +1,42 @@
package org.gcube.portlets.user.td.client.event;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.EventHandler;
import org.gcube.portlets.user.td.client.event.ImportTableType;
import com.google.gwt.event.shared.HasHandlers;
public class ImportTableEvent extends GwtEvent<ImportTableEvent.ImportTableHandler> {
public static Type<ImportTableHandler> TYPE = new Type<ImportTableHandler>();
private ImportTableType importType;
public interface ImportTableHandler extends EventHandler {
void onImportTable(ImportTableEvent event);
}
public ImportTableEvent(ImportTableType importType) {
this.importType = importType;
}
public ImportTableType getImportType() {
return importType;
}
@Override
protected void dispatch(ImportTableHandler handler) {
handler.onImportTable(this);
}
@Override
public Type<ImportTableHandler> getAssociatedType() {
return TYPE;
}
public static Type<ImportTableHandler> getType() {
return TYPE;
}
public static void fire(HasHandlers source, ImportTableType importType) {
source.fireEvent(new ImportTableEvent(importType));
}
}

View File

@ -0,0 +1,16 @@
/**
*
*/
package org.gcube.portlets.user.td.client.event;
/**
* @author "Federico De Faveri defaveri@isti.cnr.it"
*
*/
public enum ImportTableType {
NONE,
CSV,
SDMX;
}

View File

@ -0,0 +1,112 @@
/**
*
*/
package org.gcube.portlets.user.td.client.toolbar;
import org.gcube.portlets.user.td.client.resource.TabularDataResources;
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NodeList;
import com.google.gwt.dom.client.Style.Overflow;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonArrowAlign;
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonScale;
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
import com.sencha.gxt.core.client.dom.XElement;
import com.sencha.gxt.widget.core.client.ContentPanel;
import com.sencha.gxt.widget.core.client.button.ButtonGroup;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.button.ToggleButton;
import com.sencha.gxt.widget.core.client.container.FlowLayoutContainer;
import com.sencha.gxt.widget.core.client.container.MarginData;
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.menu.Menu;
import com.sencha.gxt.widget.core.client.menu.MenuItem;
import com.sencha.gxt.widget.core.client.toolbar.SeparatorToolItem;
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
/**
* @author "Federico De Faveri defaveri@isti.cnr.it"
*
*/
public class AnalysisToolBar {
protected ToolBar toolBar;
public AnalysisToolBar()
{
toolBar = new ToolBar();
build();
}
public ToolBar getToolBar()
{
return toolBar;
}
protected void build()
{
ButtonGroup group = new ButtonGroup();
group.setHeadingText("Chart");
toolBar.add(group);
FlexTable table = new FlexTable();
group.add(table);
TextButton btn = new TextButton("Bar", TabularDataResources.INSTANCE.chartBar());
table.setWidget(0, 0, btn);
btn = new TextButton("Curve", TabularDataResources.INSTANCE.chartCurve());
table.setWidget(1, 0, btn);
btn = new TextButton("Pie", TabularDataResources.INSTANCE.chartPie());
table.setWidget(0, 2, btn);
btn = new TextButton("Bulls", TabularDataResources.INSTANCE.chartBullsEye());
table.setWidget(1, 2, btn);
cleanCells(table.getElement());
group = new ButtonGroup();
group.setHeadingText("External Tool");
toolBar.add(group);
table = new FlexTable();
group.add(table);
btn = new TextButton("R Studio", TabularDataResources.INSTANCE.rstudio());
table.setWidget(0, 0, btn);
btn = new TextButton("Statistical", TabularDataResources.INSTANCE.sm());
table.setWidget(1, 0, btn);
/*btn = new TextButton("Pie", TabularDataResources.INSTANCE.chartPie());
table.setWidget(0, 2, btn);
btn = new TextButton("Bulls", TabularDataResources.INSTANCE.chartBullsEye());
table.setWidget(1, 2, btn);*/
cleanCells(table.getElement());
}
protected void cleanCells(Element elem) {
NodeList<Element> tds = elem.<XElement> cast().select("td");
for (int i = 0; i < tds.getLength(); i++) {
Element td = tds.getItem(i);
if (!td.hasChildNodes() && td.getClassName().equals("")) {
td.removeFromParent();
}
}
}
}

View File

@ -0,0 +1,159 @@
/**
*
*/
package org.gcube.portlets.user.td.client.toolbar;
import org.gcube.portlets.user.td.client.event.ImportTableEvent;
import org.gcube.portlets.user.td.client.event.ImportTableType;
import org.gcube.portlets.user.td.client.resource.TabularDataResources;
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NodeList;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonArrowAlign;
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonScale;
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
import com.sencha.gxt.core.client.dom.XElement;
import com.sencha.gxt.widget.core.client.button.ButtonGroup;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
/**
* @author "Federico De Faveri defaveri@isti.cnr.it"
*
*/
public class EditingToolBar {
protected EventBus eventBus;
protected ToolBar toolBar;
protected TextButton importButton;
protected TextButton importCSVButton;
protected TextButton importSDMXButton;
protected TextButton validationButton;
protected TextButton rulesButton;
protected TextButton exportButton;
protected TextButton exportCSVButton;
protected TextButton exportSDMXButton;
public EditingToolBar(EventBus eventBus)
{
this.eventBus = eventBus;
toolBar = new ToolBar();
build();
}
public ToolBar getToolBar()
{
return toolBar;
}
protected void build()
{
ButtonGroup importGroup = new ButtonGroup();
importGroup.setHeadingText("Import");
toolBar.add(importGroup);
FlexTable importLayout = new FlexTable();
importGroup.add(importLayout);
importButton = new TextButton("Import", TabularDataResources.INSTANCE.importTD());
importButton.setScale(ButtonScale.LARGE);
importButton.setIconAlign(IconAlign.TOP);
importButton.setToolTip("Imports a new table");
importButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
importButton.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
eventBus.fireEvent(new ImportTableEvent(ImportTableType.NONE));
}
});
importLayout.setWidget(0, 0, importButton);
importLayout.getFlexCellFormatter().setRowSpan(0, 0, 2);
importCSVButton = new TextButton("CSV", TabularDataResources.INSTANCE.csv());
importCSVButton.setToolTip("Imports a new table from a CSV file");
importLayout.setWidget(0, 2, importCSVButton);
importCSVButton.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
eventBus.fireEvent(new ImportTableEvent(ImportTableType.CSV));
}
});
importSDMXButton = new TextButton("SDMX", TabularDataResources.INSTANCE.sdmx());
importSDMXButton.setToolTip("Imports a new table from a SDMX registry");
importLayout.setWidget(1, 2, importSDMXButton);
importSDMXButton.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
eventBus.fireEvent(new ImportTableEvent(ImportTableType.SDMX));
}
});
cleanCells(importLayout.getElement());
ButtonGroup validationGroup = new ButtonGroup();
validationGroup.setHeadingText("Validation");
toolBar.add(validationGroup);
FlexTable validationLayout = new FlexTable();
validationGroup.add(validationLayout);
validationButton = new TextButton("Validate", TabularDataResources.INSTANCE.validation());
validationLayout.setWidget(0, 0, validationButton);
rulesButton = new TextButton("Rules", TabularDataResources.INSTANCE.rules());
validationLayout.setWidget(1, 0, rulesButton);
cleanCells(validationLayout.getElement());
ButtonGroup exportGroup = new ButtonGroup();
exportGroup.setHeadingText("Export");
toolBar.add(exportGroup);
FlexTable exportLayout = new FlexTable();
exportGroup.add(exportLayout);
exportButton = new TextButton("Export", TabularDataResources.INSTANCE.exportTD());
exportButton.setScale(ButtonScale.LARGE);
exportButton.setIconAlign(IconAlign.TOP);
exportButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
exportLayout.setWidget(0, 0, exportButton);
exportLayout.getFlexCellFormatter().setRowSpan(0, 0, 2);
exportCSVButton = new TextButton("CSV", TabularDataResources.INSTANCE.csv());
exportLayout.setWidget(0, 2, exportCSVButton);
exportSDMXButton = new TextButton("SDMX", TabularDataResources.INSTANCE.sdmx());
exportLayout.setWidget(1, 2, exportSDMXButton);
cleanCells(exportLayout.getElement());
}
protected void cleanCells(Element elem) {
NodeList<Element> tds = elem.<XElement> cast().select("td");
for (int i = 0; i < tds.getLength(); i++) {
Element td = tds.getItem(i);
if (!td.hasChildNodes() && td.getClassName().equals("")) {
td.removeFromParent();
}
}
}
}

View File

@ -0,0 +1,45 @@
/**
*
*/
package org.gcube.portlets.user.td.client.toolbar;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.widget.core.client.TabPanel;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
/**
* @author "Federico De Faveri defaveri@isti.cnr.it"
*
*/
public class TabularDataTooBar {
protected TabPanel container;
protected EditingToolBar editingToolBar;
protected AnalysisToolBar analysisToolBar;
public TabularDataTooBar(EventBus eventBus)
{
container = new TabPanel();
editingToolBar = new EditingToolBar(eventBus);
VerticalLayoutContainer con = new VerticalLayoutContainer();
con.add(editingToolBar.getToolBar(), new VerticalLayoutData(1, -1));
container.add(con, "Editing");
analysisToolBar = new AnalysisToolBar();
con = new VerticalLayoutContainer();
con.add(analysisToolBar.getToolBar(), new VerticalLayoutData(1, -1));
container.add(con, "Analysis");
}
/**
* @return the container
*/
public TabPanel getContainer() {
return container;
}
}