Updated Batch replace

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-column-widget@94091 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-04-02 15:18:19 +00:00
parent ea7495022d
commit 325883feab
14 changed files with 519 additions and 110 deletions

View File

@ -2344,3 +2344,35 @@ Compiling...
Compilation completed in 0.00 seconds Compilation completed in 0.00 seconds
Removing invalidated units Removing invalidated units
Finding entry point classes Finding entry point classes
Public resources found in...
Translatable source found in...
Found 0 cached/archived units. Used 0 / 2719 units from cache.
Compiling...
30% complete (ETR: 9 seconds)
30% complete (ETR: 9 seconds)
30% complete (ETR: 9 seconds)
30% complete (ETR: 9 seconds)
40% complete (ETR: 8 seconds)
50% complete (ETR: 6 seconds)
60% complete (ETR: 4 seconds)
70% complete (ETR: 3 seconds)
80% complete (ETR: 2 seconds)
90% complete (ETR: 1 seconds)
100% complete (ETR: 0 seconds)
Compilation completed in 15.08 seconds
Removing invalidated units
Finding entry point classes
Public resources found in...
Translatable source found in...
Found 2719 cached/archived units. Used 2719 / 2719 units from cache.
Compiling...
Compilation completed in 0.00 seconds
Removing invalidated units
Finding entry point classes
Public resources found in...
Translatable source found in...
Found 2719 cached/archived units. Used 2719 / 2719 units from cache.
Compiling...
Compilation completed in 0.00 seconds
Removing invalidated units
Finding entry point classes

View File

@ -3,7 +3,7 @@ package org.gcube.portlets.user.td.columnwidget.client;
import java.util.ArrayList; import java.util.ArrayList;
import org.gcube.portlets.user.td.columnwidget.client.dimension.CodelistSelectionListener; import org.gcube.portlets.user.td.columnwidget.client.dimension.CodelistSelectionListener;
import org.gcube.portlets.user.td.columnwidget.client.dimension.DialogCodelistSelection; import org.gcube.portlets.user.td.columnwidget.client.dimension.CodelistSelectionDialog;
import org.gcube.portlets.user.td.columnwidget.client.progress.ChangeColumnTypeProgressDialog; import org.gcube.portlets.user.td.columnwidget.client.progress.ChangeColumnTypeProgressDialog;
import org.gcube.portlets.user.td.columnwidget.client.properties.ColumnDataProperties; import org.gcube.portlets.user.td.columnwidget.client.properties.ColumnDataProperties;
import org.gcube.portlets.user.td.columnwidget.client.properties.ColumnDataTypeProperties; import org.gcube.portlets.user.td.columnwidget.client.properties.ColumnDataTypeProperties;
@ -758,7 +758,7 @@ public class ChangeColumnTypePanel extends FramedPanel implements
protected void callDialogCodelistSelection() { protected void callDialogCodelistSelection() {
DialogCodelistSelection dialogCodelistSelection = new DialogCodelistSelection( CodelistSelectionDialog dialogCodelistSelection = new CodelistSelectionDialog(
eventBus); eventBus);
dialogCodelistSelection.addListener(this); dialogCodelistSelection.addListener(this);
dialogCodelistSelection.show(); dialogCodelistSelection.show();

View File

@ -4,6 +4,9 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.gcube.portlets.user.td.columnwidget.client.custom.ActionButtonCell; import org.gcube.portlets.user.td.columnwidget.client.custom.ActionButtonCell;
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.resources.ResourceBundle; 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.columnwidget.client.utils.UtilsGXT3;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
@ -11,6 +14,8 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurences; import org.gcube.portlets.user.td.gwtservice.shared.tr.batch.Occurences;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.cell.client.AbstractCell;
import com.allen_sauer.gwt.log.client.Log; import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.cell.client.Cell.Context; import com.google.gwt.cell.client.Cell.Context;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
@ -60,7 +65,7 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
*/ */
public class BatchReplacePanel extends FramedPanel { public class BatchReplacePanel extends FramedPanel implements SingleValueReplaceListener, DimensionRowSelectionListener {
protected String WIDTH = "560px"; protected String WIDTH = "560px";
protected String HEIGHT = "520px"; protected String HEIGHT = "520px";
protected EventBus eventBus; protected EventBus eventBus;
@ -75,15 +80,16 @@ public class BatchReplacePanel extends FramedPanel {
private TextButton btnApply; private TextButton btnApply;
private TextButton btnClose; private TextButton btnClose;
protected ListLoader<ListLoadConfig, ListLoadResult<ReplaceEntry>> loader; protected ListLoader<ListLoadConfig, ListLoadResult<ReplaceEntry>> loader;
protected Grid<ReplaceEntry> grid; protected Grid<ReplaceEntry> grid;
protected ListStore<ReplaceEntry> store; protected ListStore<ReplaceEntry> store;
protected HTML info; protected HTML info;
public BatchReplacePanel(BatchReplaceDialog parent, TRId trId, String columnName, EventBus eventBus) { public BatchReplacePanel(BatchReplaceDialog parent, TRId trId,
String columnName, EventBus eventBus) {
this.parent = parent; this.parent = parent;
Log.debug("BatchReplacePanel:["+trId+", columnName:"+columnName+"]"); Log.debug("BatchReplacePanel:[" + trId + ", columnName:" + columnName
+ "]");
setWidth(WIDTH); setWidth(WIDTH);
setHeight(HEIGHT); setHeight(HEIGHT);
setHeaderVisible(false); setHeaderVisible(false);
@ -104,7 +110,8 @@ public class BatchReplacePanel extends FramedPanel {
CheckBoxSelectionModel<ReplaceEntry> sm = new CheckBoxSelectionModel<ReplaceEntry>( CheckBoxSelectionModel<ReplaceEntry> sm = new CheckBoxSelectionModel<ReplaceEntry>(
identity); identity);
RowNumberer<ReplaceEntry> number = new RowNumberer<ReplaceEntry>(identity); RowNumberer<ReplaceEntry> number = new RowNumberer<ReplaceEntry>(
identity);
// number.setFixed(false); // number.setFixed(false);
// number.setResizable(false); // number.setResizable(false);
number.setWidth(50); number.setWidth(50);
@ -122,9 +129,26 @@ public class BatchReplacePanel extends FramedPanel {
props.number(), 100, "Occurences"); props.number(), 100, "Occurences");
ColumnConfig<ReplaceEntry, String> replacementValueCol = new ColumnConfig<ReplaceEntry, String>( ColumnConfig<ReplaceEntry, String> replacementValueCol = new ColumnConfig<ReplaceEntry, String>(
props.replacementValue(), 130, "Replacement"); props.replacementValue(), 130, "Replacement");
/*ColumnConfig<ReplaceEntry, String> replacementIdCol = new ColumnConfig<ReplaceEntry, String>(
props.replacementId()); 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'";
sb.appendHtmlConstant("<span " + style
+">" + DON_T_REPLACE
+ "</span>");
} else {
String style = "style='color: green;font-weight:normal'";
sb.appendHtmlConstant("<span " + style
+">" + value
+ "</span>");
}
}
});
ColumnConfig<ReplaceEntry, String> changeColumn = new ColumnConfig<ReplaceEntry, String>( ColumnConfig<ReplaceEntry, String> changeColumn = new ColumnConfig<ReplaceEntry, String>(
props.value(), 24); props.value(), 24);
@ -136,9 +160,8 @@ public class BatchReplacePanel extends FramedPanel {
@Override @Override
public void onSelect(SelectEvent event) { public void onSelect(SelectEvent event) {
Context c = event.getContext(); Context c = event.getContext();
int row = c.getIndex(); int rowIndex = c.getIndex();
ReplaceEntry re = store.get(row); startReplaceEntry(rowIndex);
Log.debug("ReplaceEntry " + re.toString() + " was clicked.");
} }
}); });
@ -163,10 +186,8 @@ public class BatchReplacePanel extends FramedPanel {
} }
}); });
RpcProxy<ListLoadConfig, ListLoadResult<ReplaceEntry>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<ReplaceEntry>>() { RpcProxy<ListLoadConfig, ListLoadResult<ReplaceEntry>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<ReplaceEntry>>() {
public void load(ListLoadConfig loadConfig, public void load(ListLoadConfig loadConfig,
@ -247,23 +268,18 @@ public class BatchReplacePanel extends FramedPanel {
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE); flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
flowButton.setPack(BoxLayoutPack.CENTER); flowButton.setPack(BoxLayoutPack.CENTER);
flowButton flowButton.add(btnApply, new BoxLayoutData(new Margins(2, 4, 2, 4)));
.add(btnApply, new BoxLayoutData(new Margins(2, 4, 2, 4))); flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4)));
flowButton
.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4)));
VerticalLayoutContainer v = new VerticalLayoutContainer(); VerticalLayoutContainer v = new VerticalLayoutContainer();
v.add(grid, new VerticalLayoutData(-1, -1, new Margins(0))); v.add(grid, new VerticalLayoutData(-1, -1, new Margins(0)));
v.add(toolBar, new VerticalLayoutData(1, 25, new Margins(0))); v.add(toolBar, new VerticalLayoutData(1, 25, new Margins(0)));
v.add(flowButton, new VerticalLayoutData(-1, 36, new Margins( v.add(flowButton, new VerticalLayoutData(-1, 36,
5, 2, 5, 2))); new Margins(5, 2, 5, 2)));
add(v); add(v);
} }
protected void retrieveColumn() { protected void retrieveColumn() {
TDGWTServiceAsync.INSTANCE.getColumn(trId, columnName, TDGWTServiceAsync.INSTANCE.getColumn(trId, columnName,
new AsyncCallback<ColumnData>() { new AsyncCallback<ColumnData>() {
@ -304,7 +320,6 @@ public class BatchReplacePanel extends FramedPanel {
callback.onSuccess(new ListLoadResultBean<ReplaceEntry>( callback.onSuccess(new ListLoadResultBean<ReplaceEntry>(
getRecord(result))); getRecord(result)));
} }
}); });
@ -320,41 +335,35 @@ public class BatchReplacePanel extends FramedPanel {
for (ReplaceEntry record : store.getAll()) { for (ReplaceEntry record : store.getAll()) {
int errors = record.getNumber(); int errors = record.getNumber();
totalErrors += errors; totalErrors += errors;
if (record.getReplacementValue() != null && record.getReplacementValue().compareTo(DON_T_REPLACE)!=0) { if (record.getReplacementValue() != null
&& record.getReplacementValue().compareTo(DON_T_REPLACE) != 0) {
assigned++; assigned++;
assignedErrors += errors; assignedErrors += errors;
} }
} }
String text = Format String text = Format.substitute(
.substitute("Assigned {0} ({1} occurences) of {2} ({3} occurences)", "Assigned {0} ({1} occurences) of {2} ({3} occurences)",
String.valueOf(assigned), String.valueOf(assigned), String.valueOf(assignedErrors),
String.valueOf(assignedErrors), String.valueOf(total), String.valueOf(total), String.valueOf(totalErrors));
String.valueOf(totalErrors));
info.setText(text); info.setText(text);
Log.debug(text); Log.debug(text);
} }
/*public ArrayList<ReplaceEntry> getReplaceEntries() { /*
ArrayList<ReplaceEntry> entries = new ArrayList<ReplaceEntry>(); * public ArrayList<ReplaceEntry> getReplaceEntries() {
for (ReplaceEntry record : store.getAll() { * ArrayList<ReplaceEntry> entries = new ArrayList<ReplaceEntry>(); for
if (record.getAsString(REPLACE_ID_FIELD) != null) { * (ReplaceEntry record : store.getAll() { if
ReplaceEntry entry = new ReplaceEntry( * (record.getAsString(REPLACE_ID_FIELD) != null) { ReplaceEntry entry = new
record.getAsString(ERROR_VALUE_FIELD), * ReplaceEntry( record.getAsString(ERROR_VALUE_FIELD),
record.getAsString(REPLACE_VALUE_FIELD), * record.getAsString(REPLACE_VALUE_FIELD),
record.getAsString(REPLACE_ID_FIELD)); * record.getAsString(REPLACE_ID_FIELD)); entries.add(entry); } } return
entries.add(entry); * entries; }
} *
} * protected void updateEntries(ArrayList<Occurences> entries) {
return entries; * store.clear(); ArrayList<ReplaceEntry> records = getRecord(entries);
} * store.addAll(records); store.commitChanges(); }
*/
protected void updateEntries(ArrayList<Occurences> entries) {
store.clear();
ArrayList<ReplaceEntry> records = getRecord(entries);
store.addAll(records);
store.commitChanges();
}*/
protected ArrayList<ReplaceEntry> getRecord(ArrayList<Occurences> entries) { protected ArrayList<ReplaceEntry> getRecord(ArrayList<Occurences> entries) {
ArrayList<ReplaceEntry> records = new ArrayList<ReplaceEntry>(); ArrayList<ReplaceEntry> records = new ArrayList<ReplaceEntry>();
@ -364,11 +373,17 @@ public class BatchReplacePanel extends FramedPanel {
} }
protected ReplaceEntry getRecord(Occurences entry) { protected ReplaceEntry getRecord(Occurences entry) {
ReplaceEntry data = new ReplaceEntry(entry.getValue(), entry.getNumber(), ReplaceEntry data = new ReplaceEntry(entry.getValue(),
DON_T_REPLACE, null); entry.getNumber(), null, null);
return data; return data;
} }
protected void startReplaceEntry(int rowIndex){
ReplaceEntry re = store.get(rowIndex);
Log.debug("ReplaceEntry " + re.toString() + " was clicked.");
}
protected void save() { protected void save() {
} }
@ -378,4 +393,36 @@ public class BatchReplacePanel extends FramedPanel {
} }
protected void callDialogDimensionRowSelection() {
/*DimensionRowSelectionDialog dialogDimensionRowSelection = new DimensionRowSelectionDialog(
column, cellData, eventBus);
dialogDimensionRowSelection.addListener(this);
dialogDimensionRowSelection.show();*/
}
@Override
public void selected(String replaceValue) {
// TODO Auto-generated method stub
}
@Override
public void aborted() {
// TODO Auto-generated method stub
}
@Override
public void failed(String reason, String detail) {
// TODO Auto-generated method stub
}
@Override
public void selected(DimensionRow dimensionRow) {
// TODO Auto-generated method stub
}
} }

View File

@ -1,23 +1,26 @@
package org.gcube.portlets.user.td.columnwidget.client.batch; package org.gcube.portlets.user.td.columnwidget.client.batch;
import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRow;
class ReplaceEntry { class ReplaceEntry {
protected String value; protected String value;
protected Integer number; protected Integer number;
protected String replacementValue; protected String replacementValue;
protected String replacementId; protected DimensionRow replacementDimensionRow;
/** /**
* @param errorValue * @param errorValue
* @param replacementValue * @param replacementValue
* @param replacementId * @param replacementId
*/ */
public ReplaceEntry(String value, Integer number, String replacementValue, String replacementId) { public ReplaceEntry(String value, Integer number, String replacementValue, DimensionRow replacementDimensionRow) {
this.value = value; this.value = value;
this.number = number; this.number = number;
this.replacementValue = replacementValue; this.replacementValue = replacementValue;
this.replacementId = replacementId; this.replacementDimensionRow = replacementDimensionRow;
} }
public String getValue() { public String getValue() {
@ -44,23 +47,24 @@ class ReplaceEntry {
this.replacementValue = replacementValue; this.replacementValue = replacementValue;
} }
public String getReplacementId() { public DimensionRow getReplacementDimensionRow() {
return replacementId; return replacementDimensionRow;
} }
public void setReplacementId(String replacementId) { public void setReplacementDimensionRow(DimensionRow replacementDimensionRow) {
this.replacementId = replacementId; this.replacementDimensionRow = replacementDimensionRow;
} }
@Override @Override
public String toString() { public String toString() {
return "ReplaceEntry [value=" + value + ", number=" + number return "ReplaceEntry [value=" + value + ", number=" + number
+ ", replacementValue=" + replacementValue + ", replacementId=" + ", replacementValue=" + replacementValue
+ replacementId + "]"; + ", replacementDimensionRow=" + replacementDimensionRow + "]";
} }
} }

View File

@ -22,6 +22,6 @@ public interface ReplaceEntryProperties extends PropertyAccess<ReplaceEntry> {
ValueProvider<ReplaceEntry, String> value(); ValueProvider<ReplaceEntry, String> value();
ValueProvider<ReplaceEntry, Integer> number(); ValueProvider<ReplaceEntry, Integer> number();
ValueProvider<ReplaceEntry, String> replacementValue(); ValueProvider<ReplaceEntry, String> replacementValue();
ValueProvider<ReplaceEntry, String> replacementId(); ValueProvider<ReplaceEntry, String> replacementDimensionRow();
} }

View File

@ -0,0 +1,102 @@
package org.gcube.portlets.user.td.columnwidget.client.batch;
import java.util.ArrayList;
import org.gcube.portlets.user.td.columnwidget.client.resources.ResourceBundle;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.widget.core.client.Window;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class SingleValueReplaceDialog extends Window {
protected String WIDTH = "500px";
protected String HEIGHT = "150px";
protected SingleValueReplacePanel ReplacePanel;
protected EventBus eventBus;
protected String value;
protected ColumnData column;
protected ArrayList<SingleValueReplaceListener> listeners;
public SingleValueReplaceDialog(String value, ColumnData column, EventBus eventBus) {
listeners=new ArrayList<SingleValueReplaceListener>();
this.value=value;
this.column=column;
this.eventBus = eventBus;
initWindow();
create();
}
protected void initWindow() {
setWidth(WIDTH);
setHeight(HEIGHT);
setBodyBorder(false);
setResizable(false);
setHeadingText("Replace Value");
setClosable(true);
getHeader().setIcon(ResourceBundle.INSTANCE.columnValue());
}
/**
* {@inheritDoc}
*/
@Override
protected void initTools() {
super.initTools();
closeBtn.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
close();
}
});
}
protected void create() {
SingleValueReplacePanel replacePanel = new SingleValueReplacePanel(this, value,column,
eventBus);
add(replacePanel);
}
protected void close() {
hide();
}
public void addListener(SingleValueReplaceListener listener) {
listeners.add(listener);
}
public void removeListener(SingleValueReplaceListener listener) {
listeners.remove(listener);
}
public void fireCompleted(String replaceValue) {
for (SingleValueReplaceListener listener : listeners)
listener.selected(replaceValue);
hide();
}
public void fireAborted() {
for (SingleValueReplaceListener listener : listeners)
listener.aborted();
hide();
}
public void fireFailed(String reason, String details) {
for (SingleValueReplaceListener listener : listeners)
listener.failed(reason, details);
hide();
}
}

View File

@ -0,0 +1,29 @@
package org.gcube.portlets.user.td.columnwidget.client.batch;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface SingleValueReplaceListener {
/**
* Called when selected replaceValue without errors
*/
public void selected(String replaceValue);
/**
* Called when the select operation is aborted by the user.
*/
public void aborted();
/**
* Called when the something in the wizard is failed.
*
* @param reason
* @param detail
*/
public void failed(String reason, String detail);
}

View File

@ -0,0 +1,189 @@
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.column.ReplaceColumnSession;
import com.allen_sauer.gwt.log.client.Log;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.FramedPanel;
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;
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.form.FieldLabel;
import com.sencha.gxt.widget.core.client.form.TextField;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class SingleValueReplacePanel extends FramedPanel {
protected String WIDTH = "500px";
protected String HEIGHT = "150px";
protected EventBus eventBus;
protected SingleValueReplaceDialog parent;
protected ColumnData column;
protected String value;
protected DimensionRow dimensionRow;
protected ReplaceColumnSession replaceColumnSession;
private TextField valueField;
private TextField replaceValueField;
private TextButton btnApply;
private TextButton btnClose;
public SingleValueReplacePanel(SingleValueReplaceDialog parent,
String value, ColumnData column, EventBus eventBus) {
this.parent = parent;
this.value = value;
this.eventBus = eventBus;
this.column = column;
dimensionRow = null;
Log.debug("SingleValueReplacePanel:[" + value + "]");
initPanel();
create();
}
protected void initPanel() {
setWidth(WIDTH);
setHeight(HEIGHT);
setHeaderVisible(false);
setBodyBorder(false);
}
protected void create() {
valueField = new TextField();
valueField.setValue(value);
valueField.setReadOnly(true);
replaceValueField = new TextField();
btnApply = new TextButton("Replace");
btnApply.setIcon(ResourceBundle.INSTANCE.replace());
btnApply.setIconAlign(IconAlign.RIGHT);
btnApply.setTitle("Replace Value");
btnApply.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
Log.debug("Pressed Apply");
replaceValue();
}
});
btnClose = new TextButton("Close");
btnClose.setIcon(ResourceBundle.INSTANCE.close());
btnClose.setIconAlign(IconAlign.RIGHT);
btnClose.setTitle("Close");
btnClose.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
Log.debug("Pressed Close");
close();
}
});
HBoxLayoutContainer flowButton = new HBoxLayoutContainer();
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
flowButton.setPack(BoxLayoutPack.CENTER);
flowButton.add(btnApply, new BoxLayoutData(new Margins(2, 4, 2, 4)));
flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4)));
VerticalLayoutContainer v = new VerticalLayoutContainer();
v.add(new FieldLabel(valueField, "Value"),
new VerticalLayoutData(1, -1));
v.add(new FieldLabel(replaceValueField, "Replace"),
new VerticalLayoutData(1, -1));
v.add(flowButton, new VerticalLayoutData(-1, 36,
new Margins(5, 2, 5, 2)));
add(v);
}
protected void replaceValue() {
String rValue = replaceValueField.getCurrentValue();
if (rValue == null || rValue.isEmpty()) {
UtilsGXT3.alert("Attention", "Insert a valid replace value");
} else {
String checkedValue = checkTypeData(rValue);
if (checkedValue != null && !checkedValue.isEmpty()) {
callReplaceValue(rValue);
} else {
UtilsGXT3.alert("Attention",
"Insert a valid replace value for this column");
}
}
}
protected String checkTypeData(String rValue) {
String checked = null;
try {
if (column.getDataTypeName().compareTo("Boolean") == 0) {
Boolean b = new Boolean(rValue);
checked = b.toString();
} else {
if (column.getDataTypeName().compareTo("Date") == 0) {
Date d = Date.valueOf(rValue);
if (d != null) {
checked = rValue;
}
} else {
if (column.getDataTypeName().compareTo("Geometry") == 0) {
checked = rValue;
} else {
if (column.getDataTypeName().compareTo("Integer") == 0) {
Integer in = new Integer(rValue);
checked = in.toString();
} else {
if (column.getDataTypeName().compareTo("Numeric") == 0) {
Float fl = new Float(rValue);
checked = fl.toString();
} else {
if (column.getDataTypeName().compareTo("Text") == 0) {
checked = rValue;
} else {
}
}
}
}
}
}
} catch (Throwable e) {
Log.debug("Error no valid type data: " + e.getLocalizedMessage());
}
return checked;
}
protected void callReplaceValue(String rValue) {
parent.fireCompleted(rValue);
}
protected void close() {
parent.close();
}
}

View File

@ -55,7 +55,7 @@ import com.sencha.gxt.widget.core.client.grid.LiveToolItem;
import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem; import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem;
import com.sencha.gxt.widget.core.client.toolbar.ToolBar; import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
public class DialogCodelistSelection extends Window { public class CodelistSelectionDialog extends Window {
protected static final int WIDTH = 550; protected static final int WIDTH = 550;
protected static final int HEIGHT = 520; protected static final int HEIGHT = 520;
protected static final int CACHE_SIZE = 200; protected static final int CACHE_SIZE = 200;
@ -84,7 +84,7 @@ public class DialogCodelistSelection extends Window {
protected ResourceBundle res; protected ResourceBundle res;
private TextButton select; private TextButton select;
public DialogCodelistSelection(EventBus eventBus) { public CodelistSelectionDialog(EventBus eventBus) {
this.eventBus = eventBus; this.eventBus = eventBus;
Log.info("Dialog CodelistSelection"); Log.info("Dialog CodelistSelection");
setWidth(WIDTH); setWidth(WIDTH);

View File

@ -26,7 +26,7 @@ import com.sencha.gxt.widget.core.client.form.FieldLabel;
import com.sencha.gxt.widget.core.client.form.TextField; import com.sencha.gxt.widget.core.client.form.TextField;
import com.sencha.gxt.widget.core.client.info.Info; import com.sencha.gxt.widget.core.client.info.Info;
public class DialogDimensionRowSelection extends Window { public class DimensionRowSelectionDialog extends Window {
protected static final int WIDTH = 550; protected static final int WIDTH = 550;
protected static final int HEIGHT = 520; protected static final int HEIGHT = 520;
@ -42,7 +42,7 @@ public class DialogDimensionRowSelection extends Window {
private TextField value; private TextField value;
private TextButton select; private TextButton select;
public DialogDimensionRowSelection(ColumnData column, CellData cellData, public DimensionRowSelectionDialog(ColumnData column, CellData cellData,
EventBus eventBus) { EventBus eventBus) {
this.column = column; this.column = column;
this.eventBus = eventBus; this.eventBus = eventBus;

View File

@ -1,9 +1,8 @@
/** /**
* *
*/ */
package org.gcube.portlets.user.td.columnwidget.client.replace; package org.gcube.portlets.user.td.columnwidget.client.dimension;
import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRow;
import com.google.gwt.editor.client.Editor.Path; import com.google.gwt.editor.client.Editor.Path;
import com.sencha.gxt.data.shared.LabelProvider; import com.sencha.gxt.data.shared.LabelProvider;

View File

@ -71,7 +71,7 @@ public class ReplaceColumnProgressUpdater extends Timer {
break; break;
case SUCCEDED: case SUCCEDED:
cancel(); cancel();
Log.info("Import fisnish TableId :" Log.info("ReplaceColumn fisnish:"
+ result.getTrId()); + result.getTrId());
fireOperationComplete(result.getTrId()); fireOperationComplete(result.getTrId());
break; break;

View File

@ -9,6 +9,12 @@ import com.sencha.gxt.widget.core.client.Window;
import com.sencha.gxt.widget.core.client.event.SelectEvent; 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.event.SelectEvent.SelectHandler;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ReplaceDialog extends Window { public class ReplaceDialog extends Window {
protected String WIDTH = "500px"; protected String WIDTH = "500px";
protected String HEIGHT = "150px"; protected String HEIGHT = "150px";
@ -32,7 +38,7 @@ public class ReplaceDialog extends Window {
setHeight(HEIGHT); setHeight(HEIGHT);
setBodyBorder(false); setBodyBorder(false);
setResizable(false); setResizable(false);
setHeadingText("Replace All"); setHeadingText("Replace Value");
setClosable(true); setClosable(true);
getHeader().setIcon(ResourceBundle.INSTANCE.replace()); getHeader().setIcon(ResourceBundle.INSTANCE.replace());

View File

@ -2,9 +2,10 @@ package org.gcube.portlets.user.td.columnwidget.client.replace;
import java.sql.Date; import java.sql.Date;
import org.gcube.portlets.user.td.columnwidget.client.dimension.DialogDimensionRowSelection; 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.DimensionRow;
import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRowSelectionListener; 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; import org.gcube.portlets.user.td.columnwidget.client.progress.ReplaceColumnProgressDialog;
import org.gcube.portlets.user.td.columnwidget.client.resources.ResourceBundle; 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.columnwidget.client.utils.UtilsGXT3;
@ -370,7 +371,7 @@ public class ReplacePanel extends FramedPanel implements
} }
protected void callDialogDimensionRowSelection() { protected void callDialogDimensionRowSelection() {
DialogDimensionRowSelection dialogDimensionRowSelection = new DialogDimensionRowSelection( DimensionRowSelectionDialog dialogDimensionRowSelection = new DimensionRowSelectionDialog(
column, cellData, eventBus); column, cellData, eventBus);
dialogDimensionRowSelection.addListener(this); dialogDimensionRowSelection.addListener(this);
dialogDimensionRowSelection.show(); dialogDimensionRowSelection.show();