Added Change Table Type
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-information-widget@92299 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ed8501f7cf
commit
9035ef3691
|
@ -0,0 +1,189 @@
|
|||
package org.gcube.portlets.user.td.informationwidget.client;
|
||||
|
||||
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
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.informationwidget.client.progress.ChangeTableTypeProgressDialog;
|
||||
import org.gcube.portlets.user.td.informationwidget.client.table.TableTypeElement;
|
||||
import org.gcube.portlets.user.td.informationwidget.client.table.TableTypeProperties;
|
||||
import org.gcube.portlets.user.td.informationwidget.client.table.TableTypeStore;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
|
||||
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
|
||||
import com.sencha.gxt.core.client.util.Margins;
|
||||
import com.sencha.gxt.data.shared.ListStore;
|
||||
import com.sencha.gxt.widget.core.client.FramedPanel;
|
||||
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;
|
||||
import com.sencha.gxt.widget.core.client.form.ComboBox;
|
||||
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ChangeTableType extends FramedPanel {
|
||||
protected String WIDTH = "640px";
|
||||
protected String HEIGHT = "520px";
|
||||
|
||||
protected TRId trId;
|
||||
protected TableData table;
|
||||
protected String headingTitle;
|
||||
protected VerticalLayoutContainer vl;
|
||||
protected EventBus eventBus;
|
||||
protected ChangeTableTypeSession changeTableTypeSession;
|
||||
protected ChangeTableTypeProgressDialog changeTableTypeProgressDialog;
|
||||
|
||||
protected ComboBox<TableTypeElement> comboTableType;
|
||||
protected TextButton change;
|
||||
|
||||
|
||||
|
||||
public ChangeTableType(TRId trId, EventBus eventBus) {
|
||||
super();
|
||||
this.trId=trId;
|
||||
this.eventBus = eventBus;
|
||||
forceLayoutOnResize=true;
|
||||
load();
|
||||
}
|
||||
|
||||
protected void create(){
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
setHeaderVisible(false);
|
||||
setBodyBorder(false);
|
||||
|
||||
|
||||
TableTypeProperties props = GWT.create(TableTypeProperties.class);
|
||||
ListStore<TableTypeElement> storeTableType = new ListStore<TableTypeElement>(props.id());
|
||||
|
||||
storeTableType.addAll(TableTypeStore.getTableTypes());
|
||||
|
||||
Log.trace("Store created");
|
||||
|
||||
comboTableType = new ComboBox<TableTypeElement>(storeTableType,
|
||||
props.label());
|
||||
|
||||
Log.trace("ComboTableType created");
|
||||
|
||||
|
||||
comboTableType.setEmptyText("Select a Table Type...");
|
||||
comboTableType.setItemId("ComboTableType");
|
||||
comboTableType.setWidth("200px");
|
||||
comboTableType.setEditable(false);
|
||||
comboTableType.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
|
||||
change=new TextButton("Change");
|
||||
change.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
onChangeTableType();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
vl = new VerticalLayoutContainer();
|
||||
vl.setScrollMode(ScrollMode.AUTO);
|
||||
vl.setAdjustForScroll(true);
|
||||
|
||||
|
||||
vl.add(new FieldLabel(comboTableType, "Table Type"), new VerticalLayoutData(1,
|
||||
-1));
|
||||
vl.add(change, new VerticalLayoutData(-1, -1, new Margins(10, 0, 10, 0)));
|
||||
|
||||
add(vl);
|
||||
|
||||
show();
|
||||
setCurrentType();
|
||||
|
||||
}
|
||||
|
||||
protected void onChangeTableType(){
|
||||
TableTypeElement tableTypeElement = comboTableType.getCurrentValue();
|
||||
if(tableTypeElement!=null){
|
||||
changeTableTypeSession=new ChangeTableTypeSession(trId,tableTypeElement.getTableType());
|
||||
callChangeTableType();
|
||||
} else {
|
||||
alert("Attention", "Select a table type!");
|
||||
}
|
||||
}
|
||||
|
||||
private void callChangeTableType() {
|
||||
TDGWTServiceAsync.INSTANCE.startChangeTableType(
|
||||
changeTableTypeSession, new AsyncCallback<Void>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
Log.debug("Change The Table Type Error: "
|
||||
+ caught.getLocalizedMessage());
|
||||
alert("Error Changing The Table Type",
|
||||
"Error in invocation of Change Table Type operation!");
|
||||
|
||||
}
|
||||
|
||||
public void onSuccess(Void result) {
|
||||
changeTableTypeProgressDialog= new ChangeTableTypeProgressDialog(changeTableTypeSession, eventBus);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void setCurrentType(){
|
||||
TableTypeElement tElement=TableTypeStore.getTableTypeElement(table.getTypeName());
|
||||
comboTableType.setValue(tElement);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void load() {
|
||||
TDGWTServiceAsync.INSTANCE.getTable(trId,
|
||||
new AsyncCallback<TableData>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
Log.error("Error retrieving table: "
|
||||
+ caught.getMessage());
|
||||
alert("Error retrieving table",caught.getMessage());
|
||||
}
|
||||
|
||||
public void onSuccess(TableData result) {
|
||||
Log.debug("Retrieved table: "+result.toString());
|
||||
table=result;
|
||||
create();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void alert(String title, String message) {
|
||||
final AlertMessageBox d = new AlertMessageBox(title, message);
|
||||
d.addHideHandler(new HideHandler() {
|
||||
|
||||
public void onHide(HideEvent event) {
|
||||
|
||||
}
|
||||
});
|
||||
d.show();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
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(String reason, String details) {
|
||||
Log.info("Stopped");
|
||||
progressBar.updateText("Stopped");
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
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(String reason, String details) {
|
||||
ok.setVisible(true);
|
||||
this.trId=null;
|
||||
AlertMessageBox d = new AlertMessageBox("Stopped Changing The Table Type", reason);
|
||||
d.addHideHandler(new HideHandler() {
|
||||
public void onHide(HideEvent event) {
|
||||
}
|
||||
});
|
||||
d.show();
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
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 failed.
|
||||
* @param caught the failure exception.
|
||||
* @param reason the failure reason.
|
||||
*/
|
||||
public void operationStopped(String reason, String details);
|
||||
|
||||
}
|
|
@ -0,0 +1,182 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
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(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(String reason, String details) {
|
||||
for (ChangeTableTypeProgressListener listener : listeners)
|
||||
listener.operationStopped(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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package org.gcube.portlets.user.td.informationwidget.client.table;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.TableType;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class TableTypeElement implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -5913441587564742269L;
|
||||
|
||||
protected Integer id;
|
||||
protected TableType tableType;
|
||||
|
||||
public TableTypeElement(Integer id, TableType tableType){
|
||||
this.id=id;
|
||||
this.tableType=tableType;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public TableType getTableType() {
|
||||
return tableType;
|
||||
}
|
||||
|
||||
public void setTableType(TableType tableType) {
|
||||
this.tableType = tableType;
|
||||
}
|
||||
|
||||
public String getLabel(){
|
||||
return tableType.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TableTypeElement [id=" + id + ", tableType=" + tableType + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package org.gcube.portlets.user.td.informationwidget.client.table;
|
||||
|
||||
|
||||
import com.google.gwt.editor.client.Editor.Path;
|
||||
import com.sencha.gxt.data.shared.LabelProvider;
|
||||
import com.sencha.gxt.data.shared.ModelKeyProvider;
|
||||
import com.sencha.gxt.data.shared.PropertyAccess;
|
||||
|
||||
public interface TableTypeProperties extends PropertyAccess<TableTypeElement> {
|
||||
|
||||
@Path("id")
|
||||
ModelKeyProvider<TableTypeElement> id();
|
||||
|
||||
LabelProvider<TableTypeElement> label();
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package org.gcube.portlets.user.td.informationwidget.client.table;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.TableType;
|
||||
|
||||
public class TableTypeStore {
|
||||
|
||||
protected static TableTypeElement genericElement=new TableTypeElement(1, TableType.GENERIC);
|
||||
protected static TableTypeElement codelistElement=new TableTypeElement(2, TableType.CODELIST);
|
||||
protected static TableTypeElement datasetElement=new TableTypeElement(3, TableType.DATASET);
|
||||
|
||||
|
||||
protected static ArrayList<TableTypeElement> tableType = new ArrayList<TableTypeElement>() {
|
||||
private static final long serialVersionUID = -6559885743626876431L;
|
||||
{
|
||||
add(genericElement);
|
||||
add(codelistElement);
|
||||
add(datasetElement);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
public static ArrayList<TableTypeElement> getTableTypes() {
|
||||
return tableType;
|
||||
}
|
||||
|
||||
public static TableTypeElement getTableTypeElement(String tableType){
|
||||
if(tableType.compareTo(TableType.GENERIC.toString())==0){
|
||||
return genericElement;
|
||||
} else {
|
||||
if(tableType.compareTo(TableType.CODELIST.toString())==0){
|
||||
return genericElement;
|
||||
} else {
|
||||
if(tableType.compareTo(TableType.DATASET.toString())==0){
|
||||
return genericElement;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue