|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|
|
|
|
|
|
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.CloseCreationFormEvent;
|
|
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.CloseCreationFormEventHandler;
|
|
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.openlayerwidget.GeoJsonAreaSelectionDialog;
|
|
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.metadata.timeandreanges.DataTimeBox;
|
|
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.GcubeDialogExtended;
|
|
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.metadata.FieldAsGroup;
|
|
|
|
@ -18,6 +19,7 @@ import com.github.gwtbootstrap.client.ui.ControlGroup;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.ControlLabel;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.Controls;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.Icon;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.InputAddOn;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.ListBox;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.Popover;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.TextArea;
|
|
|
|
@ -37,6 +39,7 @@ import com.google.gwt.event.shared.HandlerManager;
|
|
|
|
|
import com.google.gwt.uibinder.client.UiBinder;
|
|
|
|
|
import com.google.gwt.uibinder.client.UiField;
|
|
|
|
|
import com.google.gwt.uibinder.client.UiHandler;
|
|
|
|
|
import com.google.gwt.user.client.Command;
|
|
|
|
|
import com.google.gwt.user.client.Window;
|
|
|
|
|
import com.google.gwt.user.client.ui.Composite;
|
|
|
|
|
import com.google.gwt.user.client.ui.FlowPanel;
|
|
|
|
@ -111,7 +114,7 @@ public class MetaDataFieldSkeleton extends Composite{
|
|
|
|
|
|
|
|
|
|
switch(field.getType()){
|
|
|
|
|
|
|
|
|
|
case Boolean :
|
|
|
|
|
case Boolean :
|
|
|
|
|
|
|
|
|
|
// its a checkbox
|
|
|
|
|
holder = new CheckBox();
|
|
|
|
@ -120,7 +123,44 @@ public class MetaDataFieldSkeleton extends Composite{
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GeoJSON:
|
|
|
|
|
case Text:
|
|
|
|
|
//MANAGED By FRANCESCO
|
|
|
|
|
InputAddOn addOn = new InputAddOn();
|
|
|
|
|
final TextArea textArea = new TextArea();
|
|
|
|
|
|
|
|
|
|
if(field.getDefaultValue() != null)
|
|
|
|
|
textArea.setText(field.getDefaultValue());
|
|
|
|
|
|
|
|
|
|
addOn.add(textArea);
|
|
|
|
|
Button butt = new Button();
|
|
|
|
|
butt.setIcon(IconType.MAP_MARKER);
|
|
|
|
|
butt.addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
|
|
|
|
|
|
final GeoJsonAreaSelectionDialog dialog=new GeoJsonAreaSelectionDialog();
|
|
|
|
|
|
|
|
|
|
Command fillGeoJSONArea = new Command() {
|
|
|
|
|
public void execute() {
|
|
|
|
|
textArea.setText(dialog.getWKTToGeoJSON());
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
dialog.fireCommandOnResponse(fillGeoJSONArea);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dialog.show();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addOn.add(butt);
|
|
|
|
|
holder = addOn;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case Text:
|
|
|
|
|
|
|
|
|
|
holder = new TextArea();
|
|
|
|
|
|
|
|
|
@ -150,7 +190,7 @@ public class MetaDataFieldSkeleton extends Composite{
|
|
|
|
|
rangesList.add(rangeBox);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case Times_ListOf:
|
|
|
|
|
case Times_ListOf:
|
|
|
|
|
|
|
|
|
|
holder = new FlowPanel();
|
|
|
|
|
|
|
|
|
@ -161,7 +201,7 @@ public class MetaDataFieldSkeleton extends Composite{
|
|
|
|
|
SimplePanel panelFirstRange = new SimplePanel();
|
|
|
|
|
DataTimeBox rangeBoxFirst = new DataTimeBox(true);
|
|
|
|
|
setRangeTimeInTimeBox(field.getDefaultValue(), rangeBoxFirst);
|
|
|
|
|
((SimplePanel)panelFirstRange).add(rangeBoxFirst);
|
|
|
|
|
panelFirstRange.add(rangeBoxFirst);
|
|
|
|
|
rangesList.add(rangeBoxFirst);
|
|
|
|
|
|
|
|
|
|
// Add more button
|
|
|
|
@ -350,12 +390,12 @@ public class MetaDataFieldSkeleton extends Composite{
|
|
|
|
|
|
|
|
|
|
switch(field.getType()){
|
|
|
|
|
|
|
|
|
|
case Boolean :
|
|
|
|
|
case Boolean :
|
|
|
|
|
|
|
|
|
|
// nothing to validate
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
case Text:
|
|
|
|
|
case Text:
|
|
|
|
|
case GeoJSON: // validation for geojson will be performed at server side as well TODO
|
|
|
|
|
|
|
|
|
|
String textAreaValue = getFieldCurrentValue().get(0);
|
|
|
|
@ -368,7 +408,7 @@ public class MetaDataFieldSkeleton extends Composite{
|
|
|
|
|
else return checkValidator(textAreaValue, field.getValidator()) ? null : MALFORMED_ATTRIBUTE;
|
|
|
|
|
else return MANDATORY_ATTRIBUTE_MISSING;
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
if(textAreaValue.trim().isEmpty())
|
|
|
|
|
return null;
|
|
|
|
@ -403,7 +443,7 @@ public class MetaDataFieldSkeleton extends Composite{
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
case Times_ListOf:
|
|
|
|
|
case Times_ListOf:
|
|
|
|
|
|
|
|
|
|
for(DataTimeBox el: rangesList){
|
|
|
|
|
|
|
|
|
@ -447,7 +487,7 @@ public class MetaDataFieldSkeleton extends Composite{
|
|
|
|
|
|
|
|
|
|
case String:
|
|
|
|
|
|
|
|
|
|
// just handle the case of textbox
|
|
|
|
|
// just handle the case of textbox
|
|
|
|
|
if(holder.getClass().equals(TextBox.class)){
|
|
|
|
|
|
|
|
|
|
String textBoxValue = getFieldCurrentValue().get(0);
|
|
|
|
@ -458,7 +498,7 @@ public class MetaDataFieldSkeleton extends Composite{
|
|
|
|
|
else return checkValidator(textBoxValue, field.getValidator()) ? null : MALFORMED_ATTRIBUTE;
|
|
|
|
|
else return MANDATORY_ATTRIBUTE_MISSING;
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
}else{
|
|
|
|
|
if(textBoxValue.trim().isEmpty())
|
|
|
|
|
return null;
|
|
|
|
|
else return checkValidator(textBoxValue, field.getValidator()) ? null : MALFORMED_ATTRIBUTE;
|
|
|
|
@ -467,7 +507,7 @@ public class MetaDataFieldSkeleton extends Composite{
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
|
|
List<String> listboxValues = getFieldCurrentValue();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(listboxValues.isEmpty() && field.getMandatory())
|
|
|
|
|
return MANDATORY_ATTRIBUTE_MISSING;
|
|
|
|
|
|
|
|
|
@ -476,7 +516,7 @@ public class MetaDataFieldSkeleton extends Composite{
|
|
|
|
|
|
|
|
|
|
if(field.getValidator() == null || field.getValidator().isEmpty())
|
|
|
|
|
continue;
|
|
|
|
|
else
|
|
|
|
|
else
|
|
|
|
|
if(checkValidator(value, field.getValidator()))
|
|
|
|
|
continue;
|
|
|
|
|
else return MALFORMED_ATTRIBUTE;
|
|
|
|
@ -533,12 +573,12 @@ public class MetaDataFieldSkeleton extends Composite{
|
|
|
|
|
|
|
|
|
|
switch(field.getType()){
|
|
|
|
|
|
|
|
|
|
case Boolean :
|
|
|
|
|
case Boolean :
|
|
|
|
|
|
|
|
|
|
toReturn.add(((CheckBox)holder).getValue().toString());
|
|
|
|
|
toReturn.add(((CheckBox)holder).getValue().toString());
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case Text:
|
|
|
|
|
case Text:
|
|
|
|
|
case GeoJSON:
|
|
|
|
|
|
|
|
|
|
toReturn.add(((TextArea)holder).getText());
|
|
|
|
@ -563,7 +603,7 @@ public class MetaDataFieldSkeleton extends Composite{
|
|
|
|
|
toReturn.add(manipulatedTemp);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case Times_ListOf:
|
|
|
|
|
case Times_ListOf:
|
|
|
|
|
|
|
|
|
|
manipulatedTemp = "";
|
|
|
|
|
for (DataTimeBox elem : rangesList) {
|
|
|
|
@ -574,9 +614,9 @@ public class MetaDataFieldSkeleton extends Composite{
|
|
|
|
|
|
|
|
|
|
String[] splitted = currentRange.split(DataTimeBox.RANGE_SEPARATOR_START_END);
|
|
|
|
|
if(splitted[0].equals(splitted[1]))
|
|
|
|
|
manipulatedTemp += (manipulatedTemp.isEmpty()) ? splitted[0] : RANGE_SEPARATOR + splitted[0];
|
|
|
|
|
manipulatedTemp += manipulatedTemp.isEmpty() ? splitted[0] : RANGE_SEPARATOR + splitted[0];
|
|
|
|
|
else
|
|
|
|
|
manipulatedTemp += (manipulatedTemp.isEmpty()) ? splitted[0] + DataTimeBox.RANGE_SEPARATOR_START_END + splitted[1] :
|
|
|
|
|
manipulatedTemp += manipulatedTemp.isEmpty() ? splitted[0] + DataTimeBox.RANGE_SEPARATOR_START_END + splitted[1] :
|
|
|
|
|
RANGE_SEPARATOR + splitted[0] + DataTimeBox.RANGE_SEPARATOR_START_END + splitted[1];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -607,7 +647,7 @@ public class MetaDataFieldSkeleton extends Composite{
|
|
|
|
|
toReturn.clear();
|
|
|
|
|
toReturn.add("");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
@ -647,13 +687,13 @@ public class MetaDataFieldSkeleton extends Composite{
|
|
|
|
|
|
|
|
|
|
switch(field.getType()){
|
|
|
|
|
|
|
|
|
|
case Boolean :
|
|
|
|
|
case Boolean :
|
|
|
|
|
|
|
|
|
|
((CheckBox)holder).setEnabled(false);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GeoJSON:
|
|
|
|
|
case Text:
|
|
|
|
|
case Text:
|
|
|
|
|
|
|
|
|
|
((TextArea)holder).setEnabled(false);
|
|
|
|
|
break;
|
|
|
|
@ -668,7 +708,7 @@ public class MetaDataFieldSkeleton extends Composite{
|
|
|
|
|
rangesList.get(0).freeze();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case Times_ListOf:
|
|
|
|
|
case Times_ListOf:
|
|
|
|
|
|
|
|
|
|
for(DataTimeBox el : rangesList)
|
|
|
|
|
el.freeze();
|
|
|
|
@ -684,7 +724,7 @@ public class MetaDataFieldSkeleton extends Composite{
|
|
|
|
|
|
|
|
|
|
if(holder.getClass().equals(ListBox.class))
|
|
|
|
|
((ListBox)holder).setEnabled(false);
|
|
|
|
|
else
|
|
|
|
|
else
|
|
|
|
|
((TextBox)holder).setEnabled(false);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
@ -782,7 +822,7 @@ public class MetaDataFieldSkeleton extends Composite{
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if the propagateUp is set
|
|
|
|
|
* @return
|
|
|
|
|