Updated OperationMonitor

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-table-widget@99295 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-08-27 10:08:40 +00:00 committed by Giancarlo Panichi
parent 514b66e212
commit e3ee6366d5
45 changed files with 584 additions and 4261 deletions

View File

@ -131,6 +131,14 @@
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<!-- tabular-data-monitor-widget -->
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>tabular-data-monitor-widget</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<!-- LOGGING -->
<dependency>

View File

@ -4,13 +4,17 @@ import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.ChangeTableTypeSession;
import org.gcube.portlets.user.td.tablewidget.client.progress.ChangeTableTypeProgressDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
import org.gcube.portlets.user.td.tablewidget.client.resources.ResourceBundle;
import org.gcube.portlets.user.td.tablewidget.client.type.TableTypeElement;
import org.gcube.portlets.user.td.tablewidget.client.type.TableTypeProperties;
import org.gcube.portlets.user.td.tablewidget.client.type.TableTypeStore;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
@ -38,7 +42,8 @@ import com.sencha.gxt.widget.core.client.form.FieldLabel;
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ChangeTableTypePanel extends FramedPanel {
public class ChangeTableTypePanel extends FramedPanel implements
MonitorDialogListener {
protected String WIDTH = "640px";
protected String HEIGHT = "520px";
@ -48,7 +53,7 @@ public class ChangeTableTypePanel extends FramedPanel {
protected VerticalLayoutContainer vl;
protected EventBus eventBus;
protected ChangeTableTypeSession changeTableTypeSession;
protected ChangeTableTypeProgressDialog changeTableTypeProgressDialog;
protected ComboBox<TableTypeElement> comboTableType;
protected TextButton change;
@ -90,8 +95,7 @@ public class ChangeTableTypePanel extends FramedPanel {
change.setIcon(ResourceBundle.INSTANCE.tableType());
change.setIconAlign(IconAlign.RIGHT);
change.setTitle("Change Table Type");
change.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
@ -128,7 +132,7 @@ public class ChangeTableTypePanel extends FramedPanel {
private void callChangeTableType() {
TDGWTServiceAsync.INSTANCE.startChangeTableType(changeTableTypeSession,
new AsyncCallback<Void>() {
new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
@ -143,9 +147,9 @@ public class ChangeTableTypePanel extends FramedPanel {
}
}
public void onSuccess(Void result) {
changeTableTypeProgressDialog = new ChangeTableTypeProgressDialog(
changeTableTypeSession, eventBus);
public void onSuccess(String taskId) {
openMonitorDialog(taskId);
}
});
@ -191,4 +195,56 @@ public class ChangeTableTypePanel extends FramedPanel {
load();
}
protected void close() {
/*if (parent != null) {
parent.close();
}*/
}
///
protected void openMonitorDialog(String taskId) {
MonitorDialog monitorDialog = new MonitorDialog(taskId, eventBus);
monitorDialog.addProgressDialogListener(this);
monitorDialog.show();
}
@Override
public void operationComplete(TRId trId) {
ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.CHANGETABLETYPE, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
@Override
public void operationFailed(Throwable caught, String reason, String details) {
UtilsGXT3.alert(reason, details);
close();
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
ChangeTableWhy why = ChangeTableWhy.TABLECURATION;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.CHANGETABLETYPE, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
@Override
public void operationAborted() {
close();
}
@Override
public void operationPutInBackground() {
close();
}
}

View File

@ -3,9 +3,13 @@ package org.gcube.portlets.user.td.tablewidget.client;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.tr.clone.CloneTabularResourceSession;
import org.gcube.portlets.user.td.tablewidget.client.progress.CloneProgressDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
@ -13,7 +17,7 @@ import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.web.bindery.event.shared.EventBus;
public class CloneTabularResource {
public class CloneTabularResource implements MonitorDialogListener {
protected TRId trId;
protected EventBus eventBus;
@ -32,7 +36,7 @@ public class CloneTabularResource {
protected void onCloneTR() {
TDGWTServiceAsync.INSTANCE.startCloneTabularResource(
cloneTabularResourceSession, new AsyncCallback<Void>() {
cloneTabularResourceSession, new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
@ -46,16 +50,64 @@ public class CloneTabularResource {
}
}
public void onSuccess(Void result) {
public void onSuccess(String taskId) {
Log.debug("Start TR Clone");
@SuppressWarnings("unused")
CloneProgressDialog cloneProgressDialog = new CloneProgressDialog(
eventBus);
openMonitorDialog(taskId);
}
});
}
protected void close() {
/*
* if (parent != null) { parent.close(); }
*/
}
// /
protected void openMonitorDialog(String taskId) {
MonitorDialog monitorDialog = new MonitorDialog(taskId, eventBus);
monitorDialog.addProgressDialogListener(this);
monitorDialog.show();
}
@Override
public void operationComplete(TRId trId) {
ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.CLONETABULARRESOURCE, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
@Override
public void operationFailed(Throwable caught, String reason, String details) {
UtilsGXT3.alert(reason, details);
close();
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
ChangeTableWhy why = ChangeTableWhy.TABLECURATION;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.CLONETABULARRESOURCE, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
@Override
public void operationAborted() {
close();
}
@Override
public void operationPutInBackground() {
close();
}
}

View File

@ -2,10 +2,13 @@ package org.gcube.portlets.user.td.tablewidget.client.history;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSession;
import org.gcube.portlets.user.td.tablewidget.client.progress.RollBackProgressDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
@ -13,7 +16,7 @@ import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.web.bindery.event.shared.EventBus;
public class HistoryDiscard {
public class HistoryDiscard implements MonitorDialogListener {
protected TRId trId;
protected EventBus eventBus;
@ -50,8 +53,8 @@ public class HistoryDiscard {
}
protected void callDiscard() {
TDGWTServiceAsync.INSTANCE.discard(trId,
new AsyncCallback<RollBackSession>() {
TDGWTServiceAsync.INSTANCE.startDiscard(trId,
new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
@ -60,28 +63,74 @@ public class HistoryDiscard {
} else {
Log.error("Error in discard: "
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error in discard",
UtilsGXT3.alert("Error in undo",
caught.getLocalizedMessage());
}
}
public void onSuccess(RollBackSession result) {
Log.debug("Discard Session " + result);
if (result == null) {
public void onSuccess(String taskId) {
Log.debug("Discard Session taskId: " + taskId);
if (taskId == null) {
Log.info("Attention: undo not applicable");
UtilsGXT3.info("Attention", "Undo not applicable");
} else {
callRollBackProgressDialog(result);
openMonitorDialog(taskId);
}
}
});
}
protected void callRollBackProgressDialog(RollBackSession rollBackSession) {
RollBackProgressDialog dialog = new RollBackProgressDialog(
rollBackSession, eventBus);
dialog.show();
protected void close() {
/*
* if (parent != null) { parent.close(); }
*/
}
// /
protected void openMonitorDialog(String taskId) {
MonitorDialog monitorDialog = new MonitorDialog(taskId, eventBus);
monitorDialog.addProgressDialogListener(this);
monitorDialog.show();
}
@Override
public void operationComplete(TRId trId) {
ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.ROLLBACK, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
@Override
public void operationFailed(Throwable caught, String reason, String details) {
UtilsGXT3.alert(reason, details);
close();
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
ChangeTableWhy why = ChangeTableWhy.TABLECURATION;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.ROLLBACK, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
@Override
public void operationAborted() {
close();
}
@Override
public void operationPutInBackground() {
close();
}

View File

@ -8,12 +8,16 @@ import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpire
import org.gcube.portlets.user.td.gwtservice.shared.history.OpHistory;
import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TableData;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
import org.gcube.portlets.user.td.tablewidget.client.custom.ActionButtonCellNoFirst;
import org.gcube.portlets.user.td.tablewidget.client.progress.RollBackProgressDialog;
import org.gcube.portlets.user.td.tablewidget.client.properties.OpHistoryProperties;
import org.gcube.portlets.user.td.tablewidget.client.resources.ResourceBundle;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
@ -50,7 +54,7 @@ import com.sencha.gxt.widget.core.client.grid.RowExpander;
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class HistoryPanel extends FramedPanel {
public class HistoryPanel extends FramedPanel implements MonitorDialogListener {
protected String WIDTH = "298px";
protected String HEIGHT = "520px";
@ -228,8 +232,8 @@ public class HistoryPanel extends FramedPanel {
protected void callRollBack() {
rollBackSession = new RollBackSession(trId,
currentOpHistory.getHistoryId());
TDGWTServiceAsync.INSTANCE.rollBack(rollBackSession,
new AsyncCallback<Void>() {
TDGWTServiceAsync.INSTANCE.startRollBack(rollBackSession,
new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
@ -243,20 +247,16 @@ public class HistoryPanel extends FramedPanel {
}
}
public void onSuccess(Void result) {
public void onSuccess(String taskId) {
Log.debug("Rollback started");
callRollBackProgressDialog();
openMonitorDialog(taskId);
}
});
}
protected void callRollBackProgressDialog() {
RollBackProgressDialog dialog = new RollBackProgressDialog(
rollBackSession, eventBus);
dialog.show();
}
protected void loadData(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<OpHistory>> callback) {
@ -319,5 +319,56 @@ public class HistoryPanel extends FramedPanel {
});
}
protected void close() {
/*
* if (parent != null) { parent.close(); }
*/
}
// /
protected void openMonitorDialog(String taskId) {
MonitorDialog monitorDialog = new MonitorDialog(taskId, eventBus);
monitorDialog.addProgressDialogListener(this);
monitorDialog.show();
}
@Override
public void operationComplete(TRId trId) {
ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.ROLLBACK, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
@Override
public void operationFailed(Throwable caught, String reason, String details) {
UtilsGXT3.alert(reason, details);
close();
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
ChangeTableWhy why = ChangeTableWhy.TABLECURATION;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.ROLLBACK, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
@Override
public void operationAborted() {
close();
}
@Override
public void operationPutInBackground() {
close();
}
}

View File

@ -2,13 +2,13 @@ package org.gcube.portlets.user.td.tablewidget.client.normalize;
import java.util.ArrayList;
import org.gcube.portlets.user.td.columnwidget.client.progress.ProgressDialogListener;
import org.gcube.portlets.user.td.columnwidget.client.properties.ColumnDataPropertiesCombo;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
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.gwtservice.shared.tr.normalization.DenormalizationSession;
import org.gcube.portlets.user.td.tablewidget.client.progress.DenormalizationProgressDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
import org.gcube.portlets.user.td.tablewidget.client.resources.ResourceBundle;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
@ -53,7 +53,7 @@ import com.sencha.gxt.widget.core.client.form.FieldLabel;
import com.sencha.gxt.widget.core.client.info.Info;
public class DenormalizePanel extends FramedPanel implements
ProgressDialogListener {
MonitorDialogListener {
protected String WIDTH = "640px";
protected String HEIGHT = "520px";
@ -74,7 +74,7 @@ public class DenormalizePanel extends FramedPanel implements
protected TextButton denormalizeButton;
protected DenormalizeDialog parent;
protected ArrayList<ColumnData> columnsRetrieved;
public DenormalizePanel(DenormalizeDialog parent, TRId trId,
@ -179,7 +179,7 @@ public class DenormalizePanel extends FramedPanel implements
denormalizeButton.setIcon(ResourceBundle.INSTANCE.tableDenormalize());
denormalizeButton.setIconAlign(IconAlign.RIGHT);
denormalizeButton.setTitle("Denormalize");
SelectHandler deleteHandler = new SelectHandler() {
public void onSelect(SelectEvent event) {
@ -205,8 +205,7 @@ public class DenormalizePanel extends FramedPanel implements
comboAttributeColumnLabel.setVisible(false);
denormalizeButton.disable();
}
protected void addHandlersForComboColumn(
@ -254,15 +253,15 @@ public class DenormalizePanel extends FramedPanel implements
protected void updateComboValueColumn(ColumnData columnData) {
comboAttributeColumn.clear();
storeComboAttributeColumn.clear();
for(ColumnData c:columnsRetrieved){
if(c.getColumnId().compareTo(columnData.getColumnId())!=0){
for (ColumnData c : columnsRetrieved) {
if (c.getColumnId().compareTo(columnData.getColumnId()) != 0) {
storeComboAttributeColumn.add(c);
}
}
storeComboAttributeColumn.commitChanges();
comboAttributeColumnLabel.setVisible(true);
denormalizeButton.disable();
}
protected void updateComboAttributeColumn(ColumnData columnData) {
@ -298,21 +297,24 @@ public class DenormalizePanel extends FramedPanel implements
public void onSuccess(ArrayList<ColumnData> result) {
Log.trace("loaded " + result.size() + " ColumnData");
columnsRetrieved=result;
columnsRetrieved = result;
resetComboStatus();
ArrayList<ColumnData> columnsIntegerNumeric=new ArrayList<ColumnData>();
for(ColumnData c: result){
if(c.getDataTypeName().compareTo(ColumnDataType.Numeric.toString())==0 ||
c.getDataTypeName().compareTo(ColumnDataType.Integer.toString())==0) {
ArrayList<ColumnData> columnsIntegerNumeric = new ArrayList<ColumnData>();
for (ColumnData c : result) {
if (c.getDataTypeName().compareTo(
ColumnDataType.Numeric.toString()) == 0
|| c.getDataTypeName().compareTo(
ColumnDataType.Integer.toString()) == 0) {
columnsIntegerNumeric.add(c);
}
}
if(columnsIntegerNumeric.size()<1){
UtilsGXT3.alert("Attention",
"No Column with data type Integer or Numeric");
if (columnsIntegerNumeric.size() < 1) {
UtilsGXT3
.alert("Attention",
"No Column with data type Integer or Numeric");
return;
}
callback.onSuccess(new ListLoadResultBean<ColumnData>(
columnsIntegerNumeric));
@ -325,28 +327,29 @@ public class DenormalizePanel extends FramedPanel implements
public void update(TRId trId) {
this.trId = trId;
loader.load();
}
protected void onDenormalize() {
ColumnData valueColumn = comboValueColumn.getCurrentValue();
if(valueColumn==null){
UtilsGXT3.alert("Attention", "Attention no value column selected!");
return;
if (valueColumn == null) {
UtilsGXT3.alert("Attention", "Attention no value column selected!");
return;
}
ColumnData attributeColumn = comboAttributeColumn.getCurrentValue();
if(attributeColumn==null){
UtilsGXT3.alert("Attention", "Attention no attribute column selected!");
return;
if (attributeColumn == null) {
UtilsGXT3.alert("Attention",
"Attention no attribute column selected!");
return;
}
denormalizationSession = new DenormalizationSession(trId, valueColumn,
attributeColumn);
TDGWTServiceAsync.INSTANCE.startDenormalization(denormalizationSession,
new AsyncCallback<Void>() {
new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
@ -360,8 +363,8 @@ public class DenormalizePanel extends FramedPanel implements
}
}
public void onSuccess(Void result) {
callDenormalizationProgressDialog();
public void onSuccess(String taskId) {
openMonitorDialog(taskId);
}
});
@ -374,11 +377,11 @@ public class DenormalizePanel extends FramedPanel implements
}
}
protected void callDenormalizationProgressDialog() {
DenormalizationProgressDialog denormalizeProgressDialog = new DenormalizationProgressDialog(
eventBus);
denormalizeProgressDialog.addProgressDialogListener(this);
denormalizeProgressDialog.show();
// /
protected void openMonitorDialog(String taskId) {
MonitorDialog monitorDialog = new MonitorDialog(taskId, eventBus);
monitorDialog.addProgressDialogListener(this);
monitorDialog.show();
}
@Override
@ -388,13 +391,13 @@ public class DenormalizePanel extends FramedPanel implements
ChangeTableRequestType.DENORMALIZE, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
@Override
public void operationFailed(Throwable caught, String reason) {
UtilsGXT3.alert("Error in Denormalize", reason);
public void operationFailed(Throwable caught, String reason, String details) {
UtilsGXT3.alert(reason, details);
close();
}
@Override
@ -404,6 +407,19 @@ public class DenormalizePanel extends FramedPanel implements
ChangeTableRequestType.DENORMALIZE, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
@Override
public void operationAborted() {
close();
}
@Override
public void operationPutInBackground() {
close();
}
}

View File

@ -3,12 +3,12 @@ package org.gcube.portlets.user.td.tablewidget.client.normalize;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.user.td.columnwidget.client.progress.ProgressDialogListener;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
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.gwtservice.shared.tr.normalization.NormalizationSession;
import org.gcube.portlets.user.td.tablewidget.client.progress.NormalizationProgressDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
import org.gcube.portlets.user.td.tablewidget.client.properties.ColumnDataProperties;
import org.gcube.portlets.user.td.tablewidget.client.resources.ResourceBundle;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
@ -52,7 +52,8 @@ import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
import com.sencha.gxt.widget.core.client.grid.Grid;
public class NormalizePanel extends FramedPanel implements ProgressDialogListener {
public class NormalizePanel extends FramedPanel implements
MonitorDialogListener {
protected String WIDTH = "640px";
protected String HEIGHT = "520px";
@ -248,7 +249,7 @@ public class NormalizePanel extends FramedPanel implements ProgressDialogListene
name,value);
TDGWTServiceAsync.INSTANCE.startNormalization(normalizationSession,
new AsyncCallback<Void>() {
new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
@ -262,8 +263,8 @@ public class NormalizePanel extends FramedPanel implements ProgressDialogListene
}
}
public void onSuccess(Void result) {
callNormalizationProgressDialog();
public void onSuccess(String taskId) {
openMonitorDialog(taskId);
}
});
@ -275,14 +276,14 @@ public class NormalizePanel extends FramedPanel implements ProgressDialogListene
parent.close();
}
}
protected void callNormalizationProgressDialog(){
NormalizationProgressDialog normalizeProgressDialog = new NormalizationProgressDialog(eventBus);
normalizeProgressDialog.addProgressDialogListener(this);
normalizeProgressDialog.show();
// /
protected void openMonitorDialog(String taskId) {
MonitorDialog monitorDialog = new MonitorDialog(taskId, eventBus);
monitorDialog.addProgressDialogListener(this);
monitorDialog.show();
}
@Override
public void operationComplete(TRId trId) {
ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED;
@ -290,13 +291,13 @@ public class NormalizePanel extends FramedPanel implements ProgressDialogListene
ChangeTableRequestType.NORMALIZE, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
@Override
public void operationFailed(Throwable caught, String reason) {
UtilsGXT3.alert("Error in Normalize", reason);
public void operationFailed(Throwable caught, String reason, String details) {
UtilsGXT3.alert(reason, details);
close();
}
@Override
@ -306,6 +307,19 @@ public class NormalizePanel extends FramedPanel implements ProgressDialogListene
ChangeTableRequestType.NORMALIZE, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
@Override
public void operationAborted() {
close();
}
@Override
public void operationPutInBackground() {
close();
}

View File

@ -1,98 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.sencha.gxt.widget.core.client.ProgressBar;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ChangeTableTypeProgressBarUpdater implements ChangeTableTypeProgressListener {
protected ProgressBar progressBar;
/**
* Creates a new {@link ProgressBar} updater.
* @param progressBar the {@link ProgressBar} to update.
*/
public ChangeTableTypeProgressBarUpdater(ProgressBar progressBar) {
this.progressBar = progressBar;
this.progressBar.updateProgress(0, "Please Wait...");
}
/**
* {@inheritDoc}
*/
@Override
public void operationComplete(TRId trId) {
Log.info("Completed");
progressBar.updateProgress(1, "Completed");
}
/**
* {@inheritDoc}
*/
@Override
public void operationFailed(Throwable caught, String reason, String failureDetails) {
Log.info("Failed");
progressBar.updateText("Failed");
}
@Override
public void operationInitializing() {
Log.info("Inizializing");
progressBar.updateProgress(0, "Initializing...");
}
@Override
public void operationUpdate(float elaborated) {
Log.info("Elaborated: "+elaborated);
if (elaborated>=0 && elaborated<1) {
Log.trace("progress "+elaborated);
int elab=new Float(elaborated*100).intValue();
progressBar.updateProgress(elaborated,elab+"% Progress...");
}
if (elaborated == 1) progressBar.updateProgress(1, "Completing...");
}
@Override
public void operationValidate(float elaborated) {
Log.info("Validation Elaborated: "+elaborated);
if (elaborated == 0) progressBar.updateProgress(0, "Start Validation...");
if (elaborated>0 && elaborated<1) {
Log.trace("Validation progress "+elaborated);
int elab=new Float(elaborated*100).intValue();
progressBar.updateProgress(elaborated,elab+"% Validation Progress...");
}
if (elaborated == 1) progressBar.updateProgress(1, "Validation...");
}
@Override
public void operationStopped(TRId trId,String reason, String details) {
Log.debug("Operation Stopped: ["+trId.toString()+", "+reason+", "+details+"]");
progressBar.updateText("Validations failed");
}
@Override
public void operationGeneratingView() {
Log.info("Generating View...");
progressBar.updateText("Generating View...");
}
}

View File

@ -1,151 +0,0 @@
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.ChangeTableTypeSession;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy;
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;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.ProgressBar;
import com.sencha.gxt.widget.core.client.Window;
import com.sencha.gxt.widget.core.client.button.TextButton;
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.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
/**
* LabelColumnProgressDialog is a Dialog that show progress of change the column
* label
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ChangeTableTypeProgressDialog extends Window implements
ChangeTableTypeProgressListener {
public static final int STATUS_POLLING_DELAY = 1000;
protected String WIDTH = "400px";
protected String HEIGHT = "120px";
protected ChangeTableTypeSession changeTableTypeSession;
protected EventBus eventBus;
protected ChangeTableTypeProgressUpdater progressUpdater;
protected TextButton ok;
protected TRId trId;
private ChangeTableWhy why;
public ChangeTableTypeProgressDialog(
ChangeTableTypeSession changeTableTypeSession, EventBus eventBus) {
this.changeTableTypeSession = changeTableTypeSession;
this.eventBus = eventBus;
setWidth(WIDTH);
setHeight(HEIGHT);
setBodyBorder(false);
setResizable(true);
setModal(true);
setHeadingText("Change The Table Type Progress");
trId = null;
FramedPanel panel = new FramedPanel();
panel.setHeaderVisible(false);
panel.setBodyBorder(false);
VerticalLayoutContainer v = new VerticalLayoutContainer();
ProgressBar progressBar = new ProgressBar();
ok = new TextButton("OK");
ok.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
updateInvocation();
}
});
v.add(progressBar,
new VerticalLayoutData(1, 1, new Margins(5, 5, 5, 5)));
panel.add(v);
panel.addButton(ok);
add(panel);
progressUpdater = new ChangeTableTypeProgressUpdater();
progressUpdater.addListener(new ChangeTableTypeProgressBarUpdater(
progressBar));
progressUpdater.addListener(this);
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
show();
ok.setVisible(false);
}
public void operationInitializing() {
// TODO Auto-generated method stub
}
public void operationUpdate(float elaborated) {
// TODO Auto-generated method stub
}
public void operationComplete(TRId trId) {
Log.debug("Operation Complete return: " + trId.toString());
this.trId = trId;
why = ChangeTableWhy.TABLEUPDATED;
updateInvocation();
}
public void operationFailed(Throwable caught, String reason,
String failureDetails) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
ok.setVisible(true);
this.trId = null;
UtilsGXT3.alert("Error Changing The Table Type", reason);
}
}
public void updateInvocation() {
if (trId != null) {
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.CHANGETABLETYPE, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
}
hide();
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
Log.debug("Operation Stopped: [" + trId.toString() + ", " + reason
+ ", " + details + "]");
ok.setVisible(true);
this.trId = trId;
why = ChangeTableWhy.TABLECURATION;
}
@Override
public void operationGeneratingView() {
// TODO Auto-generated method stub
}
@Override
public void operationValidate(float elaborated) {
// TODO Auto-generated method stub
}
}

View File

@ -1,63 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
/**
* Defines a listener for operation progress.
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface ChangeTableTypeProgressListener {
/**
* Called when the operation is starting.
*/
public void operationInitializing();
/**
* Called when there is a progress for the operation.
* @param elaborated the elaborated part.
*/
public void operationUpdate(float elaborated);
/**
* Called when there is a validate for the operation.
* @param elaborated the elaborated part.
*/
public void operationValidate(float elaborated);
/**
* Called when the operation is complete.
*/
public void operationComplete(TRId trId);
/**
* Called when the operation is failed.
* @param caught the failure exception.
* @param reason the failure reason.
*/
public void operationFailed(Throwable caught, String reason, String failureDetails);
/**
* Called when the operation is stopped
*
* @param trId
* @param reason
* @param details
*/
public void operationStopped(TRId trId, String reason, String details);
/**
* Called when the operation is generating the view
*/
public void operationGeneratingView();
}

View File

@ -1,195 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.monitor.ChangeTableTypeMonitor;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ChangeTableTypeProgressUpdater extends Timer {
protected ArrayList<ChangeTableTypeProgressListener> listeners = new ArrayList<ChangeTableTypeProgressListener>();
/**
* {@inheritDoc}
*/
@Override
public void run() {
Log.debug("requesting operation progress");
TDGWTServiceAsync.INSTANCE
.getChangeTableTypeMonitor(new AsyncCallback<ChangeTableTypeMonitor>() {
public void onFailure(Throwable caught) {
cancel();
Log.error("Error retrieving the operation state",
caught);
String message = getStack(caught);
fireOperationFailed(caught,
"Failed getting operation updates", message);
}
public void onSuccess(ChangeTableTypeMonitor result) {
Log.info("retrieved ChangeTableTypeMonitor: "
+ result.getStatus());
switch (result.getStatus()) {
case INITIALIZING:
Log.info("Change Table Type Initializing...");
fireOperationInitializing();
break;
case ABORTED:
cancel();
Log.info("Change The Table Type Operation Aborted");
break;
case IN_PROGRESS:
fireOperationUpdate(result.getProgress());
break;
case VALIDATING_RULES:
fireOperationValidate(result.getProgress());
break;
case GENERATING_VIEW:
Log.info("Generating View...");
fireOperationGeneratingView();
break;
case STOPPED:
cancel();
stopMessage(result);
break;
case FAILED:
cancel();
errorMessage(result);
break;
case SUCCEDED:
cancel();
Log.info("Fisnish TableId :"
+ result.getTrId());
fireOperationComplete(result.getTrId());
break;
default:
Log.info("Unknow State");
break;
}
}
});
}
protected void errorMessage(ChangeTableTypeMonitor result) {
Log.info("Change Table Type Failed");
Throwable th = null;
String failure = null;
String details = null;
if (result.getError() != null) {
th = result.getError();
failure = "Failed Client Library Changing the table type";
details = result.getError().getLocalizedMessage();
} else {
th = new Throwable("Failed");
failure = "Failed Client Library Changing the table type";
details = "Change the table type failed";
}
fireOperationFailed(th, failure, details);
}
protected void stopMessage(ChangeTableTypeMonitor result) {
Log.info("Change Table Type Stopped");
String failure = null;
String details = null;
if (result.getError() != null) {
failure = "Stopped changing the table type";
details = result.getError().getLocalizedMessage();
} else {
failure = "Stopped changing the table type";
details = "Change the table type stopped";
}
fireOperationStopped(result.getTrId(),failure, details);
}
protected String getStack(Throwable e) {
String message = e.getLocalizedMessage() + " -> <br>";
Throwable c = e.getCause();
if (c != null)
message += getStack(c);
return message;
}
protected void fireOperationInitializing() {
for (ChangeTableTypeProgressListener listener : listeners)
listener.operationInitializing();
}
protected void fireOperationGeneratingView() {
for (ChangeTableTypeProgressListener listener : listeners)
listener.operationGeneratingView();
}
protected void fireOperationUpdate(float elaborated) {
for (ChangeTableTypeProgressListener listener : listeners)
listener.operationUpdate(elaborated);
}
protected void fireOperationValidate(float elaborated) {
for (ChangeTableTypeProgressListener listener : listeners)
listener.operationValidate(elaborated);
}
protected void fireOperationComplete(TRId trId) {
for (ChangeTableTypeProgressListener listener : listeners)
listener.operationComplete(trId);
}
protected void fireOperationFailed(Throwable caught, String failure,
String failureDetails) {
for (ChangeTableTypeProgressListener listener : listeners)
listener.operationFailed(caught, failure, failureDetails);
}
protected void fireOperationStopped(TRId trId, String reason, String details) {
for (ChangeTableTypeProgressListener listener : listeners)
listener.operationStopped(trId,reason, details);
}
/**
* Add a new {@link ChangeTableTypeProgressListener} to this
* {@link ChangeTableTypeProgressUpdater}.
*
* @param listener
* the listener to add.
*/
public void addListener(ChangeTableTypeProgressListener listener) {
listeners.add(listener);
}
/**
* Removes the specified {@link ChangeTableTypeProgressListener} from this
* {@link ChangeTableTypeProgressUpdater}.
*
* @param listener
* the listener to remove.
*/
public void removeListener(ChangeTableTypeProgressListener listener) {
listeners.remove(listener);
}
}

View File

@ -1,98 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.sencha.gxt.widget.core.client.ProgressBar;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class CloneProgressBarUpdater implements CloneProgressListener {
protected ProgressBar progressBar;
/**
* Creates a new {@link ProgressBar} updater.
* @param progressBar the {@link ProgressBar} to update.
*/
public CloneProgressBarUpdater(ProgressBar progressBar) {
this.progressBar = progressBar;
this.progressBar.updateProgress(0, "Please Wait...");
}
/**
* {@inheritDoc}
*/
@Override
public void operationComplete(TRId trId) {
Log.info("Completed");
progressBar.updateProgress(1, "Completed");
}
/**
* {@inheritDoc}
*/
@Override
public void operationFailed(Throwable caught, String reason, String failureDetails) {
Log.info("Failed");
progressBar.updateText("Failed");
}
@Override
public void operationInitializing() {
Log.info("Inizializing");
progressBar.updateProgress(0, "Initializing...");
}
@Override
public void operationUpdate(float elaborated) {
Log.info("Elaborated: "+elaborated);
if (elaborated>=0 && elaborated<1) {
Log.trace("progress "+elaborated);
int elab=new Float(elaborated*100).intValue();
progressBar.updateProgress(elaborated,elab+"% Progress...");
}
if (elaborated == 1) progressBar.updateProgress(1, "Completing...");
}
@Override
public void operationValidate(float elaborated) {
Log.info("Validation Elaborated: "+elaborated);
if (elaborated == 0) progressBar.updateProgress(0, "Start Validation...");
if (elaborated>0 && elaborated<1) {
Log.trace("Validation progress "+elaborated);
int elab=new Float(elaborated*100).intValue();
progressBar.updateProgress(elaborated,elab+"% Validation Progress...");
}
if (elaborated == 1) progressBar.updateProgress(1, "Validation...");
}
@Override
public void operationStopped(TRId trId,String reason, String details) {
Log.debug("Operation Stopped: ["+trId.toString()+", "+reason+", "+details+"]");
progressBar.updateText("Validations failed");
}
@Override
public void operationGeneratingView() {
Log.info("Generating View...");
progressBar.updateText("Generating View...");
}
}

View File

@ -1,146 +0,0 @@
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy;
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;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.ProgressBar;
import com.sencha.gxt.widget.core.client.Window;
import com.sencha.gxt.widget.core.client.button.TextButton;
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.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
/**
*
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class CloneProgressDialog extends Window implements
CloneProgressListener {
public static final int STATUS_POLLING_DELAY = 1000;
protected String WIDTH = "400px";
protected String HEIGHT = "120px";
protected EventBus eventBus;
protected CloneProgressUpdater progressUpdater;
protected TextButton ok;
protected TRId trId;
private ChangeTableWhy why;
public CloneProgressDialog(EventBus eventBus) {
this.eventBus = eventBus;
setWidth(WIDTH);
setHeight(HEIGHT);
setBodyBorder(false);
setResizable(true);
setModal(true);
setHeadingText("Clone Progress");
trId = null;
FramedPanel panel = new FramedPanel();
panel.setHeaderVisible(false);
panel.setBodyBorder(false);
VerticalLayoutContainer v = new VerticalLayoutContainer();
ProgressBar progressBar = new ProgressBar();
ok = new TextButton("OK");
ok.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
updateInvocation();
}
});
v.add(progressBar,
new VerticalLayoutData(1, 1, new Margins(5, 5, 5, 5)));
panel.add(v);
panel.addButton(ok);
add(panel);
progressUpdater = new CloneProgressUpdater();
progressUpdater.addListener(new CloneProgressBarUpdater(progressBar));
progressUpdater.addListener(this);
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
show();
ok.setVisible(false);
}
public void operationInitializing() {
// TODO Auto-generated method stub
}
public void operationUpdate(float elaborated) {
// TODO Auto-generated method stub
}
public void operationComplete(TRId trId) {
Log.debug("Operation Complete return: " + trId.toString());
this.trId = trId;
why = ChangeTableWhy.TABLEUPDATED;
updateInvocation();
}
public void operationFailed(Throwable caught, String reason,
String failureDetails) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
ok.setVisible(true);
this.trId = null;
UtilsGXT3.alert("Error", reason);
}
}
public void updateInvocation() {
if (trId != null) {
ChangeTableRequestEvent event = new ChangeTableRequestEvent(
ChangeTableRequestType.CLONETABULARRESOURCE, trId, why);
eventBus.fireEvent(event);
}
hide();
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
Log.debug("Operation Stopped: [" + trId.toString() + ", " + reason
+ ", " + details + "]");
ok.setVisible(true);
this.trId = trId;
why = ChangeTableWhy.TABLECURATION;
}
@Override
public void operationGeneratingView() {
// TODO Auto-generated method stub
}
@Override
public void operationValidate(float elaborated) {
// TODO Auto-generated method stub
}
}

View File

@ -1,63 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
/**
* Defines a listener for operation progress.
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface CloneProgressListener {
/**
* Called when the operation is starting.
*/
public void operationInitializing();
/**
* Called when there is a progress for the operation.
* @param elaborated the elaborated part.
*/
public void operationUpdate(float elaborated);
/**
* Called when there is a validate for the operation.
* @param elaborated the elaborated part.
*/
public void operationValidate(float elaborated);
/**
* Called when the operation is complete.
*/
public void operationComplete(TRId trId);
/**
* Called when the operation is failed.
* @param caught the failure exception.
* @param reason the failure reason.
*/
public void operationFailed(Throwable caught, String reason, String failureDetails);
/**
* Called when the operation is stopped
*
* @param trId
* @param reason
* @param details
*/
public void operationStopped(TRId trId, String reason, String details);
/**
* Called when the operation is generating the view
*/
public void operationGeneratingView();
}

View File

@ -1,195 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.monitor.CloneMonitor;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class CloneProgressUpdater extends Timer {
protected ArrayList<CloneProgressListener> listeners = new ArrayList<CloneProgressListener>();
/**
* {@inheritDoc}
*/
@Override
public void run() {
Log.debug("requesting operation progress");
TDGWTServiceAsync.INSTANCE
.getCloneMonitor(new AsyncCallback<CloneMonitor>() {
public void onFailure(Throwable caught) {
cancel();
Log.error("Error retrieving the operation state",
caught);
String message = getStack(caught);
fireOperationFailed(caught,
"Failed getting operation updates", message);
}
public void onSuccess(CloneMonitor result) {
Log.info("retrieved CloneMonitor: "
+ result.getStatus());
switch (result.getStatus()) {
case INITIALIZING:
Log.info("Initializing...");
fireOperationInitializing();
break;
case ABORTED:
cancel();
Log.info("Operation Aborted");
break;
case IN_PROGRESS:
fireOperationUpdate(result.getProgress());
break;
case VALIDATING_RULES:
fireOperationValidate(result.getProgress());
break;
case GENERATING_VIEW:
Log.info("Generating View...");
fireOperationGeneratingView();
break;
case STOPPED:
cancel();
stopMessage(result);
break;
case FAILED:
cancel();
errorMessage(result);
break;
case SUCCEDED:
cancel();
Log.info("Fisnish TableId :"
+ result.getTrId());
fireOperationComplete(result.getTrId());
break;
default:
Log.info("Unknow State");
break;
}
}
});
}
protected void errorMessage(CloneMonitor result) {
Log.info("Clone Failed");
Throwable th = null;
String failure = null;
String details = null;
if (result.getError() != null) {
th = result.getError();
failure = "Failed Clone operation";
details = result.getError().getLocalizedMessage();
} else {
th = new Throwable("Failed");
failure = "Failed Clone operation";
details = "Clone failed";
}
fireOperationFailed(th, failure, details);
}
protected void stopMessage(CloneMonitor result) {
Log.info("Clone Stopped");
String failure = null;
String details = null;
if (result.getError() != null) {
failure = "Stopped operation";
details = result.getError().getLocalizedMessage();
} else {
failure = "Stopped operation";
details = "Operation stopped";
}
fireOperationStopped(result.getTrId(),failure, details);
}
protected String getStack(Throwable e) {
String message = e.getLocalizedMessage() + " -> <br>";
Throwable c = e.getCause();
if (c != null)
message += getStack(c);
return message;
}
protected void fireOperationInitializing() {
for (CloneProgressListener listener : listeners)
listener.operationInitializing();
}
protected void fireOperationGeneratingView() {
for (CloneProgressListener listener : listeners)
listener.operationGeneratingView();
}
protected void fireOperationUpdate(float elaborated) {
for (CloneProgressListener listener : listeners)
listener.operationUpdate(elaborated);
}
protected void fireOperationValidate(float elaborated) {
for (CloneProgressListener listener : listeners)
listener.operationValidate(elaborated);
}
protected void fireOperationComplete(TRId trId) {
for (CloneProgressListener listener : listeners)
listener.operationComplete(trId);
}
protected void fireOperationFailed(Throwable caught, String failure,
String failureDetails) {
for (CloneProgressListener listener : listeners)
listener.operationFailed(caught, failure, failureDetails);
}
protected void fireOperationStopped(TRId trId, String reason, String details) {
for (CloneProgressListener listener : listeners)
listener.operationStopped(trId,reason, details);
}
/**
* Add a new {@link CloneProgressListener} to this
* {@link CloneProgressUpdater}.
*
* @param listener
* the listener to add.
*/
public void addListener(CloneProgressListener listener) {
listeners.add(listener);
}
/**
* Removes the specified {@link CloneProgressListener} from this
* {@link CloneProgressUpdater}.
*
* @param listener
* the listener to remove.
*/
public void removeListener(CloneProgressListener listener) {
listeners.remove(listener);
}
}

View File

@ -1,97 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.sencha.gxt.widget.core.client.ProgressBar;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class DeleteRowsProgressBarUpdater implements DeleteRowsProgressListener {
protected ProgressBar progressBar;
/**
* Creates a new {@link ProgressBar} updater.
* @param progressBar the {@link ProgressBar} to update.
*/
public DeleteRowsProgressBarUpdater(ProgressBar progressBar) {
this.progressBar = progressBar;
this.progressBar.updateProgress(0, "Please Wait...");
}
/**
* {@inheritDoc}
*/
@Override
public void operationComplete(TRId trId) {
Log.info("Completed");
progressBar.updateProgress(1, "Completed");
}
/**
* {@inheritDoc}
*/
@Override
public void operationFailed(Throwable caught, String reason, String failureDetails) {
Log.info("Failed");
progressBar.updateText("Failed");
}
@Override
public void operationInitializing() {
Log.info("Inizializing");
progressBar.updateProgress(0, "Initializing...");
}
@Override
public void operationUpdate(float elaborated) {
Log.info("Elaborated: "+elaborated);
if (elaborated>=0 && elaborated<1) {
Log.trace("progress "+elaborated);
int elab=new Float(elaborated*100).intValue();
progressBar.updateProgress(elaborated,elab+"% Progress...");
}
if (elaborated == 1) progressBar.updateProgress(1, "Completing...");
}
@Override
public void operationValidate(float elaborated) {
Log.info("Validation Elaborated: "+elaborated);
if (elaborated == 0) progressBar.updateProgress(0, "Start Validation...");
if (elaborated>0 && elaborated<1) {
Log.trace("Validation progress "+elaborated);
int elab=new Float(elaborated*100).intValue();
progressBar.updateProgress(elaborated,elab+"% Validation Progress...");
}
if (elaborated == 1) progressBar.updateProgress(1, "Validation...");
}
@Override
public void operationStopped(TRId trId,String reason, String details) {
Log.debug("Operation Stopped: ["+trId.toString()+", "+reason+", "+details+"]");
progressBar.updateText("Validations failed");
}
@Override
public void operationGeneratingView() {
Log.info("Generating View...");
progressBar.updateText("Generating View...");
}
}

View File

@ -1,152 +0,0 @@
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DeleteRowsSession;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy;
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;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.ProgressBar;
import com.sencha.gxt.widget.core.client.Window;
import com.sencha.gxt.widget.core.client.button.TextButton;
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.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
/**
* LabelColumnProgressDialog is a Dialog that show progress of change the column
* label
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class DeleteRowsProgressDialog extends Window implements
DeleteRowsProgressListener {
public static final int STATUS_POLLING_DELAY = 1000;
protected String WIDTH = "400px";
protected String HEIGHT = "120px";
protected DeleteRowsSession deleteRowsSession;
protected EventBus eventBus;
protected DeleteRowsProgressUpdater progressUpdater;
protected TextButton ok;
protected TRId trId;
private ChangeTableWhy why;
public DeleteRowsProgressDialog(DeleteRowsSession deleteRowsSession,
EventBus eventBus) {
this.deleteRowsSession = deleteRowsSession;
this.eventBus = eventBus;
setWidth(WIDTH);
setHeight(HEIGHT);
setBodyBorder(false);
setResizable(true);
setModal(true);
setHeadingText("Delete Rows Progress");
trId = null;
FramedPanel panel = new FramedPanel();
panel.setHeaderVisible(false);
panel.setBodyBorder(false);
VerticalLayoutContainer v = new VerticalLayoutContainer();
ProgressBar progressBar = new ProgressBar();
ok = new TextButton("OK");
ok.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
updateInvocation();
}
});
v.add(progressBar,
new VerticalLayoutData(1, 1, new Margins(5, 5, 5, 5)));
panel.add(v);
panel.addButton(ok);
add(panel);
progressUpdater = new DeleteRowsProgressUpdater();
progressUpdater.addListener(new DeleteRowsProgressBarUpdater(
progressBar));
progressUpdater.addListener(this);
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
show();
ok.setVisible(false);
}
public void operationInitializing() {
// TODO Auto-generated method stub
}
public void operationUpdate(float elaborated) {
// TODO Auto-generated method stub
}
public void operationComplete(TRId trId) {
Log.debug("Operation Complete return: " + trId.toString());
this.trId = trId;
why = ChangeTableWhy.TABLEUPDATED;
updateInvocation();
}
public void operationFailed(Throwable caught, String reason,
String failureDetails) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
ok.setVisible(true);
this.trId = null;
UtilsGXT3.alert("Error Deleting Rows", reason);
}
}
public void updateInvocation() {
if (trId != null) {
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.DELETEROWS, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
}
hide();
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
Log.debug("Operation Stopped: [" + trId.toString() + ", " + reason
+ ", " + details + "]");
ok.setVisible(true);
this.trId = trId;
why = ChangeTableWhy.TABLECURATION;
}
@Override
public void operationGeneratingView() {
// TODO Auto-generated method stub
}
@Override
public void operationValidate(float elaborated) {
// TODO Auto-generated method stub
}
}

View File

@ -1,62 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
/**
* Defines a listener for operation progress.
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface DeleteRowsProgressListener {
/**
* Called when the operation is starting.
*/
public void operationInitializing();
/**
* Called when there is a progress for the operation.
* @param elaborated the elaborated part.
*/
public void operationUpdate(float elaborated);
/**
* Called when there is a validate for the operation.
* @param elaborated the elaborated part.
*/
public void operationValidate(float elaborated);
/**
* Called when the operation is complete.
*/
public void operationComplete(TRId trId);
/**
* Called when the operation is failed.
* @param caught the failure exception.
* @param reason the failure reason.
*/
public void operationFailed(Throwable caught, String reason, String failureDetails);
/**
* Called when the operation is stopped
*
* @param trId
* @param reason
* @param details
*/
public void operationStopped(TRId trId, String reason, String details);
/**
* Called when the operation is generating the view
*/
public void operationGeneratingView();
}

View File

@ -1,195 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.monitor.DeleteRowsMonitor;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class DeleteRowsProgressUpdater extends Timer {
protected ArrayList<DeleteRowsProgressListener> listeners = new ArrayList<DeleteRowsProgressListener>();
/**
* {@inheritDoc}
*/
@Override
public void run() {
Log.debug("requesting operation progress");
TDGWTServiceAsync.INSTANCE
.getDeleteRowsMonitor(new AsyncCallback<DeleteRowsMonitor>() {
public void onFailure(Throwable caught) {
cancel();
Log.error("Error retrieving the operation state",
caught);
String message = getStack(caught);
fireOperationFailed(caught,
"Failed getting operation updates", message);
}
public void onSuccess(DeleteRowsMonitor result) {
Log.info("retrieved DeleteRowsMonitor: "
+ result.getStatus());
switch (result.getStatus()) {
case INITIALIZING:
Log.info("Initializing...");
fireOperationInitializing();
break;
case ABORTED:
cancel();
Log.info("Delete Rows Operation Aborted");
break;
case IN_PROGRESS:
fireOperationUpdate(result.getProgress());
break;
case VALIDATING_RULES:
fireOperationValidate(result.getProgress());
break;
case GENERATING_VIEW:
Log.info("Generating View...");
fireOperationGeneratingView();
break;
case STOPPED:
cancel();
stopMessage(result);
break;
case FAILED:
cancel();
errorMessage(result);
break;
case SUCCEDED:
cancel();
Log.info("Fisnish TableId :"
+ result.getTrId());
fireOperationComplete(result.getTrId());
break;
default:
Log.info("Unknow State");
break;
}
}
});
}
protected void errorMessage(DeleteRowsMonitor result) {
Log.info("Delete Rows Failed");
Throwable th = null;
String failure = null;
String details = null;
if (result.getError() != null) {
th = result.getError();
failure = "Failed Client Library Delete Rows";
details = result.getError().getLocalizedMessage();
} else {
th = new Throwable("Failed");
failure = "Failed Client Library Delete Rows";
details = "Delete Rows failed";
}
fireOperationFailed(th, failure, details);
}
protected void stopMessage(DeleteRowsMonitor result) {
Log.info("Delete Rows Stopped");
String failure = null;
String details = null;
if (result.getError() != null) {
failure = "Stopped deleting rows";
details = result.getError().getLocalizedMessage();
} else {
failure = "Stopped deleting rows";
details = "Delete Rows stopped";
}
fireOperationStopped(result.getTrId(),failure, details);
}
protected String getStack(Throwable e) {
String message = e.getLocalizedMessage() + " -> <br>";
Throwable c = e.getCause();
if (c != null)
message += getStack(c);
return message;
}
protected void fireOperationInitializing() {
for (DeleteRowsProgressListener listener : listeners)
listener.operationInitializing();
}
protected void fireOperationGeneratingView() {
for (DeleteRowsProgressListener listener : listeners)
listener.operationGeneratingView();
}
protected void fireOperationUpdate(float elaborated) {
for (DeleteRowsProgressListener listener : listeners)
listener.operationUpdate(elaborated);
}
protected void fireOperationValidate(float elaborated) {
for (DeleteRowsProgressListener listener : listeners)
listener.operationValidate(elaborated);
}
protected void fireOperationComplete(TRId trId) {
for (DeleteRowsProgressListener listener : listeners)
listener.operationComplete(trId);
}
protected void fireOperationFailed(Throwable caught, String failure,
String failureDetails) {
for (DeleteRowsProgressListener listener : listeners)
listener.operationFailed(caught, failure, failureDetails);
}
protected void fireOperationStopped(TRId trId, String reason, String details) {
for (DeleteRowsProgressListener listener : listeners)
listener.operationStopped(trId,reason, details);
}
/**
* Add a new {@link DeleteRowsProgressListener} to this
* {@link DeleteRowsProgressUpdater}.
*
* @param listener
* the listener to add.
*/
public void addListener(DeleteRowsProgressListener listener) {
listeners.add(listener);
}
/**
* Removes the specified {@link DeleteRowsProgressListener} from this
* {@link DeleteRowsProgressUpdater}.
*
* @param listener
* the listener to remove.
*/
public void removeListener(DeleteRowsProgressListener listener) {
listeners.remove(listener);
}
}

View File

@ -1,102 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.sencha.gxt.widget.core.client.ProgressBar;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class DenormalizationProgressBarUpdater implements
DenormalizationProgressListener {
protected ProgressBar progressBar;
/**
* Creates a new {@link ProgressBar} updater.
*
* @param progressBar
* the {@link ProgressBar} to update.
*/
public DenormalizationProgressBarUpdater(ProgressBar progressBar) {
this.progressBar = progressBar;
this.progressBar.updateProgress(0, "Please Wait...");
}
/**
* {@inheritDoc}
*/
@Override
public void operationComplete(TRId trId) {
Log.info("Completed");
progressBar.updateProgress(1, "Completed");
}
/**
* {@inheritDoc}
*/
@Override
public void operationFailed(Throwable caught, String reason,
String failureDetails) {
Log.info("Failed");
progressBar.updateText("Failed");
}
@Override
public void operationInitializing() {
Log.info("Inizializing");
progressBar.updateProgress(0, "Initializing...");
}
@Override
public void operationUpdate(float elaborated) {
Log.info("Elaborated: " + elaborated);
if (elaborated >= 0 && elaborated < 1) {
Log.trace("progress " + elaborated);
int elab = new Float(elaborated * 100).intValue();
progressBar.updateProgress(elaborated, elab + "% Progress...");
}
if (elaborated == 1)
progressBar.updateProgress(1, "Completing...");
}
@Override
public void operationValidate(float elaborated) {
Log.info("Validation Elaborated: " + elaborated);
if (elaborated == 0)
progressBar.updateProgress(0, "Start Validation...");
if (elaborated > 0 && elaborated < 1) {
Log.trace("Validation progress " + elaborated);
int elab = new Float(elaborated * 100).intValue();
progressBar.updateProgress(elaborated, elab
+ "% Validation Progress...");
}
if (elaborated == 1)
progressBar.updateProgress(1, "Validation...");
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
Log.debug("Operation Stopped: [" + trId.toString() + ", " + reason
+ ", " + details + "]");
progressBar.updateText("Validations failed");
}
@Override
public void operationGeneratingView() {
Log.info("Generating View...");
progressBar.updateText("Generating View...");
}
}

View File

@ -1,178 +0,0 @@
package org.gcube.portlets.user.td.tablewidget.client.progress;
import java.util.ArrayList;
import org.gcube.portlets.user.td.columnwidget.client.progress.ProgressDialogListener;
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;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.ProgressBar;
import com.sencha.gxt.widget.core.client.Window;
import com.sencha.gxt.widget.core.client.button.TextButton;
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.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
/**
*
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class DenormalizationProgressDialog extends Window implements
DenormalizationProgressListener {
protected ArrayList<ProgressDialogListener> listeners = new ArrayList<ProgressDialogListener>();
public static final int STATUS_POLLING_DELAY = 1000;
protected String WIDTH = "400px";
protected String HEIGHT = "120px";
protected EventBus eventBus;
protected DenormalizationProgressUpdater progressUpdater;
protected TextButton ok;
protected TRId trId;
private String reason;
private String details;
public DenormalizationProgressDialog(EventBus eventBus) {
this.eventBus = eventBus;
setWidth(WIDTH);
setHeight(HEIGHT);
setBodyBorder(false);
setResizable(true);
setModal(true);
setHeadingText("Denormalization Progress");
trId = null;
FramedPanel panel = new FramedPanel();
panel.setHeaderVisible(false);
panel.setBodyBorder(false);
VerticalLayoutContainer v = new VerticalLayoutContainer();
ProgressBar progressBar = new ProgressBar();
ok = new TextButton("OK");
ok.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
updateInvocation();
}
});
v.add(progressBar,
new VerticalLayoutData(1, 1, new Margins(5, 5, 5, 5)));
panel.add(v);
panel.addButton(ok);
add(panel);
progressUpdater = new DenormalizationProgressUpdater();
progressUpdater
.addListener(new DenormalizationProgressBarUpdater(progressBar));
progressUpdater.addListener(this);
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
show();
ok.setVisible(false);
}
public void addProgressDialogListener(ProgressDialogListener listener) {
listeners.add(listener);
}
public void removeProgressDialogListener(ProgressDialogListener listener) {
listeners.remove(listener);
}
@Override
public void operationInitializing() {
// TODO Auto-generated method stub
}
@Override
public void operationUpdate(float elaborated) {
// TODO Auto-generated method stub
}
@Override
public void operationComplete(TRId trId) {
Log.debug("Operation Complete return: " + trId.toString());
this.trId = trId;
fireOperationComplete(trId);
hide();
}
@Override
public void operationFailed(Throwable caught, String reason,
String failureDetails) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
fireOperationFailed(caught, reason);
hide();
}
}
public void updateInvocation() {
if (trId != null) {
fireOperationStopped(trId, reason, details);
}
hide();
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
Log.debug("Operation Stopped: [" + trId.toString() + ", " + reason
+ ", " + details + "]");
this.trId = trId;
this.reason = reason;
this.details = details;
ok.setVisible(true);
}
@Override
public void operationGeneratingView() {
// TODO Auto-generated method stub
}
@Override
public void operationValidate(float elaborated) {
// TODO Auto-generated method stub
}
protected void fireOperationComplete(TRId trId) {
for (ProgressDialogListener listener : listeners)
listener.operationComplete(trId);
}
protected void fireOperationFailed(Throwable caught, String reason) {
for (ProgressDialogListener listener : listeners)
listener.operationFailed(caught, reason);
}
protected void fireOperationStopped(TRId trId, String reason, String details) {
for (ProgressDialogListener listener : listeners)
listener.operationStopped(trId, reason, details);
}
}

View File

@ -1,63 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
/**
* Defines a listener for operation progress.
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface DenormalizationProgressListener {
/**
* Called when the operation is starting.
*/
public void operationInitializing();
/**
* Called when there is a progress for the operation.
* @param elaborated the elaborated part.
*/
public void operationUpdate(float elaborated);
/**
* Called when there is a validate for the operation.
* @param elaborated the elaborated part.
*/
public void operationValidate(float elaborated);
/**
* Called when the operation is complete.
*/
public void operationComplete(TRId trId);
/**
* Called when the operation is failed.
* @param caught the failure exception.
* @param reason the failure reason.
*/
public void operationFailed(Throwable caught, String reason, String failureDetails);
/**
* Called when the operation is stopped
*
* @param trId
* @param reason
* @param details
*/
public void operationStopped(TRId trId, String reason, String details);
/**
* Called when the operation is generating the view
*/
public void operationGeneratingView();
}

View File

@ -1,195 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.monitor.DenormalizationMonitor;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class DenormalizationProgressUpdater extends Timer {
protected ArrayList<DenormalizationProgressListener> listeners = new ArrayList<DenormalizationProgressListener>();
/**
* {@inheritDoc}
*/
@Override
public void run() {
Log.debug("requesting operation progress");
TDGWTServiceAsync.INSTANCE
.getDenormalizationMonitor(new AsyncCallback<DenormalizationMonitor>() {
public void onFailure(Throwable caught) {
cancel();
Log.error("Error retrieving the operation state",
caught);
String message = getStack(caught);
fireOperationFailed(caught,
"Failed getting operation updates", message);
}
public void onSuccess(DenormalizationMonitor result) {
Log.info("retrieved DenormalizationMonitor: "
+ result.getStatus());
switch (result.getStatus()) {
case INITIALIZING:
Log.info("Initializing...");
fireOperationInitializing();
break;
case ABORTED:
cancel();
Log.info("Aborted");
break;
case IN_PROGRESS:
fireOperationUpdate(result.getProgress());
break;
case VALIDATING_RULES:
fireOperationValidate(result.getProgress());
break;
case GENERATING_VIEW:
Log.info("Generating View...");
fireOperationGeneratingView();
break;
case STOPPED:
cancel();
stopMessage(result);
break;
case FAILED:
cancel();
errorMessage(result);
break;
case SUCCEDED:
cancel();
Log.info("Fisnish :"
+ result.getTrId());
fireOperationComplete(result.getTrId());
break;
default:
Log.info("Unknow State");
break;
}
}
});
}
protected void errorMessage(DenormalizationMonitor result) {
Log.info("Denormalize Failed");
Throwable th = null;
String failure = null;
String details = null;
if (result.getError() != null) {
th = result.getError();
failure = "Failed Client Library Denormalize";
details = result.getError().getLocalizedMessage();
} else {
th = new Throwable("Failed");
failure = "Failed Client Library Denormalize";
details = "Denormalize failed";
}
fireOperationFailed(th, failure, details);
}
protected void stopMessage(DenormalizationMonitor result) {
Log.info("Denormalize Stopped");
String failure = null;
String details = null;
if (result.getError() != null) {
failure = "Stopped denormalize";
details = result.getError().getLocalizedMessage();
} else {
failure = "Stopped denormalize";
details = "Denormalize stopped";
}
fireOperationStopped(result.getTrId(),failure, details);
}
protected String getStack(Throwable e) {
String message = e.getLocalizedMessage() + " -> <br>";
Throwable c = e.getCause();
if (c != null)
message += getStack(c);
return message;
}
protected void fireOperationInitializing() {
for (DenormalizationProgressListener listener : listeners)
listener.operationInitializing();
}
protected void fireOperationGeneratingView() {
for (DenormalizationProgressListener listener : listeners)
listener.operationGeneratingView();
}
protected void fireOperationUpdate(float elaborated) {
for (DenormalizationProgressListener listener : listeners)
listener.operationUpdate(elaborated);
}
protected void fireOperationValidate(float elaborated) {
for (DenormalizationProgressListener listener : listeners)
listener.operationValidate(elaborated);
}
protected void fireOperationComplete(TRId trId) {
for (DenormalizationProgressListener listener : listeners)
listener.operationComplete(trId);
}
protected void fireOperationFailed(Throwable caught, String failure,
String failureDetails) {
for (DenormalizationProgressListener listener : listeners)
listener.operationFailed(caught, failure, failureDetails);
}
protected void fireOperationStopped(TRId trId, String reason, String details) {
for (DenormalizationProgressListener listener : listeners)
listener.operationStopped(trId,reason, details);
}
/**
* Add a new {@link DenormalizationProgressListener} to this
* {@link DenormalizationProgressUpdater}.
*
* @param listener
* the listener to add.
*/
public void addListener(DenormalizationProgressListener listener) {
listeners.add(listener);
}
/**
* Removes the specified {@link DenormalizationProgressListener} from this
* {@link DenormalizationProgressUpdater}.
*
* @param listener
* the listener to remove.
*/
public void removeListener(DenormalizationProgressListener listener) {
listeners.remove(listener);
}
}

View File

@ -1,97 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.sencha.gxt.widget.core.client.ProgressBar;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class DuplicatesRowsProgressBarUpdater implements DuplicatesRowsProgressListener {
protected ProgressBar progressBar;
/**
* Creates a new {@link ProgressBar} updater.
* @param progressBar the {@link ProgressBar} to update.
*/
public DuplicatesRowsProgressBarUpdater(ProgressBar progressBar) {
this.progressBar = progressBar;
this.progressBar.updateProgress(0, "Please Wait...");
}
/**
* {@inheritDoc}
*/
@Override
public void operationComplete(TRId trId) {
Log.info("Completed");
progressBar.updateProgress(1, "Completed");
}
/**
* {@inheritDoc}
*/
@Override
public void operationFailed(Throwable caught, String reason, String failureDetails) {
Log.info("Failed");
progressBar.updateText("Failed");
}
@Override
public void operationInitializing() {
Log.info("Inizializing");
progressBar.updateProgress(0, "Initializing...");
}
@Override
public void operationUpdate(float elaborated) {
Log.info("Elaborated: "+elaborated);
if (elaborated>=0 && elaborated<1) {
Log.trace("progress "+elaborated);
int elab=new Float(elaborated*100).intValue();
progressBar.updateProgress(elaborated,elab+"% Progress...");
}
if (elaborated == 1) progressBar.updateProgress(1, "Completing...");
}
@Override
public void operationValidate(float elaborated) {
Log.info("Validation Elaborated: "+elaborated);
if (elaborated == 0) progressBar.updateProgress(0, "Start Validation...");
if (elaborated>0 && elaborated<1) {
Log.trace("Validation progress "+elaborated);
int elab=new Float(elaborated*100).intValue();
progressBar.updateProgress(elaborated,elab+"% Validation Progress...");
}
if (elaborated == 1) progressBar.updateProgress(1, "Validation...");
}
@Override
public void operationStopped(TRId trId,String reason, String details) {
Log.debug("Operation Stopped: ["+trId.toString()+", "+reason+", "+details+"]");
progressBar.updateText("Validations failed");
}
@Override
public void operationGeneratingView() {
Log.info("Generating View...");
progressBar.updateText("Generating View...");
}
}

View File

@ -1,151 +0,0 @@
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DuplicatesSession;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy;
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;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.ProgressBar;
import com.sencha.gxt.widget.core.client.Window;
import com.sencha.gxt.widget.core.client.button.TextButton;
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.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
/**
* LabelColumnProgressDialog is a Dialog that show progress of change the column
* label
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class DuplicatesRowsProgressDialog extends Window implements
DuplicatesRowsProgressListener {
public static final int STATUS_POLLING_DELAY = 1000;
protected String WIDTH = "400px";
protected String HEIGHT = "120px";
protected DuplicatesSession duplicatesSession;
protected EventBus eventBus;
protected DuplicatesRowsProgressUpdater progressUpdater;
protected TextButton ok;
protected TRId trId;
private ChangeTableWhy why;
public DuplicatesRowsProgressDialog(DuplicatesSession duplicatesSession,
EventBus eventBus) {
this.duplicatesSession = duplicatesSession;
this.eventBus = eventBus;
setWidth(WIDTH);
setHeight(HEIGHT);
setBodyBorder(false);
setResizable(true);
setModal(true);
setHeadingText("Duplicates Rows Progress");
trId = null;
FramedPanel panel = new FramedPanel();
panel.setHeaderVisible(false);
panel.setBodyBorder(false);
VerticalLayoutContainer v = new VerticalLayoutContainer();
ProgressBar progressBar = new ProgressBar();
ok = new TextButton("OK");
ok.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
updateInvocation();
}
});
v.add(progressBar,
new VerticalLayoutData(1, 1, new Margins(5, 5, 5, 5)));
panel.add(v);
panel.addButton(ok);
add(panel);
progressUpdater = new DuplicatesRowsProgressUpdater();
progressUpdater.addListener(new DuplicatesRowsProgressBarUpdater(
progressBar));
progressUpdater.addListener(this);
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
show();
ok.setVisible(false);
}
public void operationInitializing() {
// TODO Auto-generated method stub
}
public void operationUpdate(float elaborated) {
// TODO Auto-generated method stub
}
public void operationComplete(TRId trId) {
Log.debug("Operation Complete return: " + trId.toString());
this.trId = trId;
why = ChangeTableWhy.TABLEUPDATED;
updateInvocation();
}
public void operationFailed(Throwable caught, String reason,
String failureDetails) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
ok.setVisible(true);
this.trId = null;
UtilsGXT3.alert("Error Deleting Rows", reason);
}
}
public void updateInvocation() {
if (trId != null) {
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.DUPLICATES, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
}
hide();
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
Log.debug("Operation Stopped: [" + trId.toString() + ", " + reason
+ ", " + details + "]");
ok.setVisible(true);
this.trId = trId;
why = ChangeTableWhy.TABLECURATION;
}
@Override
public void operationGeneratingView() {
// TODO Auto-generated method stub
}
@Override
public void operationValidate(float elaborated) {
// TODO Auto-generated method stub
}
}

View File

@ -1,62 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
/**
* Defines a listener for operation progress.
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface DuplicatesRowsProgressListener {
/**
* Called when the operation is starting.
*/
public void operationInitializing();
/**
* Called when there is a progress for the operation.
* @param elaborated the elaborated part.
*/
public void operationUpdate(float elaborated);
/**
* Called when there is a validate for the operation.
* @param elaborated the elaborated part.
*/
public void operationValidate(float elaborated);
/**
* Called when the operation is complete.
*/
public void operationComplete(TRId trId);
/**
* Called when the operation is failed.
* @param caught the failure exception.
* @param reason the failure reason.
*/
public void operationFailed(Throwable caught, String reason, String failureDetails);
/**
* Called when the operation is stopped
*
* @param trId
* @param reason
* @param details
*/
public void operationStopped(TRId trId, String reason, String details);
/**
* Called when the operation is generating the view
*/
public void operationGeneratingView();
}

View File

@ -1,195 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.monitor.DuplicatesMonitor;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class DuplicatesRowsProgressUpdater extends Timer {
protected ArrayList<DuplicatesRowsProgressListener> listeners = new ArrayList<DuplicatesRowsProgressListener>();
/**
* {@inheritDoc}
*/
@Override
public void run() {
Log.debug("requesting operation progress");
TDGWTServiceAsync.INSTANCE
.getDuplicatesMonitor(new AsyncCallback<DuplicatesMonitor>() {
public void onFailure(Throwable caught) {
cancel();
Log.error("Error retrieving the operation state",
caught);
String message = getStack(caught);
fireOperationFailed(caught,
"Failed getting operation updates", message);
}
public void onSuccess(DuplicatesMonitor result) {
Log.info("retrieved DuplicatesMonitor: "
+ result.getStatus());
switch (result.getStatus()) {
case INITIALIZING:
Log.info("Initializing...");
fireOperationInitializing();
break;
case ABORTED:
cancel();
Log.info("Operation Aborted");
break;
case IN_PROGRESS:
fireOperationUpdate(result.getProgress());
break;
case VALIDATING_RULES:
fireOperationValidate(result.getProgress());
break;
case GENERATING_VIEW:
Log.info("Generating View...");
fireOperationGeneratingView();
break;
case STOPPED:
cancel();
stopMessage(result);
break;
case FAILED:
cancel();
errorMessage(result);
break;
case SUCCEDED:
cancel();
Log.info("Fisnish TableId :"
+ result.getTrId());
fireOperationComplete(result.getTrId());
break;
default:
Log.info("Unknow State");
break;
}
}
});
}
protected void errorMessage(DuplicatesMonitor result) {
Log.info("Operation on duplicates Failed");
Throwable th = null;
String failure = null;
String details = null;
if (result.getError() != null) {
th = result.getError();
failure = "Failed Client Library Operation on duplicates";
details = result.getError().getLocalizedMessage();
} else {
th = new Throwable("Failed");
failure = "Failed Client Library Operation on duplicates";
details = "Operation on duplicates failed";
}
fireOperationFailed(th, failure, details);
}
protected void stopMessage(DuplicatesMonitor result) {
Log.info("Operation on duplicates Stopped");
String failure = null;
String details = null;
if (result.getError() != null) {
failure = "Stopped operation on duplicates";
details = result.getError().getLocalizedMessage();
} else {
failure = "Stopped operation on duplicates";
details = "Operation on duplicates stopped";
}
fireOperationStopped(result.getTrId(),failure, details);
}
protected String getStack(Throwable e) {
String message = e.getLocalizedMessage() + " -> <br>";
Throwable c = e.getCause();
if (c != null)
message += getStack(c);
return message;
}
protected void fireOperationInitializing() {
for (DuplicatesRowsProgressListener listener : listeners)
listener.operationInitializing();
}
protected void fireOperationGeneratingView() {
for (DuplicatesRowsProgressListener listener : listeners)
listener.operationGeneratingView();
}
protected void fireOperationUpdate(float elaborated) {
for (DuplicatesRowsProgressListener listener : listeners)
listener.operationUpdate(elaborated);
}
protected void fireOperationValidate(float elaborated) {
for (DuplicatesRowsProgressListener listener : listeners)
listener.operationValidate(elaborated);
}
protected void fireOperationComplete(TRId trId) {
for (DuplicatesRowsProgressListener listener : listeners)
listener.operationComplete(trId);
}
protected void fireOperationFailed(Throwable caught, String failure,
String failureDetails) {
for (DuplicatesRowsProgressListener listener : listeners)
listener.operationFailed(caught, failure, failureDetails);
}
protected void fireOperationStopped(TRId trId, String reason, String details) {
for (DuplicatesRowsProgressListener listener : listeners)
listener.operationStopped(trId,reason, details);
}
/**
* Add a new {@link DuplicatesRowsProgressListener} to this
* {@link DuplicatesRowsProgressUpdater}.
*
* @param listener
* the listener to add.
*/
public void addListener(DuplicatesRowsProgressListener listener) {
listeners.add(listener);
}
/**
* Removes the specified {@link DuplicatesRowsProgressListener} from this
* {@link DuplicatesRowsProgressUpdater}.
*
* @param listener
* the listener to remove.
*/
public void removeListener(DuplicatesRowsProgressListener listener) {
listeners.remove(listener);
}
}

View File

@ -1,98 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.sencha.gxt.widget.core.client.ProgressBar;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class EditRowProgressBarUpdater implements EditRowProgressListener {
protected ProgressBar progressBar;
/**
* Creates a new {@link ProgressBar} updater.
* @param progressBar the {@link ProgressBar} to update.
*/
public EditRowProgressBarUpdater(ProgressBar progressBar) {
this.progressBar = progressBar;
this.progressBar.updateProgress(0, "Please Wait...");
}
/**
* {@inheritDoc}
*/
@Override
public void operationComplete(TRId trId) {
Log.info("Completed");
progressBar.updateProgress(1, "Completed");
}
/**
* {@inheritDoc}
*/
@Override
public void operationFailed(Throwable caught, String reason, String failureDetails) {
Log.info("Failed");
progressBar.updateText("Failed");
}
@Override
public void operationInitializing() {
Log.info("Inizializing");
progressBar.updateProgress(0, "Initializing...");
}
@Override
public void operationUpdate(float elaborated) {
Log.info("Elaborated: "+elaborated);
if (elaborated>=0 && elaborated<1) {
Log.trace("progress "+elaborated);
int elab=new Float(elaborated*100).intValue();
progressBar.updateProgress(elaborated,elab+"% Progress...");
}
if (elaborated == 1) progressBar.updateProgress(1, "Completing...");
}
@Override
public void operationValidate(float elaborated) {
Log.info("Validation Elaborated: "+elaborated);
if (elaborated == 0) progressBar.updateProgress(0, "Start Validation...");
if (elaborated>0 && elaborated<1) {
Log.trace("Validation progress "+elaborated);
int elab=new Float(elaborated*100).intValue();
progressBar.updateProgress(elaborated,elab+"% Validation Progress...");
}
if (elaborated == 1) progressBar.updateProgress(1, "Validation...");
}
@Override
public void operationStopped(TRId trId,String reason, String details) {
Log.debug("Operation Stopped: ["+trId.toString()+", "+reason+", "+details+"]");
progressBar.updateText("Validations failed");
}
@Override
public void operationGeneratingView() {
Log.info("Generating View...");
progressBar.updateText("Generating View...");
}
}

View File

@ -1,149 +0,0 @@
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.tablewidget.client.rows.EditRowPanel;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy;
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;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.ProgressBar;
import com.sencha.gxt.widget.core.client.Window;
import com.sencha.gxt.widget.core.client.button.TextButton;
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.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
/**
*
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class EditRowProgressDialog extends Window implements
EditRowProgressListener {
public static final int STATUS_POLLING_DELAY = 1000;
protected String WIDTH = "400px";
protected String HEIGHT = "120px";
protected EditRowPanel parent;
protected EventBus eventBus;
protected EditRowProgressUpdater progressUpdater;
protected TextButton ok;
protected TRId trId;
private ChangeTableWhy why;
public EditRowProgressDialog(EditRowPanel editRowPanel, EventBus eventBus) {
this.parent = editRowPanel;
this.eventBus = eventBus;
setWidth(WIDTH);
setHeight(HEIGHT);
setBodyBorder(false);
setResizable(true);
setModal(true);
setHeadingText("Row Progress");
trId = null;
FramedPanel panel = new FramedPanel();
panel.setHeaderVisible(false);
panel.setBodyBorder(false);
VerticalLayoutContainer v = new VerticalLayoutContainer();
ProgressBar progressBar = new ProgressBar();
ok = new TextButton("OK");
ok.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
updateInvocation();
}
});
v.add(progressBar,
new VerticalLayoutData(1, 1, new Margins(5, 5, 5, 5)));
panel.add(v);
panel.addButton(ok);
add(panel);
progressUpdater = new EditRowProgressUpdater();
progressUpdater.addListener(new EditRowProgressBarUpdater(progressBar));
progressUpdater.addListener(this);
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
show();
ok.setVisible(false);
}
public void operationInitializing() {
// TODO Auto-generated method stub
}
public void operationUpdate(float elaborated) {
// TODO Auto-generated method stub
}
public void operationComplete(TRId trId) {
Log.debug("Operation Complete return: " + trId.toString());
this.trId = trId;
why = ChangeTableWhy.TABLEUPDATED;
updateInvocation();
}
public void operationFailed(Throwable caught, String reason,
String failureDetails) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
ok.setVisible(true);
this.trId = null;
UtilsGXT3.alert("Error", reason);
}
}
public void updateInvocation() {
if (trId != null) {
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.EDITROW, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
}
parent.close();
hide();
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
Log.debug("Operation Stopped: [" + trId.toString() + ", " + reason
+ ", " + details + "]");
ok.setVisible(true);
this.trId = trId;
why = ChangeTableWhy.TABLECURATION;
}
@Override
public void operationGeneratingView() {
// TODO Auto-generated method stub
}
@Override
public void operationValidate(float elaborated) {
// TODO Auto-generated method stub
}
}

View File

@ -1,63 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
/**
* Defines a listener for operation progress.
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface EditRowProgressListener {
/**
* Called when the operation is starting.
*/
public void operationInitializing();
/**
* Called when there is a progress for the operation.
* @param elaborated the elaborated part.
*/
public void operationUpdate(float elaborated);
/**
* Called when there is a validate for the operation.
* @param elaborated the elaborated part.
*/
public void operationValidate(float elaborated);
/**
* Called when the operation is complete.
*/
public void operationComplete(TRId trId);
/**
* Called when the operation is failed.
* @param caught the failure exception.
* @param reason the failure reason.
*/
public void operationFailed(Throwable caught, String reason, String failureDetails);
/**
* Called when the operation is stopped
*
* @param trId
* @param reason
* @param details
*/
public void operationStopped(TRId trId, String reason, String details);
/**
* Called when the operation is generating the view
*/
public void operationGeneratingView();
}

View File

@ -1,195 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.monitor.EditRowMonitor;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class EditRowProgressUpdater extends Timer {
protected ArrayList<EditRowProgressListener> listeners = new ArrayList<EditRowProgressListener>();
/**
* {@inheritDoc}
*/
@Override
public void run() {
Log.debug("requesting operation progress");
TDGWTServiceAsync.INSTANCE
.getEditRowMonitor(new AsyncCallback<EditRowMonitor>() {
public void onFailure(Throwable caught) {
cancel();
Log.error("Error retrieving the operation state",
caught);
String message = getStack(caught);
fireOperationFailed(caught,
"Failed getting operation updates", message);
}
public void onSuccess(EditRowMonitor result) {
Log.info("retrieved EditRowMonitor: "
+ result.getStatus());
switch (result.getStatus()) {
case INITIALIZING:
Log.info("Initializing...");
fireOperationInitializing();
break;
case ABORTED:
cancel();
Log.info("Operation Aborted");
break;
case IN_PROGRESS:
fireOperationUpdate(result.getProgress());
break;
case VALIDATING_RULES:
fireOperationValidate(result.getProgress());
break;
case GENERATING_VIEW:
Log.info("Generating View...");
fireOperationGeneratingView();
break;
case STOPPED:
cancel();
stopMessage(result);
break;
case FAILED:
cancel();
errorMessage(result);
break;
case SUCCEDED:
cancel();
Log.info("Fisnish TableId :"
+ result.getTrId());
fireOperationComplete(result.getTrId());
break;
default:
Log.info("Unknow State");
break;
}
}
});
}
protected void errorMessage(EditRowMonitor result) {
Log.info("EditRow Failed");
Throwable th = null;
String failure = null;
String details = null;
if (result.getError() != null) {
th = result.getError();
failure = "Failed Client Library operation";
details = result.getError().getLocalizedMessage();
} else {
th = new Throwable("Failed");
failure = "Failed Client Library operation";
details = "Rollback failed";
}
fireOperationFailed(th, failure, details);
}
protected void stopMessage(EditRowMonitor result) {
Log.info("EditRow Stopped");
String failure = null;
String details = null;
if (result.getError() != null) {
failure = "Stopped operation";
details = result.getError().getLocalizedMessage();
} else {
failure = "Stopped operation";
details = "Operation stopped";
}
fireOperationStopped(result.getTrId(),failure, details);
}
protected String getStack(Throwable e) {
String message = e.getLocalizedMessage() + " -> <br>";
Throwable c = e.getCause();
if (c != null)
message += getStack(c);
return message;
}
protected void fireOperationInitializing() {
for (EditRowProgressListener listener : listeners)
listener.operationInitializing();
}
protected void fireOperationGeneratingView() {
for (EditRowProgressListener listener : listeners)
listener.operationGeneratingView();
}
protected void fireOperationUpdate(float elaborated) {
for (EditRowProgressListener listener : listeners)
listener.operationUpdate(elaborated);
}
protected void fireOperationValidate(float elaborated) {
for (EditRowProgressListener listener : listeners)
listener.operationValidate(elaborated);
}
protected void fireOperationComplete(TRId trId) {
for (EditRowProgressListener listener : listeners)
listener.operationComplete(trId);
}
protected void fireOperationFailed(Throwable caught, String failure,
String failureDetails) {
for (EditRowProgressListener listener : listeners)
listener.operationFailed(caught, failure, failureDetails);
}
protected void fireOperationStopped(TRId trId, String reason, String details) {
for (EditRowProgressListener listener : listeners)
listener.operationStopped(trId,reason, details);
}
/**
* Add a new {@link EditRowProgressListener} to this
* {@link EditRowProgressUpdater}.
*
* @param listener
* the listener to add.
*/
public void addListener(EditRowProgressListener listener) {
listeners.add(listener);
}
/**
* Removes the specified {@link EditRowProgressListener} from this
* {@link EditRowProgressUpdater}.
*
* @param listener
* the listener to remove.
*/
public void removeListener(EditRowProgressListener listener) {
listeners.remove(listener);
}
}

View File

@ -1,102 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.sencha.gxt.widget.core.client.ProgressBar;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class NormalizationProgressBarUpdater implements
NormalizationProgressListener {
protected ProgressBar progressBar;
/**
* Creates a new {@link ProgressBar} updater.
*
* @param progressBar
* the {@link ProgressBar} to update.
*/
public NormalizationProgressBarUpdater(ProgressBar progressBar) {
this.progressBar = progressBar;
this.progressBar.updateProgress(0, "Please Wait...");
}
/**
* {@inheritDoc}
*/
@Override
public void operationComplete(TRId trId) {
Log.info("Completed");
progressBar.updateProgress(1, "Completed");
}
/**
* {@inheritDoc}
*/
@Override
public void operationFailed(Throwable caught, String reason,
String failureDetails) {
Log.info("Failed");
progressBar.updateText("Failed");
}
@Override
public void operationInitializing() {
Log.info("Inizializing");
progressBar.updateProgress(0, "Initializing...");
}
@Override
public void operationUpdate(float elaborated) {
Log.info("Elaborated: " + elaborated);
if (elaborated >= 0 && elaborated < 1) {
Log.trace("progress " + elaborated);
int elab = new Float(elaborated * 100).intValue();
progressBar.updateProgress(elaborated, elab + "% Progress...");
}
if (elaborated == 1)
progressBar.updateProgress(1, "Completing...");
}
@Override
public void operationValidate(float elaborated) {
Log.info("Validation Elaborated: " + elaborated);
if (elaborated == 0)
progressBar.updateProgress(0, "Start Validation...");
if (elaborated > 0 && elaborated < 1) {
Log.trace("Validation progress " + elaborated);
int elab = new Float(elaborated * 100).intValue();
progressBar.updateProgress(elaborated, elab
+ "% Validation Progress...");
}
if (elaborated == 1)
progressBar.updateProgress(1, "Validation...");
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
Log.debug("Operation Stopped: [" + trId.toString() + ", " + reason
+ ", " + details + "]");
progressBar.updateText("Validations failed");
}
@Override
public void operationGeneratingView() {
Log.info("Generating View...");
progressBar.updateText("Generating View...");
}
}

View File

@ -1,178 +0,0 @@
package org.gcube.portlets.user.td.tablewidget.client.progress;
import java.util.ArrayList;
import org.gcube.portlets.user.td.columnwidget.client.progress.ProgressDialogListener;
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;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.ProgressBar;
import com.sencha.gxt.widget.core.client.Window;
import com.sencha.gxt.widget.core.client.button.TextButton;
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.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
/**
*
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class NormalizationProgressDialog extends Window implements
NormalizationProgressListener {
protected ArrayList<ProgressDialogListener> listeners = new ArrayList<ProgressDialogListener>();
public static final int STATUS_POLLING_DELAY = 1000;
protected String WIDTH = "400px";
protected String HEIGHT = "120px";
protected EventBus eventBus;
protected NormalizationProgressUpdater progressUpdater;
protected TextButton ok;
protected TRId trId;
private String reason;
private String details;
public NormalizationProgressDialog(EventBus eventBus) {
this.eventBus = eventBus;
setWidth(WIDTH);
setHeight(HEIGHT);
setBodyBorder(false);
setResizable(true);
setModal(true);
setHeadingText("Normalization Progress");
trId = null;
FramedPanel panel = new FramedPanel();
panel.setHeaderVisible(false);
panel.setBodyBorder(false);
VerticalLayoutContainer v = new VerticalLayoutContainer();
ProgressBar progressBar = new ProgressBar();
ok = new TextButton("OK");
ok.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
updateInvocation();
}
});
v.add(progressBar,
new VerticalLayoutData(1, 1, new Margins(5, 5, 5, 5)));
panel.add(v);
panel.addButton(ok);
add(panel);
progressUpdater = new NormalizationProgressUpdater();
progressUpdater
.addListener(new NormalizationProgressBarUpdater(progressBar));
progressUpdater.addListener(this);
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
show();
ok.setVisible(false);
}
public void addProgressDialogListener(ProgressDialogListener listener) {
listeners.add(listener);
}
public void removeProgressDialogListener(ProgressDialogListener listener) {
listeners.remove(listener);
}
@Override
public void operationInitializing() {
// TODO Auto-generated method stub
}
@Override
public void operationUpdate(float elaborated) {
// TODO Auto-generated method stub
}
@Override
public void operationComplete(TRId trId) {
Log.debug("Operation Complete return: " + trId.toString());
this.trId = trId;
fireOperationComplete(trId);
hide();
}
@Override
public void operationFailed(Throwable caught, String reason,
String failureDetails) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
fireOperationFailed(caught, reason);
hide();
}
}
public void updateInvocation() {
if (trId != null) {
fireOperationStopped(trId, reason, details);
}
hide();
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
Log.debug("Operation Stopped: [" + trId.toString() + ", " + reason
+ ", " + details + "]");
this.trId = trId;
this.reason = reason;
this.details = details;
ok.setVisible(true);
}
@Override
public void operationGeneratingView() {
// TODO Auto-generated method stub
}
@Override
public void operationValidate(float elaborated) {
// TODO Auto-generated method stub
}
protected void fireOperationComplete(TRId trId) {
for (ProgressDialogListener listener : listeners)
listener.operationComplete(trId);
}
protected void fireOperationFailed(Throwable caught, String reason) {
for (ProgressDialogListener listener : listeners)
listener.operationFailed(caught, reason);
}
protected void fireOperationStopped(TRId trId, String reason, String details) {
for (ProgressDialogListener listener : listeners)
listener.operationStopped(trId, reason, details);
}
}

View File

@ -1,63 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
/**
* Defines a listener for operation progress.
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface NormalizationProgressListener {
/**
* Called when the operation is starting.
*/
public void operationInitializing();
/**
* Called when there is a progress for the operation.
* @param elaborated the elaborated part.
*/
public void operationUpdate(float elaborated);
/**
* Called when there is a validate for the operation.
* @param elaborated the elaborated part.
*/
public void operationValidate(float elaborated);
/**
* Called when the operation is complete.
*/
public void operationComplete(TRId trId);
/**
* Called when the operation is failed.
* @param caught the failure exception.
* @param reason the failure reason.
*/
public void operationFailed(Throwable caught, String reason, String failureDetails);
/**
* Called when the operation is stopped
*
* @param trId
* @param reason
* @param details
*/
public void operationStopped(TRId trId, String reason, String details);
/**
* Called when the operation is generating the view
*/
public void operationGeneratingView();
}

View File

@ -1,195 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.monitor.NormalizationMonitor;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class NormalizationProgressUpdater extends Timer {
protected ArrayList<NormalizationProgressListener> listeners = new ArrayList<NormalizationProgressListener>();
/**
* {@inheritDoc}
*/
@Override
public void run() {
Log.debug("requesting operation progress");
TDGWTServiceAsync.INSTANCE
.getNormalizationMonitor(new AsyncCallback<NormalizationMonitor>() {
public void onFailure(Throwable caught) {
cancel();
Log.error("Error retrieving the operation state",
caught);
String message = getStack(caught);
fireOperationFailed(caught,
"Failed getting operation updates", message);
}
public void onSuccess(NormalizationMonitor result) {
Log.info("retrieved NormalizationMonitor: "
+ result.getStatus());
switch (result.getStatus()) {
case INITIALIZING:
Log.info("Initializing...");
fireOperationInitializing();
break;
case ABORTED:
cancel();
Log.info("Aborted");
break;
case IN_PROGRESS:
fireOperationUpdate(result.getProgress());
break;
case VALIDATING_RULES:
fireOperationValidate(result.getProgress());
break;
case GENERATING_VIEW:
Log.info("Generating View...");
fireOperationGeneratingView();
break;
case STOPPED:
cancel();
stopMessage(result);
break;
case FAILED:
cancel();
errorMessage(result);
break;
case SUCCEDED:
cancel();
Log.info("Fisnish :"
+ result.getTrId());
fireOperationComplete(result.getTrId());
break;
default:
Log.info("Unknow State");
break;
}
}
});
}
protected void errorMessage(NormalizationMonitor result) {
Log.info("Normalize Failed");
Throwable th = null;
String failure = null;
String details = null;
if (result.getError() != null) {
th = result.getError();
failure = "Failed Client Library Normalize";
details = result.getError().getLocalizedMessage();
} else {
th = new Throwable("Failed");
failure = "Failed Client Library Normalize";
details = "Normalize failed";
}
fireOperationFailed(th, failure, details);
}
protected void stopMessage(NormalizationMonitor result) {
Log.info("Normalize Stopped");
String failure = null;
String details = null;
if (result.getError() != null) {
failure = "Stopped normalize";
details = result.getError().getLocalizedMessage();
} else {
failure = "Stopped normalize";
details = "Normalize stopped";
}
fireOperationStopped(result.getTrId(),failure, details);
}
protected String getStack(Throwable e) {
String message = e.getLocalizedMessage() + " -> <br>";
Throwable c = e.getCause();
if (c != null)
message += getStack(c);
return message;
}
protected void fireOperationInitializing() {
for (NormalizationProgressListener listener : listeners)
listener.operationInitializing();
}
protected void fireOperationGeneratingView() {
for (NormalizationProgressListener listener : listeners)
listener.operationGeneratingView();
}
protected void fireOperationUpdate(float elaborated) {
for (NormalizationProgressListener listener : listeners)
listener.operationUpdate(elaborated);
}
protected void fireOperationValidate(float elaborated) {
for (NormalizationProgressListener listener : listeners)
listener.operationValidate(elaborated);
}
protected void fireOperationComplete(TRId trId) {
for (NormalizationProgressListener listener : listeners)
listener.operationComplete(trId);
}
protected void fireOperationFailed(Throwable caught, String failure,
String failureDetails) {
for (NormalizationProgressListener listener : listeners)
listener.operationFailed(caught, failure, failureDetails);
}
protected void fireOperationStopped(TRId trId, String reason, String details) {
for (NormalizationProgressListener listener : listeners)
listener.operationStopped(trId,reason, details);
}
/**
* Add a new {@link NormalizationProgressListener} to this
* {@link NormalizationProgressUpdater}.
*
* @param listener
* the listener to add.
*/
public void addListener(NormalizationProgressListener listener) {
listeners.add(listener);
}
/**
* Removes the specified {@link NormalizationProgressListener} from this
* {@link NormalizationProgressUpdater}.
*
* @param listener
* the listener to remove.
*/
public void removeListener(NormalizationProgressListener listener) {
listeners.remove(listener);
}
}

View File

@ -1,98 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.sencha.gxt.widget.core.client.ProgressBar;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class RollBackProgressBarUpdater implements RollBackProgressListener {
protected ProgressBar progressBar;
/**
* Creates a new {@link ProgressBar} updater.
* @param progressBar the {@link ProgressBar} to update.
*/
public RollBackProgressBarUpdater(ProgressBar progressBar) {
this.progressBar = progressBar;
this.progressBar.updateProgress(0, "Please Wait...");
}
/**
* {@inheritDoc}
*/
@Override
public void operationComplete(TRId trId) {
Log.info("Completed");
progressBar.updateProgress(1, "Completed");
}
/**
* {@inheritDoc}
*/
@Override
public void operationFailed(Throwable caught, String reason, String failureDetails) {
Log.info("Failed");
progressBar.updateText("Failed");
}
@Override
public void operationInitializing() {
Log.info("Inizializing");
progressBar.updateProgress(0, "Initializing...");
}
@Override
public void operationUpdate(float elaborated) {
Log.info("Elaborated: "+elaborated);
if (elaborated>=0 && elaborated<1) {
Log.trace("progress "+elaborated);
int elab=new Float(elaborated*100).intValue();
progressBar.updateProgress(elaborated,elab+"% Progress...");
}
if (elaborated == 1) progressBar.updateProgress(1, "Completing...");
}
@Override
public void operationValidate(float elaborated) {
Log.info("Validation Elaborated: "+elaborated);
if (elaborated == 0) progressBar.updateProgress(0, "Start Validation...");
if (elaborated>0 && elaborated<1) {
Log.trace("Validation progress "+elaborated);
int elab=new Float(elaborated*100).intValue();
progressBar.updateProgress(elaborated,elab+"% Validation Progress...");
}
if (elaborated == 1) progressBar.updateProgress(1, "Validation...");
}
@Override
public void operationStopped(TRId trId,String reason, String details) {
Log.debug("Operation Stopped: ["+trId.toString()+", "+reason+", "+details+"]");
progressBar.updateText("Validations failed");
}
@Override
public void operationGeneratingView() {
Log.info("Generating View...");
progressBar.updateText("Generating View...");
}
}

View File

@ -1,150 +0,0 @@
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSession;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy;
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;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.ProgressBar;
import com.sencha.gxt.widget.core.client.Window;
import com.sencha.gxt.widget.core.client.button.TextButton;
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.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
/**
*
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class RollBackProgressDialog extends Window implements
RollBackProgressListener {
public static final int STATUS_POLLING_DELAY = 1000;
protected String WIDTH = "400px";
protected String HEIGHT = "120px";
protected RollBackSession rollBackSession;
protected EventBus eventBus;
protected RollBackProgressUpdater progressUpdater;
protected TextButton ok;
protected TRId trId;
private ChangeTableWhy why;
public RollBackProgressDialog(RollBackSession rollBackSession,
EventBus eventBus) {
this.rollBackSession = rollBackSession;
this.eventBus = eventBus;
setWidth(WIDTH);
setHeight(HEIGHT);
setBodyBorder(false);
setResizable(true);
setModal(true);
setHeadingText("Rollback Progress");
trId = null;
FramedPanel panel = new FramedPanel();
panel.setHeaderVisible(false);
panel.setBodyBorder(false);
VerticalLayoutContainer v = new VerticalLayoutContainer();
ProgressBar progressBar = new ProgressBar();
ok = new TextButton("OK");
ok.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
updateInvocation();
}
});
v.add(progressBar,
new VerticalLayoutData(1, 1, new Margins(5, 5, 5, 5)));
panel.add(v);
panel.addButton(ok);
add(panel);
progressUpdater = new RollBackProgressUpdater();
progressUpdater
.addListener(new RollBackProgressBarUpdater(progressBar));
progressUpdater.addListener(this);
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
show();
ok.setVisible(false);
}
public void operationInitializing() {
// TODO Auto-generated method stub
}
public void operationUpdate(float elaborated) {
// TODO Auto-generated method stub
}
public void operationComplete(TRId trId) {
Log.debug("Operation Complete return: " + trId.toString());
this.trId = trId;
why = ChangeTableWhy.TABLEUPDATED;
updateInvocation();
}
public void operationFailed(Throwable caught, String reason,
String failureDetails) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
ok.setVisible(true);
this.trId = null;
UtilsGXT3.alert("Error in RollBack", reason);
}
}
public void updateInvocation() {
if (trId != null) {
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.DELETEROWS, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
}
hide();
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
Log.debug("Operation Stopped: [" + trId.toString() + ", " + reason
+ ", " + details + "]");
ok.setVisible(true);
this.trId = trId;
why = ChangeTableWhy.TABLECURATION;
}
@Override
public void operationGeneratingView() {
// TODO Auto-generated method stub
}
@Override
public void operationValidate(float elaborated) {
// TODO Auto-generated method stub
}
}

View File

@ -1,63 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
/**
* Defines a listener for operation progress.
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface RollBackProgressListener {
/**
* Called when the operation is starting.
*/
public void operationInitializing();
/**
* Called when there is a progress for the operation.
* @param elaborated the elaborated part.
*/
public void operationUpdate(float elaborated);
/**
* Called when there is a validate for the operation.
* @param elaborated the elaborated part.
*/
public void operationValidate(float elaborated);
/**
* Called when the operation is complete.
*/
public void operationComplete(TRId trId);
/**
* Called when the operation is failed.
* @param caught the failure exception.
* @param reason the failure reason.
*/
public void operationFailed(Throwable caught, String reason, String failureDetails);
/**
* Called when the operation is stopped
*
* @param trId
* @param reason
* @param details
*/
public void operationStopped(TRId trId, String reason, String details);
/**
* Called when the operation is generating the view
*/
public void operationGeneratingView();
}

View File

@ -1,195 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.td.tablewidget.client.progress;
import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.monitor.RollBackSessionMonitor;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class RollBackProgressUpdater extends Timer {
protected ArrayList<RollBackProgressListener> listeners = new ArrayList<RollBackProgressListener>();
/**
* {@inheritDoc}
*/
@Override
public void run() {
Log.debug("requesting operation progress");
TDGWTServiceAsync.INSTANCE
.getRollBackMonitor(new AsyncCallback<RollBackSessionMonitor>() {
public void onFailure(Throwable caught) {
cancel();
Log.error("Error retrieving the operation state",
caught);
String message = getStack(caught);
fireOperationFailed(caught,
"Failed getting operation updates", message);
}
public void onSuccess(RollBackSessionMonitor result) {
Log.info("retrieved DeleteRowsMonitor: "
+ result.getStatus());
switch (result.getStatus()) {
case INITIALIZING:
Log.info("Initializing...");
fireOperationInitializing();
break;
case ABORTED:
cancel();
Log.info("Delete Rows Operation Aborted");
break;
case IN_PROGRESS:
fireOperationUpdate(result.getProgress());
break;
case VALIDATING_RULES:
fireOperationValidate(result.getProgress());
break;
case GENERATING_VIEW:
Log.info("Generating View...");
fireOperationGeneratingView();
break;
case STOPPED:
cancel();
stopMessage(result);
break;
case FAILED:
cancel();
errorMessage(result);
break;
case SUCCEDED:
cancel();
Log.info("Fisnish TableId :"
+ result.getTrId());
fireOperationComplete(result.getTrId());
break;
default:
Log.info("Unknow State");
break;
}
}
});
}
protected void errorMessage(RollBackSessionMonitor result) {
Log.info("RollBack Failed");
Throwable th = null;
String failure = null;
String details = null;
if (result.getError() != null) {
th = result.getError();
failure = "Failed Client Library rollback";
details = result.getError().getLocalizedMessage();
} else {
th = new Throwable("Failed");
failure = "Failed Client Library rollback";
details = "Rollback failed";
}
fireOperationFailed(th, failure, details);
}
protected void stopMessage(RollBackSessionMonitor result) {
Log.info("RollBack Stopped");
String failure = null;
String details = null;
if (result.getError() != null) {
failure = "Stopped rollback";
details = result.getError().getLocalizedMessage();
} else {
failure = "Stopped rollback";
details = "Rollback stopped";
}
fireOperationStopped(result.getTrId(),failure, details);
}
protected String getStack(Throwable e) {
String message = e.getLocalizedMessage() + " -> <br>";
Throwable c = e.getCause();
if (c != null)
message += getStack(c);
return message;
}
protected void fireOperationInitializing() {
for (RollBackProgressListener listener : listeners)
listener.operationInitializing();
}
protected void fireOperationGeneratingView() {
for (RollBackProgressListener listener : listeners)
listener.operationGeneratingView();
}
protected void fireOperationUpdate(float elaborated) {
for (RollBackProgressListener listener : listeners)
listener.operationUpdate(elaborated);
}
protected void fireOperationValidate(float elaborated) {
for (RollBackProgressListener listener : listeners)
listener.operationValidate(elaborated);
}
protected void fireOperationComplete(TRId trId) {
for (RollBackProgressListener listener : listeners)
listener.operationComplete(trId);
}
protected void fireOperationFailed(Throwable caught, String failure,
String failureDetails) {
for (RollBackProgressListener listener : listeners)
listener.operationFailed(caught, failure, failureDetails);
}
protected void fireOperationStopped(TRId trId, String reason, String details) {
for (RollBackProgressListener listener : listeners)
listener.operationStopped(trId,reason, details);
}
/**
* Add a new {@link RollBackProgressListener} to this
* {@link RollBackProgressUpdater}.
*
* @param listener
* the listener to add.
*/
public void addListener(RollBackProgressListener listener) {
listeners.add(listener);
}
/**
* Removes the specified {@link RollBackProgressListener} from this
* {@link RollBackProgressUpdater}.
*
* @param listener
* the listener to remove.
*/
public void removeListener(RollBackProgressListener listener) {
listeners.remove(listener);
}
}

View File

@ -5,9 +5,13 @@ import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DeleteRowsSession;
import org.gcube.portlets.user.td.tablewidget.client.progress.DeleteRowsProgressDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
@ -21,13 +25,12 @@ import com.google.web.bindery.event.shared.EventBus;
* @author "Giancarlo Panichi"
*
*/
public class DeleteRows {
public class DeleteRows implements MonitorDialogListener {
protected TRId trId;
protected EventBus eventBus;
protected ArrayList<String> rows;
protected DeleteRowsSession deleteRowsSession;
protected DeleteRowsProgressDialog deleteRowsProgressDialog;
public DeleteRows(TRId trId, ArrayList<String> rows, EventBus eventBus) {
this.trId = trId;
this.rows = rows;
@ -41,7 +44,7 @@ public class DeleteRows {
protected void onDelete() {
TDGWTServiceAsync.INSTANCE.startDeleteRows(deleteRowsSession,
new AsyncCallback<Void>() {
new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
@ -56,13 +59,65 @@ public class DeleteRows {
}
}
public void onSuccess(Void result) {
deleteRowsProgressDialog = new DeleteRowsProgressDialog(
deleteRowsSession, eventBus);
public void onSuccess(String taskId) {
openMonitorDialog(taskId);
}
});
}
protected void close() {
/*if (parent != null) {
parent.close();
}
*/
}
// /
protected void openMonitorDialog(String taskId) {
MonitorDialog monitorDialog = new MonitorDialog(taskId, eventBus);
monitorDialog.addProgressDialogListener(this);
monitorDialog.show();
}
@Override
public void operationComplete(TRId trId) {
ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.DELETEROWS, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
@Override
public void operationFailed(Throwable caught, String reason, String details) {
UtilsGXT3.alert(reason, details);
close();
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
ChangeTableWhy why = ChangeTableWhy.TABLECURATION;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.DELETEROWS, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
@Override
public void operationAborted() {
close();
}
@Override
public void operationPutInBackground() {
close();
}
}

View File

@ -3,16 +3,19 @@ package org.gcube.portlets.user.td.tablewidget.client.rows;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
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.gwtservice.shared.tr.rows.DuplicatesSession;
import org.gcube.portlets.user.td.tablewidget.client.progress.DuplicatesRowsProgressDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
import org.gcube.portlets.user.td.tablewidget.client.properties.ColumnDataProperties;
import org.gcube.portlets.user.td.tablewidget.client.resources.ResourceBundle;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
@ -48,7 +51,8 @@ import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
import com.sencha.gxt.widget.core.client.grid.Grid;
public class DuplicatesRowsPanel extends FramedPanel {
public class DuplicatesRowsPanel extends FramedPanel
implements MonitorDialogListener {
protected String WIDTH = "640px";
protected String HEIGHT = "520px";
@ -57,8 +61,7 @@ public class DuplicatesRowsPanel extends FramedPanel {
protected ArrayList<String> rows;
protected DuplicatesSession duplicatesSession;
protected DuplicatesRowsProgressDialog duplicatesRowsProgressDialog;
protected ListLoader<ListLoadConfig, ListLoadResult<ColumnData>> loader;
protected Grid<ColumnData> grid;
protected CheckBoxSelectionModel<ColumnData> sm;
@ -227,7 +230,7 @@ public class DuplicatesRowsPanel extends FramedPanel {
DuplicatesSession.DuplicateOp.DELETE);
TDGWTServiceAsync.INSTANCE.startDuplicates(duplicatesSession,
new AsyncCallback<Void>() {
new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
@ -242,9 +245,8 @@ public class DuplicatesRowsPanel extends FramedPanel {
}
}
public void onSuccess(Void result) {
duplicatesRowsProgressDialog = new DuplicatesRowsProgressDialog(
duplicatesSession, eventBus);
public void onSuccess(String taskId) {
openMonitorDialog(taskId);
}
});
@ -261,7 +263,7 @@ public class DuplicatesRowsPanel extends FramedPanel {
DuplicatesSession.DuplicateOp.VALIDATE);
TDGWTServiceAsync.INSTANCE.startDuplicates(duplicatesSession,
new AsyncCallback<Void>() {
new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
@ -276,13 +278,64 @@ public class DuplicatesRowsPanel extends FramedPanel {
}
}
public void onSuccess(Void result) {
duplicatesRowsProgressDialog = new DuplicatesRowsProgressDialog(
duplicatesSession, eventBus);
public void onSuccess(String taskId) {
openMonitorDialog(taskId);
}
});
}
protected void close() {
/*if (parent != null) {
parent.close();
}
*/
}
// /
protected void openMonitorDialog(String taskId) {
MonitorDialog monitorDialog = new MonitorDialog(taskId, eventBus);
monitorDialog.addProgressDialogListener(this);
monitorDialog.show();
}
@Override
public void operationComplete(TRId trId) {
ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.DUPLICATES, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
@Override
public void operationFailed(Throwable caught, String reason, String details) {
UtilsGXT3.alert(reason, details);
close();
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
ChangeTableWhy why = ChangeTableWhy.TABLECURATION;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.DUPLICATES, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
@Override
public void operationAborted() {
close();
}
@Override
public void operationPutInBackground() {
close();
}
}

View File

@ -1,7 +1,6 @@
package org.gcube.portlets.user.td.tablewidget.client.rows;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DeleteRowsSession;
import org.gcube.portlets.user.td.tablewidget.client.progress.DeleteRowsProgressDialog;
import org.gcube.portlets.user.td.tablewidget.client.resources.ResourceBundle;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
@ -25,8 +24,7 @@ public class EditRowDialog extends Window {
protected EventBus eventBus;
protected RowRaw row;
protected DeleteRowsSession deleteRowsSession;
protected DeleteRowsProgressDialog deleteRowsProgressDialog;
private boolean addRow;
/**

View File

@ -12,10 +12,14 @@ import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpire
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.DimensionRow;
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.EditRowSession;
import org.gcube.portlets.user.td.tablewidget.client.progress.EditRowProgressDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
import org.gcube.portlets.user.td.tablewidget.client.resources.ResourceBundle;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.CellData;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
@ -63,7 +67,8 @@ import com.sencha.gxt.widget.core.client.form.TextField;
* @author "Giancarlo Panichi"
*
*/
public class EditRowPanel extends FramedPanel {
public class EditRowPanel extends FramedPanel
implements MonitorDialogListener {
protected String WIDTH = "510px";
protected String HEIGHT = "370px";
protected String FIELDSHEIGHT = "370px";
@ -76,7 +81,7 @@ public class EditRowPanel extends FramedPanel {
protected RowRaw rowRaw;
protected boolean editRow;
protected EditRowProgressDialog editRowProgressDialog;
protected VerticalLayoutContainer v;
private TextButton btnSave;
@ -633,17 +638,12 @@ public class EditRowPanel extends FramedPanel {
}
public void close() {
if (parent != null) {
parent.close();
}
}
protected void callEditRow(EditRowSession editRowSession) {
final EditRowPanel panel = this;
TDGWTServiceAsync.INSTANCE.startEditRow(editRowSession,
new AsyncCallback<Void>() {
new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
Log.debug("EditRow: " + caught.getLocalizedMessage());
@ -656,13 +656,64 @@ public class EditRowPanel extends FramedPanel {
}
}
public void onSuccess(Void result) {
editRowProgressDialog = new EditRowProgressDialog(
panel, eventBus);
public void onSuccess(String taskId) {
openMonitorDialog(taskId);
}
});
}
protected void close() {
if (parent != null) {
parent.close();
}
}
// /
protected void openMonitorDialog(String taskId) {
MonitorDialog monitorDialog = new MonitorDialog(taskId, eventBus);
monitorDialog.addProgressDialogListener(this);
monitorDialog.show();
}
@Override
public void operationComplete(TRId trId) {
ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.EDITROW, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
@Override
public void operationFailed(Throwable caught, String reason, String details) {
UtilsGXT3.alert(reason, details);
close();
}
@Override
public void operationStopped(TRId trId, String reason, String details) {
ChangeTableWhy why = ChangeTableWhy.TABLECURATION;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.EDITROW, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
@Override
public void operationAborted() {
close();
}
@Override
public void operationPutInBackground() {
close();
}
}

View File

@ -4,8 +4,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.gcube.portlets.user.td.columnwidget.client.progress.ResumeDialogListener;
import org.gcube.portlets.user.td.columnwidget.client.progress.TaskResumeProgressDialog;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.gcube.portlets.user.td.gwtservice.shared.OperationsId;
@ -14,6 +12,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.task.InvocationS;
import org.gcube.portlets.user.td.gwtservice.shared.task.TaskResumeSession;
import org.gcube.portlets.user.td.gwtservice.shared.task.ValidationsTasksMetadata;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ConditionCode;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
import org.gcube.portlets.user.td.tablewidget.client.custom.ValidationCell;
import org.gcube.portlets.user.td.tablewidget.client.resources.ResourceBundle;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
@ -75,7 +75,7 @@ import com.sencha.gxt.widget.core.client.treegrid.TreeGrid;
*
*/
public class ValidationsTasksPanel extends FramedPanel implements
ResumeDialogListener {
MonitorDialogListener {
protected String WIDTH = "298px";
protected String HEIGHT = "520px";
protected ValidationsTasksPanel thisPanel;
@ -554,7 +554,7 @@ public class ValidationsTasksPanel extends FramedPanel implements
protected void startTaskResume(TaskResumeSession taskResumeSession) {
Log.debug(taskResumeSession.toString());
TDGWTServiceAsync.INSTANCE.startTaskResume(taskResumeSession,
new AsyncCallback<Void>() {
new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
@ -570,42 +570,68 @@ public class ValidationsTasksPanel extends FramedPanel implements
}
@Override
public void onSuccess(Void result) {
TaskResumeProgressDialog taskResumeProgressDialog = new TaskResumeProgressDialog(
eventBus);
taskResumeProgressDialog
.addResumeDialogListener(thisPanel);
taskResumeProgressDialog.show();
public void onSuccess(String taskId) {
openMonitorDialog(taskId);
}
});
}
protected void close() {
/*if (parent != null) {
parent.close();
}*/
}
// /
protected void openMonitorDialog(String taskId) {
MonitorDialog monitorDialog = new MonitorDialog(taskId, eventBus);
monitorDialog.addProgressDialogListener(this);
monitorDialog.show();
}
@Override
public void resumeComplete(TRId trId) {
public void operationComplete(TRId trId) {
ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.TASKRESUME, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
@Override
public void operationFailed(Throwable caught, String reason, String details) {
UtilsGXT3.alert(reason, details);
close();
}
@Override
public void resumeFailed(Throwable caught, String reason) {
UtilsGXT3.alert("Error in Resume", reason);
}
@Override
public void resumeStopped(TRId trId, String reason, String details) {
public void operationStopped(TRId trId, String reason, String details) {
ChangeTableWhy why = ChangeTableWhy.TABLECURATION;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.TASKRESUME, trId, why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
@Override
public void operationAborted() {
close();
}
@Override
public void operationPutInBackground() {
close();
}
// @SuppressWarnings("rawtypes")
// protected AbstractCell actionButton = new AbstractCell<Boolean>() {
//

View File

@ -19,6 +19,7 @@
<inherits name="com.allen_sauer.gwt.log.gwt-log-TRACE" />
<inherits name='org.gcube.portlets.user.td.gwtservice.TDGWTService' />
<inherits name='org.gcube.portlets.user.td.columnwidget.ColumnWidget' />
<inherits name='org.gcube.portlets.user.td.monitorwidget.MonitorWidgetTD' />
<!-- Specify the app entry point class. -->
<!-- <entry-point class='org.gcube.portlets.user.td.sharewidget.client.TableWidgetEntry' /> -->