Merge pull request 'feature_27488' (!4) from feature_27488 into master

Reviewed-on: #4
This commit is contained in:
Francesco Mangiacrapa 2024-06-28 16:34:15 +02:00
commit 6347b32450
11 changed files with 361 additions and 102 deletions

View File

@ -4,6 +4,13 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v2.2.0-SNAPSHOT] - 2024-05-17
#### Enhancements
- [#27488] In edit mode allowed to erase (not mandatory) fields according to data type
- [#27627] Moved logs at TRACE level
## [v2.1.1] - 2024-03-19 ## [v2.1.1] - 2024-03-19
#### Enhancements #### Enhancements

View File

@ -14,7 +14,7 @@
<groupId>org.gcube.portlets.widgets</groupId> <groupId>org.gcube.portlets.widgets</groupId>
<artifactId>metadata-profile-form-builder-widget</artifactId> <artifactId>metadata-profile-form-builder-widget</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>2.1.1</version> <version>2.2.0-SNAPSHOT</version>
<name>Metadata Profile Form Builder</name> <name>Metadata Profile Form Builder</name>
<description> <description>
The Metadata Profile Form Builder is a widget able to build dynamically a web form by reading "gCube Metadata Profile/s" The Metadata Profile Form Builder is a widget able to build dynamically a web form by reading "gCube Metadata Profile/s"

View File

@ -30,6 +30,7 @@ import com.github.gwtbootstrap.client.ui.TextBox;
import com.github.gwtbootstrap.client.ui.constants.AlertType; import com.github.gwtbootstrap.client.ui.constants.AlertType;
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType; import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
import com.github.gwtbootstrap.client.ui.constants.IconType; import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.github.gwtbootstrap.client.ui.constants.ResizeType;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.SpanElement; import com.google.gwt.dom.client.SpanElement;
@ -58,10 +59,24 @@ import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
/**
* The Class MetaDataFieldSkeleton.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* May 20, 2024
*/
public class MetaDataFieldSkeleton extends Composite { public class MetaDataFieldSkeleton extends Composite {
private static MetaDataFieldSkeletonUiBinder uiBinder = GWT.create(MetaDataFieldSkeletonUiBinder.class); private static MetaDataFieldSkeletonUiBinder uiBinder = GWT.create(MetaDataFieldSkeletonUiBinder.class);
/**
* The Interface MetaDataFieldSkeletonUiBinder.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* May 20, 2024
*/
interface MetaDataFieldSkeletonUiBinder extends UiBinder<Widget, MetaDataFieldSkeleton> { interface MetaDataFieldSkeletonUiBinder extends UiBinder<Widget, MetaDataFieldSkeleton> {
} }
@ -70,7 +85,7 @@ public class MetaDataFieldSkeleton extends Composite {
@UiField @UiField
SpanElement name; SpanElement name;
@UiField @UiField
SimplePanel elementPanel; FlowPanel elementPanel;
@UiField @UiField
FlowPanel noteFieldContainer; FlowPanel noteFieldContainer;
@UiField @UiField
@ -85,6 +100,11 @@ public class MetaDataFieldSkeleton extends Composite {
FocusPanel focusPanelIconContainer; FocusPanel focusPanelIconContainer;
@UiField @UiField
ControlGroup metafieldControlGroup; ControlGroup metafieldControlGroup;
@UiField
Button eraseButton;
@UiField
FlowPanel eraseFieldContainer;
// private static final String REGEX_IS_NUMBER = "[0-9]+[.]?[0-9]+"; // private static final String REGEX_IS_NUMBER = "[0-9]+[.]?[0-9]+";
@ -122,16 +142,26 @@ public class MetaDataFieldSkeleton extends Composite {
private static final String UPLOAD_MISSING_FILE = "You must upload a file"; private static final String UPLOAD_MISSING_FILE = "You must upload a file";
/**
* Instantiates a new meta data field skeleton.
*
* @param field the field
* @param eventBus the event bus
* @param operation the operation
* @throws Exception the exception
*/
public MetaDataFieldSkeleton(final MetadataFieldWrapper field, HandlerManager eventBus, OPERATION operation) public MetaDataFieldSkeleton(final MetadataFieldWrapper field, HandlerManager eventBus, OPERATION operation)
throws Exception { throws Exception {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
// prepare information // prepare information
this.field = field; this.field = field;
// event bus // event bus
this.eventBus = eventBus; this.eventBus = eventBus;
eraseFieldContainer.setVisible(false);
eraseButton.setIcon(IconType.BAN_CIRCLE);
// bind // bind
bind(); bind();
@ -165,6 +195,7 @@ public class MetaDataFieldSkeleton extends Composite {
final TextArea textArea = new TextArea(); final TextArea textArea = new TextArea();
textArea.setWidth("100%"); textArea.setWidth("100%");
textArea.setResize(ResizeType.VERTICAL);
if (field.getDefaultValue() != null) if (field.getDefaultValue() != null)
textArea.setText(field.getDefaultValue()); textArea.setText(field.getDefaultValue());
@ -237,14 +268,16 @@ public class MetaDataFieldSkeleton extends Composite {
case Text: case Text:
holder = new TextArea(); holder = new TextArea();
TextArea txtArea = ((TextArea) holder);
txtArea.setResize(ResizeType.VERTICAL);
if (field.getDefaultValue() != null) if (field.getDefaultValue() != null)
((TextArea) holder).setText(field.getDefaultValue()); txtArea.setText(field.getDefaultValue());
if (operation.equals(OPERATION.UPDATE)) { if (operation.equals(OPERATION.UPDATE)) {
try { try {
if (field.getCurrentSingleValue() != null) if (field.getCurrentSingleValue() != null)
((TextArea) holder).setText((String) field.getCurrentSingleValue()); txtArea.setText((String) field.getCurrentSingleValue());
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
} }
@ -420,11 +453,7 @@ public class MetaDataFieldSkeleton extends Composite {
// if it is not mandatory and not multi-selection, add a disabled option // if it is not mandatory and not multi-selection, add a disabled option
// (placeholder) // (placeholder)
if (!field.getMandatory() && !field.isMultiSelection()) { if (!field.getMandatory() && !field.isMultiSelection()) {
tempListBox.addItem("Select " + field.getFieldName()); listBoxSelectPlaceholder(tempListBox);
tempListBox.setValue(0, "");
tempListBox.getElement().getElementsByTagName("option").getItem(0).setAttribute("disabled",
"disabled");
tempListBox.setSelectedValue("Select " + field.getFieldName());
} }
// get vocabulary fields // get vocabulary fields
@ -438,23 +467,23 @@ public class MetaDataFieldSkeleton extends Composite {
if (field.getDefaultValue() != null) if (field.getDefaultValue() != null)
tempListBox.setSelectedValue(field.getDefaultValue()); tempListBox.setSelectedValue(field.getDefaultValue());
//to be sure // to be sure
tempListBox.setMultipleSelect(field.isMultiSelection()); tempListBox.setMultipleSelect(field.isMultiSelection());
if (operation.equals(OPERATION.UPDATE)) { if (operation.equals(OPERATION.UPDATE)) {
try { try {
if (field.getCurrentValues() != null) { if (field.getCurrentValues() != null) {
if (field.isMultiSelection()) { if (field.isMultiSelection()) {
//Buggy in Bootstrap // Buggy in Bootstrap
for (String value : field.getCurrentValues()) { for (String value : field.getCurrentValues()) {
GWT.log("Multiple Selecting: "+value); GWT.log("Multiple Selecting: " + value);
tempListBox.setSelectedValue((String) value); tempListBox.setSelectedValue((String) value);
} }
}else { } else {
GWT.log("Selecting: "+field.getCurrentSingleValue()); GWT.log("Selecting: " + field.getCurrentSingleValue());
tempListBox.setSelectedValue((String) field.getCurrentSingleValue()); tempListBox.setSelectedValue((String) field.getCurrentSingleValue());
} }
} }
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
@ -498,13 +527,18 @@ public class MetaDataFieldSkeleton extends Composite {
mandatorySymbol.getStyle().setDisplay(Display.NONE); mandatorySymbol.getStyle().setDisplay(Display.NONE);
// add to the elementPanel // add to the elementPanel
elementPanel.add(holder); elementPanel.insert(holder, 0);
// set holder width // set holder width
if (holder.getClass().equals(ListBox.class)) if (holder.getClass().equals(ListBox.class))
holder.setWidth("96%"); holder.setWidth("99%");
else else
holder.setWidth("95%"); holder.setWidth("97%");
//If the field is erasable views the erase panel
if(field.isErasableField()) {
eraseFieldContainer.setVisible(true);
}
// set the notes, if any, and the popover // set the notes, if any, and the popover
if (field.getNote() != null && !field.getNote().isEmpty()) { if (field.getNote() != null && !field.getNote().isEmpty()) {
@ -541,7 +575,7 @@ public class MetaDataFieldSkeleton extends Composite {
} }
/** /**
* Bind on events * Bind on events.
*/ */
private void bind() { private void bind() {
@ -557,8 +591,22 @@ public class MetaDataFieldSkeleton extends Composite {
} }
}); });
eraseButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
erase();
}
});
} }
/**
* On info icon click.
*
* @param c the c
*/
@UiHandler("focusPanelIconContainer") @UiHandler("focusPanelIconContainer")
void onInfoIconClick(ClickEvent c) { void onInfoIconClick(ClickEvent c) {
@ -577,8 +625,8 @@ public class MetaDataFieldSkeleton extends Composite {
} }
/** /**
* Check if this field has valid values * Check if this field has valid values.
* *
* @return a string with the occurred error on error, null otherwise * @return a string with the occurred error on error, null otherwise
*/ */
public String isFieldValueValid() { public String isFieldValueValid() {
@ -764,10 +812,10 @@ public class MetaDataFieldSkeleton extends Composite {
} }
/** /**
* Check if this string is a number * Check if this string is a number.
* *
* @param numberValue * @param numberValue the number value
* @return * @return true, if is a number
*/ */
private boolean isANumber(String numberValue) { private boolean isANumber(String numberValue) {
return numberValue.matches("-?\\d+(\\.\\d+)?"); return numberValue.matches("-?\\d+(\\.\\d+)?");
@ -776,9 +824,9 @@ public class MetaDataFieldSkeleton extends Composite {
/** /**
* Check if value matches validator (regex). In case validator is null, true is * Check if value matches validator (regex). In case validator is null, true is
* returned. * returned.
* *
* @param value * @param value the value
* @param validator * @param validator the validator
* @return true if validator is null OR value.matches(reges), false otherwise * @return true if validator is null OR value.matches(reges), false otherwise
*/ */
private boolean checkValidator(String value, String validator) { private boolean checkValidator(String value, String validator) {
@ -793,8 +841,8 @@ public class MetaDataFieldSkeleton extends Composite {
/** /**
* Returns the current value of the field. In case of TimeInterval or TimeList * Returns the current value of the field. In case of TimeInterval or TimeList
* see getTimeIntervalOrTimeListWithoutMissing() * see getTimeIntervalOrTimeListWithoutMissing()
* *
* @return * @return the field current value
*/ */
public List<String> getFieldCurrentValue() { public List<String> getFieldCurrentValue() {
@ -918,9 +966,9 @@ public class MetaDataFieldSkeleton extends Composite {
} }
/** /**
* Returns the current name of the field * Returns the current name of the field.
* *
* @return * @return the field name original
*/ */
public String getFieldNameOriginal() { public String getFieldNameOriginal() {
@ -929,28 +977,149 @@ public class MetaDataFieldSkeleton extends Composite {
} }
/** /**
* Returns the current name of the field * Returns the current name of the field.
* *
* @return * @return the field name qualified
*/ */
public String getFieldNameQualified() { public String getFieldNameQualified() {
//see https://support.d4science.org/issues/23544 // see https://support.d4science.org/issues/23544
if (field.getFieldId() != null) { if (field.getFieldId() != null) {
return field.getFieldId(); return field.getFieldId();
} }
//Using the getFieldNameFromCategory if the category is present in the model as cateogory:fieldName // Using the getFieldNameFromCategory if the category is present in the model as
if (field.getFieldNameFromCategory() != null && field.getFieldNameFromCategory().compareTo(field.getFieldName())!=0) { // cateogory:fieldName
if (field.getFieldNameFromCategory() != null
&& field.getFieldNameFromCategory().compareTo(field.getFieldName()) != 0) {
return field.getFieldNameFromCategory(); return field.getFieldNameFromCategory();
} }
return field.getFieldName(); return field.getFieldName();
} }
/** /**
* Freeze this widget (after on create) * Erase the field. Reset the field
*/
private void erase() {
if (field.isErasableField()) {
switch (field.getType()) {
case Boolean:
((CheckBox) holder).setValue(false);
break;
case GeoJSON:
case Text:
((TextArea) holder).setText("");
break;
case Time:
DataTimeBox dtbox = ((DataTimeBox) holder);
dtbox.setStartDate(null, null);
dtbox.setEndDate(null, null);
break;
case Time_Interval:
DataTimeBox dtboxTI = rangesList.get(0);
dtboxTI.setStartDate(null, null);
dtboxTI.setEndDate(null, null);
break;
case Times_ListOf:
for (DataTimeBox el : rangesList) {
el.setStartDate(null, null);
el.setEndDate(null, null);
}
break;
case Number:
((TextBox) holder).setText("");
break;
case String:
if (holder.getClass().equals(ListBox.class)) {
ListBox tempListBox = (ListBox) holder;
// if it is not mandatory and not multi-selection, add a disabled option
// (placeholder)
//selecting the default value of the list
// if (field.getDefaultValue() != null) {
// tempListBox.setSelectedValue(field.getDefaultValue());
// return;
// }
//selecting unique element of the list
// if(tempListBox.getItemCount()==1) {
// tempListBox.setSelectedValue(tempListBox.getItemText(0));
// return;
// }
if (!field.isMultiSelection()) {
listBoxSelectPlaceholder(tempListBox);
} else {
// TODO
}
} else
((TextBox) holder).setText("");
break;
case File:
if (holder.getClass().equals(MultipleDilaogUpload.class)
|| holder.getClass().equals(DialogUpload.class)) {
DialogUpload dUpload = (DialogUpload) holder;
dUpload.eraseLastUpload();
}
break;
default:
break;
}
}
}
/**
* List box select placeholder.
*
* @param listBox the list box
*/
private void listBoxSelectPlaceholder(ListBox listBox) {
String placeholder = "Select " + field.getFieldName();
if(listBox.getItemCount()==0) {
//create
listBox.addItem(placeholder);
listBox.setValue(0, "");
listBox.getElement().getElementsByTagName("option").getItem(0).setAttribute("disabled", "disabled");
listBox.setSelectedIndex(0);
}else {
//update
String itemText = listBox.getItemText(0);
//if the first element is the placeholder, select it
if(itemText!=null && itemText.compareTo(placeholder)==0) {
listBox.setValue(0, "");
listBox.getElement().getElementsByTagName("option").getItem(0).setAttribute("disabled", "disabled");
listBox.setSelectedIndex(0);
}
}
}
/**
* Freeze this widget (after on create).
*
* @param bool the bool
*/ */
public void freeze(boolean bool) { public void freeze(boolean bool) {
@ -998,7 +1167,7 @@ public class MetaDataFieldSkeleton extends Composite {
break; break;
case File: case File:
if (holder.getClass().equals(MultipleDilaogUpload.class) || holder.getClass().equals(DialogUpload.class)) { if (holder.getClass().equals(MultipleDilaogUpload.class) || holder.getClass().equals(DialogUpload.class)) {
DialogUpload dUpload = (DialogUpload) holder; DialogUpload dUpload = (DialogUpload) holder;
dUpload.enableUpload(!bool); dUpload.enableUpload(!bool);
@ -1011,20 +1180,26 @@ public class MetaDataFieldSkeleton extends Composite {
} }
/** /**
* Get the original MetadataFieldWrapper object * Get the original MetadataFieldWrapper object.
* *
* @return * @return the field
*/ */
public MetadataFieldWrapper getField() { public MetadataFieldWrapper getField() {
return field; return field;
} }
/**
* Removes the error.
*/
public void removeError() { public void removeError() {
metafieldControlGroup.setType(ControlGroupType.NONE); metafieldControlGroup.setType(ControlGroupType.NONE);
} }
/**
* Show error.
*/
public void showError() { public void showError() {
metafieldControlGroup.setType(ControlGroupType.ERROR); metafieldControlGroup.setType(ControlGroupType.ERROR);
@ -1032,10 +1207,10 @@ public class MetaDataFieldSkeleton extends Composite {
} }
/** /**
* Build the range interval * Build the range interval.
* *
* @param rangeValues * @param rangeValues the range values
* @param tb * @param tb the tb
*/ */
private void setRangeTimeInTimeBox(String rangeValues, DataTimeBox tb) { private void setRangeTimeInTimeBox(String rangeValues, DataTimeBox tb) {
// set time, if present // set time, if present
@ -1096,9 +1271,9 @@ public class MetaDataFieldSkeleton extends Composite {
} }
/** /**
* Check if the group associated (if it exists) should be forced * Check if the group associated (if it exists) should be forced.
* *
* @return * @return true, if is group to force
*/ */
public boolean isGroupToForce() { public boolean isGroupToForce() {
FieldAsGroup asGroup = field.getAsGroup(); FieldAsGroup asGroup = field.getAsGroup();
@ -1109,9 +1284,9 @@ public class MetaDataFieldSkeleton extends Composite {
} }
/** /**
* Check if the propagateUp is set * Check if the propagateUp is set.
* *
* @return * @return true, if is propagate up
*/ */
public boolean isPropagateUp() { public boolean isPropagateUp() {
FieldAsGroup asGroup = field.getAsGroup(); FieldAsGroup asGroup = field.getAsGroup();

View File

@ -1,15 +1,15 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"> <!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:b="urn:import:com.github.gwtbootstrap.client.ui" xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"
xmlns:b2="urn:import:com.github.gwtbootstrap.datetimepicker.client.ui" xmlns:b2="urn:import:com.github.gwtbootstrap.datetimepicker.client.ui"
xmlns:b3="urn:import:com.github.gwtbootstrap.datepicker.client.ui"> xmlns:b3="urn:import:com.github.gwtbootstrap.datepicker.client.ui">
<ui:style> <ui:style>
.note-container { .button-container {
display: inline-block;
float: right;
width: 5%;
color: #aaaaaa; color: #aaaaaa;
height: 100%;
text-align: center;
} }
.note-field-text { .note-field-text {
@ -22,6 +22,10 @@
.element-panel { .element-panel {
display: inline-block; display: inline-block;
} }
.flex-display-panel {
display: flex;
}
</ui:style> </ui:style>
<g:HTMLPanel width="100%"> <g:HTMLPanel width="100%">
<b:ControlGroup ui:field="metafieldControlGroup"> <b:ControlGroup ui:field="metafieldControlGroup">
@ -30,20 +34,41 @@
<span ui:field="name"></span> <span ui:field="name"></span>
</b:ControlLabel> </b:ControlLabel>
<b:Controls ui:field="controls"> <b:Controls ui:field="controls">
<g:FlowPanel width="95%"> <g:HTMLPanel width="95%">
<g:SimplePanel ui:field="elementPanel" styleName="{style.element-panel}" <table style="width:100%; table-layout:fixed; cellspacing:2;"><!-- you might want to use CSS instead of cellspacing -->
width="95%"> <colgroup>
<!-- Listbox, Checkbox, Textbox, Calendar etc --> <col style="width:95%;" />
</g:SimplePanel> <col style="width:5%;" />
<g:FlowPanel ui:field="noteFieldContainer" styleName="{style.note-container}"> </colgroup>
<b:Popover ui:field="noteFieldPopover" html="true" <tr>
animation="true" placement="LEFT"> <td>
<g:FocusPanel ui:field="focusPanelIconContainer"> <g:FlowPanel styleName="{style.flex-display-panel}">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIcon" /> <g:FlowPanel ui:field="elementPanel" width="95%">
</g:FocusPanel> <!-- Listbox, Checkbox, Textbox, Calendar etc -->
</b:Popover> </g:FlowPanel>
</g:FlowPanel> <g:FlowPanel ui:field="eraseFieldContainer"
</g:FlowPanel> width="5%">
<b:Button ui:field="eraseButton"
title="Reset this field" type="LINK"></b:Button>
</g:FlowPanel>
</g:FlowPanel>
</td>
<td style="vertical-align: top;">
<g:FlowPanel styleName="{style.button-container}">
<g:FlowPanel ui:field="noteFieldContainer">
<b:Popover ui:field="noteFieldPopover" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelIconContainer">
<b:Icon type="INFO_SIGN" size="TWO_TIMES"
ui:field="infoIcon" />
</g:FocusPanel>
</b:Popover>
</g:FlowPanel>
</g:FlowPanel>
</td>
</tr>
</table>
</g:HTMLPanel>
</b:Controls> </b:Controls>
</b:ControlGroup> </b:ControlGroup>
</g:HTMLPanel> </g:HTMLPanel>

View File

@ -17,6 +17,8 @@ import com.google.gwt.user.client.ui.Widget;
/** /**
* Widget for handling date-like fields. * Widget for handling date-like fields.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*
* @author updated by Francesco Mangiacrapa at ISTI-CNR
*/ */
public class DataTimeBox extends Composite{ public class DataTimeBox extends Composite{
@ -83,23 +85,35 @@ public class DataTimeBox extends Composite{
public void setStartDate(String date, String time){ public void setStartDate(String date, String time){
GWT.log("Date is " + date + " and time is " + time); GWT.log("Date is " + date + " and time is " + time);
startRangeDate.setValue(new Date(date)); if(date!=null && !date.isEmpty()) {
startRangeDate.setValue(new Date(date));
}else {
startRangeDate.setValue(null);
}
if(time != null && !time.isEmpty()){ if(time != null && !time.isEmpty()){
Date completeDate = new Date(); Date completeDate = new Date();
completeDate.setHours(Integer.parseInt(time.split(COLON)[0])); completeDate.setHours(Integer.parseInt(time.split(COLON)[0]));
completeDate.setMinutes(Integer.parseInt(time.split(COLON)[1])); completeDate.setMinutes(Integer.parseInt(time.split(COLON)[1]));
startRangeTime.setValue(completeDate); startRangeTime.setValue(completeDate);
}else {
startRangeTime.setValue(null);
} }
} }
public void setEndDate(String date, String time){ public void setEndDate(String date, String time){
GWT.log("Date is " + date + " and time is " + time); GWT.log("Date is " + date + " and time is " + time);
endRangeDate.setValue(new Date(date)); if(date!=null && !date.isEmpty()) {
endRangeDate.setValue(new Date(date));
}else {
endRangeDate.setValue(null);
}
if(time != null && !time.isEmpty()){ if(time != null && !time.isEmpty()){
Date completeDate = new Date(); Date completeDate = new Date();
completeDate.setHours(Integer.parseInt(time.split(COLON)[0])); completeDate.setHours(Integer.parseInt(time.split(COLON)[0]));
completeDate.setMinutes(Integer.parseInt(time.split(COLON)[1])); completeDate.setMinutes(Integer.parseInt(time.split(COLON)[1]));
endRangeTime.setValue(completeDate); endRangeTime.setValue(completeDate);
}else {
endRangeTime.setValue(null);
} }
} }

View File

@ -1,29 +1,34 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"> <!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:b2="urn:import:com.github.gwtbootstrap.datetimepicker.client.ui" xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b2="urn:import:com.github.gwtbootstrap.datetimepicker.client.ui"
xmlns:b3="urn:import:com.github.gwtbootstrap.datepicker.client.ui"> xmlns:b3="urn:import:com.github.gwtbootstrap.datepicker.client.ui">
<ui:style> <ui:style>
.flow-panel-style { .flow-panel-style {
display: inline-block; display: inline-block;
} }
.margin-left-5 {
margin-left: 5px;
}
</ui:style> </ui:style>
<g:HTMLPanel width="100%"> <g:HTMLPanel width="100%">
<g:FlowPanel width="100%"> <g:FlowPanel width="100%">
<g:FlowPanel width="100%" ui:field="singleDataStart" styleName="{style.flow-panel-style}" <g:FlowPanel width="100%" ui:field="singleDataStart"
visible="true"> styleName="{style.flow-panel-style}" visible="true">
<b3:DateBox format="yyyy-mm-dd" autoClose="true" <b3:DateBox format="yyyy-mm-dd" autoClose="true"
language="en" ui:field="startRangeDate" width="70%" /> language="en" ui:field="startRangeDate" width="70%" />
<b2:DateTimeBox format="hh:ii" autoClose="true" <b2:DateTimeBox format="hh:ii" autoClose="true"
maxView="HOUR" startView="HOUR" language="en" maxView="HOUR" startView="HOUR" language="en" width="25%"
width="20%" ui:field="startRangeTime" /> ui:field="startRangeTime" addStyleNames="{style.margin-left-5}" />
</g:FlowPanel> </g:FlowPanel>
<g:FlowPanel width="100%" ui:field="singleDataEnd" visible="false" <g:FlowPanel width="100%" ui:field="singleDataEnd"
styleName="{style.flow-panel-style}"> visible="false" styleName="{style.flow-panel-style}">
<b3:DateBox format="yyyy-mm-dd" autoClose="true" width="70%" <b3:DateBox format="yyyy-mm-dd" autoClose="true"
language="en" ui:field="endRangeDate" /> width="70%" language="en" ui:field="endRangeDate" />
<b2:DateTimeBox format="hh:ii" autoClose="true" <b2:DateTimeBox format="hh:ii" autoClose="true"
maxView="HOUR" startView="HOUR" language="en" maxView="HOUR" startView="HOUR" language="en" width="25%"
width="20%" ui:field="endRangeTime" /> ui:field="endRangeTime" addStyleNames="{style.margin-left-5}" />
</g:FlowPanel> </g:FlowPanel>
</g:FlowPanel> </g:FlowPanel>
</g:HTMLPanel> </g:HTMLPanel>

View File

@ -24,7 +24,6 @@ import com.google.gwt.user.client.ui.Hidden;
import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.VerticalPanel;
// TODO: Auto-generated Javadoc
/** /**
* The Class DialogUploadStream. * The Class DialogUploadStream.
* *
@ -59,8 +58,6 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific
/** The vertical main panel. */ /** The vertical main panel. */
protected VerticalPanel verticalMainPanel; protected VerticalPanel verticalMainPanel;
// private MonitorPanel monitorPanel;
// protected String clientUploadKey;
/** The purged uploading file name. */ /** The purged uploading file name. */
private String purgedUploadingFileName; private String purgedUploadingFileName;
@ -73,7 +70,6 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific
*/ */
public DialogUpload() { public DialogUpload() {
fileUpload = new FileUpload(); fileUpload = new FileUpload();
// fileUpload.getElement().setAttribute("multiple", "multiple");
setAction(ConstantsMPFormBuilder.METADATA_FORM_BUILDER_UPLOADING_SERVLET); setAction(ConstantsMPFormBuilder.METADATA_FORM_BUILDER_UPLOADING_SERVLET);
setEncoding(FormPanel.ENCODING_MULTIPART); setEncoding(FormPanel.ENCODING_MULTIPART);
setMethod(FormPanel.METHOD_POST); setMethod(FormPanel.METHOD_POST);
@ -98,7 +94,6 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific
verticalMainPanel.add(fileUpload); verticalMainPanel.add(fileUpload);
HorizontalPanel hp = new HorizontalPanel(); HorizontalPanel hp = new HorizontalPanel();
// hp.getElement().setId("hpID");
hp.getElement().getStyle().setWidth(100, Unit.PCT); hp.getElement().getStyle().setWidth(100, Unit.PCT);
hp.getElement().getStyle().setMarginTop(5, Unit.PX); hp.getElement().getStyle().setMarginTop(5, Unit.PX);
hp.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); hp.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
@ -145,7 +140,6 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific
*/ */
public void bindEvents() { public void bindEvents() {
this.addHandlers(); this.addHandlers();
// this.addListeners();
} }
/** /**
@ -165,8 +159,6 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific
if (result == null) { if (result == null) {
removeLoading(); removeLoading();
Window.alert("An error occurred during file upload"); Window.alert("An error occurred during file upload");
// new DialogResult(null, "Error during upload", "An error occurred during file
// upload.").center();
return; return;
} }
String strippedResult = new HTML(result).getText(); String strippedResult = new HTML(result).getText();
@ -276,6 +268,27 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific
fakeUploaders.clear(); fakeUploaders.clear();
} }
public void eraseLastUpload() {
try {
if (upv != null) {
verticalMainPanel.remove(upv.getPanel());
}
} catch (Exception e) {
}
if (timer != null) {
FileUploadingState upload = timer.getLastWorkspaceUploader();
if (upload != null)
timer.resetLastWorkspaceUploader();
}
fakeUploaders.clear();
fileUpload.getElement().setNodeValue("");
fileUpload.getElement().setPropertyObject("value", "");
}
/** /**
* Gets the file uploading state. * Gets the file uploading state.
* *
@ -355,7 +368,6 @@ public class DialogUpload extends FormPanel implements HasWorskpaceUploadNotific
* @param itemId the item id * @param itemId the item id
*/ */
protected void updateItemSubmitForm(String itemId) { protected void updateItemSubmitForm(String itemId) {
// hiddenOverwrite.setValue("true");
submitForm(); submitForm();
} }

View File

@ -156,6 +156,10 @@ public class TimerUpload extends Timer{
public FileUploadingState getLastWorkspaceUploader() { public FileUploadingState getLastWorkspaceUploader() {
return lastWorkspaceUploader; return lastWorkspaceUploader;
} }
protected void resetLastWorkspaceUploader() {
lastWorkspaceUploader = null;
}
} }

View File

@ -19,12 +19,12 @@ public class UploadedFileHttpSessionListener implements HttpSessionListener {
@Override @Override
public void sessionDestroyed(HttpSessionEvent event) { public void sessionDestroyed(HttpSessionEvent event) {
LOG.info("sessionDestroyed called"); LOG.trace("sessionDestroyed called");
try { try {
HttpSession httpSession = event.getSession(); HttpSession httpSession = event.getSession();
if(httpSession!=null) { if(httpSession!=null) {
LOG.info("Sesson id is: "+httpSession.getId()); LOG.trace("Sesson id is: "+httpSession.getId());
List<FileUploaded> listFileUploaded = (List<FileUploaded>) httpSession.getAttribute(ConstantsMPFormBuilder.FILE_UPLOADED_SESSION_ATTR); List<FileUploaded> listFileUploaded = (List<FileUploaded>) httpSession.getAttribute(ConstantsMPFormBuilder.FILE_UPLOADED_SESSION_ATTR);
if(listFileUploaded!=null) { if(listFileUploaded!=null) {
LOG.info("found file uploded in session, removing it"); LOG.info("found file uploded in session, removing it");
@ -41,6 +41,6 @@ public class UploadedFileHttpSessionListener implements HttpSessionListener {
@Override @Override
public void sessionCreated(HttpSessionEvent arg0) { public void sessionCreated(HttpSessionEvent arg0) {
LOG.info("sessionCreated called. Session id is: "+arg0.getSession().getId()); LOG.trace("sessionCreated called. Session id is: "+arg0.getSession().getId());
} }
} }

View File

@ -0,0 +1,6 @@
package org.gcube.portlets.widgets.mpformbuilder.shared.metadata;
public interface ErasableField {
public boolean isErasableField();
}

View File

@ -11,7 +11,7 @@ import java.util.List;
* *
* Mar 3, 2022 * Mar 3, 2022
*/ */
public class MetadataFieldWrapper implements UpdatableField, Serializable { public class MetadataFieldWrapper implements UpdatableField, ErasableField, Serializable {
private static final long serialVersionUID = -8476731365884466698L; private static final long serialVersionUID = -8476731365884466698L;
private String fieldId; private String fieldId;
@ -362,6 +362,17 @@ public class MetadataFieldWrapper implements UpdatableField, Serializable {
return null; return null;
} }
@Override
public boolean isErasableField() {
if(mandatory)
return false;
return true;
}
/** /**
* To string. * To string.