Added ReplaceDialog
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-column-widget@93605 82a268e6-3cf1-43bd-a215-b396298e98cf
|
@ -2054,3 +2054,67 @@ Compiling...
|
|||
Compilation completed in 0.00 seconds
|
||||
Removing invalidated units
|
||||
Finding entry point classes
|
||||
Public resources found in...
|
||||
Translatable source found in...
|
||||
Found 0 cached/archived units. Used 0 / 2719 units from cache.
|
||||
Compiling...
|
||||
20% complete (ETR: 20 seconds)
|
||||
20% complete (ETR: 20 seconds)
|
||||
20% complete (ETR: 20 seconds)
|
||||
30% complete (ETR: 14 seconds)
|
||||
40% complete (ETR: 10 seconds)
|
||||
50% complete (ETR: 7 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.41 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
|
||||
Public resources found in...
|
||||
Translatable source found in...
|
||||
Found 0 cached/archived units. Used 0 / 2719 units from cache.
|
||||
Compiling...
|
||||
40% complete (ETR: 5 seconds)
|
||||
40% complete (ETR: 5 seconds)
|
||||
40% complete (ETR: 5 seconds)
|
||||
40% complete (ETR: 5 seconds)
|
||||
40% complete (ETR: 5 seconds)
|
||||
50% complete (ETR: 5 seconds)
|
||||
60% complete (ETR: 4 seconds)
|
||||
70% complete (ETR: 3 seconds)
|
||||
80% complete (ETR: 2 seconds)
|
||||
90% complete (ETR: 1 seconds)
|
||||
100% complete (ETR: 0 seconds)
|
||||
Compilation completed in 12.59 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
|
||||
|
|
|
@ -41,7 +41,7 @@ public class BatchReplaceDialog extends Window {
|
|||
setClosable(true);
|
||||
setModal(true);
|
||||
forceLayoutOnResize = true;
|
||||
getHeader().setIcon(ResourceBundle.INSTANCE.replace());
|
||||
getHeader().setIcon(ResourceBundle.INSTANCE.replaceBatch());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.gcube.portlets.user.td.columnwidget.client.batch;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.td.columnwidget.client.ChangeColumnTypeDialog;
|
||||
import org.gcube.portlets.user.td.columnwidget.client.custom.ActionButtonCell;
|
||||
import org.gcube.portlets.user.td.columnwidget.client.resources.ResourceBundle;
|
||||
import org.gcube.portlets.user.td.columnwidget.client.utils.UtilsGXT3;
|
||||
|
@ -65,12 +64,11 @@ public class BatchReplacePanel extends FramedPanel {
|
|||
protected String WIDTH = "560px";
|
||||
protected String HEIGHT = "520px";
|
||||
protected EventBus eventBus;
|
||||
protected ChangeColumnTypeDialog parent;
|
||||
protected TextField label = null;
|
||||
protected TRId trId;
|
||||
protected String columnName;
|
||||
protected ColumnData column;
|
||||
protected BatchReplaceDialog batchReplaceDialog;
|
||||
protected BatchReplaceDialog parent;
|
||||
|
||||
protected static final String DON_T_REPLACE = "Don't replace";
|
||||
|
||||
|
@ -83,8 +81,8 @@ public class BatchReplacePanel extends FramedPanel {
|
|||
protected ListStore<ReplaceEntry> store;
|
||||
protected HTML info;
|
||||
|
||||
public BatchReplacePanel(BatchReplaceDialog batchReplaceDialog, TRId trId, String columnName, EventBus eventBus) {
|
||||
this.batchReplaceDialog=batchReplaceDialog;
|
||||
public BatchReplacePanel(BatchReplaceDialog parent, TRId trId, String columnName, EventBus eventBus) {
|
||||
this.parent=parent;
|
||||
Log.debug("BatchReplacePanel:["+trId+", columnName:"+columnName+"]");
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
|
@ -376,7 +374,7 @@ public class BatchReplacePanel extends FramedPanel {
|
|||
}
|
||||
|
||||
protected void close(){
|
||||
batchReplaceDialog.close();
|
||||
parent.close();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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 ReplaceColumnProgressBarUpdater implements ReplaceColumnProgressListener {
|
||||
|
||||
protected ProgressBar progressBar;
|
||||
|
||||
/**
|
||||
* Creates a new {@link ProgressBar} updater.
|
||||
* @param progressBar the {@link ProgressBar} to update.
|
||||
*/
|
||||
public ReplaceColumnProgressBarUpdater(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.replace.ReplaceDialog;
|
||||
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;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* ReplaceColumnProgressDialog is a Dialog that show progress of replace the column value
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ReplaceColumnProgressDialog extends Window implements ReplaceColumnProgressListener {
|
||||
public static final int STATUS_POLLING_DELAY = 1000;
|
||||
protected String WIDTH = "400px";
|
||||
protected String HEIGHT = "120px";
|
||||
protected ReplaceDialog parent;
|
||||
protected EventBus eventBus;
|
||||
protected ReplaceColumnProgressUpdater progressUpdater;
|
||||
protected TextButton ok;
|
||||
protected TRId trId;
|
||||
|
||||
public ReplaceColumnProgressDialog(ReplaceDialog replaceDialog, EventBus eventBus) {
|
||||
this.parent=replaceDialog;
|
||||
this.eventBus=eventBus;
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
setBodyBorder(false);
|
||||
setResizable(true);
|
||||
setModal(true);
|
||||
setHeadingText("Replace The Column Value 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 ReplaceColumnProgressUpdater();
|
||||
progressUpdater.addListener(new ReplaceColumnProgressBarUpdater(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;
|
||||
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 ReplaceColumnProgressListener {
|
||||
|
||||
/**
|
||||
* 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.column.ReplaceColumnMonitor;
|
||||
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 ReplaceColumnProgressUpdater extends Timer {
|
||||
|
||||
protected ArrayList<ReplaceColumnProgressListener> listeners = new ArrayList<ReplaceColumnProgressListener>();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
Log.debug("requesting operation progress");
|
||||
TDGWTServiceAsync.INSTANCE
|
||||
.getReplaceColumnMonitor(new AsyncCallback<ReplaceColumnMonitor>() {
|
||||
|
||||
|
||||
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(ReplaceColumnMonitor result) {
|
||||
Log.info("retrieved LabelColumnMonitor: "
|
||||
+ result.getStatus());
|
||||
switch (result.getStatus()) {
|
||||
case INITIALIZING:
|
||||
Log.info("Replace Column Value Initializing...");
|
||||
fireOperationInitializing();
|
||||
break;
|
||||
case ABORTED:
|
||||
cancel();
|
||||
Log.info("Replace Column Value 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(ReplaceColumnMonitor result) {
|
||||
Log.info("Replace the column value Failed");
|
||||
Throwable th = null;
|
||||
String failure = null;
|
||||
String details = null;
|
||||
if (result.getError() != null) {
|
||||
th = result.getError();
|
||||
failure = "Failed Client Library Replacing the column value";
|
||||
details = result.getError().getLocalizedMessage();
|
||||
} else {
|
||||
th = new Throwable("Failed");
|
||||
failure = "Failed Client Library Replacing the column value";
|
||||
details = "Replace the column value failed";
|
||||
}
|
||||
|
||||
|
||||
fireOperationFailed(th, failure, details);
|
||||
}
|
||||
|
||||
protected void stopMessage(ReplaceColumnMonitor result) {
|
||||
Log.info("Replace Column Value Stopped");
|
||||
String failure = null;
|
||||
String details = null;
|
||||
if (result.getError() != null) {
|
||||
failure = "Stopped";
|
||||
details = result.getError().getLocalizedMessage();
|
||||
} else {
|
||||
failure = "Stopped";
|
||||
details = "Stopped replacing the column value";
|
||||
}
|
||||
|
||||
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 (ReplaceColumnProgressListener listener : listeners)
|
||||
listener.operationInitializing();
|
||||
}
|
||||
|
||||
protected void fireOperationUpdate(float elaborated) {
|
||||
for (ReplaceColumnProgressListener listener : listeners)
|
||||
listener.operationUpdate(elaborated);
|
||||
}
|
||||
|
||||
protected void fireOperationComplete(TRId trId) {
|
||||
for (ReplaceColumnProgressListener listener : listeners)
|
||||
listener.operationComplete(trId);
|
||||
}
|
||||
|
||||
protected void fireOperationFailed(Throwable caught, String failure,
|
||||
String failureDetails) {
|
||||
for (ReplaceColumnProgressListener listener : listeners)
|
||||
listener.operationFailed(caught, failure, failureDetails);
|
||||
}
|
||||
|
||||
protected void fireOperationStopped(TRId trId, String reason, String details) {
|
||||
for (ReplaceColumnProgressListener listener : listeners)
|
||||
listener.operationStopped(trId,reason, details);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a new {@link } to this
|
||||
* {@link ReplaceColumnProgressUpdater}.
|
||||
*
|
||||
* @param listener
|
||||
* the listener to add.
|
||||
*/
|
||||
public void addListener(ReplaceColumnProgressListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified {@link } from this
|
||||
* {@link ReplaceColumnProgressUpdater}.
|
||||
*
|
||||
* @param listener
|
||||
* the listener to remove.
|
||||
*/
|
||||
public void removeListener(ReplaceColumnProgressListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
package org.gcube.portlets.user.td.columnwidget.client.replace;
|
||||
|
||||
import org.gcube.portlets.user.td.columnwidget.client.resources.ResourceBundle;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.CellData;
|
||||
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;
|
||||
|
||||
public class ReplaceDialog extends Window {
|
||||
protected String WIDTH = "500px";
|
||||
protected String HEIGHT = "150px";
|
||||
protected ReplacePanel ReplacePanel;
|
||||
protected CellData cellData;
|
||||
protected TRId trId;
|
||||
protected EventBus eventBus;
|
||||
|
||||
// private ReplaceSession columnFilterSession;
|
||||
// private ReplaceProgressDialog dialog;
|
||||
|
||||
public ReplaceDialog(CellData cellData, TRId trId, EventBus eventBus) {
|
||||
initWindow();
|
||||
this.cellData = cellData;
|
||||
this.trId = trId;
|
||||
this.eventBus = eventBus;
|
||||
create();
|
||||
|
||||
}
|
||||
|
||||
protected void initWindow() {
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
setBodyBorder(false);
|
||||
setResizable(false);
|
||||
setHeadingText("Replace");
|
||||
setClosable(true);
|
||||
getHeader().setIcon(ResourceBundle.INSTANCE.replace());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void initTools() {
|
||||
super.initTools();
|
||||
|
||||
closeBtn.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
close();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void create() {
|
||||
ReplacePanel replacePanel = new ReplacePanel(this, trId, cellData,
|
||||
eventBus);
|
||||
add(replacePanel);
|
||||
}
|
||||
|
||||
protected void close() {
|
||||
hide();
|
||||
}
|
||||
|
||||
/*
|
||||
* protected void callApplyFilter() { columnFilterSession = new
|
||||
* ColumnFilterSession(column, exp);
|
||||
* Log.debug(columnFilterSession.toString());
|
||||
*
|
||||
* ExpressionServiceAsync.INSTANCE.submitColumnFilter(columnFilterSession,
|
||||
* new AsyncCallback<Void>() {
|
||||
*
|
||||
* @Override public void onSuccess(Void result) {
|
||||
* Log.debug("Submitted column filter"); callColumnFilterProgressDialog(); }
|
||||
*
|
||||
* @Override public void onFailure(Throwable caught) {
|
||||
* Log.error("Error submitting the column filter: " + caught.getMessage() +
|
||||
* " " + caught.getCause()); caught.printStackTrace();
|
||||
* UtilsGXT3.alert("Error submitting the column filter",
|
||||
* caught.getMessage());
|
||||
*
|
||||
* } });
|
||||
*
|
||||
* }
|
||||
*
|
||||
* protected void callColumnFilterProgressDialog() { dialog = new
|
||||
* ColumnFilterProgressDialog(this, eventBus); dialog.show(); }
|
||||
*/
|
||||
|
||||
}
|
|
@ -0,0 +1,200 @@
|
|||
package org.gcube.portlets.user.td.columnwidget.client.replace;
|
||||
|
||||
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.ColumnData;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnSession;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.CellData;
|
||||
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.cell.core.client.ButtonCell.IconAlign;
|
||||
import com.sencha.gxt.core.client.util.Margins;
|
||||
import com.sencha.gxt.widget.core.client.FramedPanel;
|
||||
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
|
||||
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer.HBoxLayoutAlign;
|
||||
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;
|
||||
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
||||
import com.sencha.gxt.widget.core.client.form.TextField;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ReplacePanel extends FramedPanel {
|
||||
protected String WIDTH = "500px";
|
||||
protected String HEIGHT = "150px";
|
||||
protected EventBus eventBus;
|
||||
protected TRId trId;
|
||||
protected CellData cellData;
|
||||
protected ReplaceDialog parent;
|
||||
protected ColumnData column;
|
||||
|
||||
protected ReplaceColumnSession replaceColumnSession;
|
||||
|
||||
private TextField value;
|
||||
private TextField replaceValue;
|
||||
private TextButton btnApply;
|
||||
private TextButton btnClose;
|
||||
|
||||
public ReplacePanel(ReplaceDialog parent, TRId trId, CellData cellData,
|
||||
EventBus eventBus) {
|
||||
this.parent = parent;
|
||||
this.cellData = cellData;
|
||||
this.trId = trId;
|
||||
this.eventBus = eventBus;
|
||||
|
||||
Log.debug("ReplacePanel:[" + trId + ", CellData:" + cellData + "]");
|
||||
initPanel();
|
||||
retrieveColumn();
|
||||
|
||||
}
|
||||
|
||||
protected void initPanel() {
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
setHeaderVisible(false);
|
||||
setBodyBorder(false);
|
||||
}
|
||||
|
||||
protected void retrieveColumn() {
|
||||
TDGWTServiceAsync.INSTANCE.getColumn(trId, cellData.getColumnName(),
|
||||
new AsyncCallback<ColumnData>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
Log.error("Error retrieving column: "
|
||||
+ caught.getMessage());
|
||||
UtilsGXT3.alert("Error retrieving column",
|
||||
caught.getMessage());
|
||||
}
|
||||
|
||||
public void onSuccess(ColumnData result) {
|
||||
Log.debug("Retrived column: " + result);
|
||||
if (result.isViewColumn()) {
|
||||
UtilsGXT3
|
||||
.info("View Column",
|
||||
"You can not replace value on view column for now");
|
||||
close();
|
||||
} else {
|
||||
column = result;
|
||||
create();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void create() {
|
||||
value = new TextField();
|
||||
value.setValue(cellData.getValue());
|
||||
value.setReadOnly(true);
|
||||
|
||||
replaceValue = new TextField();
|
||||
|
||||
btnApply = new TextButton("Replace");
|
||||
btnApply.setIcon(ResourceBundle.INSTANCE.replace());
|
||||
btnApply.setIconAlign(IconAlign.RIGHT);
|
||||
btnApply.setTitle("Replace Value");
|
||||
btnApply.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.debug("Pressed Apply");
|
||||
replaceValue();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
btnClose = new TextButton("Close");
|
||||
btnClose.setIcon(ResourceBundle.INSTANCE.close());
|
||||
btnClose.setIconAlign(IconAlign.RIGHT);
|
||||
btnClose.setTitle("Close");
|
||||
btnClose.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.debug("Pressed Close");
|
||||
close();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
HBoxLayoutContainer flowButton = new HBoxLayoutContainer();
|
||||
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
||||
flowButton.setPack(BoxLayoutPack.CENTER);
|
||||
|
||||
flowButton.add(btnApply, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
||||
flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
||||
|
||||
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
||||
v.add(new FieldLabel(value, "Value"), new VerticalLayoutData(1, -1));
|
||||
v.add(new FieldLabel(replaceValue, "Replace"), new VerticalLayoutData(
|
||||
1, -1));
|
||||
v.add(flowButton, new VerticalLayoutData(-1, 36,
|
||||
new Margins(5, 2, 5, 2)));
|
||||
add(v);
|
||||
|
||||
}
|
||||
|
||||
protected void replaceValue() {
|
||||
String rValue = replaceValue.getCurrentValue();
|
||||
if (rValue == null || rValue.isEmpty()) {
|
||||
UtilsGXT3.alert("Attention", "Insert a valid replace value");
|
||||
} else {
|
||||
callReplaceValue(rValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void callReplaceValue(String rValue) {
|
||||
replaceColumnSession = new ReplaceColumnSession(
|
||||
value.getCurrentValue(), rValue, trId, column,
|
||||
cellData.getRowId());
|
||||
Log.debug(replaceColumnSession.toString());
|
||||
|
||||
TDGWTServiceAsync.INSTANCE.startReplaceColumn(replaceColumnSession,
|
||||
new AsyncCallback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
Log.debug("Submitted replace column value");
|
||||
callReplaceColumnProgressDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Log.error("Error submitting replace column value: "
|
||||
+ caught.getMessage() + " " + caught.getCause());
|
||||
caught.printStackTrace();
|
||||
UtilsGXT3.alert(
|
||||
"Error submitting replace column value",
|
||||
caught.getMessage());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void callReplaceColumnProgressDialog() {
|
||||
ReplaceColumnProgressDialog dialog = new ReplaceColumnProgressDialog(
|
||||
parent, eventBus);
|
||||
dialog.show();
|
||||
|
||||
}
|
||||
|
||||
protected void close() {
|
||||
parent.close();
|
||||
}
|
||||
|
||||
}
|
|
@ -35,11 +35,23 @@ public interface ResourceBundle extends ClientBundle {
|
|||
ImageResource magnifier32();
|
||||
|
||||
@Source("column-values.png")
|
||||
ImageResource replace();
|
||||
ImageResource columnValue();
|
||||
|
||||
@Source("column-values_32.png")
|
||||
ImageResource columnValue32();
|
||||
|
||||
@Source("column-replace.png")
|
||||
ImageResource replace();
|
||||
|
||||
@Source("column-replace_32.png")
|
||||
ImageResource replace32();
|
||||
|
||||
@Source("column-replace-batch.png")
|
||||
ImageResource replaceBatch();
|
||||
|
||||
@Source("column-replace-batch_32.png")
|
||||
ImageResource replaceBatch32();
|
||||
|
||||
@Source("close-red.png")
|
||||
ImageResource close();
|
||||
|
||||
|
|
After Width: | Height: | Size: 843 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 761 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 843 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 761 B |
After Width: | Height: | Size: 1.2 KiB |