2014-05-07 12:04:10 +02:00
|
|
|
package org.gcube.portlets.user.td.tablewidget.client.rows;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2014-05-14 18:20:18 +02:00
|
|
|
import java.util.Date;
|
2014-05-15 12:57:06 +02:00
|
|
|
import java.util.HashMap;
|
2014-05-07 12:04:10 +02:00
|
|
|
|
2014-05-13 18:10:30 +02:00
|
|
|
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.dimension.DimensionRowsProperties;
|
2014-05-07 12:04:10 +02:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
2014-05-15 18:49:28 +02:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
2014-05-07 12:04:10 +02:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
2014-05-13 18:10:30 +02:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.DimensionRow;
|
2014-05-15 18:49:28 +02:00
|
|
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.EditRowSession;
|
|
|
|
import org.gcube.portlets.user.td.tablewidget.client.progress.EditRowProgressDialog;
|
2014-05-07 12:04:10 +02:00
|
|
|
import org.gcube.portlets.user.td.tablewidget.client.resources.ResourceBundle;
|
|
|
|
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
|
2014-05-16 16:21:10 +02:00
|
|
|
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
|
|
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
2014-05-13 18:10:30 +02:00
|
|
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.CellData;
|
2014-05-07 12:04:10 +02:00
|
|
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
2014-05-14 18:20:18 +02:00
|
|
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.grid.model.RowRaw;
|
2014-05-09 14:16:38 +02:00
|
|
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
|
|
|
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode;
|
2014-05-07 12:04:10 +02:00
|
|
|
|
|
|
|
import com.allen_sauer.gwt.log.client.Log;
|
2014-05-09 14:16:38 +02:00
|
|
|
import com.google.gwt.core.client.GWT;
|
|
|
|
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
|
|
|
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
2014-05-14 18:20:18 +02:00
|
|
|
import com.google.gwt.i18n.client.DateTimeFormat;
|
2014-05-14 20:37:52 +02:00
|
|
|
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
|
2014-05-07 12:04:10 +02:00
|
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
2014-05-23 14:58:56 +02:00
|
|
|
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
|
2014-05-09 14:16:38 +02:00
|
|
|
import com.google.gwt.user.client.ui.HorizontalPanel;
|
2014-05-07 12:04:10 +02:00
|
|
|
import com.google.web.bindery.event.shared.EventBus;
|
|
|
|
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
|
2014-05-09 14:16:38 +02:00
|
|
|
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
|
2014-05-14 20:03:31 +02:00
|
|
|
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
|
2014-05-07 12:04:10 +02:00
|
|
|
import com.sencha.gxt.core.client.util.Margins;
|
2014-05-14 18:20:18 +02:00
|
|
|
import com.sencha.gxt.core.client.util.ToggleGroup;
|
2014-05-09 14:16:38 +02:00
|
|
|
import com.sencha.gxt.data.shared.ListStore;
|
2014-05-07 12:04:10 +02: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-05-09 14:16:38 +02:00
|
|
|
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
|
2014-05-07 12:04:10 +02:00
|
|
|
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer.HBoxLayoutAlign;
|
2014-05-09 18:40:22 +02:00
|
|
|
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
2014-05-09 14:16:38 +02:00
|
|
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
2014-05-07 12:04:10 +02:00
|
|
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
|
|
|
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
2014-05-13 18:10:30 +02:00
|
|
|
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
2014-05-14 20:37:52 +02:00
|
|
|
import com.sencha.gxt.widget.core.client.event.TriggerClickEvent;
|
2014-05-09 14:16:38 +02:00
|
|
|
import com.sencha.gxt.widget.core.client.event.TriggerClickEvent.TriggerClickHandler;
|
|
|
|
import com.sencha.gxt.widget.core.client.form.ComboBox;
|
|
|
|
import com.sencha.gxt.widget.core.client.form.DateField;
|
|
|
|
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
|
|
|
import com.sencha.gxt.widget.core.client.form.Radio;
|
|
|
|
import com.sencha.gxt.widget.core.client.form.TextField;
|
2014-05-07 12:04:10 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @author "Giancarlo Panichi"
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public class EditRowPanel extends FramedPanel {
|
2014-05-16 16:35:37 +02:00
|
|
|
protected String WIDTH = "510px";
|
|
|
|
protected String HEIGHT = "370px";
|
|
|
|
protected String FIELDSHEIGHT = "370px";
|
2014-05-14 20:37:52 +02:00
|
|
|
protected int LABELSIZE = 140;
|
|
|
|
|
2014-05-07 12:04:10 +02:00
|
|
|
protected EditRowDialog parent;
|
|
|
|
protected TRId trId;
|
|
|
|
protected EventBus eventBus;
|
|
|
|
protected ArrayList<ColumnData> columns;
|
2014-05-14 18:20:18 +02:00
|
|
|
protected RowRaw rowRaw;
|
2014-05-15 12:57:06 +02:00
|
|
|
protected boolean editRow;
|
2014-05-16 16:21:10 +02:00
|
|
|
|
2014-05-15 18:49:28 +02:00
|
|
|
protected EditRowProgressDialog editRowProgressDialog;
|
2014-05-16 16:21:10 +02:00
|
|
|
|
2014-05-15 12:57:06 +02:00
|
|
|
protected VerticalLayoutContainer v;
|
2014-05-07 12:04:10 +02:00
|
|
|
private TextButton btnSave;
|
|
|
|
private TextButton btnClose;
|
2014-05-14 20:37:52 +02:00
|
|
|
|
|
|
|
private DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd");
|
|
|
|
|
2014-05-15 18:49:28 +02:00
|
|
|
/**
|
|
|
|
* Edit Row
|
|
|
|
*
|
|
|
|
* @param parent
|
|
|
|
* @param trId
|
|
|
|
* @param rowRaw
|
|
|
|
* @param eventBus
|
|
|
|
*/
|
|
|
|
public EditRowPanel(EditRowDialog parent, TRId trId, RowRaw rowRaw,
|
2014-05-14 18:20:18 +02:00
|
|
|
EventBus eventBus) {
|
2014-05-09 18:40:22 +02:00
|
|
|
super();
|
2014-05-07 12:04:10 +02:00
|
|
|
this.parent = parent;
|
|
|
|
this.trId = trId;
|
2014-05-15 18:49:28 +02:00
|
|
|
this.rowRaw = rowRaw;
|
2014-05-07 12:04:10 +02:00
|
|
|
this.eventBus = eventBus;
|
2014-05-15 12:57:06 +02:00
|
|
|
this.editRow = true;
|
2014-05-14 18:20:18 +02:00
|
|
|
Log.debug("Create EditRowPanel(): [" + trId.toString() + " , RowRaw:"
|
2014-05-15 18:49:28 +02:00
|
|
|
+ rowRaw + "]");
|
2014-05-14 18:20:18 +02:00
|
|
|
if (rowRaw == null) {
|
2014-05-09 18:40:22 +02:00
|
|
|
UtilsGXT3.alert("Attentions", "No row selected");
|
|
|
|
} else {
|
|
|
|
init();
|
|
|
|
retrieveColumn();
|
|
|
|
}
|
2014-05-07 12:04:10 +02:00
|
|
|
}
|
|
|
|
|
2014-05-15 12:57:06 +02:00
|
|
|
/**
|
2014-05-15 18:49:28 +02:00
|
|
|
* Add a new rowe
|
2014-05-15 12:57:06 +02:00
|
|
|
*
|
|
|
|
* @param parent
|
|
|
|
* @param trId
|
|
|
|
* @param eventBus
|
|
|
|
*/
|
|
|
|
public EditRowPanel(EditRowDialog parent, TRId trId, EventBus eventBus) {
|
|
|
|
super();
|
|
|
|
this.parent = parent;
|
|
|
|
this.trId = trId;
|
|
|
|
this.eventBus = eventBus;
|
|
|
|
this.editRow = false;
|
|
|
|
Log.debug("Create For Add Row EditRowPanel(): [" + trId.toString()
|
|
|
|
+ "]");
|
|
|
|
init();
|
|
|
|
retrieveColumn();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-05-07 12:04:10 +02:00
|
|
|
protected void init() {
|
|
|
|
setWidth(WIDTH);
|
|
|
|
setHeight(HEIGHT);
|
|
|
|
setHeaderVisible(false);
|
|
|
|
setBodyBorder(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void create() {
|
2014-05-09 18:40:22 +02:00
|
|
|
SimpleContainer container = new SimpleContainer();
|
|
|
|
container.setHeight(FIELDSHEIGHT);
|
|
|
|
|
2014-05-15 12:57:06 +02:00
|
|
|
v = new VerticalLayoutContainer();
|
2014-05-14 20:03:31 +02:00
|
|
|
v.setScrollMode(ScrollMode.AUTO);
|
2014-05-09 18:40:22 +02:00
|
|
|
container.add(v);
|
|
|
|
|
2014-05-07 12:04:10 +02:00
|
|
|
btnSave = new TextButton("Save");
|
|
|
|
btnSave.setIcon(ResourceBundle.INSTANCE.save());
|
|
|
|
btnSave.setIconAlign(IconAlign.RIGHT);
|
|
|
|
btnSave.setTitle("Save");
|
|
|
|
btnSave.addSelectHandler(new SelectHandler() {
|
|
|
|
|
|
|
|
public void onSelect(SelectEvent event) {
|
|
|
|
Log.debug("Pressed Save");
|
|
|
|
btnSave.disable();
|
|
|
|
save();
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
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(btnSave, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
|
|
|
flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
|
|
|
|
2014-05-09 18:40:22 +02:00
|
|
|
ArrayList<FieldLabel> fields = generateFields();
|
|
|
|
for (FieldLabel fl : fields) {
|
|
|
|
v.add(fl, new VerticalLayoutData(1, -1, new Margins(1)));
|
|
|
|
|
2014-05-09 14:16:38 +02:00
|
|
|
}
|
2014-05-15 12:57:06 +02:00
|
|
|
|
2014-05-14 20:37:52 +02:00
|
|
|
container.forceLayout();
|
2014-05-15 12:57:06 +02:00
|
|
|
|
2014-05-09 18:40:22 +02:00
|
|
|
VerticalLayoutContainer vPanel = new VerticalLayoutContainer();
|
|
|
|
vPanel.add(container, new VerticalLayoutData(1, -1));
|
|
|
|
vPanel.add(flowButton, new VerticalLayoutData(1, -1, new Margins(1)));
|
|
|
|
add(vPanel);
|
2014-05-15 12:57:06 +02:00
|
|
|
|
2014-05-07 12:04:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void retrieveColumn() {
|
|
|
|
TDGWTServiceAsync.INSTANCE.getColumns(trId,
|
|
|
|
new AsyncCallback<ArrayList<ColumnData>>() {
|
|
|
|
|
|
|
|
public void onFailure(Throwable caught) {
|
2014-05-16 16:21:10 +02:00
|
|
|
if (caught instanceof TDGWTSessionExpiredException) {
|
|
|
|
eventBus.fireEvent(new SessionExpiredEvent(
|
|
|
|
SessionExpiredType.EXPIREDONSERVER));
|
|
|
|
} else {
|
|
|
|
Log.error("load columns failure:"
|
|
|
|
+ caught.getLocalizedMessage());
|
|
|
|
UtilsGXT3.alert("Error retrieving columns",
|
|
|
|
"Error retrieving columns");
|
|
|
|
}
|
2014-05-07 12:04:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void onSuccess(ArrayList<ColumnData> result) {
|
|
|
|
Log.trace("loaded " + result.size() + " ColumnData");
|
|
|
|
columns = result;
|
2014-05-09 14:16:38 +02:00
|
|
|
create();
|
2014-05-07 12:04:10 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-05-09 18:40:22 +02:00
|
|
|
protected ArrayList<FieldLabel> generateFields() {
|
|
|
|
ArrayList<FieldLabel> fields = new ArrayList<FieldLabel>();
|
|
|
|
|
|
|
|
for (ColumnData col : columns) {
|
2014-05-14 20:37:52 +02:00
|
|
|
String label = new String();
|
|
|
|
if (col != null && col.getLabel() != null) {
|
|
|
|
label = SafeHtmlUtils.htmlEscape(col.getLabel());
|
|
|
|
if (label.length() > LABELSIZE - 1) {
|
|
|
|
label = label.substring(0, LABELSIZE - 3);
|
|
|
|
label += "..";
|
|
|
|
}
|
2014-05-15 12:57:06 +02:00
|
|
|
}
|
2014-05-13 18:10:30 +02:00
|
|
|
if (!col.isViewColumn()) {
|
|
|
|
if (col.getTypeCode().compareTo(
|
|
|
|
ColumnTypeCode.DIMENSION.toString()) == 0
|
|
|
|
|| col.getTypeCode().compareTo(
|
|
|
|
ColumnTypeCode.TIMEDIMENSION.toString()) == 0) {
|
2014-05-14 18:20:18 +02:00
|
|
|
|
2014-05-14 20:37:52 +02:00
|
|
|
FieldLabel dimensionLabel = retrieveDimensionLabel(col,
|
|
|
|
label);
|
2014-05-14 20:03:31 +02:00
|
|
|
dimensionLabel.setLabelWidth(LABELSIZE);
|
2014-05-13 18:10:30 +02:00
|
|
|
fields.add(dimensionLabel);
|
2014-05-09 14:16:38 +02:00
|
|
|
} else {
|
2014-05-09 18:40:22 +02:00
|
|
|
if (col.getDataTypeName().compareTo(
|
2014-05-13 18:10:30 +02:00
|
|
|
ColumnDataType.Boolean.toString()) == 0) {
|
|
|
|
Radio radioTrue = new Radio();
|
|
|
|
radioTrue.setBoxLabel("true");
|
|
|
|
Radio radioFalse = new Radio();
|
|
|
|
radioFalse.setBoxLabel("false");
|
2014-05-14 20:37:52 +02:00
|
|
|
|
2014-05-15 12:57:06 +02:00
|
|
|
String value = "true";
|
|
|
|
if (editRow) {
|
|
|
|
value = rowRaw.getMap().get(col.getColumnId());
|
|
|
|
}
|
|
|
|
|
2014-05-14 20:37:52 +02:00
|
|
|
if (new Boolean(value)) {
|
2014-05-14 18:20:18 +02:00
|
|
|
radioTrue.setValue(true);
|
|
|
|
} else {
|
|
|
|
radioFalse.setValue(true);
|
|
|
|
}
|
|
|
|
ToggleGroup toggleGroup = new ToggleGroup();
|
|
|
|
toggleGroup.add(radioTrue);
|
|
|
|
toggleGroup.add(radioFalse);
|
2014-05-14 20:37:52 +02:00
|
|
|
|
2014-05-13 18:10:30 +02:00
|
|
|
HorizontalPanel hp = new HorizontalPanel();
|
2014-05-23 14:58:56 +02:00
|
|
|
hp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
|
2014-05-13 18:10:30 +02:00
|
|
|
hp.add(radioTrue);
|
|
|
|
hp.add(radioFalse);
|
2014-05-14 20:37:52 +02:00
|
|
|
FieldLabel booleanLabel = new FieldLabel(hp, label);
|
2014-05-14 20:03:31 +02:00
|
|
|
booleanLabel.setLabelWidth(LABELSIZE);
|
2014-05-13 18:10:30 +02:00
|
|
|
booleanLabel.setId(col.getColumnId());
|
|
|
|
fields.add(booleanLabel);
|
2014-05-09 14:16:38 +02:00
|
|
|
} else {
|
2014-05-09 18:40:22 +02:00
|
|
|
if (col.getDataTypeName().compareTo(
|
2014-05-13 18:10:30 +02:00
|
|
|
ColumnDataType.Date.toString()) == 0) {
|
|
|
|
DateField date = new DateField();
|
2014-05-14 20:37:52 +02:00
|
|
|
Date d = null;
|
2014-05-15 12:57:06 +02:00
|
|
|
if (editRow) {
|
|
|
|
String value = rowRaw.getMap().get(
|
|
|
|
col.getColumnId());
|
|
|
|
|
|
|
|
try {
|
|
|
|
d = sdf.parse(value);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
Log.error("Error parsing date string: "
|
|
|
|
+ e.getLocalizedMessage());
|
|
|
|
}
|
2014-05-14 18:20:18 +02:00
|
|
|
}
|
2014-05-14 20:37:52 +02:00
|
|
|
if (d != null) {
|
2014-05-14 18:20:18 +02:00
|
|
|
date.setValue(d);
|
|
|
|
}
|
2014-05-14 20:37:52 +02:00
|
|
|
FieldLabel dateLabel = new FieldLabel(date, label);
|
2014-05-14 20:03:31 +02:00
|
|
|
dateLabel.setLabelWidth(LABELSIZE);
|
2014-05-13 18:10:30 +02:00
|
|
|
dateLabel.setId(col.getColumnId());
|
|
|
|
fields.add(dateLabel);
|
2014-05-09 14:16:38 +02:00
|
|
|
} else {
|
2014-05-09 18:40:22 +02:00
|
|
|
if (col.getDataTypeName().compareTo(
|
2014-05-13 18:10:30 +02:00
|
|
|
ColumnDataType.Text.toString()) == 0) {
|
|
|
|
TextField text = new TextField();
|
2014-05-15 12:57:06 +02:00
|
|
|
String value = "";
|
|
|
|
if (editRow) {
|
|
|
|
value = rowRaw.getMap().get(
|
|
|
|
col.getColumnId());
|
|
|
|
}
|
2014-05-14 18:20:18 +02:00
|
|
|
text.setValue(value);
|
2014-05-13 18:10:30 +02:00
|
|
|
text.addValueChangeHandler(new ValueChangeHandler<String>() {
|
2014-05-09 14:16:38 +02:00
|
|
|
@Override
|
2014-05-09 18:40:22 +02:00
|
|
|
public void onValueChange(
|
|
|
|
ValueChangeEvent<String> event) {
|
|
|
|
|
2014-05-09 14:16:38 +02:00
|
|
|
}
|
|
|
|
});
|
2014-05-14 20:37:52 +02:00
|
|
|
|
2014-05-13 18:10:30 +02:00
|
|
|
FieldLabel textLabel = new FieldLabel(text,
|
2014-05-14 20:37:52 +02:00
|
|
|
label);
|
2014-05-14 20:03:31 +02:00
|
|
|
textLabel.setLabelWidth(LABELSIZE);
|
2014-05-13 18:10:30 +02:00
|
|
|
textLabel.setId(col.getColumnId());
|
|
|
|
fields.add(textLabel);
|
2014-05-09 14:16:38 +02:00
|
|
|
} else {
|
2014-05-09 18:40:22 +02:00
|
|
|
if (col.getDataTypeName().compareTo(
|
2014-05-13 18:10:30 +02:00
|
|
|
ColumnDataType.Geometry.toString()) == 0) {
|
|
|
|
TextField geometry = new TextField();
|
2014-05-15 12:57:06 +02:00
|
|
|
String value = "";
|
|
|
|
if (editRow) {
|
|
|
|
value = rowRaw.getMap().get(
|
|
|
|
col.getColumnId());
|
|
|
|
}
|
2014-05-14 18:20:18 +02:00
|
|
|
geometry.setValue(value);
|
2014-05-13 18:10:30 +02:00
|
|
|
geometry.addValueChangeHandler(new ValueChangeHandler<String>() {
|
2014-05-09 14:16:38 +02:00
|
|
|
@Override
|
2014-05-09 18:40:22 +02:00
|
|
|
public void onValueChange(
|
|
|
|
ValueChangeEvent<String> event) {
|
|
|
|
|
2014-05-09 14:16:38 +02:00
|
|
|
}
|
|
|
|
});
|
2014-05-14 20:37:52 +02:00
|
|
|
|
2014-05-13 18:10:30 +02:00
|
|
|
FieldLabel geometryLabel = new FieldLabel(
|
2014-05-14 20:37:52 +02:00
|
|
|
geometry, label);
|
2014-05-14 20:03:31 +02:00
|
|
|
geometryLabel.setLabelWidth(LABELSIZE);
|
2014-05-13 18:10:30 +02:00
|
|
|
geometryLabel.setId(col.getColumnId());
|
|
|
|
fields.add(geometryLabel);
|
2014-05-09 14:16:38 +02:00
|
|
|
} else {
|
2014-05-09 18:40:22 +02:00
|
|
|
if (col.getDataTypeName().compareTo(
|
2014-05-13 18:10:30 +02:00
|
|
|
ColumnDataType.Integer.toString()) == 0) {
|
|
|
|
TextField integ = new TextField();
|
2014-05-15 12:57:06 +02:00
|
|
|
String value = "";
|
|
|
|
if (editRow) {
|
|
|
|
value = rowRaw.getMap().get(
|
|
|
|
col.getColumnId());
|
|
|
|
}
|
2014-05-14 18:20:18 +02:00
|
|
|
integ.setValue(value);
|
2014-05-13 18:10:30 +02:00
|
|
|
integ.addValueChangeHandler(new ValueChangeHandler<String>() {
|
2014-05-09 14:16:38 +02:00
|
|
|
@Override
|
2014-05-09 18:40:22 +02:00
|
|
|
public void onValueChange(
|
|
|
|
ValueChangeEvent<String> event) {
|
|
|
|
|
2014-05-09 14:16:38 +02:00
|
|
|
}
|
|
|
|
});
|
2014-05-14 20:37:52 +02:00
|
|
|
|
2014-05-13 18:10:30 +02:00
|
|
|
FieldLabel integLabel = new FieldLabel(
|
2014-05-14 20:37:52 +02:00
|
|
|
integ, label);
|
2014-05-14 20:03:31 +02:00
|
|
|
integLabel.setLabelWidth(LABELSIZE);
|
2014-05-13 18:10:30 +02:00
|
|
|
integLabel.setId(col.getColumnId());
|
|
|
|
fields.add(integLabel);
|
2014-05-09 14:16:38 +02:00
|
|
|
} else {
|
2014-05-13 18:10:30 +02:00
|
|
|
if (col.getDataTypeName().compareTo(
|
|
|
|
ColumnDataType.Numeric
|
|
|
|
.toString()) == 0) {
|
|
|
|
TextField numeric = new TextField();
|
2014-05-15 12:57:06 +02:00
|
|
|
String value = "";
|
|
|
|
if (editRow) {
|
|
|
|
value = rowRaw.getMap().get(
|
|
|
|
col.getColumnId());
|
|
|
|
}
|
2014-05-14 18:20:18 +02:00
|
|
|
numeric.setValue(value);
|
2014-05-13 18:10:30 +02:00
|
|
|
numeric.setId(col.getColumnId());
|
|
|
|
numeric.addValueChangeHandler(new ValueChangeHandler<String>() {
|
|
|
|
@Override
|
|
|
|
public void onValueChange(
|
|
|
|
ValueChangeEvent<String> event) {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
FieldLabel numericLabel = new FieldLabel(
|
2014-05-14 20:37:52 +02:00
|
|
|
numeric, label);
|
|
|
|
numericLabel
|
|
|
|
.setLabelWidth(LABELSIZE);
|
2014-05-13 18:10:30 +02:00
|
|
|
numericLabel.setId(col
|
|
|
|
.getColumnId());
|
|
|
|
fields.add(numericLabel);
|
|
|
|
} else {
|
2014-05-09 18:40:22 +02:00
|
|
|
|
2014-05-13 18:10:30 +02:00
|
|
|
}
|
2014-05-09 14:16:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return fields;
|
|
|
|
|
2014-05-09 18:40:22 +02:00
|
|
|
}
|
2014-05-07 12:04:10 +02:00
|
|
|
|
2014-05-14 20:37:52 +02:00
|
|
|
protected FieldLabel retrieveDimensionLabel(final ColumnData col,
|
|
|
|
String label) {
|
2014-05-13 18:10:30 +02:00
|
|
|
// comboDimension
|
|
|
|
DimensionRowsProperties propsDimension = GWT
|
|
|
|
.create(DimensionRowsProperties.class);
|
|
|
|
ListStore<DimensionRow> storeComboDimensionType = new ListStore<DimensionRow>(
|
|
|
|
propsDimension.rowId());
|
|
|
|
|
|
|
|
final ComboBox<DimensionRow> comboDimension = new ComboBox<DimensionRow>(
|
|
|
|
storeComboDimensionType, propsDimension.value());
|
2014-05-14 20:37:52 +02:00
|
|
|
|
2014-05-14 18:20:18 +02:00
|
|
|
Log.debug("ComboDimensionType created");
|
|
|
|
|
|
|
|
final DimensionRowSelectionListener listener = new DimensionRowSelectionListener() {
|
|
|
|
|
2014-05-13 18:10:30 +02:00
|
|
|
@Override
|
|
|
|
public void selectedDimensionRow(DimensionRow dimensionRow) {
|
|
|
|
comboDimension.setValue(dimensionRow);
|
|
|
|
|
|
|
|
}
|
2014-05-14 18:20:18 +02:00
|
|
|
|
2014-05-13 18:10:30 +02:00
|
|
|
@Override
|
|
|
|
public void failedDimensionRowSelection(String reason, String detail) {
|
|
|
|
Log.error("Change Value Failed:" + reason + " " + detail);
|
2014-05-14 18:20:18 +02:00
|
|
|
|
2014-05-13 18:10:30 +02:00
|
|
|
}
|
2014-05-14 18:20:18 +02:00
|
|
|
|
2014-05-13 18:10:30 +02:00
|
|
|
@Override
|
|
|
|
public void abortedDimensionRowSelection() {
|
|
|
|
Log.debug("Change Value Aborted");
|
2014-05-14 18:20:18 +02:00
|
|
|
|
2014-05-13 18:10:30 +02:00
|
|
|
}
|
|
|
|
};
|
2014-05-14 20:37:52 +02:00
|
|
|
|
|
|
|
String viewColumn = col.getRelationship().getTargetColumnId();
|
|
|
|
|
2014-05-15 12:57:06 +02:00
|
|
|
String valueOnViewColumn = null;
|
|
|
|
String rowId = null;
|
|
|
|
if (editRow) {
|
|
|
|
valueOnViewColumn = rowRaw.getMap().get(viewColumn);
|
|
|
|
rowId = rowRaw.getRowId();
|
|
|
|
DimensionRow dimR = new DimensionRow(rowId, valueOnViewColumn);
|
|
|
|
comboDimension.setValue(dimR);
|
|
|
|
}
|
2014-05-14 20:37:52 +02:00
|
|
|
|
|
|
|
final CellData cellData = new CellData(valueOnViewColumn, "",
|
2014-05-15 12:57:06 +02:00
|
|
|
viewColumn, "", rowId, 0, 0);
|
2014-05-14 20:37:52 +02:00
|
|
|
|
2014-05-13 18:10:30 +02:00
|
|
|
comboDimension.addTriggerClickHandler(new TriggerClickHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTriggerClick(TriggerClickEvent event) {
|
|
|
|
Log.debug("ComboDimensionRows TriggerClickEvent");
|
|
|
|
comboDimension.collapse();
|
2014-05-14 18:20:18 +02:00
|
|
|
|
2014-05-13 18:10:30 +02:00
|
|
|
DimensionRowSelectionDialog dialogDimensionRowSelection = new DimensionRowSelectionDialog(
|
|
|
|
col, cellData, eventBus);
|
|
|
|
dialogDimensionRowSelection.addListener(listener);
|
|
|
|
dialogDimensionRowSelection.show();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
comboDimension.setEmptyText("Select a Value...");
|
|
|
|
comboDimension.setWidth(300);
|
|
|
|
comboDimension.setEditable(false);
|
|
|
|
comboDimension.setTriggerAction(TriggerAction.ALL);
|
|
|
|
|
2014-05-14 20:37:52 +02:00
|
|
|
FieldLabel dimensionLabel = new FieldLabel(comboDimension, label);
|
2014-05-13 18:10:30 +02:00
|
|
|
dimensionLabel.setId(col.getColumnId());
|
2014-05-14 18:20:18 +02:00
|
|
|
return dimensionLabel;
|
2014-05-13 18:10:30 +02:00
|
|
|
}
|
|
|
|
|
2014-05-15 12:57:06 +02:00
|
|
|
protected void save() {
|
|
|
|
int i = 0;
|
|
|
|
int lenght = v.getWidgetCount();
|
|
|
|
HashMap<String, String> maps = new HashMap<String, String>();
|
|
|
|
|
|
|
|
for (; i < lenght; i++) {
|
|
|
|
FieldLabel fieldLabel = (FieldLabel) v.getWidget(i);
|
|
|
|
String columnId = fieldLabel.getId();
|
|
|
|
ColumnData colCurrent = null;
|
|
|
|
for (ColumnData col : columns) {
|
|
|
|
if (col.getColumnId().compareTo(columnId) == 0) {
|
|
|
|
colCurrent = col;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (colCurrent == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (colCurrent.getTypeCode().compareTo(
|
|
|
|
ColumnTypeCode.DIMENSION.toString()) == 0
|
|
|
|
|| colCurrent.getTypeCode().compareTo(
|
|
|
|
ColumnTypeCode.TIMEDIMENSION.toString()) == 0) {
|
|
|
|
fieldLabel.getWidget();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (colCurrent.getDataTypeName().compareTo(
|
|
|
|
ColumnDataType.Boolean.toString()) == 0) {
|
2014-05-23 14:58:56 +02:00
|
|
|
HorizontalPanel hpanel=(HorizontalPanel)fieldLabel.getWidget();
|
|
|
|
Radio radioTrue = (Radio)hpanel.getWidget(0) ;
|
2014-05-15 12:57:06 +02:00
|
|
|
maps.put(columnId, radioTrue.getValue().toString());
|
|
|
|
} else {
|
|
|
|
if (colCurrent.getDataTypeName().compareTo(
|
|
|
|
ColumnDataType.Date.toString()) == 0) {
|
|
|
|
DateField date = (DateField) fieldLabel.getWidget();
|
|
|
|
if (date == null || date.getCurrentValue() == null) {
|
|
|
|
maps.put(columnId, null);
|
|
|
|
} else {
|
|
|
|
Date d = date.getCurrentValue();
|
|
|
|
String dateS = sdf.format(d);
|
|
|
|
maps.put(columnId, dateS);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (colCurrent.getDataTypeName().compareTo(
|
|
|
|
ColumnDataType.Text.toString()) == 0) {
|
|
|
|
TextField text = (TextField) fieldLabel.getWidget();
|
|
|
|
maps.put(columnId, text.getCurrentValue());
|
|
|
|
} else {
|
|
|
|
if (colCurrent.getDataTypeName().compareTo(
|
|
|
|
ColumnDataType.Geometry.toString()) == 0) {
|
|
|
|
TextField geometry = (TextField) fieldLabel
|
|
|
|
.getWidget();
|
|
|
|
maps.put(columnId, geometry.getCurrentValue());
|
|
|
|
} else {
|
|
|
|
if (colCurrent.getDataTypeName().compareTo(
|
|
|
|
ColumnDataType.Integer.toString()) == 0) {
|
|
|
|
TextField integ = (TextField) fieldLabel
|
|
|
|
.getWidget();
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
Integer intege;
|
|
|
|
try {
|
|
|
|
intege = new Integer(
|
|
|
|
integ.getCurrentValue());
|
|
|
|
} catch (NumberFormatException e) {
|
2014-05-15 18:49:28 +02:00
|
|
|
UtilsGXT3
|
|
|
|
.alert("Attentions",
|
|
|
|
colCurrent.getLabel()
|
|
|
|
+ " is no a valid Integer type");
|
2014-05-15 12:57:06 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-05-15 18:49:28 +02:00
|
|
|
|
2014-05-15 12:57:06 +02:00
|
|
|
maps.put(columnId, integ.getCurrentValue());
|
|
|
|
} else {
|
|
|
|
if (colCurrent.getDataTypeName().compareTo(
|
|
|
|
ColumnDataType.Numeric.toString()) == 0) {
|
|
|
|
TextField numeric = (TextField) fieldLabel
|
|
|
|
.getWidget();
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
Double d;
|
|
|
|
try {
|
|
|
|
d = new Double(
|
|
|
|
numeric.getCurrentValue());
|
|
|
|
} catch (NumberFormatException e) {
|
2014-05-15 18:49:28 +02:00
|
|
|
UtilsGXT3
|
|
|
|
.alert("Attentions",
|
|
|
|
colCurrent
|
|
|
|
.getLabel()
|
|
|
|
+ " is no a valid Numeric type");
|
2014-05-15 12:57:06 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
maps.put(columnId,
|
|
|
|
numeric.getCurrentValue());
|
|
|
|
} else {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-05-15 18:49:28 +02:00
|
|
|
|
|
|
|
EditRowSession editRowSession;
|
|
|
|
if (editRow) {
|
|
|
|
editRowSession = new EditRowSession(trId, columns, maps,
|
|
|
|
rowRaw.getRowId());
|
|
|
|
} else {
|
|
|
|
editRowSession = new EditRowSession(trId, columns, maps);
|
|
|
|
}
|
|
|
|
|
|
|
|
callEditRow(editRowSession);
|
|
|
|
|
2014-05-15 12:57:06 +02:00
|
|
|
}
|
|
|
|
|
2014-05-15 18:49:28 +02:00
|
|
|
public void close() {
|
2014-05-15 12:57:06 +02:00
|
|
|
if (parent != null) {
|
|
|
|
parent.close();
|
|
|
|
}
|
|
|
|
}
|
2014-05-15 18:49:28 +02:00
|
|
|
|
|
|
|
protected void callEditRow(EditRowSession editRowSession) {
|
2014-05-16 16:21:10 +02:00
|
|
|
final EditRowPanel panel = this;
|
2014-05-15 18:49:28 +02:00
|
|
|
|
2014-05-16 16:21:10 +02:00
|
|
|
TDGWTServiceAsync.INSTANCE.startEditRow(editRowSession,
|
|
|
|
new AsyncCallback<Void>() {
|
|
|
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
Log.debug("EditRow: " + caught.getLocalizedMessage());
|
|
|
|
if (caught instanceof TDGWTSessionExpiredException) {
|
|
|
|
eventBus.fireEvent(new SessionExpiredEvent(
|
|
|
|
SessionExpiredType.EXPIREDONSERVER));
|
|
|
|
} else {
|
|
|
|
UtilsGXT3.alert("Error",
|
|
|
|
"Error in operation invocation!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onSuccess(Void result) {
|
|
|
|
editRowProgressDialog = new EditRowProgressDialog(
|
|
|
|
panel, eventBus);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2014-05-15 18:49:28 +02:00
|
|
|
|
|
|
|
}
|
2014-05-15 12:57:06 +02:00
|
|
|
|
2014-05-07 12:04:10 +02:00
|
|
|
}
|