Updated Batch Replace
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-column-widget@94272 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ed32f6cf34
commit
723f48b641
|
@ -23,11 +23,9 @@ public class BatchReplaceDialog extends Window {
|
|||
|
||||
|
||||
public BatchReplaceDialog(TRId trId, String columnName, EventBus eventBus) {
|
||||
//getHeader().setIcon(Resources.IMAGES.side_list());
|
||||
this.trId=trId;
|
||||
this.columnName=columnName;
|
||||
initWindow();
|
||||
|
||||
BatchReplacePanel batchRepalcePanel= new BatchReplacePanel(this, trId,columnName,eventBus);
|
||||
add(batchRepalcePanel);
|
||||
}
|
||||
|
@ -63,11 +61,8 @@ public class BatchReplaceDialog extends Window {
|
|||
}
|
||||
|
||||
protected void close (){
|
||||
/*ExpressionEvent expressionEvent = new ExpressionEvent(
|
||||
ExpressionType.EXPRESSIONNULL);
|
||||
//Log.debug(expressionEvent.toString());*/
|
||||
hide();
|
||||
//eventBus.fireEvent(expressionEvent);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,13 +4,16 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.td.columnwidget.client.custom.ActionButtonCell;
|
||||
import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRow;
|
||||
import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRowSelectionDialog;
|
||||
import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRowSelectionListener;
|
||||
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.DimensionRow;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurences;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceEntry;
|
||||
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;
|
||||
|
@ -64,7 +67,8 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
|||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class BatchReplacePanel extends FramedPanel implements SingleValueReplaceListener, DimensionRowSelectionListener {
|
||||
public class BatchReplacePanel extends FramedPanel implements
|
||||
SingleValueReplaceListener, DimensionRowSelectionListener {
|
||||
protected String WIDTH = "560px";
|
||||
protected String HEIGHT = "520px";
|
||||
protected EventBus eventBus;
|
||||
|
@ -73,6 +77,8 @@ public class BatchReplacePanel extends FramedPanel implements SingleValueReplace
|
|||
protected String columnName;
|
||||
protected ColumnData column;
|
||||
protected BatchReplaceDialog parent;
|
||||
private ReplaceEntry currentReplaceEntry;
|
||||
private int currentRowIndex;
|
||||
|
||||
protected static final String DON_T_REPLACE = "Don't replace";
|
||||
|
||||
|
@ -87,22 +93,23 @@ public class BatchReplacePanel extends FramedPanel implements SingleValueReplace
|
|||
public BatchReplacePanel(BatchReplaceDialog parent, TRId trId,
|
||||
String columnName, EventBus eventBus) {
|
||||
this.parent = parent;
|
||||
Log.debug("BatchReplacePanel:[" + trId + ", columnName:" + columnName
|
||||
+ "]");
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
setHeaderVisible(false);
|
||||
setBodyBorder(false);
|
||||
this.trId = trId;
|
||||
this.columnName = columnName;
|
||||
this.eventBus = eventBus;
|
||||
Log.debug("Create BatchReplacePanel(): [" + trId.toString()
|
||||
+ " , columnName:" + columnName + "]");
|
||||
|
||||
init();
|
||||
retrieveColumn();
|
||||
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
setHeaderVisible(false);
|
||||
setBodyBorder(false);
|
||||
}
|
||||
|
||||
protected void create() {
|
||||
|
||||
IdentityValueProvider<ReplaceEntry> identity = new IdentityValueProvider<ReplaceEntry>();
|
||||
|
@ -135,13 +142,11 @@ public class BatchReplacePanel extends FramedPanel implements SingleValueReplace
|
|||
public void render(Context context, String value, SafeHtmlBuilder sb) {
|
||||
if (value == null) {
|
||||
String style = "style='color: black;font-weight:bold'";
|
||||
sb.appendHtmlConstant("<span " + style
|
||||
+">" + DON_T_REPLACE
|
||||
+ "</span>");
|
||||
sb.appendHtmlConstant("<span " + style + ">"
|
||||
+ DON_T_REPLACE + "</span>");
|
||||
} else {
|
||||
String style = "style='color: green;font-weight:normal'";
|
||||
sb.appendHtmlConstant("<span " + style
|
||||
+">" + value
|
||||
sb.appendHtmlConstant("<span " + style + ">" + value
|
||||
+ "</span>");
|
||||
}
|
||||
|
||||
|
@ -158,6 +163,7 @@ public class BatchReplacePanel extends FramedPanel implements SingleValueReplace
|
|||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.debug("Button Change Pressed");
|
||||
Context c = event.getContext();
|
||||
int rowIndex = c.getIndex();
|
||||
startReplaceEntry(rowIndex);
|
||||
|
@ -372,56 +378,124 @@ public class BatchReplacePanel extends FramedPanel implements SingleValueReplace
|
|||
}
|
||||
|
||||
protected ReplaceEntry getRecord(Occurences entry) {
|
||||
ReplaceEntry data = new ReplaceEntry(entry.getValue(),
|
||||
entry.getNumber(), null, null);
|
||||
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);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
protected void startReplaceEntry(int rowIndex){
|
||||
ReplaceEntry re = store.get(rowIndex);
|
||||
Log.debug("ReplaceEntry " + re.toString() + " was clicked.");
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void save() {
|
||||
|
||||
ArrayList<ReplaceEntry> effectiveReplaceList=new ArrayList<ReplaceEntry>();
|
||||
for(ReplaceEntry re:store.getAll()){
|
||||
if(re.getReplacementValue()!=null){
|
||||
effectiveReplaceList.add(re);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(effectiveReplaceList.size()==0){
|
||||
UtilsGXT3.alert("Attention",
|
||||
"Select at least one value to replace");
|
||||
} else {
|
||||
startReplaceBatch(effectiveReplaceList);
|
||||
}
|
||||
}
|
||||
|
||||
protected void startReplaceBatch(ArrayList<ReplaceEntry> effectiveReplaceList){
|
||||
/*
|
||||
|
||||
TDGWTServiceAsync.INSTANCE.startReplaceBatch(column,
|
||||
new AsyncCallback<ArrayList<Occurences>>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
Log.error("load columns failure:"
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error retrieving columns",
|
||||
"Error retrieving columns");
|
||||
callback.onFailure(caught);
|
||||
}
|
||||
|
||||
public void onSuccess(ArrayList<Occurences> result) {
|
||||
Log.trace("loaded " + result.size() + " Occurences");
|
||||
callback.onSuccess(new ListLoadResultBean<ReplaceEntry>(
|
||||
getRecord(result)));
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
protected void close() {
|
||||
parent.close();
|
||||
}
|
||||
|
||||
|
||||
protected void callDialogDimensionRowSelection() {
|
||||
/*DimensionRowSelectionDialog dialogDimensionRowSelection = new DimensionRowSelectionDialog(
|
||||
|
||||
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(
|
||||
column, cellData, eventBus);
|
||||
dialogDimensionRowSelection.addListener(this);
|
||||
dialogDimensionRowSelection.show();*/
|
||||
dialogDimensionRowSelection.show();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void selected(String replaceValue) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
Log.debug("Change Value: " + replaceValue);
|
||||
currentReplaceEntry.setReplacementValue(replaceValue);
|
||||
store.update(currentReplaceEntry);
|
||||
updateInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void aborted() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
Log.debug("Change Value Aborted");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(String reason, String detail) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
Log.error("Change Value Failed:" + reason + " " + detail);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selected(DimensionRow dimensionRow) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
Log.debug("Change Value: " + dimensionRow);
|
||||
currentReplaceEntry.setReplacementValue(dimensionRow.getValue());
|
||||
currentReplaceEntry.setReplacementDimensionRow(dimensionRow);
|
||||
store.update(currentReplaceEntry);
|
||||
updateInfo();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
package org.gcube.portlets.user.td.columnwidget.client.batch;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRow;
|
||||
|
||||
|
||||
public class ReplaceEntry implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1630393311734647924L;
|
||||
|
||||
protected String value;
|
||||
protected Integer number;
|
||||
protected String replacementValue;
|
||||
protected DimensionRow replacementDimensionRow;
|
||||
|
||||
public ReplaceEntry(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param errorValue
|
||||
* @param replacementValue
|
||||
* @param replacementId
|
||||
*/
|
||||
public ReplaceEntry(String value, Integer number, String replacementValue, DimensionRow replacementDimensionRow) {
|
||||
this.value = value;
|
||||
this.number = number;
|
||||
this.replacementValue = replacementValue;
|
||||
this.replacementDimensionRow = replacementDimensionRow;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Integer getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public void setNumber(Integer number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
public String getReplacementValue() {
|
||||
return replacementValue;
|
||||
}
|
||||
|
||||
public void setReplacementValue(String replacementValue) {
|
||||
this.replacementValue = replacementValue;
|
||||
}
|
||||
|
||||
public DimensionRow getReplacementDimensionRow() {
|
||||
return replacementDimensionRow;
|
||||
}
|
||||
|
||||
public void setReplacementDimensionRow(DimensionRow replacementDimensionRow) {
|
||||
this.replacementDimensionRow = replacementDimensionRow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ReplaceEntry [value=" + value + ", number=" + number
|
||||
+ ", replacementValue=" + replacementValue
|
||||
+ ", replacementDimensionRow=" + replacementDimensionRow + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -3,7 +3,8 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.td.columnwidget.client.batch;
|
||||
|
||||
import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRow;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.DimensionRow;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.ReplaceEntry;
|
||||
|
||||
import com.google.gwt.editor.client.Editor.Path;
|
||||
import com.sencha.gxt.core.client.ValueProvider;
|
||||
|
|
|
@ -22,13 +22,15 @@ public class SingleValueReplaceDialog extends Window {
|
|||
protected SingleValueReplacePanel ReplacePanel;
|
||||
protected EventBus eventBus;
|
||||
protected String value;
|
||||
protected String replaceValue;
|
||||
protected ColumnData column;
|
||||
protected ArrayList<SingleValueReplaceListener> listeners;
|
||||
|
||||
|
||||
public SingleValueReplaceDialog(String value, ColumnData column, EventBus eventBus) {
|
||||
public SingleValueReplaceDialog(String value, String replaceValue, ColumnData column, EventBus eventBus) {
|
||||
listeners=new ArrayList<SingleValueReplaceListener>();
|
||||
this.value=value;
|
||||
this.replaceValue=replaceValue;
|
||||
this.column=column;
|
||||
this.eventBus = eventBus;
|
||||
initWindow();
|
||||
|
@ -64,7 +66,7 @@ public class SingleValueReplaceDialog extends Window {
|
|||
}
|
||||
|
||||
protected void create() {
|
||||
SingleValueReplacePanel replacePanel = new SingleValueReplacePanel(this, value,column,
|
||||
SingleValueReplacePanel replacePanel = new SingleValueReplacePanel(this, value, replaceValue,column,
|
||||
eventBus);
|
||||
add(replacePanel);
|
||||
}
|
||||
|
|
|
@ -2,10 +2,10 @@ package org.gcube.portlets.user.td.columnwidget.client.batch;
|
|||
|
||||
import java.sql.Date;
|
||||
|
||||
import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRow;
|
||||
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.shared.tr.ColumnData;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.DimensionRow;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnSession;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
@ -38,6 +38,7 @@ public class SingleValueReplacePanel extends FramedPanel {
|
|||
protected SingleValueReplaceDialog parent;
|
||||
protected ColumnData column;
|
||||
protected String value;
|
||||
protected String replaceValue;
|
||||
protected DimensionRow dimensionRow;
|
||||
|
||||
protected ReplaceColumnSession replaceColumnSession;
|
||||
|
@ -48,9 +49,10 @@ public class SingleValueReplacePanel extends FramedPanel {
|
|||
private TextButton btnClose;
|
||||
|
||||
public SingleValueReplacePanel(SingleValueReplaceDialog parent,
|
||||
String value, ColumnData column, EventBus eventBus) {
|
||||
String value, String replaceValue,ColumnData column, EventBus eventBus) {
|
||||
this.parent = parent;
|
||||
this.value = value;
|
||||
this.replaceValue=replaceValue;
|
||||
this.eventBus = eventBus;
|
||||
this.column = column;
|
||||
dimensionRow = null;
|
||||
|
@ -73,6 +75,9 @@ public class SingleValueReplacePanel extends FramedPanel {
|
|||
valueField.setReadOnly(true);
|
||||
|
||||
replaceValueField = new TextField();
|
||||
if(replaceValue!=null){
|
||||
valueField.setValue(replaceValue);
|
||||
}
|
||||
|
||||
btnApply = new TextButton("Replace");
|
||||
btnApply.setIcon(ResourceBundle.INSTANCE.replace());
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
package org.gcube.portlets.user.td.columnwidget.client.dimension;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class DimensionRow implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4220185160420435932L;
|
||||
|
||||
|
||||
protected String rowId;
|
||||
protected String value;
|
||||
|
||||
public DimensionRow(){
|
||||
|
||||
}
|
||||
|
||||
public DimensionRow(String rowId, String value){
|
||||
this.rowId=rowId;
|
||||
this.value=value;
|
||||
}
|
||||
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getRowId() {
|
||||
return rowId;
|
||||
}
|
||||
|
||||
public void setRowId(String rowId) {
|
||||
this.rowId = rowId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DimensionRow [rowId=" + rowId + ", value=" + value + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||
import org.gcube.portlets.user.td.columnwidget.client.utils.Constants;
|
||||
import org.gcube.portlets.user.td.columnwidget.client.utils.UtilsGXT3;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.DimensionRow;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.CellData;
|
||||
import org.gcube.portlets.user.tdwx.client.TabularDataX;
|
||||
import org.gcube.portlets.user.tdwx.client.TabularDataXGridPanel;
|
||||
|
@ -52,6 +53,9 @@ public class DimensionRowSelectionDialog extends Window {
|
|||
create();
|
||||
open();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected void create() {
|
||||
final FramedPanel panel = new FramedPanel();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.gcube.portlets.user.td.columnwidget.client.dimension;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.DimensionRow;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
package org.gcube.portlets.user.td.columnwidget.client.dimension;
|
||||
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.DimensionRow;
|
||||
|
||||
import com.google.gwt.editor.client.Editor.Path;
|
||||
import com.sencha.gxt.data.shared.LabelProvider;
|
||||
import com.sencha.gxt.data.shared.ModelKeyProvider;
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.gcube.portlets.user.td.columnwidget.client.replace;
|
|||
import java.sql.Date;
|
||||
|
||||
import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRowSelectionDialog;
|
||||
import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRow;
|
||||
import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRowSelectionListener;
|
||||
import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRowsProperties;
|
||||
import org.gcube.portlets.user.td.columnwidget.client.progress.ReplaceColumnProgressDialog;
|
||||
|
@ -11,6 +10,7 @@ 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.DimensionRow;
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue