2014-03-17 18:59:08 +01:00
|
|
|
package org.gcube.portlets.user.td.columnwidget.client.batch;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2014-03-19 12:52:51 +01:00
|
|
|
import org.gcube.portlets.user.td.columnwidget.client.custom.ActionButtonCell;
|
2014-04-03 18:36:55 +02:00
|
|
|
import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRowSelectionDialog;
|
2014-04-02 17:18:19 +02:00
|
|
|
import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRowSelectionListener;
|
2014-03-19 12:52:51 +01:00
|
|
|
import org.gcube.portlets.user.td.columnwidget.client.resources.ResourceBundle;
|
2014-03-18 18:22:39 +01:00
|
|
|
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;
|
2014-04-03 18:36:55 +02:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.DimensionRow;
|
2014-04-04 12:33:26 +02:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurrences;
|
2014-04-04 10:21:28 +02:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceBatchColumnSession;
|
2014-04-03 18:36:55 +02:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceEntry;
|
|
|
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.CellData;
|
2014-03-17 18:59:08 +01:00
|
|
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
|
|
|
|
|
|
|
import com.allen_sauer.gwt.log.client.Log;
|
2014-04-02 17:51:15 +02:00
|
|
|
import com.google.gwt.cell.client.AbstractCell;
|
2014-03-18 18:22:39 +01:00
|
|
|
import com.google.gwt.cell.client.Cell.Context;
|
2014-03-17 18:59:08 +01:00
|
|
|
import com.google.gwt.core.client.GWT;
|
|
|
|
import com.google.gwt.core.client.Scheduler;
|
|
|
|
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
2014-03-19 12:52:51 +01:00
|
|
|
import com.google.gwt.dom.client.Style.Unit;
|
|
|
|
import com.google.gwt.safecss.shared.SafeStylesBuilder;
|
2014-04-02 17:51:15 +02:00
|
|
|
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
2014-03-17 18:59:08 +01:00
|
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
2014-03-19 15:22:35 +01:00
|
|
|
import com.google.gwt.user.client.ui.HTML;
|
2014-03-17 18:59:08 +01:00
|
|
|
import com.google.web.bindery.event.shared.EventBus;
|
2014-03-19 16:48:15 +01:00
|
|
|
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
|
2014-03-17 18:59:08 +01:00
|
|
|
import com.sencha.gxt.core.client.IdentityValueProvider;
|
|
|
|
import com.sencha.gxt.core.client.Style.SelectionMode;
|
2014-03-19 15:22:35 +01:00
|
|
|
import com.sencha.gxt.core.client.resources.ThemeStyles;
|
2014-03-18 18:22:39 +01:00
|
|
|
import com.sencha.gxt.core.client.util.Format;
|
|
|
|
import com.sencha.gxt.core.client.util.Margins;
|
2014-03-17 18:59:08 +01:00
|
|
|
import com.sencha.gxt.data.client.loader.RpcProxy;
|
|
|
|
import com.sencha.gxt.data.shared.ListStore;
|
2014-03-19 15:22:35 +01:00
|
|
|
import com.sencha.gxt.data.shared.event.StoreDataChangeEvent;
|
|
|
|
import com.sencha.gxt.data.shared.event.StoreDataChangeEvent.StoreDataChangeHandler;
|
2014-03-17 18:59:08 +01:00
|
|
|
import com.sencha.gxt.data.shared.loader.ListLoadConfig;
|
|
|
|
import com.sencha.gxt.data.shared.loader.ListLoadResult;
|
2014-03-18 18:22:39 +01:00
|
|
|
import com.sencha.gxt.data.shared.loader.ListLoadResultBean;
|
2014-03-17 18:59:08 +01:00
|
|
|
import com.sencha.gxt.data.shared.loader.ListLoader;
|
|
|
|
import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding;
|
|
|
|
import com.sencha.gxt.widget.core.client.FramedPanel;
|
2014-03-19 16:48:15 +01:00
|
|
|
import com.sencha.gxt.widget.core.client.button.TextButton;
|
|
|
|
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;
|
|
|
|
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer.HBoxLayoutAlign;
|
2014-03-18 18:22:39 +01:00
|
|
|
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;
|
2014-03-17 18:59:08 +01:00
|
|
|
import com.sencha.gxt.widget.core.client.form.TextField;
|
|
|
|
import com.sencha.gxt.widget.core.client.grid.CheckBoxSelectionModel;
|
|
|
|
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
|
|
|
|
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
|
|
|
|
import com.sencha.gxt.widget.core.client.grid.Grid;
|
|
|
|
import com.sencha.gxt.widget.core.client.grid.RowNumberer;
|
2014-03-19 15:22:35 +01:00
|
|
|
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
2014-03-17 18:59:08 +01:00
|
|
|
|
2014-03-17 19:03:29 +01:00
|
|
|
/**
|
|
|
|
*
|
2014-03-18 18:22:39 +01:00
|
|
|
* @author "Giancarlo Panichi" <a
|
|
|
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
|
|
*
|
2014-03-17 19:03:29 +01:00
|
|
|
*/
|
2014-04-04 10:21:28 +02:00
|
|
|
public class ReplaceBatchPanel extends FramedPanel implements
|
2014-04-03 18:36:55 +02:00
|
|
|
SingleValueReplaceListener, DimensionRowSelectionListener {
|
2014-03-19 15:22:35 +01:00
|
|
|
protected String WIDTH = "560px";
|
2014-03-17 18:59:08 +01:00
|
|
|
protected String HEIGHT = "520px";
|
|
|
|
protected EventBus eventBus;
|
|
|
|
protected TextField label = null;
|
|
|
|
protected TRId trId;
|
|
|
|
protected String columnName;
|
2014-03-18 18:22:39 +01:00
|
|
|
protected ColumnData column;
|
2014-04-04 10:21:28 +02:00
|
|
|
protected ReplaceBatchDialog parent;
|
2014-04-03 18:36:55 +02:00
|
|
|
private ReplaceEntry currentReplaceEntry;
|
|
|
|
private int currentRowIndex;
|
2014-04-02 17:18:19 +02:00
|
|
|
|
2014-03-19 12:52:51 +01:00
|
|
|
protected static final String DON_T_REPLACE = "Don't replace";
|
2014-04-02 17:18:19 +02:00
|
|
|
|
2014-03-19 16:48:15 +01:00
|
|
|
private TextButton btnApply;
|
|
|
|
private TextButton btnClose;
|
2014-04-02 17:18:19 +02:00
|
|
|
|
2014-03-18 18:22:39 +01:00
|
|
|
protected ListLoader<ListLoadConfig, ListLoadResult<ReplaceEntry>> loader;
|
|
|
|
protected Grid<ReplaceEntry> grid;
|
|
|
|
protected ListStore<ReplaceEntry> store;
|
2014-03-19 15:22:35 +01:00
|
|
|
protected HTML info;
|
2014-03-18 18:22:39 +01:00
|
|
|
|
2014-04-04 10:21:28 +02:00
|
|
|
public ReplaceBatchPanel(ReplaceBatchDialog parent, TRId trId,
|
2014-04-02 17:18:19 +02:00
|
|
|
String columnName, EventBus eventBus) {
|
|
|
|
this.parent = parent;
|
2014-03-17 18:59:08 +01:00
|
|
|
this.trId = trId;
|
|
|
|
this.columnName = columnName;
|
|
|
|
this.eventBus = eventBus;
|
2014-03-18 18:22:39 +01:00
|
|
|
Log.debug("Create BatchReplacePanel(): [" + trId.toString()
|
|
|
|
+ " , columnName:" + columnName + "]");
|
2014-04-03 18:36:55 +02:00
|
|
|
init();
|
2014-03-18 18:22:39 +01:00
|
|
|
retrieveColumn();
|
2014-04-02 17:18:19 +02:00
|
|
|
|
2014-03-18 18:22:39 +01:00
|
|
|
}
|
|
|
|
|
2014-04-03 18:36:55 +02:00
|
|
|
protected void init() {
|
|
|
|
setWidth(WIDTH);
|
|
|
|
setHeight(HEIGHT);
|
|
|
|
setHeaderVisible(false);
|
|
|
|
setBodyBorder(false);
|
|
|
|
}
|
|
|
|
|
2014-03-18 18:22:39 +01:00
|
|
|
protected void create() {
|
|
|
|
|
|
|
|
IdentityValueProvider<ReplaceEntry> identity = new IdentityValueProvider<ReplaceEntry>();
|
|
|
|
CheckBoxSelectionModel<ReplaceEntry> sm = new CheckBoxSelectionModel<ReplaceEntry>(
|
2014-03-17 18:59:08 +01:00
|
|
|
identity);
|
|
|
|
|
2014-04-02 17:18:19 +02:00
|
|
|
RowNumberer<ReplaceEntry> number = new RowNumberer<ReplaceEntry>(
|
|
|
|
identity);
|
|
|
|
// number.setFixed(false);
|
|
|
|
// number.setResizable(false);
|
2014-03-19 12:52:51 +01:00
|
|
|
number.setWidth(50);
|
|
|
|
number.setColumnClassSuffix("");
|
|
|
|
number.setHeader("N.");
|
2014-04-02 17:18:19 +02:00
|
|
|
SafeStylesBuilder styleBuilder = new SafeStylesBuilder();
|
2014-03-19 12:52:51 +01:00
|
|
|
styleBuilder.width(50, Unit.PX);
|
|
|
|
number.setColumnStyle(styleBuilder.toSafeStyles());
|
2014-04-02 17:18:19 +02:00
|
|
|
|
2014-03-18 18:22:39 +01:00
|
|
|
ReplaceEntryProperties props = GWT.create(ReplaceEntryProperties.class);
|
2014-04-02 17:18:19 +02:00
|
|
|
|
2014-03-18 18:22:39 +01:00
|
|
|
ColumnConfig<ReplaceEntry, String> valueCol = new ColumnConfig<ReplaceEntry, String>(
|
2014-03-19 12:52:51 +01:00
|
|
|
props.value(), 130, "Values");
|
2014-03-18 18:22:39 +01:00
|
|
|
ColumnConfig<ReplaceEntry, Integer> numberCol = new ColumnConfig<ReplaceEntry, Integer>(
|
2014-04-04 12:33:26 +02:00
|
|
|
props.number(), 100, "Occurrences");
|
2014-03-18 18:22:39 +01:00
|
|
|
ColumnConfig<ReplaceEntry, String> replacementValueCol = new ColumnConfig<ReplaceEntry, String>(
|
2014-04-02 17:18:19 +02:00
|
|
|
props.replacementValue(), 130, "Replacement");
|
|
|
|
|
|
|
|
replacementValueCol.setCell(new AbstractCell<String>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void render(Context context, String value, SafeHtmlBuilder sb) {
|
|
|
|
if (value == null) {
|
|
|
|
String style = "style='color: black;font-weight:bold'";
|
2014-04-03 18:36:55 +02:00
|
|
|
sb.appendHtmlConstant("<span " + style + ">"
|
|
|
|
+ DON_T_REPLACE + "</span>");
|
2014-04-02 17:18:19 +02:00
|
|
|
} else {
|
|
|
|
String style = "style='color: green;font-weight:normal'";
|
2014-04-03 18:36:55 +02:00
|
|
|
sb.appendHtmlConstant("<span " + style + ">" + value
|
2014-04-02 17:18:19 +02:00
|
|
|
+ "</span>");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-03-18 18:22:39 +01:00
|
|
|
ColumnConfig<ReplaceEntry, String> changeColumn = new ColumnConfig<ReplaceEntry, String>(
|
2014-04-02 17:18:19 +02:00
|
|
|
props.value(), 24);
|
2014-03-17 18:59:08 +01:00
|
|
|
|
2014-03-19 12:52:51 +01:00
|
|
|
ActionButtonCell button = new ActionButtonCell();
|
|
|
|
button.setIcon(ResourceBundle.INSTANCE.magnifier());
|
|
|
|
button.setTitle("Change");
|
2014-03-18 18:22:39 +01:00
|
|
|
button.addSelectHandler(new SelectHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSelect(SelectEvent event) {
|
2014-04-03 18:36:55 +02:00
|
|
|
Log.debug("Button Change Pressed");
|
2014-03-18 18:22:39 +01:00
|
|
|
Context c = event.getContext();
|
2014-04-02 17:18:19 +02:00
|
|
|
int rowIndex = c.getIndex();
|
|
|
|
startReplaceEntry(rowIndex);
|
2014-03-18 18:22:39 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
changeColumn.setCell(button);
|
|
|
|
|
|
|
|
List<ColumnConfig<ReplaceEntry, ?>> l = new ArrayList<ColumnConfig<ReplaceEntry, ?>>();
|
2014-03-17 18:59:08 +01:00
|
|
|
l.add(number);
|
|
|
|
l.add(valueCol);
|
|
|
|
l.add(numberCol);
|
2014-03-18 18:22:39 +01:00
|
|
|
l.add(replacementValueCol);
|
2014-04-02 17:18:19 +02:00
|
|
|
// l.add(replacementIdCol);
|
2014-03-18 18:22:39 +01:00
|
|
|
l.add(changeColumn);
|
|
|
|
ColumnModel<ReplaceEntry> cm = new ColumnModel<ReplaceEntry>(l);
|
2014-03-17 18:59:08 +01:00
|
|
|
|
2014-03-18 18:22:39 +01:00
|
|
|
store = new ListStore<ReplaceEntry>(props.id());
|
2014-04-02 17:18:19 +02:00
|
|
|
|
2014-03-19 15:22:35 +01:00
|
|
|
store.addStoreDataChangeHandler(new StoreDataChangeHandler<ReplaceEntry>() {
|
2014-03-17 18:59:08 +01:00
|
|
|
|
2014-03-19 15:22:35 +01:00
|
|
|
@Override
|
|
|
|
public void onDataChange(StoreDataChangeEvent<ReplaceEntry> event) {
|
|
|
|
updateInfo();
|
2014-04-02 17:18:19 +02:00
|
|
|
|
2014-03-19 15:22:35 +01:00
|
|
|
}
|
2014-04-02 17:18:19 +02:00
|
|
|
|
2014-03-19 15:22:35 +01:00
|
|
|
});
|
2014-04-02 17:18:19 +02:00
|
|
|
|
2014-03-18 18:22:39 +01:00
|
|
|
RpcProxy<ListLoadConfig, ListLoadResult<ReplaceEntry>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<ReplaceEntry>>() {
|
2014-03-17 18:59:08 +01:00
|
|
|
|
|
|
|
public void load(ListLoadConfig loadConfig,
|
2014-03-18 18:22:39 +01:00
|
|
|
final AsyncCallback<ListLoadResult<ReplaceEntry>> callback) {
|
2014-03-17 18:59:08 +01:00
|
|
|
loadData(loadConfig, callback);
|
|
|
|
}
|
|
|
|
};
|
2014-03-18 18:22:39 +01:00
|
|
|
loader = new ListLoader<ListLoadConfig, ListLoadResult<ReplaceEntry>>(
|
2014-03-17 18:59:08 +01:00
|
|
|
proxy);
|
|
|
|
|
|
|
|
loader.setRemoteSort(false);
|
2014-03-18 18:22:39 +01:00
|
|
|
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, ReplaceEntry, ListLoadResult<ReplaceEntry>>(
|
2014-03-17 18:59:08 +01:00
|
|
|
store) {
|
|
|
|
});
|
|
|
|
|
2014-03-18 18:22:39 +01:00
|
|
|
grid = new Grid<ReplaceEntry>(store, cm) {
|
2014-03-17 18:59:08 +01:00
|
|
|
@Override
|
|
|
|
protected void onAfterFirstAttach() {
|
|
|
|
super.onAfterFirstAttach();
|
|
|
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
|
|
|
|
|
|
|
public void execute() {
|
|
|
|
loader.load();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
sm.setSelectionMode(SelectionMode.MULTI);
|
|
|
|
grid.setLoader(loader);
|
|
|
|
grid.setSelectionModel(sm);
|
2014-03-18 18:22:39 +01:00
|
|
|
number.initPlugin(grid);
|
|
|
|
// grid.getView().setAutoExpandColumn(labelCol);
|
|
|
|
// grid.setHeight(360);
|
2014-03-19 16:48:15 +01:00
|
|
|
grid.setHeight("418px");
|
2014-03-17 18:59:08 +01:00
|
|
|
grid.getView().setStripeRows(true);
|
|
|
|
grid.getView().setColumnLines(true);
|
2014-03-18 18:22:39 +01:00
|
|
|
grid.getView().setAutoFill(true);
|
2014-03-17 18:59:08 +01:00
|
|
|
grid.setBorders(false);
|
|
|
|
grid.setLoadMask(true);
|
|
|
|
grid.setColumnReordering(true);
|
2014-03-19 12:52:51 +01:00
|
|
|
grid.setColumnResize(true);
|
|
|
|
grid.getView().setAutoExpandColumn(valueCol);
|
2014-04-02 17:18:19 +02:00
|
|
|
|
|
|
|
info = new HTML("No info");
|
|
|
|
|
2014-03-19 15:22:35 +01:00
|
|
|
ToolBar toolBar = new ToolBar();
|
|
|
|
toolBar.add(info);
|
|
|
|
toolBar.addStyleName(ThemeStyles.getStyle().borderTop());
|
|
|
|
toolBar.getElement().getStyle().setProperty("borderBottom", "none");
|
2014-04-02 17:18:19 +02:00
|
|
|
|
2014-03-19 16:48:15 +01:00
|
|
|
btnApply = new TextButton("Save");
|
|
|
|
btnApply.setIcon(ResourceBundle.INSTANCE.save());
|
|
|
|
btnApply.setIconAlign(IconAlign.RIGHT);
|
|
|
|
btnApply.setTitle("Apply Filter");
|
|
|
|
btnApply.addSelectHandler(new SelectHandler() {
|
|
|
|
|
|
|
|
public void onSelect(SelectEvent event) {
|
|
|
|
Log.debug("Pressed Apply");
|
|
|
|
save();
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
btnClose = new TextButton("Close");
|
|
|
|
btnClose.setIcon(ResourceBundle.INSTANCE.close());
|
|
|
|
btnClose.setIconAlign(IconAlign.RIGHT);
|
|
|
|
btnClose.setTitle("Cancel filter");
|
|
|
|
btnClose.addSelectHandler(new SelectHandler() {
|
|
|
|
|
|
|
|
public void onSelect(SelectEvent event) {
|
|
|
|
Log.debug("Pressed Close");
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
});
|
2014-04-02 17:18:19 +02:00
|
|
|
|
2014-03-19 16:48:15 +01:00
|
|
|
HBoxLayoutContainer flowButton = new HBoxLayoutContainer();
|
|
|
|
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
|
|
|
flowButton.setPack(BoxLayoutPack.CENTER);
|
2014-04-02 17:18:19 +02:00
|
|
|
|
|
|
|
flowButton.add(btnApply, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
|
|
|
flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
|
|
|
|
2014-03-18 18:22:39 +01:00
|
|
|
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
|
|
|
v.add(grid, new VerticalLayoutData(-1, -1, new Margins(0)));
|
2014-04-02 17:18:19 +02:00
|
|
|
v.add(toolBar, new VerticalLayoutData(1, 25, new Margins(0)));
|
|
|
|
v.add(flowButton, new VerticalLayoutData(-1, 36,
|
|
|
|
new Margins(5, 2, 5, 2)));
|
2014-03-18 18:22:39 +01:00
|
|
|
add(v);
|
2014-03-17 18:59:08 +01:00
|
|
|
|
2014-03-18 18:22:39 +01:00
|
|
|
}
|
2014-04-02 17:18:19 +02:00
|
|
|
|
|
|
|
protected void retrieveColumn() {
|
|
|
|
TDGWTServiceAsync.INSTANCE.getColumn(trId, columnName,
|
2014-03-18 18:22:39 +01:00
|
|
|
new AsyncCallback<ColumnData>() {
|
|
|
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
Log.error("load column failure:"
|
|
|
|
+ caught.getLocalizedMessage());
|
|
|
|
UtilsGXT3.alert("Error retrieving column",
|
|
|
|
"Error retrieving column");
|
2014-04-02 17:18:19 +02:00
|
|
|
|
2014-03-18 18:22:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void onSuccess(ColumnData result) {
|
2014-04-02 17:18:19 +02:00
|
|
|
Log.debug("Column: " + result);
|
|
|
|
column = result;
|
2014-03-18 18:22:39 +01:00
|
|
|
create();
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-03-17 18:59:08 +01:00
|
|
|
protected void loadData(ListLoadConfig loadConfig,
|
2014-03-18 18:22:39 +01:00
|
|
|
final AsyncCallback<ListLoadResult<ReplaceEntry>> callback) {
|
|
|
|
|
2014-04-04 12:33:26 +02:00
|
|
|
TDGWTServiceAsync.INSTANCE.getOccurrencesForBatchReplace(column,
|
|
|
|
new AsyncCallback<ArrayList<Occurrences>>() {
|
2014-03-17 18:59:08 +01:00
|
|
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
Log.error("load columns failure:"
|
|
|
|
+ caught.getLocalizedMessage());
|
2014-03-18 18:22:39 +01:00
|
|
|
UtilsGXT3.alert("Error retrieving columns",
|
2014-03-17 18:59:08 +01:00
|
|
|
"Error retrieving columns");
|
|
|
|
callback.onFailure(caught);
|
|
|
|
}
|
|
|
|
|
2014-04-04 12:33:26 +02:00
|
|
|
public void onSuccess(ArrayList<Occurrences> result) {
|
|
|
|
Log.trace("loaded " + result.size() + " Occurrences");
|
|
|
|
ListLoadResultBean<ReplaceEntry> loadedResult=new ListLoadResultBean<ReplaceEntry>(
|
|
|
|
getRecord(result));
|
|
|
|
Log.debug("created "+loadedResult.toString());
|
|
|
|
try {
|
|
|
|
callback.onSuccess(loadedResult);
|
|
|
|
} catch(Throwable e){
|
|
|
|
Log.error("Too many different occurrences");
|
|
|
|
UtilsGXT3.alert("Attention",
|
|
|
|
"Too many different occurrences");
|
|
|
|
}
|
2014-03-17 18:59:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2014-03-18 18:22:39 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void updateInfo() {
|
|
|
|
Log.trace("updating the info bar");
|
|
|
|
int total = store.size();
|
|
|
|
int totalErrors = 0;
|
|
|
|
int assignedErrors = 0;
|
|
|
|
int assigned = 0;
|
|
|
|
for (ReplaceEntry record : store.getAll()) {
|
|
|
|
int errors = record.getNumber();
|
|
|
|
totalErrors += errors;
|
2014-04-02 17:18:19 +02:00
|
|
|
if (record.getReplacementValue() != null
|
|
|
|
&& record.getReplacementValue().compareTo(DON_T_REPLACE) != 0) {
|
2014-03-18 18:22:39 +01:00
|
|
|
assigned++;
|
|
|
|
assignedErrors += errors;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-02 17:18:19 +02:00
|
|
|
String text = Format.substitute(
|
2014-04-04 12:33:26 +02:00
|
|
|
"Assigned {0} ({1} occurrences) of {2} ({3} occurrences)",
|
2014-04-02 17:18:19 +02:00
|
|
|
String.valueOf(assigned), String.valueOf(assignedErrors),
|
|
|
|
String.valueOf(total), String.valueOf(totalErrors));
|
2014-03-19 15:22:35 +01:00
|
|
|
info.setText(text);
|
2014-03-18 18:22:39 +01:00
|
|
|
Log.debug(text);
|
|
|
|
}
|
|
|
|
|
2014-04-04 12:33:26 +02:00
|
|
|
protected ArrayList<ReplaceEntry> getRecord(ArrayList<Occurrences> entries) {
|
2014-03-18 18:22:39 +01:00
|
|
|
ArrayList<ReplaceEntry> records = new ArrayList<ReplaceEntry>();
|
2014-04-04 12:33:26 +02:00
|
|
|
try {
|
|
|
|
for (Occurrences entry : entries)
|
|
|
|
records.add(getRecord(entry));
|
|
|
|
|
|
|
|
} catch (Throwable e) {
|
|
|
|
Log.debug("Error creating records:"+e.getLocalizedMessage());
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2014-03-18 18:22:39 +01:00
|
|
|
return records;
|
2014-04-04 12:33:26 +02:00
|
|
|
|
2014-03-18 18:22:39 +01:00
|
|
|
}
|
|
|
|
|
2014-04-04 12:33:26 +02:00
|
|
|
protected ReplaceEntry getRecord(Occurrences entry) {
|
2014-04-03 18:36:55 +02:00
|
|
|
ReplaceEntry data = null;
|
|
|
|
if (column.isViewColumn()) {
|
|
|
|
data = new ReplaceEntry(entry.getValue(), entry.getRowId(),
|
|
|
|
entry.getNumber(), null, null);
|
|
|
|
} else {
|
|
|
|
data = new ReplaceEntry(entry.getValue(), entry.getNumber(), null,
|
|
|
|
null);
|
|
|
|
}
|
2014-03-18 18:22:39 +01:00
|
|
|
return data;
|
2014-03-17 18:59:08 +01:00
|
|
|
}
|
2014-04-03 18:36:55 +02:00
|
|
|
|
|
|
|
protected void startReplaceEntry(int rowIndex) {
|
|
|
|
currentRowIndex = rowIndex;
|
|
|
|
currentReplaceEntry = store.get(rowIndex);
|
|
|
|
Log.debug(currentReplaceEntry.toString() + " was clicked.[rowIndex="
|
|
|
|
+ currentRowIndex + " ]");
|
|
|
|
if (column.isViewColumn()) {
|
|
|
|
callDimensionRowSelectionDialog();
|
|
|
|
} else {
|
|
|
|
callSingleValueReplaceDialog();
|
|
|
|
}
|
2014-03-19 16:48:15 +01:00
|
|
|
}
|
2014-04-02 17:18:19 +02:00
|
|
|
|
|
|
|
protected void save() {
|
2014-04-04 12:33:26 +02:00
|
|
|
ArrayList<ReplaceEntry> effectiveReplaceList = new ArrayList<ReplaceEntry>();
|
|
|
|
for (ReplaceEntry re : store.getAll()) {
|
|
|
|
if (re.getReplacementValue() != null) {
|
2014-04-03 18:36:55 +02:00
|
|
|
effectiveReplaceList.add(re);
|
|
|
|
}
|
2014-04-04 12:33:26 +02:00
|
|
|
|
2014-04-03 18:36:55 +02:00
|
|
|
}
|
2014-04-04 12:33:26 +02:00
|
|
|
|
|
|
|
if (effectiveReplaceList.size() == 0) {
|
|
|
|
UtilsGXT3
|
|
|
|
.alert("Attention", "Select at least one value to replace");
|
2014-04-03 18:36:55 +02:00
|
|
|
} else {
|
|
|
|
startReplaceBatch(effectiveReplaceList);
|
2014-04-04 12:33:26 +02:00
|
|
|
}
|
2014-04-03 18:36:55 +02:00
|
|
|
}
|
2014-04-04 12:33:26 +02:00
|
|
|
|
|
|
|
protected void startReplaceBatch(
|
|
|
|
ArrayList<ReplaceEntry> effectiveReplaceList) {
|
|
|
|
ReplaceBatchColumnSession replaceBatchColumnSession = new ReplaceBatchColumnSession(
|
|
|
|
trId, column, effectiveReplaceList, column.isViewColumn());
|
2014-04-04 10:28:03 +02:00
|
|
|
parent.startBatchReplace(replaceBatchColumnSession);
|
2014-04-02 17:18:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void close() {
|
2014-03-26 19:10:25 +01:00
|
|
|
parent.close();
|
2014-03-19 16:48:15 +01:00
|
|
|
}
|
2014-04-03 18:36:55 +02:00
|
|
|
|
|
|
|
protected void callSingleValueReplaceDialog() {
|
|
|
|
Log.debug("callSingleValueReplaceDialog");
|
|
|
|
SingleValueReplaceDialog dialogSingleValueReplace = new SingleValueReplaceDialog(
|
|
|
|
currentReplaceEntry.getValue(),
|
|
|
|
currentReplaceEntry.getReplacementValue(), column, eventBus);
|
|
|
|
dialogSingleValueReplace.addListener(this);
|
|
|
|
dialogSingleValueReplace.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void callDimensionRowSelectionDialog() {
|
|
|
|
Log.debug("callDimensionRowSelectionDialog");
|
|
|
|
CellData cellData = new CellData(currentReplaceEntry.getValue(),
|
|
|
|
column.getName(), column.getColumnId(), column.getLabel(),
|
|
|
|
currentReplaceEntry.getRowId(), 0, 0);
|
|
|
|
DimensionRowSelectionDialog dialogDimensionRowSelection = new DimensionRowSelectionDialog(
|
2014-04-02 17:18:19 +02:00
|
|
|
column, cellData, eventBus);
|
|
|
|
dialogDimensionRowSelection.addListener(this);
|
2014-04-03 18:36:55 +02:00
|
|
|
dialogDimensionRowSelection.show();
|
|
|
|
|
2014-04-02 17:18:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void selected(String replaceValue) {
|
2014-04-03 18:36:55 +02:00
|
|
|
Log.debug("Change Value: " + replaceValue);
|
|
|
|
currentReplaceEntry.setReplacementValue(replaceValue);
|
|
|
|
store.update(currentReplaceEntry);
|
|
|
|
updateInfo();
|
2014-04-02 17:18:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void aborted() {
|
2014-04-03 18:36:55 +02:00
|
|
|
Log.debug("Change Value Aborted");
|
|
|
|
|
2014-04-02 17:18:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void failed(String reason, String detail) {
|
2014-04-03 18:36:55 +02:00
|
|
|
Log.error("Change Value Failed:" + reason + " " + detail);
|
|
|
|
|
2014-04-02 17:18:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void selected(DimensionRow dimensionRow) {
|
2014-04-03 18:36:55 +02:00
|
|
|
Log.debug("Change Value: " + dimensionRow);
|
|
|
|
currentReplaceEntry.setReplacementValue(dimensionRow.getValue());
|
|
|
|
currentReplaceEntry.setReplacementDimensionRow(dimensionRow);
|
|
|
|
store.update(currentReplaceEntry);
|
|
|
|
updateInfo();
|
2014-04-02 17:18:19 +02:00
|
|
|
}
|
2014-03-18 18:22:39 +01:00
|
|
|
|
2014-03-17 18:59:08 +01:00
|
|
|
}
|