Reorganized the event classes

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-portlet@86470 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2013-12-02 19:04:19 +00:00
parent e5d40e4ad5
commit 68c0efbf1f
5 changed files with 120 additions and 189 deletions

View File

@ -5,16 +5,9 @@ package org.gcube.portlets.user.td.client;
import org.gcube.portlets.user.td.sdmximportwidget.client.SDMXImportWizardTD;
import org.gcube.portlets.user.td.wizardwidget.client.WizardListener;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.CloseTabularResourceEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.CloseTabularResourceType;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ExportTableEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ExportTableType;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ImportTableEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ImportTableType;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.OpenFunctionalityEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.OpenFunctionalityType;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.OpenTabularResourceEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.OpenTabularResourceType;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.RibbonEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.RibbonType;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.UIStateEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.UIStateType;
import org.gcube.portlets.user.td.csvexportwidget.client.CSVExportWizardTD;
@ -114,48 +107,16 @@ public class TabularDataController {
}
protected void bindToEvents() {
eventBus.addHandler(ImportTableEvent.TYPE,
new ImportTableEvent.ImportTableHandler() {
eventBus.addHandler(RibbonEvent.TYPE,
new RibbonEvent.RibbonEventHandler() {
@Override
public void onImportTable(ImportTableEvent event) {
doImportTable(event.getImportType());
}
});
eventBus.addHandler(ExportTableEvent.TYPE,
new ExportTableEvent.ExportTableHandler() {
@Override
public void onExportTable(ExportTableEvent event) {
doExportTable(event.getExportType());
}
});
eventBus.addHandler(OpenTabularResourceEvent.TYPE,
new OpenTabularResourceEvent.OpenTabularResourceHandler() {
@Override
public void onOpenTabularResource(
OpenTabularResourceEvent event) {
doOpenTabularResource(event.getOpenType());
}
});
eventBus.addHandler(CloseTabularResourceEvent.TYPE,
new CloseTabularResourceEvent.CloseTabularResourceHandler() {
@Override
public void onCloseTabularResource(
CloseTabularResourceEvent event) {
doCloseTabularResource(event.getCloseType());
}
});
eventBus.addHandler(OpenFunctionalityEvent.TYPE,
new OpenFunctionalityEvent.OpenFunctionalityHandler() {
@Override
public void onOpenFunctionality(OpenFunctionalityEvent event) {
doOpenFunctionality(event.getOpenFunctionalityType());
public void onRibbon(RibbonEvent event) {
doRibbonCommand(event);
}
});
eventBus.fireEvent(new UIStateEvent(UIStateType.START));
}
@ -195,7 +156,7 @@ public class TabularDataController {
}
}
protected void closeTabularResources() {
protected void closeTabularResource() {
if (uiState == UIStateType.TR_OPEN) {
tabularData.closeTable();
uiState = UIStateType.TR_CLOSE;
@ -208,108 +169,68 @@ public class TabularDataController {
}
}
}
protected void deleteTabularResource() {
if (uiState == UIStateType.TR_OPEN) {
tabularData.closeTable();
uiState = UIStateType.TR_CLOSE;
eventBus.fireEvent(new UIStateEvent(UIStateType.TR_CLOSE));
if (uiProperties == UIProperties.OPENED) {
functionalityPanel.collapse();
functionalityPanel.disable();
uiProperties = UIProperties.CLOSED;
functionalityTab.remove(trProperties);
}
}
}
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);
public void doRibbonCommand(RibbonEvent event){
RibbonType type=event.getRibbonType();
Log.trace("doRibbonEvent ribbonType: " + type);
try {
switch (importType) {
case SDMX:
openSDMXImportWizard();
switch (type) {
case OPEN:
openTabularResource();
break;
case CSV:
openCSVImportWizard();
case CLOSE:
closeTabularResource();
break;
case JSON:
openCSVImportWizard();
case DELETE:
deleteTabularResource();
break;
default:
break;
}
} catch (Exception e) {
Log.error("doImportTable Error : " + e.getLocalizedMessage()
+ " \n " + e.getMessage());
}
}
public void doExportTable(ExportTableType exportType) {
Log.trace("doExportTable importType: " + exportType);
Info.display("Export Tabular Resource", "type: " + exportType);
try {
switch (exportType) {
case SDMX:
openSDMXExportWizard();
break;
case CSV:
openCSVExportWizard();
break;
case JSON:
openSDMXExportWizard();
break;
default:
break;
}
} catch (Exception e) {
Log.error("doImportTable Error : " + e.getLocalizedMessage()
+ " \n " + e.getMessage());
}
}
public void doOpenTabularResource(OpenTabularResourceType openType) {
Log.trace("doOpenTabularResource openType: " + openType);
Info.display("Open Tabular Resource", "open: " + openType);
try {
switch (openType) {
case TABLE:
openTabularResources();
break;
default:
break;
}
} catch (Exception e) {
Log.error("doOpenTable Error : " + e.getLocalizedMessage() + " \n "
+ e.getMessage());
}
}
public void doCloseTabularResource(CloseTabularResourceType closeType) {
Log.trace("doCloseTabularResource closeType: " + closeType);
Info.display("Close Tabular Resource", "close: " + closeType);
try {
switch (closeType) {
case TABLE:
closeTabularResources();
break;
default:
break;
}
} catch (Exception e) {
Log.error("doOpenTable Error : " + e.getLocalizedMessage() + " \n "
+ e.getMessage());
}
}
public void doOpenFunctionality(OpenFunctionalityType openType) {
Log.trace("doOpenFunctionality openType: " + openType);
try {
switch (openType) {
case PROPERTIES:
openFunctionalityProperties();
break;
case IMPORTSDMX:
openSDMXImportWizard();
break;
case IMPORTCSV:
openCSVImportWizard();
break;
case IMPORTJSON:
break;
case EXPORTSDMX:
openSDMXExportWizard();
break;
case EXPORTCSV:
openCSVExportWizard();
break;
case EXPORTJSON:
break;
default:
break;
}
} catch (Exception e) {
Log.error("doOpenFunctionality Error : " + e.getLocalizedMessage());
e.printStackTrace();
Log.error("doRibbonCommand Error : " + e.getLocalizedMessage()
+ " \n " + e.getMessage());
}
}
protected void openFunctionalityProperties() {
if (uiState == UIStateType.TR_OPEN) {
if (uiProperties == UIProperties.OPENED) {
@ -488,7 +409,7 @@ public class TabularDataController {
/**
*
*/
protected void openTabularResources() {
protected void openTabularResource() {
Log.info("Open Tabular Resources");
GWT.runAsync(new RunAsyncCallback() {

View File

@ -135,7 +135,7 @@ public class TabularDataPortlet implements EntryPoint {
MarginData gridData = new MarginData();
mainPanelLayout.setCenterWidget(gridPanel, gridData);
// Functionality Panel
functionalityPanel= new ContentPanel();
functionalityPanel.setWidth(310);

View File

@ -20,15 +20,18 @@ public interface TabularDataResources extends ClientBundle {
@Source("page-white-add_32.png")
ImageResource open32();
@Source("page-white-close_32.png")
ImageResource close32();
@Source("page-white-close.png")
ImageResource close();
@Source("disk.png")
ImageResource save();
@Source("disk_32.png")
ImageResource save32();
@Source("close-red.png")
ImageResource close();
@Source("properties.png")
ImageResource properties();

View File

@ -3,19 +3,11 @@
*/
package org.gcube.portlets.user.td.client.ribbon;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.CloseTabularResourceEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.CloseTabularResourceType;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ExportTableEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ExportTableType;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ImportTableEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ImportTableType;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.OpenFunctionalityEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.OpenFunctionalityType;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.OpenTabularResourceEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.OpenTabularResourceType;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.UIStateEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.UIStateType;
import org.gcube.portlets.user.td.client.resource.TabularDataResources;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.RibbonEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.UIStateEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.RibbonType;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.UIStateType;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.dom.client.Element;
@ -44,7 +36,7 @@ public class FileToolBar {
protected ToolBar toolBar;
protected TextButton openButton;
// protected TextButton saveButton;
protected TextButton deleteButton;
protected TextButton closeButton;
protected TextButton propertiesButton;
@ -84,7 +76,7 @@ public class FileToolBar {
openButton = new TextButton("Open",
TabularDataResources.INSTANCE.open32());
openButton.setId("oepnButton");
openButton.setId("openButton");
openButton.setScale(ButtonScale.LARGE);
openButton.setIconAlign(IconAlign.TOP);
openButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
@ -94,45 +86,50 @@ public class FileToolBar {
@Override
public void onSelect(SelectEvent event) {
eventBus.fireEvent(new OpenTabularResourceEvent(
OpenTabularResourceType.TABLE));
eventBus.fireEvent(new RibbonEvent(
RibbonType.OPEN));
}
});
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)); }
* });
*
* dataLayout.getFlexCellFormatter().setRowSpan(0, 1, 2);
*
* dataLayout.setWidget(0, 1, saveButton);
*/
closeButton = new TextButton("Close",
TabularDataResources.INSTANCE.close());
closeButton.disable();
TabularDataResources.INSTANCE.close32());
closeButton.setId("closeButton");
closeButton.setToolTip("Close table");
closeButton.setScale(ButtonScale.LARGE);
closeButton.setIconAlign(IconAlign.TOP);
closeButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
closeButton.setToolTip("Close Tabular Resource");
dataLayout.setWidget(0, 2, closeButton);
closeButton.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
eventBus.fireEvent(new CloseTabularResourceEvent(
CloseTabularResourceType.TABLE));
eventBus.fireEvent(new RibbonEvent(
RibbonType.CLOSE));
}
});
dataLayout.setWidget(0, 1, openButton);
dataLayout.getFlexCellFormatter().setRowSpan(0, 1, 2);
deleteButton = new TextButton("Delete",
TabularDataResources.INSTANCE.close());
deleteButton.disable();
deleteButton.setId("closeButton");
deleteButton.setToolTip("Delete Tabular Resource");
dataLayout.setWidget(0, 2, deleteButton);
deleteButton.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
eventBus.fireEvent(new RibbonEvent(
RibbonType.DELETE));
}
});
@ -147,8 +144,8 @@ public class FileToolBar {
@Override
public void onSelect(SelectEvent event) {
eventBus.fireEvent(new OpenFunctionalityEvent(
OpenFunctionalityType.PROPERTIES));
eventBus.fireEvent(new RibbonEvent(
RibbonType.PROPERTIES));
}
});
@ -174,7 +171,8 @@ public class FileToolBar {
@Override
public void onSelect(SelectEvent event) {
eventBus.fireEvent(new ImportTableEvent(ImportTableType.SDMX));
eventBus.fireEvent(new RibbonEvent(
RibbonType.IMPORTSDMX));
}
});
@ -188,7 +186,8 @@ public class FileToolBar {
@Override
public void onSelect(SelectEvent event) {
eventBus.fireEvent(new ImportTableEvent(ImportTableType.CSV));
eventBus.fireEvent(new RibbonEvent(
RibbonType.IMPORTCSV));
}
});
importLayout.setWidget(0, 2, importCSVButton);
@ -201,7 +200,8 @@ public class FileToolBar {
@Override
public void onSelect(SelectEvent event) {
eventBus.fireEvent(new ImportTableEvent(ImportTableType.JSON));
eventBus.fireEvent(new RibbonEvent(
RibbonType.IMPORTJSON));
}
});
importLayout.setWidget(1, 2, importJSONButton);
@ -230,7 +230,8 @@ public class FileToolBar {
@Override
public void onSelect(SelectEvent event) {
eventBus.fireEvent(new ExportTableEvent(ExportTableType.SDMX));
eventBus.fireEvent(new RibbonEvent(
RibbonType.EXPORTSDMX));
}
});
@ -245,7 +246,8 @@ public class FileToolBar {
@Override
public void onSelect(SelectEvent event) {
eventBus.fireEvent(new ExportTableEvent(ExportTableType.CSV));
eventBus.fireEvent(new RibbonEvent(
RibbonType.EXPORTCSV));
}
});
exportLayout.setWidget(0, 2, exportCSVButton);
@ -258,7 +260,8 @@ public class FileToolBar {
@Override
public void onSelect(SelectEvent event) {
eventBus.fireEvent(new ExportTableEvent(ExportTableType.JSON));
eventBus.fireEvent(new RibbonEvent(
RibbonType.EXPORTJSON));
}
});
exportLayout.setWidget(1, 2, exportJSONButton);
@ -296,6 +299,7 @@ public class FileToolBar {
case START:
openButton.enable();
closeButton.disable();
deleteButton.disable();
propertiesButton.disable();
importCSVButton.enable();
importJSONButton.disable();
@ -307,6 +311,7 @@ public class FileToolBar {
case TR_CLOSE:
openButton.enable();
closeButton.disable();
deleteButton.disable();
propertiesButton.disable();
importCSVButton.enable();
importJSONButton.disable();
@ -318,6 +323,7 @@ public class FileToolBar {
case TR_OPEN:
openButton.enable();
closeButton.enable();
deleteButton.enable();
propertiesButton.enable();
importCSVButton.enable();
importJSONButton.disable();
@ -329,6 +335,7 @@ public class FileToolBar {
case WIZARD_OPEN:
openButton.disable();
closeButton.disable();
deleteButton.disable();
propertiesButton.disable();
importCSVButton.disable();
importJSONButton.disable();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 974 B

After

Width:  |  Height:  |  Size: 614 B