Minor Update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-column-widget@94286 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
723f48b641
commit
06941aa60b
|
@ -2440,3 +2440,35 @@ Compiling...
|
||||||
Compilation completed in 0.00 seconds
|
Compilation completed in 0.00 seconds
|
||||||
Removing invalidated units
|
Removing invalidated units
|
||||||
Finding entry point classes
|
Finding entry point classes
|
||||||
|
Public resources found in...
|
||||||
|
Translatable source found in...
|
||||||
|
Found 0 cached/archived units. Used 0 / 2719 units from cache.
|
||||||
|
Compiling...
|
||||||
|
50% complete (ETR: 5 seconds)
|
||||||
|
50% complete (ETR: 5 seconds)
|
||||||
|
50% complete (ETR: 5 seconds)
|
||||||
|
50% complete (ETR: 5 seconds)
|
||||||
|
50% complete (ETR: 5 seconds)
|
||||||
|
50% complete (ETR: 5 seconds)
|
||||||
|
60% complete (ETR: 5 seconds)
|
||||||
|
70% complete (ETR: 3 seconds)
|
||||||
|
80% complete (ETR: 2 seconds)
|
||||||
|
90% complete (ETR: 1 seconds)
|
||||||
|
100% complete (ETR: 0 seconds)
|
||||||
|
Compilation completed in 13.16 seconds
|
||||||
|
Removing invalidated units
|
||||||
|
Finding entry point classes
|
||||||
|
Public resources found in...
|
||||||
|
Translatable source found in...
|
||||||
|
Found 2719 cached/archived units. Used 2719 / 2719 units from cache.
|
||||||
|
Compiling...
|
||||||
|
Compilation completed in 0.00 seconds
|
||||||
|
Removing invalidated units
|
||||||
|
Finding entry point classes
|
||||||
|
Public resources found in...
|
||||||
|
Translatable source found in...
|
||||||
|
Found 2719 cached/archived units. Used 2719 / 2719 units from cache.
|
||||||
|
Compiling...
|
||||||
|
Compilation completed in 0.00 seconds
|
||||||
|
Removing invalidated units
|
||||||
|
Finding entry point classes
|
||||||
|
|
|
@ -1,68 +0,0 @@
|
||||||
package org.gcube.portlets.user.td.columnwidget.client.batch;
|
|
||||||
|
|
||||||
import org.gcube.portlets.user.td.columnwidget.client.resources.ResourceBundle;
|
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
|
||||||
|
|
||||||
import com.google.web.bindery.event.shared.EventBus;
|
|
||||||
import com.sencha.gxt.widget.core.client.Window;
|
|
||||||
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 BatchReplaceDialog extends Window {
|
|
||||||
protected String WIDTH = "650px";
|
|
||||||
protected String HEIGHT = "530px";
|
|
||||||
protected TRId trId;
|
|
||||||
protected String columnName=null;
|
|
||||||
|
|
||||||
|
|
||||||
public BatchReplaceDialog(TRId trId, String columnName, EventBus eventBus) {
|
|
||||||
this.trId=trId;
|
|
||||||
this.columnName=columnName;
|
|
||||||
initWindow();
|
|
||||||
BatchReplacePanel batchRepalcePanel= new BatchReplacePanel(this, trId,columnName,eventBus);
|
|
||||||
add(batchRepalcePanel);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void initWindow() {
|
|
||||||
setWidth(WIDTH);
|
|
||||||
setHeight(HEIGHT);
|
|
||||||
setBodyBorder(false);
|
|
||||||
setResizable(false);
|
|
||||||
setHeadingText("Replace Batch");
|
|
||||||
setClosable(true);
|
|
||||||
setModal(true);
|
|
||||||
forceLayoutOnResize = true;
|
|
||||||
getHeader().setIcon(ResourceBundle.INSTANCE.replaceBatch());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected void initTools() {
|
|
||||||
super.initTools();
|
|
||||||
|
|
||||||
closeBtn.addSelectHandler(new SelectHandler() {
|
|
||||||
|
|
||||||
|
|
||||||
public void onSelect(SelectEvent event) {
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void close (){
|
|
||||||
hide();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
package org.gcube.portlets.user.td.columnwidget.client.batch;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.columnwidget.client.progress.ReplaceBatchColumnProgressDialog;
|
||||||
|
import org.gcube.portlets.user.td.columnwidget.client.progress.ReplaceColumnProgressDialog;
|
||||||
|
import org.gcube.portlets.user.td.columnwidget.client.resources.ResourceBundle;
|
||||||
|
import org.gcube.portlets.user.td.columnwidget.client.utils.UtilsGXT3;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnSession;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.google.web.bindery.event.shared.EventBus;
|
||||||
|
import com.sencha.gxt.widget.core.client.Window;
|
||||||
|
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 ReplaceBatchDialog extends Window {
|
||||||
|
protected String WIDTH = "650px";
|
||||||
|
protected String HEIGHT = "530px";
|
||||||
|
protected TRId trId;
|
||||||
|
protected String columnName=null;
|
||||||
|
protected EventBus eventBus;
|
||||||
|
|
||||||
|
|
||||||
|
public ReplaceBatchDialog(TRId trId, String columnName, EventBus eventBus) {
|
||||||
|
this.trId=trId;
|
||||||
|
this.columnName=columnName;
|
||||||
|
this.eventBus=eventBus;
|
||||||
|
initWindow();
|
||||||
|
ReplaceBatchPanel batchRepalcePanel= new ReplaceBatchPanel(this, trId,columnName,eventBus);
|
||||||
|
add(batchRepalcePanel);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initWindow() {
|
||||||
|
setWidth(WIDTH);
|
||||||
|
setHeight(HEIGHT);
|
||||||
|
setBodyBorder(false);
|
||||||
|
setResizable(false);
|
||||||
|
setHeadingText("Replace Batch");
|
||||||
|
setClosable(true);
|
||||||
|
setModal(true);
|
||||||
|
forceLayoutOnResize = true;
|
||||||
|
getHeader().setIcon(ResourceBundle.INSTANCE.replaceBatch());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void initTools() {
|
||||||
|
super.initTools();
|
||||||
|
|
||||||
|
closeBtn.addSelectHandler(new SelectHandler() {
|
||||||
|
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void close (){
|
||||||
|
hide();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void startBatchReplace(ReplaceBatchColumnSession rbcSession){
|
||||||
|
TDGWTServiceAsync.INSTANCE.startReplaceBatchColumn(rbcSession,
|
||||||
|
new AsyncCallback<Void>() {
|
||||||
|
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
Log.error("Start Replace Batch failed:"
|
||||||
|
+ caught.getLocalizedMessage());
|
||||||
|
UtilsGXT3.alert("Error on batch replace",
|
||||||
|
"Error on batch replace");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSuccess(Void v) {
|
||||||
|
Log.trace("Started batch replace ");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void callReplaceBatchColumnProgressDialog() {
|
||||||
|
ReplaceBatchColumnProgressDialog dialog = new ReplaceBatchColumnProgressDialog(
|
||||||
|
this, eventBus);
|
||||||
|
dialog.show();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -12,6 +12,7 @@ import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
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.DimensionRow;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurences;
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurences;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnSession;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceEntry;
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceEntry;
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.CellData;
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.CellData;
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||||
|
@ -67,7 +68,7 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
||||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class BatchReplacePanel extends FramedPanel implements
|
public class ReplaceBatchPanel extends FramedPanel implements
|
||||||
SingleValueReplaceListener, DimensionRowSelectionListener {
|
SingleValueReplaceListener, DimensionRowSelectionListener {
|
||||||
protected String WIDTH = "560px";
|
protected String WIDTH = "560px";
|
||||||
protected String HEIGHT = "520px";
|
protected String HEIGHT = "520px";
|
||||||
|
@ -76,7 +77,7 @@ public class BatchReplacePanel extends FramedPanel implements
|
||||||
protected TRId trId;
|
protected TRId trId;
|
||||||
protected String columnName;
|
protected String columnName;
|
||||||
protected ColumnData column;
|
protected ColumnData column;
|
||||||
protected BatchReplaceDialog parent;
|
protected ReplaceBatchDialog parent;
|
||||||
private ReplaceEntry currentReplaceEntry;
|
private ReplaceEntry currentReplaceEntry;
|
||||||
private int currentRowIndex;
|
private int currentRowIndex;
|
||||||
|
|
||||||
|
@ -90,7 +91,7 @@ public class BatchReplacePanel extends FramedPanel implements
|
||||||
protected ListStore<ReplaceEntry> store;
|
protected ListStore<ReplaceEntry> store;
|
||||||
protected HTML info;
|
protected HTML info;
|
||||||
|
|
||||||
public BatchReplacePanel(BatchReplaceDialog parent, TRId trId,
|
public ReplaceBatchPanel(ReplaceBatchDialog parent, TRId trId,
|
||||||
String columnName, EventBus eventBus) {
|
String columnName, EventBus eventBus) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.trId = trId;
|
this.trId = trId;
|
||||||
|
@ -419,28 +420,8 @@ public class BatchReplacePanel extends FramedPanel implements
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void startReplaceBatch(ArrayList<ReplaceEntry> effectiveReplaceList){
|
protected void startReplaceBatch(ArrayList<ReplaceEntry> effectiveReplaceList){
|
||||||
/*
|
ReplaceBatchColumnSession rbcSession=new ReplaceBatchColumnSession(trId, column, effectiveReplaceList, column.isViewColumn());
|
||||||
|
|
||||||
TDGWTServiceAsync.INSTANCE.startReplaceBatch(column,
|
|
||||||
new AsyncCallback<ArrayList<Occurences>>() {
|
|
||||||
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
Log.error("load columns failure:"
|
|
||||||
+ caught.getLocalizedMessage());
|
|
||||||
UtilsGXT3.alert("Error retrieving columns",
|
|
||||||
"Error retrieving columns");
|
|
||||||
callback.onFailure(caught);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onSuccess(ArrayList<Occurences> result) {
|
|
||||||
Log.trace("loaded " + result.size() + " Occurences");
|
|
||||||
callback.onSuccess(new ListLoadResultBean<ReplaceEntry>(
|
|
||||||
getRecord(result)));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.columnwidget.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 ReplaceBatchColumnProgressBarUpdater implements ReplaceBatchColumnProgressListener {
|
||||||
|
|
||||||
|
protected ProgressBar progressBar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link ProgressBar} updater.
|
||||||
|
* @param progressBar the {@link ProgressBar} to update.
|
||||||
|
*/
|
||||||
|
public ReplaceBatchColumnProgressBarUpdater(ProgressBar progressBar) {
|
||||||
|
this.progressBar = progressBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public void operationComplete(TRId trId) {
|
||||||
|
Log.info("Completed");
|
||||||
|
progressBar.updateProgress(1, "Completed");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public void operationFailed(Throwable caught, String reason, String failureDetails) {
|
||||||
|
Log.info("Failed");
|
||||||
|
progressBar.updateText("Failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void operationInitializing() {
|
||||||
|
Log.info("Inizializing");
|
||||||
|
progressBar.updateProgress(0, "Initializing...");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void operationUpdate(float elaborated) {
|
||||||
|
Log.info("Import elaborated: "+elaborated);
|
||||||
|
if (elaborated == 0) progressBar.updateProgress(0, "Initializing...");
|
||||||
|
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 operationStopped(TRId trId,String reason, String details) {
|
||||||
|
Log.debug("Operation Stopped: ["+trId.toString()+", "+reason+", "+details+"]");
|
||||||
|
progressBar.updateText("Stopped");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,129 @@
|
||||||
|
package org.gcube.portlets.user.td.columnwidget.client.progress;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.columnwidget.client.batch.ReplaceBatchDialog;
|
||||||
|
import org.gcube.portlets.user.td.columnwidget.client.utils.UtilsGXT3;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ReplaceBatchColumnProgressDialog is a Dialog that show progress of replace batch the column value
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ReplaceBatchColumnProgressDialog extends Window implements ReplaceBatchColumnProgressListener {
|
||||||
|
public static final int STATUS_POLLING_DELAY = 1000;
|
||||||
|
protected String WIDTH = "400px";
|
||||||
|
protected String HEIGHT = "120px";
|
||||||
|
protected ReplaceBatchDialog parent;
|
||||||
|
protected EventBus eventBus;
|
||||||
|
protected ReplaceBatchColumnProgressUpdater progressUpdater;
|
||||||
|
protected TextButton ok;
|
||||||
|
protected TRId trId;
|
||||||
|
|
||||||
|
public ReplaceBatchColumnProgressDialog(ReplaceBatchDialog parent, EventBus eventBus) {
|
||||||
|
this.parent=parent;
|
||||||
|
this.eventBus=eventBus;
|
||||||
|
setWidth(WIDTH);
|
||||||
|
setHeight(HEIGHT);
|
||||||
|
setBodyBorder(false);
|
||||||
|
setResizable(true);
|
||||||
|
setModal(true);
|
||||||
|
setHeadingText("Replace Batch 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 ReplaceBatchColumnProgressUpdater();
|
||||||
|
progressUpdater.addListener(new ReplaceBatchColumnProgressBarUpdater(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;
|
||||||
|
updateInvocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void operationFailed(Throwable caught, String reason,
|
||||||
|
String failureDetails) {
|
||||||
|
ok.setVisible(true);
|
||||||
|
this.trId=null;
|
||||||
|
UtilsGXT3.alert("Error Replacing The Column Value", reason);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateInvocation(){
|
||||||
|
if(trId!=null){
|
||||||
|
ChangeTableRequestEvent changeTableRequestEvent=
|
||||||
|
new ChangeTableRequestEvent(ChangeTableRequestType.COLUMNREPLACE, trId);
|
||||||
|
eventBus.fireEvent(changeTableRequestEvent);
|
||||||
|
}
|
||||||
|
parent.hide();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.columnwidget.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 ReplaceBatchColumnProgressListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 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);
|
||||||
|
}
|
|
@ -0,0 +1,182 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.td.columnwidget.client.progress;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnMonitor;
|
||||||
|
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 ReplaceBatchColumnProgressUpdater extends Timer {
|
||||||
|
|
||||||
|
protected ArrayList<ReplaceBatchColumnProgressListener> listeners = new ArrayList<ReplaceBatchColumnProgressListener>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Log.debug("requesting operation progress");
|
||||||
|
TDGWTServiceAsync.INSTANCE
|
||||||
|
.getReplaceBatchColumnMonitor(new AsyncCallback<ReplaceBatchColumnMonitor>() {
|
||||||
|
|
||||||
|
|
||||||
|
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(ReplaceBatchColumnMonitor result) {
|
||||||
|
Log.info("retrieved ReplaceBatchColumnMonitor: "
|
||||||
|
+ result.getStatus());
|
||||||
|
switch (result.getStatus()) {
|
||||||
|
case INITIALIZING:
|
||||||
|
Log.info("Replace Batch Initializing...");
|
||||||
|
fireOperationInitializing();
|
||||||
|
break;
|
||||||
|
case ABORTED:
|
||||||
|
cancel();
|
||||||
|
Log.info("Replace Batch Aborted");
|
||||||
|
break;
|
||||||
|
case IN_PROGRESS:
|
||||||
|
fireOperationUpdate(result.getProgress());
|
||||||
|
break;
|
||||||
|
case VALIDATING_RULES:
|
||||||
|
fireOperationUpdate(result.getProgress());
|
||||||
|
break;
|
||||||
|
case STOPPED:
|
||||||
|
cancel();
|
||||||
|
stopMessage(result);
|
||||||
|
break;
|
||||||
|
case FAILED:
|
||||||
|
cancel();
|
||||||
|
errorMessage(result);
|
||||||
|
break;
|
||||||
|
case SUCCEDED:
|
||||||
|
cancel();
|
||||||
|
Log.info("Replace Batch fisnish:"
|
||||||
|
+ result.getTrId());
|
||||||
|
fireOperationComplete(result.getTrId());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Log.info("Unknow State");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void errorMessage(ReplaceBatchColumnMonitor result) {
|
||||||
|
Log.info("Batch Replace Failed");
|
||||||
|
Throwable th = null;
|
||||||
|
String failure = null;
|
||||||
|
String details = null;
|
||||||
|
if (result.getError() != null) {
|
||||||
|
th = result.getError();
|
||||||
|
failure = "Failed Client Library";
|
||||||
|
details = result.getError().getLocalizedMessage();
|
||||||
|
} else {
|
||||||
|
th = new Throwable("Failed");
|
||||||
|
failure = "Failed Client Library";
|
||||||
|
details = "Batch replace failed";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fireOperationFailed(th, failure, details);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void stopMessage(ReplaceBatchColumnMonitor result) {
|
||||||
|
Log.info("Batch Replace Stopped");
|
||||||
|
String failure = null;
|
||||||
|
String details = null;
|
||||||
|
if (result.getError() != null) {
|
||||||
|
failure = "Stopped";
|
||||||
|
details = result.getError().getLocalizedMessage();
|
||||||
|
} else {
|
||||||
|
failure = "Stopped";
|
||||||
|
details = "Stopped batch replace";
|
||||||
|
}
|
||||||
|
|
||||||
|
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 (ReplaceBatchColumnProgressListener listener : listeners)
|
||||||
|
listener.operationInitializing();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void fireOperationUpdate(float elaborated) {
|
||||||
|
for (ReplaceBatchColumnProgressListener listener : listeners)
|
||||||
|
listener.operationUpdate(elaborated);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void fireOperationComplete(TRId trId) {
|
||||||
|
for (ReplaceBatchColumnProgressListener listener : listeners)
|
||||||
|
listener.operationComplete(trId);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void fireOperationFailed(Throwable caught, String failure,
|
||||||
|
String failureDetails) {
|
||||||
|
for (ReplaceBatchColumnProgressListener listener : listeners)
|
||||||
|
listener.operationFailed(caught, failure, failureDetails);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void fireOperationStopped(TRId trId, String reason, String details) {
|
||||||
|
for (ReplaceBatchColumnProgressListener listener : listeners)
|
||||||
|
listener.operationStopped(trId,reason, details);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new {@link } to this
|
||||||
|
* {@link ReplaceBatchColumnProgressUpdater}.
|
||||||
|
*
|
||||||
|
* @param listener
|
||||||
|
* the listener to add.
|
||||||
|
*/
|
||||||
|
public void addListener(ReplaceBatchColumnProgressListener listener) {
|
||||||
|
listeners.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the specified {@link } from this
|
||||||
|
* {@link ReplaceBatchColumnProgressUpdater}.
|
||||||
|
*
|
||||||
|
* @param listener
|
||||||
|
* the listener to remove.
|
||||||
|
*/
|
||||||
|
public void removeListener(ReplaceColumnProgressListener listener) {
|
||||||
|
listeners.remove(listener);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue