Fixed the behavior of the user interface
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-portlet@84342 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1aa29f874b
commit
cfe897d0ab
|
@ -14,6 +14,8 @@ import org.gcube.portlets.user.td.client.event.OpenFunctionalityEvent;
|
|||
import org.gcube.portlets.user.td.client.event.OpenFunctionalityType;
|
||||
import org.gcube.portlets.user.td.client.event.OpenTabularResourceEvent;
|
||||
import org.gcube.portlets.user.td.client.event.OpenTabularResourceType;
|
||||
import org.gcube.portlets.user.td.client.event.UIStateEvent;
|
||||
import org.gcube.portlets.user.td.client.event.UIStateType;
|
||||
import org.gcube.portlets.user.td.csvimportwidget.client.CSVImportWizardTD;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.TRId;
|
||||
import org.gcube.portlets.user.td.informationwidget.client.TabularResourceProperties;
|
||||
|
@ -30,9 +32,12 @@ import com.google.web.bindery.event.shared.SimpleEventBus;
|
|||
import com.sencha.gxt.widget.core.client.ContentPanel;
|
||||
import com.sencha.gxt.widget.core.client.TabItemConfig;
|
||||
import com.sencha.gxt.widget.core.client.TabPanel;
|
||||
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
|
||||
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.BorderLayoutData;
|
||||
import com.sencha.gxt.widget.core.client.event.BeforeCloseEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.HideEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.BeforeCloseEvent.BeforeCloseHandler;
|
||||
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
|
||||
import com.sencha.gxt.widget.core.client.info.Info;
|
||||
|
||||
/**
|
||||
|
@ -46,7 +51,7 @@ public class TabularDataController {
|
|||
|
||||
protected SimpleEventBus eventBus;
|
||||
protected TabularData tabularData;
|
||||
protected UIState uiState = UIState.START;
|
||||
protected UIStateType uiState = UIStateType.START;
|
||||
protected UIProperties uiProperties = UIProperties.CLOSED;
|
||||
|
||||
protected ContentPanel functionalityPanel;
|
||||
|
@ -148,9 +153,48 @@ public class TabularDataController {
|
|||
doOpenFunctionality(event.getOpenFunctionalityType());
|
||||
}
|
||||
});
|
||||
eventBus.fireEvent(new UIStateEvent(UIStateType.START));
|
||||
|
||||
}
|
||||
|
||||
protected void alertMessage(String reason, String details){
|
||||
AlertMessageBox d = new AlertMessageBox(reason,
|
||||
details);
|
||||
d.addHideHandler(new HideHandler() {
|
||||
|
||||
@Override
|
||||
public void onHide(HideEvent event) {
|
||||
//
|
||||
}
|
||||
|
||||
});
|
||||
d.show();
|
||||
}
|
||||
|
||||
protected void resumeUIState(){
|
||||
if(uiState==UIStateType.TR_OPEN){
|
||||
eventBus.fireEvent(new UIStateEvent(UIStateType.TR_OPEN));
|
||||
} else {
|
||||
eventBus.fireEvent(new UIStateEvent(UIStateType.TR_CLOSE));
|
||||
}
|
||||
}
|
||||
|
||||
protected void openTable(TRId tabularResourceId){
|
||||
trId = tabularResourceId;
|
||||
tableOpening = new TableId(
|
||||
Constants.TD_DATASOURCE_FACTORY_ID,
|
||||
trId.getTableId());
|
||||
tabularData.openTable(tableOpening);
|
||||
uiState = UIStateType.TR_OPEN;
|
||||
eventBus.fireEvent(new UIStateEvent(UIStateType.TR_OPEN));
|
||||
}
|
||||
|
||||
protected void openWizard(){
|
||||
eventBus.fireEvent(new UIStateEvent(UIStateType.WIZARD_OPEN));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void doImportTable(ImportTableType importType) {
|
||||
Log.trace("doImportTable importType: " + importType);
|
||||
Info.display("Import Tabular Resource", "type: " + importType);
|
||||
|
@ -248,7 +292,7 @@ public class TabularDataController {
|
|||
}
|
||||
|
||||
protected void openFunctionalityProperties() {
|
||||
if (uiState == UIState.TR_OPEN) {
|
||||
if (uiState == UIStateType.TR_OPEN) {
|
||||
if (uiProperties == UIProperties.OPENED) {
|
||||
functionalityPanel.collapse();
|
||||
functionalityPanel.disable();
|
||||
|
@ -298,39 +342,30 @@ public class TabularDataController {
|
|||
};
|
||||
|
||||
protected void openSDMXImportWizard() {
|
||||
|
||||
GWT.runAsync(new RunAsyncCallback() {
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
openWizard();
|
||||
SDMXImportWizardTD importWizard = new SDMXImportWizardTD(
|
||||
"SDMX Import");
|
||||
|
||||
importWizard
|
||||
.addListener(new org.gcube.portlets.user.td.sdmximportwidget.client.general.WizardListener() {
|
||||
|
||||
@Override
|
||||
public void completed(TRId tabularResourceId) {
|
||||
trId = tabularResourceId;
|
||||
tableOpening = new TableId(
|
||||
Constants.TD_DATASOURCE_FACTORY_ID,
|
||||
trId.getTableId());
|
||||
tabularData.openTable(tableOpening);
|
||||
uiState = UIState.TR_OPEN;
|
||||
|
||||
openTable(tabularResourceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void aborted() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
resumeUIState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable throwable,
|
||||
String reason, String details) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
alertMessage(reason, details);
|
||||
resumeUIState();
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -346,6 +381,9 @@ public class TabularDataController {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected void openSDMXExportWizard() {
|
||||
/*
|
||||
GWT.runAsync(new RunAsyncCallback() {
|
||||
|
@ -361,20 +399,17 @@ public class TabularDataController {
|
|||
@Override
|
||||
public void failed(Throwable throwable,
|
||||
String reason, String details) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completed(TRId id) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void aborted() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -393,9 +428,9 @@ public class TabularDataController {
|
|||
*
|
||||
*/
|
||||
protected void closeTabularResources() {
|
||||
if (uiState == UIState.TR_OPEN) {
|
||||
if (uiState == UIStateType.TR_OPEN) {
|
||||
tabularData.closeTable();
|
||||
uiState = UIState.START;
|
||||
uiState = UIStateType.TR_CLOSE;
|
||||
if (uiProperties == UIProperties.OPENED) {
|
||||
functionalityPanel.collapse();
|
||||
functionalityPanel.disable();
|
||||
|
@ -409,40 +444,33 @@ public class TabularDataController {
|
|||
*
|
||||
*/
|
||||
protected void openTabularResources() {
|
||||
|
||||
Log.info("Open Tabular Resources");
|
||||
|
||||
GWT.runAsync(new RunAsyncCallback() {
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
openWizard();
|
||||
TDOpen tdOpen = new TDOpen("Open Tabular Resource");
|
||||
|
||||
tdOpen.addListener(new org.gcube.portlets.user.td.openwidget.client.general.WizardListener() {
|
||||
|
||||
@Override
|
||||
public void aborted() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
resumeUIState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable throwable, String reason,
|
||||
String details) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
alertMessage(reason, details);
|
||||
resumeUIState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completed(TRId tabularResourceId) {
|
||||
trId = new TRId(tabularResourceId.getId(),
|
||||
tabularResourceId.getTableId());
|
||||
tableOpening = new TableId(
|
||||
Constants.TD_DATASOURCE_FACTORY_ID, trId
|
||||
.getTableId());
|
||||
tabularData.openTable(tableOpening);
|
||||
uiState = UIState.TR_OPEN;
|
||||
|
||||
openTable(tabularResourceId);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -458,20 +486,18 @@ public class TabularDataController {
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
* protected void doSDMXDatasetImport(List<Dataset> datasets) {
|
||||
* Log.info("doSDMXDatasetImport: " + datasets.size()); for (Dataset d :
|
||||
* datasets) { Log.info("Dataset: " + d.getId() + d.getName() +
|
||||
* d.getAgencyId()); }
|
||||
*
|
||||
* }
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
protected void openCSVImportWizard() {
|
||||
GWT.runAsync(new RunAsyncCallback() {
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
openWizard();
|
||||
CSVImportWizardTD importWizard = new CSVImportWizardTD(
|
||||
"CSV Import");
|
||||
|
||||
|
@ -481,20 +507,19 @@ public class TabularDataController {
|
|||
@Override
|
||||
public void failed(Throwable throwable,
|
||||
String reason, String details) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
alertMessage(reason, details);
|
||||
resumeUIState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completed(TRId id) {
|
||||
// TODO Auto-generated method stub
|
||||
openTable(id);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void aborted() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
resumeUIState();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -509,32 +534,6 @@ public class TabularDataController {
|
|||
|
||||
}
|
||||
|
||||
/*protected void openOldCSVImportWizard() {
|
||||
CSVImporterWidget csvImporterWidget = new CSVImporterWidget();
|
||||
csvImporterWidget.show(new TabularDataImporterListener() {
|
||||
|
||||
@Override
|
||||
public void failed(Throwable throwable, String reason,
|
||||
String details) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completed() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void aborted() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}*/
|
||||
|
||||
protected void asyncCodeLoadingFailed(Throwable reason) {
|
||||
Log.error("Async code loading failed", reason);
|
||||
Info.display("Async code loading failed",
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package org.gcube.portlets.user.td.client.event;
|
||||
|
||||
public enum UIStateType {
|
||||
START,
|
||||
TR_OPEN,
|
||||
TR_CLOSE,
|
||||
WIZARD_OPEN;
|
||||
}
|
|
@ -13,9 +13,12 @@ import org.gcube.portlets.user.td.client.event.OpenFunctionalityEvent;
|
|||
import org.gcube.portlets.user.td.client.event.OpenFunctionalityType;
|
||||
import org.gcube.portlets.user.td.client.event.OpenTabularResourceEvent;
|
||||
import org.gcube.portlets.user.td.client.event.OpenTabularResourceType;
|
||||
import org.gcube.portlets.user.td.client.event.UIStateEvent;
|
||||
import org.gcube.portlets.user.td.client.event.UIStateType;
|
||||
import org.gcube.portlets.user.td.client.resource.TabularDataResources;
|
||||
|
||||
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.dom.client.Element;
|
||||
import com.google.gwt.dom.client.NodeList;
|
||||
import com.google.gwt.user.client.ui.FlexTable;
|
||||
|
@ -28,133 +31,127 @@ 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;
|
||||
|
||||
import com.sencha.gxt.widget.core.client.info.Info;
|
||||
|
||||
/**
|
||||
*
|
||||
* @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>
|
||||
*
|
||||
*/
|
||||
public class FileToolBar {
|
||||
|
||||
protected EventBus eventBus;
|
||||
protected ToolBar toolBar;
|
||||
|
||||
|
||||
protected TextButton openButton;
|
||||
//protected TextButton saveButton;
|
||||
// protected TextButton saveButton;
|
||||
protected TextButton closeButton;
|
||||
protected TextButton propertiesButton;
|
||||
|
||||
|
||||
|
||||
protected TextButton importCSVButton;
|
||||
protected TextButton importJSONButton;
|
||||
protected TextButton importSDMXButton;
|
||||
|
||||
|
||||
protected TextButton exportSDMXButton;
|
||||
protected TextButton exportCSVButton;
|
||||
protected TextButton exportJSONButton;
|
||||
|
||||
public FileToolBar(EventBus eventBus)
|
||||
{
|
||||
|
||||
public FileToolBar(EventBus eventBus) {
|
||||
this.eventBus = eventBus;
|
||||
build();
|
||||
}
|
||||
|
||||
public ToolBar getToolBar()
|
||||
{
|
||||
|
||||
public ToolBar getToolBar() {
|
||||
return toolBar;
|
||||
}
|
||||
|
||||
protected void build()
|
||||
{
|
||||
protected void build() {
|
||||
toolBar = new ToolBar();
|
||||
toolBar.setSpacing(1);
|
||||
|
||||
//File
|
||||
|
||||
// File
|
||||
ButtonGroup fileGroup = new ButtonGroup();
|
||||
fileGroup.setId("File");
|
||||
fileGroup.setStyleName("ribbon");
|
||||
fileGroup.setHeadingText("File");
|
||||
toolBar.add(fileGroup);
|
||||
|
||||
|
||||
FlexTable dataLayout = new FlexTable();
|
||||
dataLayout.setStyleName("ribbon");
|
||||
fileGroup.add(dataLayout);
|
||||
|
||||
openButton = new TextButton("Open", TabularDataResources.INSTANCE.open32());
|
||||
|
||||
openButton = new TextButton("Open",
|
||||
TabularDataResources.INSTANCE.open32());
|
||||
openButton.setId("oepnButton");
|
||||
openButton.setScale(ButtonScale.LARGE);
|
||||
openButton.setIconAlign(IconAlign.TOP);
|
||||
openButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||
openButton.setToolTip("Open Tabular Resource");
|
||||
|
||||
|
||||
openButton.addSelectHandler(new SelectHandler() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
eventBus.fireEvent(new OpenTabularResourceEvent(OpenTabularResourceType.TABLE));
|
||||
eventBus.fireEvent(new OpenTabularResourceEvent(
|
||||
OpenTabularResourceType.TABLE));
|
||||
}
|
||||
});
|
||||
|
||||
dataLayout.setWidget(0, 0, openButton);
|
||||
dataLayout.getFlexCellFormatter().setRowSpan(0, 0, 2);
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
saveButton = new TextButton("Save", TabularDataResources.INSTANCE.save32());
|
||||
saveButton.setScale(ButtonScale.LARGE);
|
||||
saveButton.setIconAlign(IconAlign.TOP);
|
||||
saveButton.setToolTip("Save table");
|
||||
saveButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||
saveButton.addSelectHandler(new SelectHandler() {
|
||||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
//eventBus.fireEvent(new ImportTableEvent(ImportTableType.SDMX));
|
||||
}
|
||||
});
|
||||
* saveButton = new TextButton("Save",
|
||||
* TabularDataResources.INSTANCE.save32());
|
||||
* saveButton.setScale(ButtonScale.LARGE);
|
||||
* saveButton.setIconAlign(IconAlign.TOP);
|
||||
* saveButton.setToolTip("Save table");
|
||||
* saveButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||
* saveButton.addSelectHandler(new SelectHandler() {
|
||||
*
|
||||
* @Override public void onSelect(SelectEvent event) {
|
||||
* //eventBus.fireEvent(new ImportTableEvent(ImportTableType.SDMX)); }
|
||||
* });
|
||||
*
|
||||
* dataLayout.getFlexCellFormatter().setRowSpan(0, 1, 2);
|
||||
*
|
||||
* dataLayout.setWidget(0, 1, saveButton);
|
||||
*/
|
||||
|
||||
dataLayout.getFlexCellFormatter().setRowSpan(0, 1, 2);
|
||||
|
||||
dataLayout.setWidget(0, 1, saveButton);
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
closeButton = new TextButton("Close", TabularDataResources.INSTANCE.close());
|
||||
closeButton = new TextButton("Close",
|
||||
TabularDataResources.INSTANCE.close());
|
||||
closeButton.setId("closeButton");
|
||||
closeButton.setToolTip("Close table");
|
||||
|
||||
|
||||
dataLayout.setWidget(0, 2, closeButton);
|
||||
closeButton.addSelectHandler(new SelectHandler() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
eventBus.fireEvent(new CloseTabularResourceEvent(CloseTabularResourceType.TABLE));
|
||||
eventBus.fireEvent(new CloseTabularResourceEvent(
|
||||
CloseTabularResourceType.TABLE));
|
||||
}
|
||||
});
|
||||
|
||||
propertiesButton = new TextButton("Properties", TabularDataResources.INSTANCE.properties());
|
||||
propertiesButton = new TextButton("Properties",
|
||||
TabularDataResources.INSTANCE.properties());
|
||||
propertiesButton.setId("propertiesButton");
|
||||
propertiesButton.setToolTip("Show properties");
|
||||
|
||||
|
||||
dataLayout.setWidget(1, 2, propertiesButton);
|
||||
propertiesButton.addSelectHandler(new SelectHandler() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
eventBus.fireEvent(new OpenFunctionalityEvent(OpenFunctionalityType.PROPERTIES));
|
||||
eventBus.fireEvent(new OpenFunctionalityEvent(
|
||||
OpenFunctionalityType.PROPERTIES));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
cleanCells(dataLayout.getElement());
|
||||
|
||||
|
||||
|
||||
//Import
|
||||
|
||||
// Import
|
||||
ButtonGroup importGroup = new ButtonGroup();
|
||||
importGroup.setId("Import");
|
||||
importGroup.setStyleName("ribbon");
|
||||
|
@ -164,13 +161,14 @@ public class FileToolBar {
|
|||
FlexTable importLayout = new FlexTable();
|
||||
importGroup.add(importLayout);
|
||||
|
||||
importSDMXButton = new TextButton("SDMX", TabularDataResources.INSTANCE.sdmx32());
|
||||
importSDMXButton = new TextButton("SDMX",
|
||||
TabularDataResources.INSTANCE.sdmx32());
|
||||
importSDMXButton.setScale(ButtonScale.LARGE);
|
||||
importSDMXButton.setIconAlign(IconAlign.TOP);
|
||||
importSDMXButton.setToolTip("Import table from SDMX source");
|
||||
importSDMXButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||
importSDMXButton.addSelectHandler(new SelectHandler() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
eventBus.fireEvent(new ImportTableEvent(ImportTableType.SDMX));
|
||||
|
@ -180,10 +178,11 @@ public class FileToolBar {
|
|||
importLayout.setWidget(0, 0, importSDMXButton);
|
||||
importLayout.getFlexCellFormatter().setRowSpan(0, 0, 2);
|
||||
|
||||
importCSVButton = new TextButton("CSV", TabularDataResources.INSTANCE.csv());
|
||||
importCSVButton = new TextButton("CSV",
|
||||
TabularDataResources.INSTANCE.csv());
|
||||
importCSVButton.setToolTip("Import table from CSV source");
|
||||
importCSVButton.addSelectHandler(new SelectHandler() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
eventBus.fireEvent(new ImportTableEvent(ImportTableType.CSV));
|
||||
|
@ -191,11 +190,12 @@ public class FileToolBar {
|
|||
});
|
||||
importLayout.setWidget(0, 2, importCSVButton);
|
||||
|
||||
importJSONButton = new TextButton("JSON", TabularDataResources.INSTANCE.json());
|
||||
importJSONButton = new TextButton("JSON",
|
||||
TabularDataResources.INSTANCE.json());
|
||||
importJSONButton.disable();
|
||||
importJSONButton.setToolTip("Import table from JSON source");
|
||||
importJSONButton.addSelectHandler(new SelectHandler() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
eventBus.fireEvent(new ImportTableEvent(ImportTableType.JSON));
|
||||
|
@ -203,28 +203,27 @@ public class FileToolBar {
|
|||
});
|
||||
importLayout.setWidget(1, 2, importJSONButton);
|
||||
|
||||
|
||||
cleanCells(importLayout.getElement());
|
||||
|
||||
|
||||
//Export
|
||||
|
||||
// Export
|
||||
ButtonGroup exportGroup = new ButtonGroup();
|
||||
exportGroup.setId("Export");
|
||||
exportGroup.setStyleName("ribbon");
|
||||
exportGroup.setHeadingText("Export");
|
||||
exportGroup.disable();
|
||||
toolBar.add(exportGroup);
|
||||
|
||||
|
||||
FlexTable exportLayout = new FlexTable();
|
||||
exportGroup.add(exportLayout);
|
||||
|
||||
exportSDMXButton = new TextButton("SDMX", TabularDataResources.INSTANCE.sdmx32());
|
||||
exportSDMXButton = new TextButton("SDMX",
|
||||
TabularDataResources.INSTANCE.sdmx32());
|
||||
exportSDMXButton.setToolTip("Export SDMX document");
|
||||
exportSDMXButton.setScale(ButtonScale.LARGE);
|
||||
exportSDMXButton.setIconAlign(IconAlign.TOP);
|
||||
exportSDMXButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
|
||||
exportSDMXButton.addSelectHandler(new SelectHandler() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
eventBus.fireEvent(new ExportTableEvent(ExportTableType.SDMX));
|
||||
|
@ -234,21 +233,23 @@ public class FileToolBar {
|
|||
exportLayout.setWidget(0, 0, exportSDMXButton);
|
||||
exportLayout.getFlexCellFormatter().setRowSpan(0, 0, 2);
|
||||
|
||||
exportCSVButton = new TextButton("CSV", TabularDataResources.INSTANCE.csv());
|
||||
exportCSVButton = new TextButton("CSV",
|
||||
TabularDataResources.INSTANCE.csv());
|
||||
exportCSVButton.setToolTip("Export CSV document");
|
||||
exportCSVButton.addSelectHandler(new SelectHandler() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
eventBus.fireEvent(new ExportTableEvent(ExportTableType.CSV));
|
||||
}
|
||||
});
|
||||
exportLayout.setWidget(0, 2, exportCSVButton);
|
||||
|
||||
exportJSONButton = new TextButton("JSON", TabularDataResources.INSTANCE.json());
|
||||
|
||||
exportJSONButton = new TextButton("JSON",
|
||||
TabularDataResources.INSTANCE.json());
|
||||
exportJSONButton.setToolTip("Export JSON document");
|
||||
exportJSONButton.addSelectHandler(new SelectHandler() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
eventBus.fireEvent(new ExportTableEvent(ExportTableType.JSON));
|
||||
|
@ -256,19 +257,85 @@ public class FileToolBar {
|
|||
});
|
||||
exportLayout.setWidget(1, 2, exportJSONButton);
|
||||
|
||||
cleanCells(exportLayout.getElement());
|
||||
|
||||
cleanCells(exportLayout.getElement());
|
||||
|
||||
eventBus.addHandler(UIStateEvent.TYPE,
|
||||
new UIStateEvent.UIStateHandler() {
|
||||
|
||||
@Override
|
||||
public void onUIState(UIStateEvent event) {
|
||||
setUI(event.getUIStateType());
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setUI(UIStateType uiStateType) {
|
||||
try {
|
||||
switch (uiStateType) {
|
||||
case START:
|
||||
openButton.enable();
|
||||
closeButton.disable();
|
||||
propertiesButton.disable();
|
||||
importCSVButton.enable();
|
||||
importJSONButton.disable();
|
||||
importSDMXButton.enable();
|
||||
exportCSVButton.disable();
|
||||
exportJSONButton.disable();
|
||||
exportSDMXButton.disable();
|
||||
break;
|
||||
case TR_CLOSE:
|
||||
openButton.enable();
|
||||
closeButton.disable();
|
||||
propertiesButton.disable();
|
||||
importCSVButton.enable();
|
||||
importJSONButton.disable();
|
||||
importSDMXButton.enable();
|
||||
exportCSVButton.disable();
|
||||
exportJSONButton.disable();
|
||||
exportSDMXButton.disable();
|
||||
break;
|
||||
case TR_OPEN:
|
||||
openButton.enable();
|
||||
closeButton.enable();
|
||||
propertiesButton.enable();
|
||||
importCSVButton.enable();
|
||||
importJSONButton.disable();
|
||||
importSDMXButton.enable();
|
||||
exportCSVButton.disable();
|
||||
exportJSONButton.disable();
|
||||
exportSDMXButton.disable();
|
||||
break;
|
||||
case WIZARD_OPEN:
|
||||
openButton.disable();
|
||||
closeButton.disable();
|
||||
propertiesButton.disable();
|
||||
importCSVButton.disable();
|
||||
importJSONButton.disable();
|
||||
importSDMXButton.disable();
|
||||
exportCSVButton.disable();
|
||||
exportJSONButton.disable();
|
||||
exportSDMXButton.disable();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.error("setUI Error : " + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue