Minor Updated
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-information-widget@92709 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b9eab076ab
commit
c60d56f0a9
|
@ -1,75 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.gcube.portlets.user.td.informationwidget.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@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");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,133 +0,0 @@
|
||||||
package org.gcube.portlets.user.td.informationwidget.client.progress;
|
|
||||||
|
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.table.ChangeTableTypeSession;
|
|
||||||
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.box.AlertMessageBox;
|
|
||||||
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.HideEvent;
|
|
||||||
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
|
|
||||||
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;
|
|
||||||
|
|
||||||
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());
|
|
||||||
ok.setVisible(true);
|
|
||||||
this.trId=trId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void operationFailed(Throwable caught, String reason,
|
|
||||||
String failureDetails) {
|
|
||||||
ok.setVisible(true);
|
|
||||||
this.trId=null;
|
|
||||||
AlertMessageBox d = new AlertMessageBox("Error Changing The Table Type", reason);
|
|
||||||
d.addHideHandler(new HideHandler() {
|
|
||||||
public void onHide(HideEvent event) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
d.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateInvocation(){
|
|
||||||
if(trId!=null){
|
|
||||||
ChangeTableRequestEvent changeTableRequestEvent=
|
|
||||||
new ChangeTableRequestEvent(ChangeTableRequestType.CHANGETABLETYPE, trId);
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.gcube.portlets.user.td.informationwidget.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 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);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,181 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.gcube.portlets.user.td.informationwidget.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.table.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:
|
|
||||||
fireOperationUpdate(result.getProgress());
|
|
||||||
break;
|
|
||||||
case STOPPED:
|
|
||||||
cancel();
|
|
||||||
stopMessage(result);
|
|
||||||
break;
|
|
||||||
case FAILED:
|
|
||||||
cancel();
|
|
||||||
errorMessage(result);
|
|
||||||
break;
|
|
||||||
case SUCCEDED:
|
|
||||||
cancel();
|
|
||||||
Log.info("Import 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 fireOperationUpdate(float elaborated) {
|
|
||||||
for (ChangeTableTypeProgressListener listener : listeners)
|
|
||||||
listener.operationUpdate(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);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue