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:
parent
101c850114
commit
b6e324b941
|
@ -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();
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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,8 +107,6 @@ 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> "
|
||||
|
@ -111,12 +115,12 @@ public class HistoryPanel extends FramedPanel {
|
|||
});
|
||||
|
||||
ColumnConfig<OpHistory, String> nameCol = new ColumnConfig<OpHistory, String>(
|
||||
props.name(), 32, "Name");
|
||||
props.name(), 132, "Name");
|
||||
ColumnConfig<OpHistory, String> dateCol = new ColumnConfig<OpHistory, String>(
|
||||
props.date(), 26, "Date");
|
||||
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());
|
||||
|
@ -175,7 +179,8 @@ 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,12 +190,15 @@ public class HistoryPanel extends FramedPanel {
|
|||
grid.setColumnResize(true);
|
||||
grid.getView().setAutoExpandColumn(nameCol);
|
||||
grid.getView().setEmptyText("Empty");
|
||||
expander.initPlugin(grid);
|
||||
|
||||
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
||||
/*VerticalLayoutContainer v = new VerticalLayoutContainer();
|
||||
v.setScrollMode(ScrollMode.AUTO);
|
||||
v.add(grid, new VerticalLayoutData(1, -1, new Margins(0)));
|
||||
add(v);
|
||||
v.add(grid, new VerticalLayoutData(1, 1, new Margins(0)));
|
||||
v.forceLayout();*/
|
||||
add(grid, new MarginData(0));
|
||||
|
||||
onResize();
|
||||
}
|
||||
|
||||
protected void startSearchRollBackId(int rowIndex) {
|
||||
|
@ -203,8 +211,10 @@ public class HistoryPanel extends FramedPanel {
|
|||
}
|
||||
|
||||
protected void callRollBack() {
|
||||
rollBackSession=new RollBackSession(trId, currentOpHistory.getHistoryId());
|
||||
TDGWTServiceAsync.INSTANCE.rollBack(rollBackSession, new AsyncCallback<Void>() {
|
||||
rollBackSession = new RollBackSession(trId,
|
||||
currentOpHistory.getHistoryId());
|
||||
TDGWTServiceAsync.INSTANCE.rollBack(rollBackSession,
|
||||
new AsyncCallback<Void>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
Log.error("Error in rollback: "
|
||||
|
@ -222,7 +232,6 @@ public class HistoryPanel extends FramedPanel {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
protected void callRollBackProgressDialog() {
|
||||
RollBackProgressDialog dialog = new RollBackProgressDialog(
|
||||
rollBackSession, eventBus);
|
||||
|
@ -230,7 +239,6 @@ public class HistoryPanel extends FramedPanel {
|
|||
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -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");
|
||||
|
||||
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);
|
||||
add(grid, new MarginData(0));
|
||||
|
||||
onResize();
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue