Added control over the type of data in ReplacePanel
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-column-widget@93618 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1a405db6d8
commit
76d657bd39
|
@ -2118,3 +2118,35 @@ Compiling...
|
|||
Compilation completed in 0.00 seconds
|
||||
Removing invalidated units
|
||||
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: 8 seconds)
|
||||
30% complete (ETR: 8 seconds)
|
||||
30% complete (ETR: 8 seconds)
|
||||
30% complete (ETR: 8 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 17.79 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
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.gcube.portlets.user.td.columnwidget.client.replace;
|
||||
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
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.utils.UtilsGXT3;
|
||||
|
@ -16,11 +18,11 @@ 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.HBoxLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||
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;
|
||||
|
@ -152,11 +154,89 @@ public class ReplacePanel extends FramedPanel {
|
|||
if (rValue == null || rValue.isEmpty()) {
|
||||
UtilsGXT3.alert("Attention", "Insert a valid replace value");
|
||||
} else {
|
||||
callReplaceValue(rValue);
|
||||
String checkedValue = checkTypeData(rValue);
|
||||
if (checkedValue != null && !checkedValue.isEmpty()) {
|
||||
callReplaceValue(rValue);
|
||||
} else {
|
||||
UtilsGXT3.alert("Attention", "Insert a valid replace value for this column");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected GregorianCalendar convertDate(String date) {
|
||||
int year, month, day, hour, min, sec;
|
||||
GregorianCalendar d = null;
|
||||
switch (date.length()) {
|
||||
case 10:
|
||||
year = Integer.parseInt(date.substring(0, 4));
|
||||
month = Integer.parseInt(date.substring(5, 7));
|
||||
day = Integer.parseInt(date.substring(8, 10));
|
||||
d = new GregorianCalendar(year, month, day);
|
||||
break;
|
||||
case 16:
|
||||
year = Integer.parseInt(date.substring(0, 4));
|
||||
month = Integer.parseInt(date.substring(5, 7));
|
||||
day = Integer.parseInt(date.substring(8, 10));
|
||||
hour = Integer.parseInt(date.substring(11, 13));
|
||||
min = Integer.parseInt(date.substring(14, 16));
|
||||
d = new GregorianCalendar(year, month, day, hour, min);
|
||||
break;
|
||||
case 19:
|
||||
year = Integer.parseInt(date.substring(0, 4));
|
||||
month = Integer.parseInt(date.substring(5, 7));
|
||||
day = Integer.parseInt(date.substring(8, 10));
|
||||
hour = Integer.parseInt(date.substring(11, 13));
|
||||
min = Integer.parseInt(date.substring(14, 16));
|
||||
sec = Integer.parseInt(date.substring(17, 19));
|
||||
d = new GregorianCalendar(year, month, day, hour, min, sec);
|
||||
break;
|
||||
}
|
||||
return d;
|
||||
|
||||
}
|
||||
|
||||
protected String checkTypeData(String rValue) {
|
||||
String checked = null;
|
||||
try {
|
||||
switch (column.getDataTypeName()) {
|
||||
case "Boolean":
|
||||
Boolean b = new Boolean(rValue);
|
||||
checked = b.toString();
|
||||
break;
|
||||
case "Date":
|
||||
GregorianCalendar d = convertDate(rValue);
|
||||
if (d != null) {
|
||||
Long data = d.getTimeInMillis();
|
||||
checked = data.toString();
|
||||
}
|
||||
break;
|
||||
case "Geometry":
|
||||
checked = rValue;
|
||||
break;
|
||||
case "Integer":
|
||||
Integer in = new Integer(rValue);
|
||||
checked = in.toString();
|
||||
break;
|
||||
case "Numeric":
|
||||
Float fl = new Float(rValue);
|
||||
checked = fl.toString();
|
||||
break;
|
||||
case "Text":
|
||||
checked = rValue;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
} catch (Throwable e) {
|
||||
Log.debug("Error no valid type data: " + e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
return checked;
|
||||
|
||||
}
|
||||
|
||||
protected void callReplaceValue(String rValue) {
|
||||
replaceColumnSession = new ReplaceColumnSession(
|
||||
value.getCurrentValue(), rValue, trId, column,
|
||||
|
|
Loading…
Reference in New Issue