Minor updated

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-portlet@86476 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2013-12-03 10:05:53 +00:00
parent 8899dbd51c
commit d3555dede3
2 changed files with 122 additions and 137 deletions

View File

@ -12,6 +12,7 @@ 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;
import org.gcube.portlets.user.td.csvimportwidget.client.CSVImportWizardTD;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TRId;
import org.gcube.portlets.user.td.informationwidget.client.TabularResourceProperties;
@ -22,6 +23,7 @@ import org.gcube.portlets.user.tdw.shared.model.TableId;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.RunAsyncCallback;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Widget;
import com.google.web.bindery.event.shared.EventBus;
import com.google.web.bindery.event.shared.SimpleEventBus;
@ -38,9 +40,9 @@ 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 TabularDataController {
// implements HasCloseHandlers<Long>, HasOpenHandlers<Long> {
@ -109,21 +111,20 @@ public class TabularDataController {
protected void bindToEvents() {
eventBus.addHandler(RibbonEvent.TYPE,
new RibbonEvent.RibbonEventHandler() {
@Override
public void onRibbon(RibbonEvent event) {
doRibbonCommand(event);
}
});
eventBus.fireEvent(new UIStateEvent(UIStateType.START));
}
protected void alertMessage(String reason, String details){
AlertMessageBox d = new AlertMessageBox(reason,
details);
protected void alertMessage(String reason, String details) {
AlertMessageBox d = new AlertMessageBox(reason, details);
d.addHideHandler(new HideHandler() {
@Override
@ -134,28 +135,27 @@ public class TabularDataController {
});
d.show();
}
protected void resumeUIState(){
if(uiState==UIStateType.TR_OPEN){
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){
protected void openTable(TRId tabularResourceId) {
trId = tabularResourceId;
tableOpening = new TableId(
Constants.TD_DATASOURCE_FACTORY_ID,
tableOpening = new TableId(Constants.TD_DATASOURCE_FACTORY_ID,
trId.getTableId());
tabularData.openTable(tableOpening);
uiState = UIStateType.TR_OPEN;
eventBus.fireEvent(new UIStateEvent(UIStateType.TR_OPEN));
if(uiProperties == UIProperties.OPENED){
if (uiProperties == UIProperties.OPENED) {
trProperties.update();
}
}
protected void closeTabularResource() {
if (uiState == UIStateType.TR_OPEN) {
tabularData.closeTable();
@ -169,28 +169,31 @@ 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);
}
}
TDGWTServiceAsync.INSTANCE.removeTabularResource(trId,
new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
alertMessage("Error", "Error on remove TabResource: "
+ caught.getLocalizedMessage());
}
@Override
public void onSuccess(Void result) {
closeTabularResource();
}
});
}
protected void openWizard(){
protected void openWizard() {
eventBus.fireEvent(new UIStateEvent(UIStateType.WIZARD_OPEN));
}
public void doRibbonCommand(RibbonEvent event){
RibbonType type=event.getRibbonType();
public void doRibbonCommand(RibbonEvent event) {
RibbonType type = event.getRibbonType();
Log.trace("doRibbonEvent ribbonType: " + type);
try {
switch (type) {
@ -230,7 +233,7 @@ public class TabularDataController {
+ " \n " + e.getMessage());
}
}
protected void openFunctionalityProperties() {
if (uiState == UIStateType.TR_OPEN) {
if (uiProperties == UIProperties.OPENED) {
@ -288,27 +291,26 @@ public class TabularDataController {
openWizard();
SDMXImportWizardTD importWizard = new SDMXImportWizardTD(
"SDMX Import");
importWizard
.addListener(new WizardListener() {
importWizard.addListener(new WizardListener() {
@Override
public void completed(TRId tabularResourceId) {
openTable(tabularResourceId);
}
@Override
public void completed(TRId tabularResourceId) {
openTable(tabularResourceId);
}
@Override
public void aborted() {
resumeUIState();
}
@Override
public void aborted() {
resumeUIState();
}
@Override
public void failed(Throwable throwable,
String reason, String details) {
alertMessage(reason, details);
resumeUIState();
}
@Override
public void failed(Throwable throwable, String reason,
String details) {
alertMessage(reason, details);
resumeUIState();
}
});
});
importWizard.show();
}
@ -321,7 +323,6 @@ public class TabularDataController {
}
protected void openCSVExportWizard() {
GWT.runAsync(new RunAsyncCallback() {
@ -331,26 +332,25 @@ public class TabularDataController {
CSVExportWizardTD exportWizard = new CSVExportWizardTD(
"CSV Export");
exportWizard
.addListener(new WizardListener() {
@Override
public void failed(Throwable throwable,
String reason, String details) {
alertMessage(reason, details);
resumeUIState();
}
exportWizard.addListener(new WizardListener() {
@Override
public void failed(Throwable throwable, String reason,
String details) {
alertMessage(reason, details);
resumeUIState();
}
@Override
public void completed(TRId id) {
resumeUIState();
@Override
public void completed(TRId id) {
resumeUIState();
}
}
@Override
public void aborted() {
resumeUIState();
}
});
@Override
public void aborted() {
resumeUIState();
}
});
exportWizard.show();
}
@ -362,50 +362,38 @@ public class TabularDataController {
});
}
protected void openSDMXExportWizard() {
/*
GWT.runAsync(new RunAsyncCallback() {
@Override
public void onSuccess() {
SDMXExportWizardTD exportWizard = new SDMXExportWizardTD(
"SDMX Export");
exportWizard
.addListener(new org.gcube.portlets.user.sdmxexportwizardtd.client.general.WizardListener() {
@Override
public void failed(Throwable throwable,
String reason, String details) {
}
@Override
public void completed(TRId id) {
}
@Override
public void aborted() {
}
});
exportWizard.show();
}
@Override
public void onFailure(Throwable reason) {
asyncCodeLoadingFailed(reason);
}
});
* GWT.runAsync(new RunAsyncCallback() {
*
* @Override public void onSuccess() { SDMXExportWizardTD exportWizard =
* new SDMXExportWizardTD( "SDMX Export");
*
* exportWizard .addListener(new
* org.gcube.portlets.user.sdmxexportwizardtd
* .client.general.WizardListener() {
*
* @Override public void failed(Throwable throwable, String reason,
* String details) {
*
* }
*
* @Override public void completed(TRId id) {
*
* }
*
* @Override public void aborted() {
*
* } });
*
* exportWizard.show(); }
*
* @Override public void onFailure(Throwable reason) {
* asyncCodeLoadingFailed(reason); } });
*/
}
/**
*
*/
@ -436,7 +424,7 @@ public class TabularDataController {
@Override
public void completed(TRId tabularResourceId) {
openTable(tabularResourceId);
}
});
@ -452,12 +440,6 @@ public class TabularDataController {
}
protected void openCSVImportWizard() {
GWT.runAsync(new RunAsyncCallback() {
@ -467,27 +449,26 @@ public class TabularDataController {
CSVImportWizardTD importWizard = new CSVImportWizardTD(
"CSV Import");
importWizard
.addListener(new WizardListener() {
importWizard.addListener(new WizardListener() {
@Override
public void failed(Throwable throwable,
String reason, String details) {
alertMessage(reason, details);
resumeUIState();
}
@Override
public void failed(Throwable throwable, String reason,
String details) {
alertMessage(reason, details);
resumeUIState();
}
@Override
public void completed(TRId id) {
openTable(id);
@Override
public void completed(TRId id) {
openTable(id);
}
}
@Override
public void aborted() {
resumeUIState();
}
});
@Override
public void aborted() {
resumeUIState();
}
});
importWizard.show();
}

View File

@ -96,6 +96,7 @@ public class FileToolBar {
closeButton = new TextButton("Close",
TabularDataResources.INSTANCE.close32());
closeButton.disable();
closeButton.setId("closeButton");
closeButton.setScale(ButtonScale.LARGE);
closeButton.setIconAlign(IconAlign.TOP);
@ -111,14 +112,14 @@ public class FileToolBar {
}
});
dataLayout.setWidget(0, 1, openButton);
dataLayout.setWidget(0, 1, closeButton);
dataLayout.getFlexCellFormatter().setRowSpan(0, 1, 2);
deleteButton = new TextButton("Delete",
TabularDataResources.INSTANCE.close());
TabularDataResources.INSTANCE.delete());
deleteButton.disable();
deleteButton.setId("closeButton");
deleteButton.setToolTip("Delete Tabular Resource");
@ -132,6 +133,9 @@ public class FileToolBar {
RibbonType.DELETE));
}
});
propertiesButton = new TextButton("Properties",
TabularDataResources.INSTANCE.properties());