Fixed Final and Lock error

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-codelistmapping-import-widget@100224 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-09-26 14:38:15 +00:00
parent 363d673c82
commit 2b630e06af
11 changed files with 249 additions and 296 deletions

View File

@ -163,7 +163,7 @@ public class CodelistMappingFileUploadPanel extends FormPanel {
public void operationFailed(Throwable caught, String reason,
String failureDetails) {
card.showErrorAndHide("Error uploading the xml file", reason,
failureDetails, caught);
caught);
}
public void operationComplete() {

View File

@ -5,9 +5,12 @@ package org.gcube.portlets.user.td.codelistmappingimportwidget.client;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFinalException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
import org.gcube.portlets.user.td.monitorwidget.client.utils.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
@ -20,15 +23,10 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.FlexTable;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer.VBoxLayoutAlign;
import com.sencha.gxt.widget.core.client.event.HideEvent;
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
/**
*
@ -36,16 +34,16 @@ import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class CodelistMappingOperationInProgressCard extends WizardCard implements
MonitorDialogListener {
public class CodelistMappingOperationInProgressCard extends WizardCard
implements MonitorDialogListener {
protected CodelistMappingOperationInProgressCard thisCard;
protected CodelistMappingSession codelistMappingSession;
protected TRId newTrId;
protected HtmlLayoutContainer resultField;
public CodelistMappingOperationInProgressCard(final CodelistMappingSession codelistMappingSession) {
public CodelistMappingOperationInProgressCard(
final CodelistMappingSession codelistMappingSession) {
super("Operation In Progress", "");
this.codelistMappingSession = codelistMappingSession;
@ -68,7 +66,8 @@ MonitorDialogListener {
description.setHTML(2, 0,
"<span style=\"font-weight:bold;\";>Name: </span>");
description.setText(2, 1, codelistMappingSession.getResourceTD().getName());
description.setText(2, 1, codelistMappingSession.getResourceTD()
.getName());
FramedPanel summary = new FramedPanel();
summary.setHeadingText("Import Summary");
@ -87,10 +86,9 @@ MonitorDialogListener {
}
public void importCodelistMapping() {
TDGWTServiceAsync.INSTANCE.startCodelistMappingImport(codelistMappingSession,
new AsyncCallback<String>() {
TDGWTServiceAsync.INSTANCE.startCodelistMappingImport(
codelistMappingSession, new AsyncCallback<String>() {
public void onSuccess(String taskId) {
openMonitorDialog(taskId);
@ -103,11 +101,24 @@ MonitorDialogListener {
new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
showErrorAndHide(
"Error in import codelist mapping",
"An error occured in import codelist mapping: "
+ caught.getLocalizedMessage(),
caught.getStackTrace().toString(), caught);
if (caught instanceof TDGWTIsLockedException) {
Log.error(caught.getLocalizedMessage());
showErrorAndHide("Error Locked",
caught.getLocalizedMessage(), caught);
} else {
if (caught instanceof TDGWTIsFinalException) {
Log.error(caught.getLocalizedMessage());
showErrorAndHide("Error Final",
caught.getLocalizedMessage(),
caught);
} else {
showErrorAndHide(
"Error in import codelist mapping",
"An error occured in import codelist mapping: "
+ caught.getLocalizedMessage(),
caught);
}
}
}
}
});
@ -122,13 +133,7 @@ MonitorDialogListener {
getWizardWindow().setNextButtonToFinish();
importCodelistMapping();
}
//
protected void openMonitorDialog(String taskId) {
MonitorDialog monitorDialog = new MonitorDialog(taskId, getEventBus());
@ -181,13 +186,19 @@ MonitorDialogListener {
new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
AlertMessageBox d = new AlertMessageBox("Error in Codelist Mapping Import",
reason);
d.addHideHandler(new HideHandler() {
public void onHide(HideEvent event) {
if (caught instanceof TDGWTIsLockedException) {
Log.error(caught.getLocalizedMessage());
showErrorAndHide("Error Locked", caught.getLocalizedMessage(),
caught);
} else {
if (caught instanceof TDGWTIsFinalException) {
Log.error(caught.getLocalizedMessage());
showErrorAndHide("Error Final",
caught.getLocalizedMessage(), caught);
} else {
UtilsGXT3.alert("Error in Codelist Mapping Import", reason);
}
});
d.show();
}
}
forceLayout();

View File

@ -5,6 +5,8 @@ package org.gcube.portlets.user.td.codelistmappingimportwidget.client;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFinalException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.resource.ResourceTD;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
@ -33,18 +35,16 @@ import com.sencha.gxt.widget.core.client.form.TextField;
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class CodelistMappingTableDetailCard extends WizardCard
implements MonitorDialogListener {
public class CodelistMappingTableDetailCard extends WizardCard implements
MonitorDialogListener {
protected CodelistMappingSession codelistMappingSession;
protected CodelistMappingTableDetailCard thisCard;
protected VerticalLayoutContainer p;
protected TextField name;
protected TextArea description;
protected ResourceTD resourceDetails = new ResourceTD();
@ -55,21 +55,20 @@ public class CodelistMappingTableDetailCard extends WizardCard
this.codelistMappingSession = codelistMappingSession;
thisCard = this;
FramedPanel form = new FramedPanel();
form.setHeadingText("Details");
p = new VerticalLayoutContainer();
form.add(p);
name = new TextField();
name.setAllowBlank(false);
name.setEmptyText("Enter a name...");
if(codelistMappingSession.getLocalFileName()!=null&&
!codelistMappingSession.getLocalFileName().isEmpty()){
if (codelistMappingSession.getLocalFileName() != null
&& !codelistMappingSession.getLocalFileName().isEmpty()) {
name.setValue(codelistMappingSession.getLocalFileName());
} else {
}
name.setAllowBlank(false);
p.add(new FieldLabel(name, "Name"), new VerticalLayoutData(1, -1));
@ -150,22 +149,25 @@ public class CodelistMappingTableDetailCard extends WizardCard
codelistMappingSession.setResourceTD(resourceDetails);
/*CodelistMappingOperationInProgressCard codelistMappingOperationInProgressCard = new CodelistMappingOperationInProgressCard(
codelistMappingSession);
getWizardWindow().addCard(codelistMappingOperationInProgressCard);
Log.info("NextCard CodelistMappingOperationInProgressCard");
getWizardWindow().nextCard();*/
/*
* CodelistMappingOperationInProgressCard
* codelistMappingOperationInProgressCard = new
* CodelistMappingOperationInProgressCard( codelistMappingSession);
* getWizardWindow
* ().addCard(codelistMappingOperationInProgressCard);
* Log.info("NextCard CodelistMappingOperationInProgressCard");
* getWizardWindow().nextCard();
*/
importCodelistMapping();
} catch (Throwable e) {
Log.error("sayNextCard :" + e.getLocalizedMessage());
}
}
protected void importCodelistMapping() {
TDGWTServiceAsync.INSTANCE.startCodelistMappingImport(codelistMappingSession,
new AsyncCallback<String>() {
TDGWTServiceAsync.INSTANCE.startCodelistMappingImport(
codelistMappingSession, new AsyncCallback<String>() {
public void onSuccess(String taskId) {
openMonitorDialog(taskId);
@ -178,18 +180,31 @@ public class CodelistMappingTableDetailCard extends WizardCard
new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
showErrorAndHide(
"Error in import codelist mapping",
"An error occured in import codelist mapping: "
+ caught.getLocalizedMessage(),
caught.getStackTrace().toString(), caught);
if (caught instanceof TDGWTIsLockedException) {
Log.error(caught.getLocalizedMessage());
showErrorAndHide("Error Locked",
caught.getLocalizedMessage(), caught);
} else {
if (caught instanceof TDGWTIsFinalException) {
Log.error(caught.getLocalizedMessage());
showErrorAndHide("Error Final",
caught.getLocalizedMessage(),
caught);
} else {
showErrorAndHide(
"Error in import codelist mapping",
"An error occured in import codelist mapping: "
+ caught.getLocalizedMessage(),
caught);
}
}
}
}
});
}
protected void openMonitorDialog(String taskId){
MonitorDialog monitorDialog=new MonitorDialog(taskId,getEventBus());
protected void openMonitorDialog(String taskId) {
MonitorDialog monitorDialog = new MonitorDialog(taskId, getEventBus());
monitorDialog.add(thisCard);
monitorDialog.show();
}
@ -197,7 +212,7 @@ public class CodelistMappingTableDetailCard extends WizardCard
@Override
public void operationComplete(TRId trId) {
getWizardWindow().fireCompleted(trId);
}
@Override
@ -208,29 +223,41 @@ public class CodelistMappingTableDetailCard extends WizardCard
new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
getWizardWindow().fireFailed(caught, "Error in Codelist Mapping Import", details);
if (caught instanceof TDGWTIsLockedException) {
Log.error(caught.getLocalizedMessage());
showErrorAndHide("Error Locked", caught.getLocalizedMessage(),
caught);
} else {
if (caught instanceof TDGWTIsFinalException) {
Log.error(caught.getLocalizedMessage());
showErrorAndHide("Error Final",
caught.getLocalizedMessage(), caught);
} else {
getWizardWindow().fireFailed(null,
"Error in Codelist Mapping Import", caught);
}
}
}
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
getWizardWindow().fireCompleted(trId);
}
@Override
public void operationAborted() {
getWizardWindow().fireAborted();
}
@Override
public void operationPutInBackground() {
// TODO Auto-generated method stub
}
}

View File

@ -6,6 +6,8 @@ package org.gcube.portlets.user.td.codelistmappingimportwidget.client;
import org.gcube.portlets.user.td.codelistmappingimportwidget.client.workspace.WorkspacePanel;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFinalException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
@ -135,10 +137,24 @@ public class CodelistMappingWorkSpaceSelectionCard extends WizardCard {
new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
thisCard.showErrorAndHide("Error",
"Error retrieving the file from the workspace: "
+ caught.getLocalizedMessage(),
caught.toString(), caught);
if (caught instanceof TDGWTIsLockedException) {
Log.error(caught.getLocalizedMessage());
showErrorAndHide("Error Locked",
caught.getLocalizedMessage(), caught);
} else {
if (caught instanceof TDGWTIsFinalException) {
Log.error(caught.getLocalizedMessage());
showErrorAndHide("Error Final",
caught.getLocalizedMessage(),
caught);
} else {
showErrorAndHide(
"Error",
"Error retrieving the file from the workspace: "
+ caught.getLocalizedMessage(),
caught);
}
}
}
}

View File

@ -55,7 +55,7 @@ public class ColumnSelectionCard extends WizardCard {
Log.error("CodelistMappingSession has TRId null: "+codelistMappingSession.getConnectedTR());
}
columnsGridPanel = new ColumnDataGridPanel(trId);
columnsGridPanel = new ColumnDataGridPanel(this, trId);
columnsGridPanel
.addSelectionHandler(new SelectionHandler<ColumnData>() {

View File

@ -2,8 +2,11 @@ package org.gcube.portlets.user.td.codelistmappingimportwidget.client;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import com.allen_sauer.gwt.log.client.Log;
@ -23,19 +26,22 @@ public class TabResourcesSelectionCard extends WizardCard {
protected TabResourcesSelectionPanel tabResourcesSelectionPanel;
protected TabResource selectedTabResource = null;
public TabResourcesSelectionCard(final CodelistMappingSession codelistMappingSession) {
public TabResourcesSelectionCard(
final CodelistMappingSession codelistMappingSession) {
super("Select the Codelist before curation", "");
Log.debug("TabResourcesSelectionCard");
this.codelistMappingSession = codelistMappingSession;
thisCard = this;
tabResourcesSelectionPanel = new TabResourcesSelectionPanel(thisCard,res);
tabResourcesSelectionPanel = new TabResourcesSelectionPanel(thisCard,
res);
tabResourcesSelectionPanel
.addSelectionHandler(new SelectionHandler<TabResource>() {
public void onSelection(SelectionEvent<TabResource> event) {
codelistMappingSession.setConnectedTR(tabResourcesSelectionPanel
codelistMappingSession
.setConnectedTR(tabResourcesSelectionPanel
.getSelectedItem());
getWizardWindow().setEnableNextButton(true);
}
@ -54,7 +60,7 @@ public class TabResourcesSelectionCard extends WizardCard {
public void execute() {
Log.debug("TabResourcesSelectionCard Call sayNextCard");
retrieveLastTable();
}
};
@ -76,45 +82,46 @@ public class TabResourcesSelectionCard extends WizardCard {
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
getWizardWindow().setEnableNextButton(false);
getWizardWindow().setEnableBackButton(true);
}
protected void retrieveLastTable() {
getWizardWindow().setEnableNextButton(false);
getWizardWindow().setEnableBackButton(false);
TDGWTServiceAsync.INSTANCE.getLastTable(codelistMappingSession
.getConnectedTR().getTrId(),
new AsyncCallback<TableData>() {
.getConnectedTR().getTrId(), new AsyncCallback<TableData>() {
@Override
public void onFailure(Throwable caught) {
Log.debug("Attention",
"This tabular resource does not have a valid table");
AlertMessageBox d = new AlertMessageBox("Attention",
"This tabular resource does not have a valid table");
d.addHideHandler(new HideHandler() {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
getEventBus().fireEvent(
new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.debug("Attention",
"This tabular resource does not have a valid table");
AlertMessageBox d = new AlertMessageBox("Attention",
"This tabular resource does not have a valid table");
d.addHideHandler(new HideHandler() {
public void onHide(HideEvent event) {
deleteTRWithLastTableNull();
public void onHide(HideEvent event) {
deleteTRWithLastTableNull();
}
});
d.show();
}
});
d.show();
}
}
}
@Override
public void onSuccess(TableData result) {
Log.debug("Retrieve last table: " + result);
updateConnectedTRInfo(result);
}
@Override
public void onSuccess(TableData result) {
Log.debug("Retrieve last table: " + result);
updateConnectedTRInfo(result);
}
});
});
}
@ -126,7 +133,7 @@ public class TabResourcesSelectionCard extends WizardCard {
if (mb.getHideButton() == mb.getButtonById(PredefinedButton.YES
.name())) {
callDeleteLastTable();
} else if (mb.getHideButton() == mb
.getButtonById(PredefinedButton.NO.name())) {
getWizardWindow().setEnableNextButton(true);
@ -138,39 +145,37 @@ public class TabResourcesSelectionCard extends WizardCard {
mb.show();
}
protected void callDeleteLastTable(){
Log.debug("Delete TR:" + codelistMappingSession.getConnectedTR()
.getTrId());
TDGWTServiceAsync.INSTANCE.removeTabularResource(codelistMappingSession.getConnectedTR()
.getTrId(),
new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
AlertMessageBox d = new AlertMessageBox("Error",
"Error on delete TabResource: "
+ caught.getLocalizedMessage());
d.addHideHandler(new HideHandler() {
protected void callDeleteLastTable() {
Log.debug("Delete TR:"
+ codelistMappingSession.getConnectedTR().getTrId());
TDGWTServiceAsync.INSTANCE.removeTabularResource(codelistMappingSession
.getConnectedTR().getTrId(), new AsyncCallback<Void>() {
public void onHide(HideEvent event) {
getWizardWindow().setEnableNextButton(true);
getWizardWindow().setEnableBackButton(true);
public void onFailure(Throwable caught) {
AlertMessageBox d = new AlertMessageBox("Error",
"Error on delete TabResource: "
+ caught.getLocalizedMessage());
d.addHideHandler(new HideHandler() {
}
});
d.show();
}
public void onSuccess(Void result) {
tabResourcesSelectionPanel.gridReload();
getWizardWindow().setEnableNextButton(false);
public void onHide(HideEvent event) {
getWizardWindow().setEnableNextButton(true);
getWizardWindow().setEnableBackButton(true);
}
}
});
d.show();
}
public void onSuccess(Void result) {
tabResourcesSelectionPanel.gridReload();
getWizardWindow().setEnableNextButton(false);
getWizardWindow().setEnableBackButton(true);
}
});
}
protected void updateConnectedTRInfo(TableData table) {
TabResource tabResource = codelistMappingSession.getConnectedTR();
@ -185,8 +190,7 @@ public class TabResourcesSelectionCard extends WizardCard {
Log.info("NextCard ColumnSelectionCard");
ColumnSelectionCard columnSelectionCard = new ColumnSelectionCard(
codelistMappingSession);
getWizardWindow().addCard(
columnSelectionCard);
getWizardWindow().addCard(columnSelectionCard);
getWizardWindow().nextCard();
} catch (Throwable e) {
Log.error("goNext: " + e.getLocalizedMessage());

View File

@ -5,12 +5,15 @@ import java.util.Arrays;
import java.util.List;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFinalException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle;
import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
@ -37,7 +40,6 @@ import com.sencha.gxt.data.shared.loader.ListLoader;
import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding;
import com.sencha.gxt.widget.core.client.ContentPanel;
import com.sencha.gxt.widget.core.client.Dialog.PredefinedButton;
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
import com.sencha.gxt.widget.core.client.box.ConfirmMessageBox;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
@ -107,7 +109,7 @@ public class TabResourcesSelectionPanel extends ContentPanel implements
protected void init() {
setHeaderVisible(false);
//new Resizable(this, Dir.E, Dir.SE, Dir.S);
// new Resizable(this, Dir.E, Dir.SE, Dir.S);
}
@ -216,7 +218,9 @@ public class TabResourcesSelectionPanel extends ContentPanel implements
contextMenu = new Menu();
MenuItem deleteTRItem = new MenuItem("Delete");
deleteTRItem.setId("DeleteTR");
deleteTRItem.setIcon(org.gcube.portlets.user.td.codelistmappingimportwidget.client.dataresource.ResourceBundle.INSTANCE.delete());
deleteTRItem
.setIcon(org.gcube.portlets.user.td.codelistmappingimportwidget.client.dataresource.ResourceBundle.INSTANCE
.delete());
deleteTRItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override
@ -268,19 +272,24 @@ public class TabResourcesSelectionPanel extends ContentPanel implements
new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.debug("Error retrieving tabular resource: "
+ caught.getLocalizedMessage());
AlertMessageBox d = new AlertMessageBox("Error!",
"Error retrieving tabular resources on server!");
d.addHideHandler(new HideHandler() {
public void onHide(HideEvent event) {
//
if (caught instanceof TDGWTIsLockedException) {
Log.error(caught.getLocalizedMessage());
parent.showErrorAndHide("Error Locked",
caught.getLocalizedMessage(), caught);
} else {
if (caught instanceof TDGWTIsFinalException) {
Log.error(caught.getLocalizedMessage());
parent.showErrorAndHide("Error Final",
caught.getLocalizedMessage(),
caught);
} else {
Log.debug("Error retrieving tabular resource: "
+ caught.getLocalizedMessage());
UtilsGXT3
.alert("Error!",
"Error retrieving tabular resources on server!");
}
});
d.show();
}
}
callback.onFailure(caught);
}
@ -345,18 +354,9 @@ public class TabResourcesSelectionPanel extends ContentPanel implements
new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
AlertMessageBox d = new AlertMessageBox("Error",
UtilsGXT3.alert("Error",
"Error on delete TabResource: "
+ caught.getLocalizedMessage());
d.addHideHandler(new HideHandler() {
public void onHide(HideEvent event) {
}
});
d.show();
}
public void onSuccess(Void result) {

View File

@ -3,8 +3,13 @@ package org.gcube.portlets.user.td.codelistmappingimportwidget.client.grid;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.user.td.codelistmappingimportwidget.client.ColumnSelectionCard;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
@ -44,27 +49,31 @@ public class ColumnDataGridPanel extends ContentPanel implements
protected final CheckBoxSelectionModel<ColumnData> sm;
protected final Grid<ColumnData> grid;
protected TRId trId;
public ColumnDataGridPanel(TRId trId) {
protected TRId trId;
private ColumnSelectionCard parent;
public ColumnDataGridPanel(ColumnSelectionCard parent, TRId trId) {
Log.debug("ColumnDataGridPanel");
if(trId==null){
if (trId == null) {
Log.error("ColumnDataGridPanel: TRId is null");
}
Log.debug("ColumnDataGridPanel: "+trId.toString());
this.trId=trId;
Log.debug("ColumnDataGridPanel: " + trId.toString());
this.parent = parent;
this.trId = trId;
setHeaderVisible(false);
//setHeadingText("Columns");
// setHeadingText("Columns");
ColumnConfig<ColumnData, String> labelCol = new ColumnConfig<ColumnData, String>(
props.label(), 120,"Column");
props.label(), 120, "Column");
IdentityValueProvider<ColumnData> identity = new IdentityValueProvider<ColumnData>();
sm = new CheckBoxSelectionModel<ColumnData>(identity);
List<ColumnConfig<ColumnData, ?>> l = new ArrayList<ColumnConfig<ColumnData, ?>>();
l.add(labelCol);
ColumnModel<ColumnData> cm = new ColumnModel<ColumnData>(l);
@ -122,12 +131,26 @@ public class ColumnDataGridPanel extends ContentPanel implements
protected void loadData(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
TDGWTServiceAsync.INSTANCE
.getColumns(trId, new AsyncCallback<ArrayList<ColumnData>>() {
TDGWTServiceAsync.INSTANCE.getColumns(trId,
new AsyncCallback<ArrayList<ColumnData>>() {
public void onFailure(Throwable caught) {
Log.error("No load columns: "
+ caught.getLocalizedMessage());
if (caught instanceof TDGWTSessionExpiredException) {
parent.getEventBus()
.fireEvent(
new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
if (caught instanceof TDGWTIsLockedException) {
Log.error(caught.getLocalizedMessage());
parent.showErrorAndHide("Error Locked",
caught.getLocalizedMessage(), caught);
} else {
Log.error("No load columns: "
+ caught.getLocalizedMessage());
}
}
callback.onFailure(caught);
}
@ -141,8 +164,6 @@ public class ColumnDataGridPanel extends ContentPanel implements
});
}
public ColumnData getSelectedItem() {
return grid.getSelectionModel().getSelectedItem();

View File

@ -1,67 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.codelistmappingimportwidget.client.util;
import com.google.gwt.core.client.Callback;
import com.google.gwt.user.client.ui.Label;
import com.sencha.gxt.widget.core.client.Dialog;
import com.sencha.gxt.widget.core.client.Dialog.PredefinedButton;
import com.sencha.gxt.widget.core.client.box.MessageBox;
import com.sencha.gxt.widget.core.client.event.HideEvent;
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ErrorMessageBox {
private static final String DETAILS = "Details";
public static void showError(String title, String failureReason, final String failureDetails)
{
showError(title, failureReason, failureDetails, new NOPCallBack<Dialog, Void>());
}
public static void showError(String title, String failureReason, final String failureDetails, final Callback<Dialog, Void> callback)
{
final MessageBox box = new MessageBox(title);
box.setMessage(failureReason);
box.addHideHandler(new HideHandler() {
public void onHide(HideEvent event) {
Dialog dialog = (Dialog) event.getSource();
if (dialog.getHideButton().getText().equals(DETAILS)){
//box.close();
showErrorDetails("Error details", failureDetails);
} else callback.onSuccess(dialog);
}
});
box.show();
}
public static void showErrorDetails(String title, String failureDetails)
{
final Dialog simple = new Dialog();
simple.setHeadingText(title);
simple.setPredefinedButtons(PredefinedButton.OK);
simple.setBodyStyleName("pad-text");
simple.add(new Label("<PRE>"+failureDetails+"</PRE>"));
simple.setHideOnButtonClick(true);
simple.setWidth(400);
simple.setHeight(400);
simple.show();
}
}

View File

@ -1,37 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.codelistmappingimportwidget.client.util;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class Format {
/**
* Converts a file size into a {@link String} representation adding the misure unit.
* @param size the file size.
* @return the textual representation.
*/
public static String fileSize(long size) {
StringBuilder text = new StringBuilder();
if (size < 1024) {
text.append(size);
text.append(" bytes");
} else if (size < 1048576) {
text.append(Math.round(((size * 10) / 1024)) / 10);
text.append(" KB");
} else if (size < 1073741824) {
text.append(Math.round(((size * 10) / 1048576)) / 10);
text.append(" MB");
} else {
text.append(Math.round(((size * 10) / 1073741824)) / 10);
text.append(" GB");
}
return text.toString();
}
}

View File

@ -1,22 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.codelistmappingimportwidget.client.util;
import com.google.gwt.core.client.Callback;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
* @param <T>
* @param <F>
*/
public class NOPCallBack<T,F> implements Callback<T, F> {
public void onFailure(F reason) {}
public void onSuccess(T result) {}
}