Minor Update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-table-widget@94933 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-04-16 17:10:01 +00:00 committed by Giancarlo Panichi
parent 101c850114
commit b6e324b941
3 changed files with 144 additions and 66 deletions

View File

@ -0,0 +1,73 @@
package org.gcube.portlets.user.td.tablewidget.client.history;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.history.RollBackSession;
import org.gcube.portlets.user.td.tablewidget.client.progress.RollBackProgressDialog;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
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;
public class HistoryDiscard {
protected TRId trId;
protected EventBus eventBus;
public HistoryDiscard(EventBus eventBus) {
this.eventBus = eventBus;
}
public void discard(){
retrieveCurrentTR();
}
protected void retrieveCurrentTR() {
TDGWTServiceAsync.INSTANCE.getCurrentTRId(new AsyncCallback<TRId>() {
public void onFailure(Throwable caught) {
Log.error("Error retrieving trId: "
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error",
"Error retrieving current tabular resource id");
}
public void onSuccess(TRId result) {
Log.debug("retrieved " + result);
trId = result;
callDiscard();
}
});
}
protected void callDiscard(){
TDGWTServiceAsync.INSTANCE.discard(trId, new AsyncCallback<RollBackSession>() {
public void onFailure(Throwable caught) {
Log.error("Error in discard: "
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error in discard",
"Error in discard");
}
public void onSuccess(RollBackSession result) {
Log.debug("Discard started "+result);
callRollBackProgressDialog(result);
}
});
}
protected void callRollBackProgressDialog(RollBackSession rollBackSession) {
RollBackProgressDialog dialog = new RollBackProgressDialog(
rollBackSession, eventBus);
dialog.show();
}
}

View File

@ -24,8 +24,6 @@ import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.core.client.IdentityValueProvider;
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.data.client.loader.RpcProxy;
import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.data.shared.loader.ListLoadConfig;
@ -34,8 +32,8 @@ import com.sencha.gxt.data.shared.loader.ListLoadResultBean;
import com.sencha.gxt.data.shared.loader.ListLoader;
import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.container.MarginData;
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;
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
@ -50,7 +48,7 @@ import com.sencha.gxt.widget.core.client.grid.RowExpander;
*
*/
public class HistoryPanel extends FramedPanel {
protected String WIDTH = "640px";
protected String WIDTH = "298px";
protected String HEIGHT = "520px";
protected TRId trId;
@ -59,21 +57,22 @@ public class HistoryPanel extends FramedPanel {
protected VerticalLayoutContainer vl;
protected EventBus eventBus;
// protected ComboBox<Validations> comboValidations;
protected ListStore<OpHistory> store;
protected ListLoader<ListLoadConfig, ListLoadResult<OpHistory>> loader;
protected Grid<OpHistory> grid;
private OpHistory currentOpHistory;
private int currentRowIndex;
private RollBackSession rollBackSession;
protected OpHistory currentOpHistory;
protected int currentRowIndex;
protected RollBackSession rollBackSession;
private boolean drawed = false;
public HistoryPanel(EventBus eventBus) {
super();
this.eventBus = eventBus;
retrieveCurrentTR();
forceLayoutOnResize = true;
init();
create();
retrieveCurrentTR();
}
public HistoryPanel(TRId trId, EventBus eventBus) {
@ -81,6 +80,11 @@ public class HistoryPanel extends FramedPanel {
this.trId = trId;
this.eventBus = eventBus;
forceLayoutOnResize = true;
draw();
}
protected void draw() {
drawed = true;
init();
create();
}
@ -90,6 +94,8 @@ public class HistoryPanel extends FramedPanel {
setHeight(HEIGHT);
setHeaderVisible(false);
setBodyBorder(false);
setResize(true);
}
protected void create() {
@ -101,22 +107,20 @@ public class HistoryPanel extends FramedPanel {
@Override
public void render(Context context, OpHistory value,
SafeHtmlBuilder sb) {
sb.appendHtmlConstant("<p style='margin: 5px 5px 10px'><b>Name:</b>"
+ value.getName() + "</p>");
sb.appendHtmlConstant("<p style='margin: 5px 5px 10px'><b>Date:</b>"
+ value.getDate() + "</p>");
sb.appendHtmlConstant("<p style='margin: 5px 5px 10px'><b>Description:</b> "
+ value.getDescription());
}
});
ColumnConfig<OpHistory, String> nameCol = new ColumnConfig<OpHistory, String>(
props.name(), 32, "Name");
ColumnConfig<OpHistory, String> dateCol = new ColumnConfig<OpHistory, String>(
props.date(), 26, "Date");
ColumnConfig<OpHistory, String> nameCol = new ColumnConfig<OpHistory, String>(
props.name(), 132, "Name");
ColumnConfig<OpHistory, String> dateCol = new ColumnConfig<OpHistory, String>(
props.date(), 106, "Date");
ColumnConfig<OpHistory, String> rollBackColumn = new ColumnConfig<OpHistory, String>(
props.name(), 16);
props.date(), 40, "Undo");
ActionButtonCell button = new ActionButtonCell();
button.setIcon(ResourceBundle.INSTANCE.undo());
@ -133,7 +137,7 @@ public class HistoryPanel extends FramedPanel {
});
rollBackColumn.setCell(button);
List<ColumnConfig<OpHistory, ?>> l = new ArrayList<ColumnConfig<OpHistory, ?>>();
l.add(expander);
l.add(nameCol);
@ -173,9 +177,10 @@ public class HistoryPanel extends FramedPanel {
});
}
};
grid.setLoader(loader);
grid.setHeight(360);
grid.setSize("200px","300px");
grid.getView().setStripeRows(true);
grid.getView().setColumnLines(true);
grid.getView().setAutoFill(true);
@ -185,33 +190,38 @@ public class HistoryPanel extends FramedPanel {
grid.setColumnResize(true);
grid.getView().setAutoExpandColumn(nameCol);
grid.getView().setEmptyText("Empty");
VerticalLayoutContainer v = new VerticalLayoutContainer();
v.setScrollMode(ScrollMode.AUTO);
v.add(grid, new VerticalLayoutData(1, -1, new Margins(0)));
add(v);
}
expander.initPlugin(grid);
/*VerticalLayoutContainer v = new VerticalLayoutContainer();
v.setScrollMode(ScrollMode.AUTO);
v.add(grid, new VerticalLayoutData(1, 1, new Margins(0)));
v.forceLayout();*/
add(grid, new MarginData(0));
onResize();
}
protected void startSearchRollBackId(int rowIndex) {
currentRowIndex = rowIndex;
currentOpHistory = store.get(rowIndex);
Log.debug(currentOpHistory.toString() + " was clicked.[rowIndex="
+ currentRowIndex + " ]");
callRollBack();
}
protected void callRollBack(){
rollBackSession=new RollBackSession(trId, currentOpHistory.getHistoryId());
TDGWTServiceAsync.INSTANCE.rollBack(rollBackSession, new AsyncCallback<Void>() {
protected void callRollBack() {
rollBackSession = new RollBackSession(trId,
currentOpHistory.getHistoryId());
TDGWTServiceAsync.INSTANCE.rollBack(rollBackSession,
new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
Log.error("Error in rollback: "
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error in rollback",
"Error in rollback");
}
public void onSuccess(Void result) {
@ -221,16 +231,14 @@ public class HistoryPanel extends FramedPanel {
});
}
protected void callRollBackProgressDialog() {
RollBackProgressDialog dialog = new RollBackProgressDialog(
rollBackSession, eventBus);
dialog.show();
}
protected void loadData(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<OpHistory>> callback) {
@ -264,16 +272,20 @@ public class HistoryPanel extends FramedPanel {
TDGWTServiceAsync.INSTANCE.getCurrentTRId(new AsyncCallback<TRId>() {
public void onFailure(Throwable caught) {
Log.error("Error retrieving history: "
Log.error("Error retrieving current TRId: "
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error retrieving history",
"Error retrieving history");
UtilsGXT3.alert("Error",
"Error retrieving current tabular resource id");
}
public void onSuccess(TRId result) {
Log.debug("retrieved " + result);
trId = result;
if (!drawed) {
draw();
}
}
});

View File

@ -20,8 +20,6 @@ import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.data.client.loader.RpcProxy;
import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.data.shared.loader.ListLoadConfig;
@ -30,8 +28,8 @@ import com.sencha.gxt.data.shared.loader.ListLoadResultBean;
import com.sencha.gxt.data.shared.loader.ListLoader;
import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.container.MarginData;
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.form.ComboBox;
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
@ -44,7 +42,7 @@ import com.sencha.gxt.widget.core.client.grid.Grid;
*
*/
public class ValidationsTablePanel extends FramedPanel {
protected String WIDTH = "640px";
protected String WIDTH = "298px";
protected String HEIGHT = "520px";
protected TRId trId;
@ -80,7 +78,7 @@ public class ValidationsTablePanel extends FramedPanel {
ColumnConfig<Validations, String> descriptionCol = new ColumnConfig<Validations, String>(
props.description(), 168, "Description");
ColumnConfig<Validations, Boolean> validCol = new ColumnConfig<Validations, Boolean>(
props.valid(), 32, "Valid");
props.valid(), 28, "Valid");
validCol.setCell(new AbstractCell<Boolean>() {
@Override
@ -141,7 +139,7 @@ public class ValidationsTablePanel extends FramedPanel {
};
grid.setLoader(loader);
grid.setHeight(360);
grid.setSize("200px", "300px");
grid.getView().setStripeRows(true);
grid.getView().setColumnLines(true);
grid.getView().setAutoFill(true);
@ -152,15 +150,10 @@ public class ValidationsTablePanel extends FramedPanel {
grid.getView().setAutoExpandColumn(descriptionCol);
grid.getView().setEmptyText("No validation");
// FieldLabel validationsLabel = new FieldLabel(null, "Validations");
// validationsLabel.getElement().applyStyles("font-weight:bold");
add(grid, new MarginData(0));
VerticalLayoutContainer v = new VerticalLayoutContainer();
v.setScrollMode(ScrollMode.AUTO);
// v.add(validationsLabel, new VerticalLayoutData(-1, -1, new
// Margins(2,1,5,1)));
v.add(grid, new VerticalLayoutData(1, -1, new Margins(0)));
add(v);
onResize();
}
@ -182,17 +175,17 @@ public class ValidationsTablePanel extends FramedPanel {
public void onSuccess(TabValidationsMetadata result) {
Log.debug("loaded " + result.getId());
if (result.getValidations() != null) {
Log.debug("Validations Retrieved: "
+ result.getValidations().size());
callback.onSuccess(new ListLoadResultBean<Validations>(
result.getValidations()));
} else {
Log.debug("No validations");
ArrayList<Validations> empty=new ArrayList<Validations>();
callback.onSuccess(new ListLoadResultBean<Validations>(
Log.debug("Validations Retrieved: "
+ result.getValidations().size());
callback.onSuccess(new ListLoadResultBean<Validations>(
result.getValidations()));
} else {
Log.debug("No validations");
ArrayList<Validations> empty = new ArrayList<Validations>();
callback.onSuccess(new ListLoadResultBean<Validations>(
empty));
}
}
}
});