2014-03-26 19:10:25 +01:00
|
|
|
package org.gcube.portlets.user.td.columnwidget.client.replace;
|
|
|
|
|
2014-05-13 17:33:14 +02:00
|
|
|
import java.util.Date;
|
2014-03-27 10:54:31 +01:00
|
|
|
|
2014-04-02 17:18:19 +02:00
|
|
|
import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRowSelectionDialog;
|
2014-03-27 17:56:46 +01:00
|
|
|
import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRowSelectionListener;
|
2014-04-02 17:18:19 +02:00
|
|
|
import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRowsProperties;
|
2014-03-26 19:10:25 +01:00
|
|
|
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;
|
2014-09-26 12:20:11 +02:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFinalException;
|
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
|
2014-05-16 12:24:29 +02:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
2014-03-26 19:10:25 +01:00
|
|
|
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-03-26 19:10:25 +01:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnSession;
|
2014-08-26 19:11:11 +02:00
|
|
|
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
|
|
|
|
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
|
|
|
|
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
|
2014-05-16 12:24:29 +02:00
|
|
|
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
2014-08-26 19:11:11 +02:00
|
|
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
|
|
|
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy;
|
2014-05-16 12:24:29 +02:00
|
|
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
2014-03-26 19:10:25 +01:00
|
|
|
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;
|
2014-03-27 17:56:46 +01:00
|
|
|
import com.google.gwt.core.client.GWT;
|
2014-05-13 17:33:14 +02:00
|
|
|
import com.google.gwt.i18n.client.DateTimeFormat;
|
2014-03-26 19:10:25 +01:00
|
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
|
|
import com.google.web.bindery.event.shared.EventBus;
|
|
|
|
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
|
2014-03-27 17:56:46 +01:00
|
|
|
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
|
2014-03-26 19:10:25 +01:00
|
|
|
import com.sencha.gxt.core.client.util.Margins;
|
2014-03-27 17:56:46 +01:00
|
|
|
import com.sencha.gxt.data.shared.LabelProvider;
|
|
|
|
import com.sencha.gxt.data.shared.ListStore;
|
2014-03-26 19:10:25 +01:00
|
|
|
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;
|
2014-03-27 10:54:31 +01:00
|
|
|
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
|
2014-03-26 19:10:25 +01:00
|
|
|
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer.HBoxLayoutAlign;
|
2014-03-27 10:54:31 +01:00
|
|
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
2014-03-26 19:10:25 +01:00
|
|
|
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-27 17:56:46 +01:00
|
|
|
import com.sencha.gxt.widget.core.client.event.TriggerClickEvent;
|
|
|
|
import com.sencha.gxt.widget.core.client.event.TriggerClickEvent.TriggerClickHandler;
|
|
|
|
import com.sencha.gxt.widget.core.client.form.ComboBox;
|
2014-05-13 17:33:14 +02:00
|
|
|
import com.sencha.gxt.widget.core.client.form.DateField;
|
2014-03-26 19:10:25 +01:00
|
|
|
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>
|
|
|
|
*
|
|
|
|
*/
|
2014-03-27 17:56:46 +01:00
|
|
|
public class ReplacePanel extends FramedPanel implements
|
2014-09-26 12:20:11 +02:00
|
|
|
DimensionRowSelectionListener, MonitorDialogListener {
|
2014-06-03 15:01:41 +02:00
|
|
|
private DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd");
|
2014-09-26 12:20:11 +02:00
|
|
|
|
2014-03-26 19:10:25 +01:00
|
|
|
protected String WIDTH = "500px";
|
|
|
|
protected String HEIGHT = "150px";
|
|
|
|
protected EventBus eventBus;
|
|
|
|
protected TRId trId;
|
|
|
|
protected CellData cellData;
|
|
|
|
protected ReplaceDialog parent;
|
|
|
|
protected ColumnData column;
|
2014-05-16 12:24:29 +02:00
|
|
|
|
2014-03-27 18:26:24 +01:00
|
|
|
protected DimensionRow dimensionRow;
|
2014-05-16 12:24:29 +02:00
|
|
|
|
2014-03-26 19:10:25 +01:00
|
|
|
protected ReplaceColumnSession replaceColumnSession;
|
2014-03-27 17:56:46 +01:00
|
|
|
private ComboBox<DimensionRow> comboDimensionType;
|
|
|
|
private FieldLabel comboDimensionTypeLabel;
|
2014-03-26 19:10:25 +01:00
|
|
|
|
|
|
|
private TextField value;
|
2014-05-13 17:33:14 +02:00
|
|
|
private DateField valueDate;
|
2014-03-26 19:10:25 +01:00
|
|
|
private TextField replaceValue;
|
2014-05-13 17:33:14 +02:00
|
|
|
private DateField replaceValueDate;
|
2014-03-26 19:10:25 +01:00
|
|
|
private TextButton btnApply;
|
|
|
|
private TextButton btnClose;
|
2014-03-27 17:56:46 +01:00
|
|
|
private boolean isDimension;
|
2014-03-26 19:10:25 +01:00
|
|
|
|
|
|
|
public ReplacePanel(ReplaceDialog parent, TRId trId, CellData cellData,
|
|
|
|
EventBus eventBus) {
|
|
|
|
this.parent = parent;
|
|
|
|
this.cellData = cellData;
|
|
|
|
this.trId = trId;
|
|
|
|
this.eventBus = eventBus;
|
2014-05-16 12:24:29 +02:00
|
|
|
dimensionRow = null;
|
2014-03-26 19:10:25 +01:00
|
|
|
Log.debug("ReplacePanel:[" + trId + ", CellData:" + cellData + "]");
|
|
|
|
initPanel();
|
|
|
|
retrieveColumn();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void initPanel() {
|
|
|
|
setWidth(WIDTH);
|
|
|
|
setHeight(HEIGHT);
|
|
|
|
setHeaderVisible(false);
|
|
|
|
setBodyBorder(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void retrieveColumn() {
|
|
|
|
TDGWTServiceAsync.INSTANCE.getColumn(trId, cellData.getColumnName(),
|
|
|
|
new AsyncCallback<ColumnData>() {
|
|
|
|
|
|
|
|
public void onFailure(Throwable caught) {
|
2014-05-16 12:24:29 +02:00
|
|
|
if (caught instanceof TDGWTSessionExpiredException) {
|
|
|
|
eventBus.fireEvent(new SessionExpiredEvent(
|
|
|
|
SessionExpiredType.EXPIREDONSERVER));
|
|
|
|
} else {
|
2014-09-26 12:20:11 +02:00
|
|
|
if (caught instanceof TDGWTIsLockedException) {
|
|
|
|
Log.error(caught.getLocalizedMessage());
|
|
|
|
UtilsGXT3.alert("Error Locked",
|
|
|
|
caught.getLocalizedMessage());
|
|
|
|
} else {
|
|
|
|
if (caught instanceof TDGWTIsFinalException) {
|
|
|
|
Log.error(caught.getLocalizedMessage());
|
|
|
|
UtilsGXT3.alert("Error Final",
|
|
|
|
caught.getLocalizedMessage());
|
|
|
|
} else {
|
|
|
|
Log.error("Error retrieving column: "
|
|
|
|
+ caught.getMessage());
|
|
|
|
UtilsGXT3.alert("Error retrieving column",
|
|
|
|
caught.getMessage());
|
|
|
|
}
|
|
|
|
}
|
2014-05-16 12:24:29 +02:00
|
|
|
}
|
2014-03-26 19:10:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void onSuccess(ColumnData result) {
|
|
|
|
Log.debug("Retrived column: " + result);
|
2014-03-27 17:56:46 +01:00
|
|
|
column = result;
|
2014-05-16 12:24:29 +02:00
|
|
|
|
|
|
|
if (result.isViewColumn()) {
|
|
|
|
isDimension = true;
|
2014-03-27 17:56:46 +01:00
|
|
|
createForDimension();
|
2014-03-26 19:10:25 +01:00
|
|
|
} else {
|
2014-05-16 12:24:29 +02:00
|
|
|
isDimension = false;
|
2014-03-26 19:10:25 +01:00
|
|
|
create();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void create() {
|
2014-05-16 12:24:29 +02:00
|
|
|
if (column.getDataTypeName().compareTo("Date") == 0) {
|
2014-05-13 17:33:14 +02:00
|
|
|
valueDate = new DateField();
|
|
|
|
Date d = null;
|
2014-05-16 12:24:29 +02:00
|
|
|
Log.debug("Date value: " + cellData.getValue());
|
2014-05-13 17:33:14 +02:00
|
|
|
try {
|
|
|
|
d = sdf.parse(cellData.getValue());
|
|
|
|
} catch (Exception e) {
|
|
|
|
Log.error("Unparseable using " + sdf);
|
|
|
|
}
|
2014-05-16 12:24:29 +02:00
|
|
|
if (d != null) {
|
2014-05-13 17:33:14 +02:00
|
|
|
valueDate.setValue(d);
|
|
|
|
}
|
|
|
|
valueDate.setReadOnly(true);
|
2014-03-26 19:10:25 +01:00
|
|
|
|
2014-05-13 17:33:14 +02:00
|
|
|
replaceValueDate = new DateField();
|
2014-05-16 12:24:29 +02:00
|
|
|
|
2014-05-13 17:33:14 +02:00
|
|
|
} else {
|
|
|
|
value = new TextField();
|
|
|
|
value.setValue(cellData.getValue());
|
|
|
|
value.setReadOnly(true);
|
2014-03-26 19:10:25 +01:00
|
|
|
|
2014-05-13 17:33:14 +02:00
|
|
|
replaceValue = new TextField();
|
|
|
|
}
|
2014-05-16 12:24:29 +02:00
|
|
|
|
2014-03-26 19:10:25 +01:00
|
|
|
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);
|
2014-12-05 17:48:51 +01:00
|
|
|
|
|
|
|
BoxLayoutData boxLayoutData=new BoxLayoutData(new Margins(2, 4, 2, 4));
|
|
|
|
|
|
|
|
flowButton.add(btnApply, boxLayoutData);
|
|
|
|
flowButton.add(btnClose, boxLayoutData);
|
2014-03-26 19:10:25 +01:00
|
|
|
|
|
|
|
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
2014-05-16 12:24:29 +02:00
|
|
|
if (column.getDataTypeName().compareTo("Date") == 0) {
|
|
|
|
v.add(new FieldLabel(valueDate, "Value"), new VerticalLayoutData(1,
|
|
|
|
-1));
|
|
|
|
v.add(new FieldLabel(replaceValueDate, "Replace"),
|
|
|
|
new VerticalLayoutData(1, -1));
|
2014-05-13 17:33:14 +02:00
|
|
|
} else {
|
|
|
|
v.add(new FieldLabel(value, "Value"), new VerticalLayoutData(1, -1));
|
2014-05-16 12:24:29 +02:00
|
|
|
v.add(new FieldLabel(replaceValue, "Replace"),
|
|
|
|
new VerticalLayoutData(1, -1));
|
2014-05-13 17:33:14 +02:00
|
|
|
}
|
2014-12-05 17:48:51 +01:00
|
|
|
v.add(flowButton, new VerticalLayoutData(1, 36,
|
2014-03-26 19:10:25 +01:00
|
|
|
new Margins(5, 2, 5, 2)));
|
|
|
|
add(v);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-03-27 17:56:46 +01:00
|
|
|
protected void createForDimension() {
|
|
|
|
value = new TextField();
|
|
|
|
value.setValue(cellData.getValue());
|
|
|
|
value.setReadOnly(true);
|
|
|
|
|
|
|
|
// comboDimensionType
|
|
|
|
DimensionRowsProperties propsDimensionType = GWT
|
|
|
|
.create(DimensionRowsProperties.class);
|
|
|
|
ListStore<DimensionRow> storeComboDimensionType = new ListStore<DimensionRow>(
|
|
|
|
propsDimensionType.rowId());
|
|
|
|
|
|
|
|
comboDimensionType = new ComboBox<DimensionRow>(
|
|
|
|
storeComboDimensionType, propsDimensionType.value());
|
|
|
|
|
|
|
|
Log.trace("ComboDimensionType created");
|
|
|
|
|
|
|
|
addHandlersForComboDimensionType(propsDimensionType.value());
|
|
|
|
|
|
|
|
comboDimensionType.setEmptyText("Select a Value...");
|
|
|
|
comboDimensionType.setWidth(300);
|
|
|
|
comboDimensionType.setEditable(false);
|
|
|
|
comboDimensionType.setTriggerAction(TriggerAction.ALL);
|
|
|
|
|
|
|
|
comboDimensionTypeLabel = new FieldLabel(comboDimensionType, "Replace");
|
|
|
|
|
|
|
|
//
|
|
|
|
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) {
|
2014-03-27 18:26:24 +01:00
|
|
|
Log.debug("Pressed Apply For Dimension");
|
2014-03-27 17:56:46 +01:00
|
|
|
replaceValueForDimension();
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
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) {
|
2014-03-27 18:26:24 +01:00
|
|
|
Log.debug("Pressed Close For Dimension");
|
2014-03-27 17:56:46 +01:00
|
|
|
close();
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
HBoxLayoutContainer flowButton = new HBoxLayoutContainer();
|
|
|
|
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
|
|
|
flowButton.setPack(BoxLayoutPack.CENTER);
|
2014-12-05 17:48:51 +01:00
|
|
|
|
|
|
|
BoxLayoutData boxLayoutData=new BoxLayoutData(new Margins(2, 4, 2, 4));
|
|
|
|
flowButton.add(btnApply, boxLayoutData);
|
|
|
|
flowButton.add(btnClose, boxLayoutData);
|
2014-03-27 17:56:46 +01:00
|
|
|
|
|
|
|
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
|
|
|
v.add(new FieldLabel(value, "Value"), new VerticalLayoutData(1, -1));
|
|
|
|
v.add(comboDimensionTypeLabel, new VerticalLayoutData(1, -1));
|
2014-12-05 17:48:51 +01:00
|
|
|
v.add(flowButton, new VerticalLayoutData(1, 36,
|
2014-03-27 17:56:46 +01:00
|
|
|
new Margins(5, 2, 5, 2)));
|
|
|
|
add(v);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-03-26 19:10:25 +01:00
|
|
|
protected void replaceValue() {
|
2014-05-13 17:33:14 +02:00
|
|
|
String rValue;
|
2014-05-16 12:24:29 +02:00
|
|
|
|
|
|
|
if (column.getDataTypeName().compareTo("Date") == 0) {
|
|
|
|
Date d = replaceValueDate.getCurrentValue();
|
|
|
|
if (d == null) {
|
2014-05-13 17:33:14 +02:00
|
|
|
UtilsGXT3.alert("Attention", "Insert a valid replace value");
|
|
|
|
return;
|
2014-05-16 12:24:29 +02:00
|
|
|
} else {
|
2014-06-03 15:01:41 +02:00
|
|
|
String dateS = sdf.format(d);
|
|
|
|
rValue = dateS;
|
2014-05-13 17:33:14 +02:00
|
|
|
}
|
2014-05-16 12:24:29 +02:00
|
|
|
|
2014-03-26 19:10:25 +01:00
|
|
|
} else {
|
2014-05-13 17:33:14 +02:00
|
|
|
rValue = replaceValue.getCurrentValue();
|
2014-07-11 14:25:41 +02:00
|
|
|
if (rValue == null) {
|
2014-05-13 17:33:14 +02:00
|
|
|
UtilsGXT3.alert("Attention", "Insert a valid replace value");
|
|
|
|
return;
|
2014-03-27 10:54:31 +01:00
|
|
|
} else {
|
2014-05-13 17:33:14 +02:00
|
|
|
String checkedValue = checkTypeData(rValue);
|
|
|
|
if (checkedValue == null || checkedValue.isEmpty()) {
|
|
|
|
UtilsGXT3.alert("Attention",
|
2014-05-16 12:24:29 +02:00
|
|
|
"Insert a valid replace value for this column");
|
2014-05-13 17:33:14 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-05-16 12:24:29 +02:00
|
|
|
}
|
2014-03-27 11:21:24 +01:00
|
|
|
}
|
2014-05-13 17:33:14 +02:00
|
|
|
callReplaceValue(rValue);
|
2014-05-16 12:24:29 +02:00
|
|
|
|
2014-03-26 19:10:25 +01:00
|
|
|
}
|
|
|
|
|
2014-03-27 17:56:46 +01:00
|
|
|
protected void replaceValueForDimension() {
|
2014-05-16 12:24:29 +02:00
|
|
|
Log.debug("Current Dimension Row in combo: " + dimensionRow);
|
2014-03-27 18:26:24 +01:00
|
|
|
if (dimensionRow == null) {
|
2014-03-27 17:56:46 +01:00
|
|
|
UtilsGXT3.alert("Attention", "Select a valid value");
|
|
|
|
} else {
|
2014-03-27 18:26:24 +01:00
|
|
|
callReplaceValue(dimensionRow.getRowId());
|
2014-03-27 17:56:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-03-27 10:54:31 +01:00
|
|
|
protected String checkTypeData(String rValue) {
|
|
|
|
String checked = null;
|
|
|
|
try {
|
2014-03-27 11:21:24 +01:00
|
|
|
if (column.getDataTypeName().compareTo("Boolean") == 0) {
|
2014-03-27 10:54:31 +01:00
|
|
|
Boolean b = new Boolean(rValue);
|
|
|
|
checked = b.toString();
|
2014-03-27 11:21:24 +01:00
|
|
|
} else {
|
|
|
|
if (column.getDataTypeName().compareTo("Date") == 0) {
|
2014-05-13 17:33:14 +02:00
|
|
|
Date d = null;
|
|
|
|
try {
|
|
|
|
d = sdf.parse(value.getValue());
|
|
|
|
} catch (Exception e) {
|
|
|
|
Log.error("Unparseable using " + sdf);
|
|
|
|
return null;
|
|
|
|
}
|
2014-03-27 11:21:24 +01:00
|
|
|
if (d != null) {
|
2014-06-03 15:01:41 +02:00
|
|
|
String dateS = sdf.format(d);
|
|
|
|
checked = dateS;
|
2014-09-26 12:20:11 +02:00
|
|
|
|
2014-03-27 11:21:24 +01:00
|
|
|
}
|
|
|
|
} 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 {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-03-27 10:54:31 +01:00
|
|
|
}
|
2014-03-27 11:21:24 +01:00
|
|
|
|
2014-03-27 10:54:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Throwable e) {
|
|
|
|
Log.debug("Error no valid type data: " + e.getLocalizedMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
return checked;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-03-26 19:10:25 +01:00
|
|
|
protected void callReplaceValue(String rValue) {
|
2014-05-16 12:24:29 +02:00
|
|
|
Log.debug("callRepalceValue is Dimension: " + isDimension);
|
2014-03-27 17:56:46 +01:00
|
|
|
if (isDimension) {
|
|
|
|
replaceColumnSession = new ReplaceColumnSession(
|
|
|
|
value.getCurrentValue(), rValue, trId, column,
|
|
|
|
cellData.getRowId(), true);
|
|
|
|
Log.debug(replaceColumnSession.toString());
|
|
|
|
} else {
|
2014-03-26 19:10:25 +01:00
|
|
|
|
2014-03-27 17:56:46 +01:00
|
|
|
replaceColumnSession = new ReplaceColumnSession(
|
|
|
|
value.getCurrentValue(), rValue, trId, column,
|
|
|
|
cellData.getRowId());
|
|
|
|
Log.debug(replaceColumnSession.toString());
|
|
|
|
}
|
2014-03-26 19:10:25 +01:00
|
|
|
TDGWTServiceAsync.INSTANCE.startReplaceColumn(replaceColumnSession,
|
2014-08-26 19:11:11 +02:00
|
|
|
new AsyncCallback<String>() {
|
2014-03-26 19:10:25 +01:00
|
|
|
@Override
|
2014-08-26 19:11:11 +02:00
|
|
|
public void onSuccess(String taskId) {
|
2014-03-26 19:10:25 +01:00
|
|
|
Log.debug("Submitted replace column value");
|
2014-08-26 19:11:11 +02:00
|
|
|
openMonitorDialog(taskId);
|
2014-09-26 12:20:11 +02:00
|
|
|
|
2014-03-26 19:10:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
2014-05-16 12:24:29 +02:00
|
|
|
if (caught instanceof TDGWTSessionExpiredException) {
|
|
|
|
eventBus.fireEvent(new SessionExpiredEvent(
|
|
|
|
SessionExpiredType.EXPIREDONSERVER));
|
|
|
|
} else {
|
2014-09-26 12:20:11 +02:00
|
|
|
if (caught instanceof TDGWTIsLockedException) {
|
|
|
|
Log.error(caught.getLocalizedMessage());
|
|
|
|
UtilsGXT3.alert("Error Locked",
|
|
|
|
caught.getLocalizedMessage());
|
|
|
|
} else {
|
|
|
|
if (caught instanceof TDGWTIsFinalException) {
|
|
|
|
Log.error(caught.getLocalizedMessage());
|
|
|
|
UtilsGXT3.alert("Error Final",
|
|
|
|
caught.getLocalizedMessage());
|
|
|
|
} else {
|
|
|
|
Log.error("Error submitting replace column value: "
|
|
|
|
+ caught.getMessage()
|
|
|
|
+ " "
|
|
|
|
+ caught.getCause());
|
|
|
|
caught.printStackTrace();
|
|
|
|
UtilsGXT3
|
|
|
|
.alert("Error submitting replace column value",
|
|
|
|
caught.getMessage());
|
|
|
|
}
|
|
|
|
}
|
2014-05-16 12:24:29 +02:00
|
|
|
}
|
2014-03-26 19:10:25 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-03-27 17:56:46 +01:00
|
|
|
protected void addHandlersForComboDimensionType(
|
|
|
|
final LabelProvider<DimensionRow> labelProvider) {
|
|
|
|
|
|
|
|
comboDimensionType.addTriggerClickHandler(new TriggerClickHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTriggerClick(TriggerClickEvent event) {
|
|
|
|
Log.debug("ComboDimensionRows TriggerClickEvent");
|
|
|
|
callDialogDimensionRowSelection();
|
|
|
|
comboDimensionType.collapse();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void callDialogDimensionRowSelection() {
|
2014-04-02 17:18:19 +02:00
|
|
|
DimensionRowSelectionDialog dialogDimensionRowSelection = new DimensionRowSelectionDialog(
|
2014-03-27 17:56:46 +01:00
|
|
|
column, cellData, eventBus);
|
|
|
|
dialogDimensionRowSelection.addListener(this);
|
|
|
|
dialogDimensionRowSelection.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-04-11 16:12:21 +02:00
|
|
|
public void selectedDimensionRow(DimensionRow dimRow) {
|
2014-03-27 17:56:46 +01:00
|
|
|
Log.debug("Selected dimension row: " + dimRow);
|
2014-05-16 12:24:29 +02:00
|
|
|
dimensionRow = dimRow;
|
2014-03-27 17:56:46 +01:00
|
|
|
comboDimensionType.setValue(dimRow);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-04-11 16:12:21 +02:00
|
|
|
public void abortedDimensionRowSelection() {
|
2014-03-27 18:26:24 +01:00
|
|
|
Log.debug("Aborted");
|
2014-03-27 17:56:46 +01:00
|
|
|
comboDimensionType.setValue(null);
|
2014-05-16 12:24:29 +02:00
|
|
|
dimensionRow = null;
|
2014-03-27 17:56:46 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-04-11 16:12:21 +02:00
|
|
|
public void failedDimensionRowSelection(String reason, String detail) {
|
2014-05-16 12:24:29 +02:00
|
|
|
Log.debug("Failed: " + reason + " " + detail);
|
2014-03-27 17:56:46 +01:00
|
|
|
comboDimensionType.setValue(null);
|
2014-05-16 12:24:29 +02:00
|
|
|
dimensionRow = null;
|
2014-03-27 17:56:46 +01:00
|
|
|
|
|
|
|
}
|
2014-09-26 12:20:11 +02:00
|
|
|
|
2014-08-26 19:11:11 +02:00
|
|
|
public void close() {
|
|
|
|
if (parent != null) {
|
|
|
|
parent.close();
|
|
|
|
}
|
|
|
|
}
|
2014-09-26 12:20:11 +02:00
|
|
|
|
|
|
|
// /
|
2014-08-26 19:11:11 +02:00
|
|
|
protected void openMonitorDialog(String taskId) {
|
|
|
|
MonitorDialog monitorDialog = new MonitorDialog(taskId, eventBus);
|
2014-08-27 15:51:44 +02:00
|
|
|
monitorDialog.addProgressDialogListener(this);
|
2014-08-26 19:11:11 +02:00
|
|
|
monitorDialog.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void operationComplete(TRId trId) {
|
|
|
|
ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED;
|
|
|
|
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
|
|
|
|
ChangeTableRequestType.COLUMNREPLACE, trId, why);
|
|
|
|
eventBus.fireEvent(changeTableRequestEvent);
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void operationFailed(Throwable caught, String reason, String details) {
|
|
|
|
UtilsGXT3.alert(reason, details);
|
|
|
|
close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void operationStopped(TRId trId, String reason, String details) {
|
|
|
|
ChangeTableWhy why = ChangeTableWhy.TABLECURATION;
|
|
|
|
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
|
|
|
|
ChangeTableRequestType.COLUMNREPLACE, trId, why);
|
|
|
|
eventBus.fireEvent(changeTableRequestEvent);
|
|
|
|
close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void operationAborted() {
|
|
|
|
close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void operationPutInBackground() {
|
|
|
|
close();
|
|
|
|
|
|
|
|
}
|
2014-09-26 12:20:11 +02:00
|
|
|
|
2014-03-26 19:10:25 +01:00
|
|
|
}
|