Minor Update
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-table-widget@95693 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
924d659745
commit
85be5cfce1
|
@ -1,12 +1,11 @@
|
|||
package org.gcube.portlets.user.td.tablewidget.client.rows;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DeleteRowsSession;
|
||||
import org.gcube.portlets.user.td.tablewidget.client.progress.DeleteRowsProgressDialog;
|
||||
import org.gcube.portlets.user.td.tablewidget.client.resources.ResourceBundle;
|
||||
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.grid.model.RowRaw;
|
||||
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
import com.sencha.gxt.widget.core.client.Window;
|
||||
|
@ -24,20 +23,20 @@ public class EditRowDialog extends Window {
|
|||
protected String HEIGHT = "486px";
|
||||
protected TRId trId;
|
||||
protected EventBus eventBus;
|
||||
protected ArrayList<String> rows;
|
||||
protected RowRaw row;
|
||||
protected DeleteRowsSession deleteRowsSession;
|
||||
protected DeleteRowsProgressDialog deleteRowsProgressDialog;
|
||||
|
||||
public EditRowDialog(TRId trId, ArrayList<String> rows, EventBus eventBus) {
|
||||
public EditRowDialog(TRId trId, RowRaw row, EventBus eventBus) {
|
||||
this.trId = trId;
|
||||
this.rows = rows;
|
||||
this.row = row;
|
||||
this.eventBus = eventBus;
|
||||
if (rows == null || rows.size() <= 0) {
|
||||
if (row == null) {
|
||||
UtilsGXT3.alert("Attentions",
|
||||
"No row selected");
|
||||
} else {
|
||||
initWindow();
|
||||
EditRowPanel editRowPanel = new EditRowPanel(this, trId, rows,
|
||||
EditRowPanel editRowPanel = new EditRowPanel(this, trId, row,
|
||||
eventBus);
|
||||
add(editRowPanel);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portlets.user.td.tablewidget.client.rows;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRowSelectionDialog;
|
||||
import org.gcube.portlets.user.td.columnwidget.client.dimension.DimensionRowSelectionListener;
|
||||
|
@ -12,6 +13,7 @@ import org.gcube.portlets.user.td.tablewidget.client.resources.ResourceBundle;
|
|||
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.CellData;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.grid.model.RowRaw;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode;
|
||||
|
||||
|
@ -19,12 +21,14 @@ import com.allen_sauer.gwt.log.client.Log;
|
|||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
||||
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
|
||||
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
|
||||
import com.sencha.gxt.core.client.util.Margins;
|
||||
import com.sencha.gxt.core.client.util.ToggleGroup;
|
||||
import com.sencha.gxt.data.shared.ListStore;
|
||||
import com.sencha.gxt.widget.core.client.FramedPanel;
|
||||
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||
|
@ -58,24 +62,24 @@ public class EditRowPanel extends FramedPanel {
|
|||
protected EditRowDialog parent;
|
||||
protected TRId trId;
|
||||
protected EventBus eventBus;
|
||||
protected ArrayList<String> rows;
|
||||
protected ArrayList<ColumnData> columns;
|
||||
protected String currentRow;
|
||||
protected RowRaw rowRaw;
|
||||
|
||||
private TextButton btnSave;
|
||||
private TextButton btnClose;
|
||||
|
||||
public EditRowPanel(EditRowDialog parent, TRId trId,
|
||||
ArrayList<String> rows, EventBus eventBus) {
|
||||
|
||||
private DateTimeFormat sdf= DateTimeFormat.getFormat("yyyy-MM-dd");
|
||||
|
||||
public EditRowPanel(EditRowDialog parent, TRId trId, RowRaw row,
|
||||
EventBus eventBus) {
|
||||
super();
|
||||
this.parent = parent;
|
||||
this.trId = trId;
|
||||
this.rows = rows;
|
||||
this.rowRaw = row;
|
||||
this.eventBus = eventBus;
|
||||
Log.debug("Create EditRowPanel(): [" + trId.toString() + " , rows:"
|
||||
+ rows + "]");
|
||||
if (rows == null || rows.size() <= 0) {
|
||||
currentRow = rows.get(0);
|
||||
Log.debug("Create EditRowPanel(): [" + trId.toString() + " , RowRaw:"
|
||||
+ row + "]");
|
||||
if (rowRaw == null) {
|
||||
UtilsGXT3.alert("Attentions", "No row selected");
|
||||
} else {
|
||||
init();
|
||||
|
@ -180,8 +184,8 @@ public class EditRowPanel extends FramedPanel {
|
|||
ColumnTypeCode.DIMENSION.toString()) == 0
|
||||
|| col.getTypeCode().compareTo(
|
||||
ColumnTypeCode.TIMEDIMENSION.toString()) == 0) {
|
||||
|
||||
FieldLabel dimensionLabel=retrieveDimensionLabel(col);
|
||||
|
||||
FieldLabel dimensionLabel = retrieveDimensionLabel(col);
|
||||
fields.add(dimensionLabel);
|
||||
} else {
|
||||
if (col.getDataTypeName().compareTo(
|
||||
|
@ -190,9 +194,21 @@ public class EditRowPanel extends FramedPanel {
|
|||
radioTrue.setBoxLabel("true");
|
||||
Radio radioFalse = new Radio();
|
||||
radioFalse.setBoxLabel("false");
|
||||
|
||||
String value=rowRaw.getMap().get(col.getColumnId());
|
||||
if(new Boolean(value)){
|
||||
radioTrue.setValue(true);
|
||||
} else {
|
||||
radioFalse.setValue(true);
|
||||
}
|
||||
ToggleGroup toggleGroup = new ToggleGroup();
|
||||
toggleGroup.add(radioTrue);
|
||||
toggleGroup.add(radioFalse);
|
||||
|
||||
HorizontalPanel hp = new HorizontalPanel();
|
||||
hp.add(radioTrue);
|
||||
hp.add(radioFalse);
|
||||
|
||||
FieldLabel booleanLabel = new FieldLabel(hp,
|
||||
col.getLabel());
|
||||
booleanLabel.setId(col.getColumnId());
|
||||
|
@ -201,6 +217,16 @@ public class EditRowPanel extends FramedPanel {
|
|||
if (col.getDataTypeName().compareTo(
|
||||
ColumnDataType.Date.toString()) == 0) {
|
||||
DateField date = new DateField();
|
||||
String value=rowRaw.getMap().get(col.getColumnId());
|
||||
Date d=null;
|
||||
try{
|
||||
d=sdf.parse(value);
|
||||
} catch(Throwable e){
|
||||
Log.error("Error parsing date string: "+e.getLocalizedMessage());
|
||||
}
|
||||
if(d!=null){
|
||||
date.setValue(d);
|
||||
}
|
||||
FieldLabel dateLabel = new FieldLabel(date,
|
||||
col.getLabel());
|
||||
dateLabel.setId(col.getColumnId());
|
||||
|
@ -209,6 +235,8 @@ public class EditRowPanel extends FramedPanel {
|
|||
if (col.getDataTypeName().compareTo(
|
||||
ColumnDataType.Text.toString()) == 0) {
|
||||
TextField text = new TextField();
|
||||
String value=rowRaw.getMap().get(col.getColumnId());
|
||||
text.setValue(value);
|
||||
text.addValueChangeHandler(new ValueChangeHandler<String>() {
|
||||
@Override
|
||||
public void onValueChange(
|
||||
|
@ -224,6 +252,8 @@ public class EditRowPanel extends FramedPanel {
|
|||
if (col.getDataTypeName().compareTo(
|
||||
ColumnDataType.Geometry.toString()) == 0) {
|
||||
TextField geometry = new TextField();
|
||||
String value=rowRaw.getMap().get(col.getColumnId());
|
||||
geometry.setValue(value);
|
||||
geometry.addValueChangeHandler(new ValueChangeHandler<String>() {
|
||||
@Override
|
||||
public void onValueChange(
|
||||
|
@ -239,7 +269,8 @@ public class EditRowPanel extends FramedPanel {
|
|||
if (col.getDataTypeName().compareTo(
|
||||
ColumnDataType.Integer.toString()) == 0) {
|
||||
TextField integ = new TextField();
|
||||
|
||||
String value=rowRaw.getMap().get(col.getColumnId());
|
||||
integ.setValue(value);
|
||||
integ.addValueChangeHandler(new ValueChangeHandler<String>() {
|
||||
@Override
|
||||
public void onValueChange(
|
||||
|
@ -256,6 +287,8 @@ public class EditRowPanel extends FramedPanel {
|
|||
ColumnDataType.Numeric
|
||||
.toString()) == 0) {
|
||||
TextField numeric = new TextField();
|
||||
String value=rowRaw.getMap().get(col.getColumnId());
|
||||
numeric.setValue(value);
|
||||
numeric.setId(col.getColumnId());
|
||||
numeric.addValueChangeHandler(new ValueChangeHandler<String>() {
|
||||
@Override
|
||||
|
@ -284,54 +317,50 @@ public class EditRowPanel extends FramedPanel {
|
|||
|
||||
}
|
||||
|
||||
|
||||
protected FieldLabel retrieveDimensionLabel(final ColumnData col){
|
||||
protected FieldLabel retrieveDimensionLabel(final ColumnData col) {
|
||||
// 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());
|
||||
|
||||
|
||||
Log.debug("ComboDimensionType created");
|
||||
|
||||
|
||||
|
||||
final DimensionRowSelectionListener listener=new DimensionRowSelectionListener() {
|
||||
|
||||
|
||||
final DimensionRowSelectionListener listener = new DimensionRowSelectionListener() {
|
||||
|
||||
@Override
|
||||
public void selectedDimensionRow(DimensionRow dimensionRow) {
|
||||
comboDimension.setValue(dimensionRow);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void failedDimensionRowSelection(String reason, String detail) {
|
||||
Log.error("Change Value Failed:" + reason + " " + detail);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void abortedDimensionRowSelection() {
|
||||
Log.debug("Change Value Aborted");
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
final CellData cellData = new CellData(currentRow,
|
||||
col.getName(), col.getColumnId(), col.getLabel(),
|
||||
currentRow, 0, 0);
|
||||
|
||||
|
||||
final CellData cellData = new CellData(rowRaw.getMap().get(
|
||||
col.getColumnId()), col.getName(), col.getColumnId(),
|
||||
col.getLabel(), rowRaw.getRowId(), 0, 0);
|
||||
|
||||
comboDimension.addTriggerClickHandler(new TriggerClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onTriggerClick(TriggerClickEvent event) {
|
||||
Log.debug("ComboDimensionRows TriggerClickEvent");
|
||||
comboDimension.collapse();
|
||||
|
||||
|
||||
DimensionRowSelectionDialog dialogDimensionRowSelection = new DimensionRowSelectionDialog(
|
||||
col, cellData, eventBus);
|
||||
dialogDimensionRowSelection.addListener(listener);
|
||||
|
@ -346,12 +375,10 @@ public class EditRowPanel extends FramedPanel {
|
|||
comboDimension.setEditable(false);
|
||||
comboDimension.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
|
||||
FieldLabel dimensionLabel = new FieldLabel(comboDimension,
|
||||
col.getLabel());
|
||||
dimensionLabel.setId(col.getColumnId());
|
||||
return dimensionLabel;
|
||||
return dimensionLabel;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue