added and managed gui events

This commit is contained in:
francesco 2020-10-20 15:20:41 +02:00
parent 0ef68513b4
commit 133cbf63b8
2 changed files with 33 additions and 23 deletions

View File

@ -22,7 +22,9 @@ public class ConstantsMPFormBuilder {
public static final String DATE_FORMAT = "yyyy-MM-dd";
public static final String TIME_FORMAT = "HH:mm";
public static final String HOURS_MINUTES_SEPARATOR = ":";
public static final String TIME_FORMAT = "HH"+HOURS_MINUTES_SEPARATOR+"mm";
/**
* Log.

View File

@ -164,12 +164,6 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
/** The form builder service. */
private final MetadataProfileFormBuilderServiceAsync formBuilderService = GWT.create(MetadataProfileFormBuilderService.class);
/** The Constant REGEX_TITLE_PRODUCT_SUBWORD. */
private static final String REGEX_TITLE_PRODUCT_SUBWORD = "[^a-zA-Z0-9_.-]";
/** The Constant REGEX_MAIL. */
private static final String REGEX_MAIL = "\\b[\\w.%-]+@[-.\\w]+\\.[A-Za-z]{2,4}\\b";
/** The Constant NONE_PROFILE. */
private static final String NONE_PROFILE = "none";
@ -200,7 +194,9 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
/** The event bus. */
// event bus
private HandlerManager eventBus = new HandlerManager(null);
private HandlerManager uiBus = new HandlerManager(null);
private HandlerManager appManagerBus;
/** The custom field entries list. */
// added custom field entries (by the user)
@ -248,8 +244,8 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
* @param scope the scope
* @param genericResourceSecondaryType the generic resource secondary type
*/
public CreateMetadataForm(String scope, String genericResourceSecondaryType) {
this();
public CreateMetadataForm(String scope, String genericResourceSecondaryType, HandlerManager eventBus) {
this(eventBus);
this.scope = scope;
this.genericResourceSecondaryType = genericResourceSecondaryType;
showLoadingProfiles(true);
@ -275,8 +271,8 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
*
* @param profiles the profiles
*/
public CreateMetadataForm(List<MetaDataProfileBean> profiles) {
this();
public CreateMetadataForm(List<MetaDataProfileBean> profiles, HandlerManager eventBus) {
this(eventBus);
showLoadingProfiles(true);
createDatasetFormBody(profiles);
showLoadingProfiles(false);
@ -295,9 +291,11 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
/**
* Instantiates a new creates the dataset form.
* @param eventBus2
*/
private CreateMetadataForm() {
private CreateMetadataForm(HandlerManager eventBus) {
initWidget(uiBinder.createAndBindUi(this));
this.appManagerBus = eventBus;
bind();
prepareInfoIcons();
showSelectedProfiles(false);
@ -331,7 +329,7 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
*/
private void bind() {
// when a custom field is removed, remove it from the list
eventBus.addHandler(DeleteCustomFieldEvent.TYPE, new DeleteCustomFieldEventHandler() {
uiBus.addHandler(DeleteCustomFieldEvent.TYPE, new DeleteCustomFieldEventHandler() {
@Override
public void onRemoveEntry(DeleteCustomFieldEvent event) {
@ -341,7 +339,7 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
});
// on close form
eventBus.addHandler(CloseCreationFormEvent.TYPE, new CloseCreationFormEventHandler() {
uiBus.addHandler(CloseCreationFormEvent.TYPE, new CloseCreationFormEventHandler() {
@Override
public void onClose(CloseCreationFormEvent event) {
InfoIconsLabels.closeDialogBox(popupOpenedIds);
@ -465,7 +463,7 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
MetaDataField fieldWidget;
try {
fieldWidget = new MetaDataField(field, eventBus);
fieldWidget = new MetaDataField(field, uiBus);
metadataFieldsPanel.add(fieldWidget);
listOfMetadataFields.add(fieldWidget);
} catch (Exception e) {
@ -494,7 +492,7 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
MetaDataField fieldWidget;
try {
fieldWidget = new MetaDataField(metadataFieldWrapper, eventBus);
fieldWidget = new MetaDataField(metadataFieldWrapper, uiBus);
cp.addField(fieldWidget);
listOfMetadataFields.add(fieldWidget);
} catch (Exception e) {
@ -520,7 +518,7 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
MetaDataField fieldWidget;
try {
fieldWidget = new MetaDataField(field, eventBus);
fieldWidget = new MetaDataField(field, uiBus);
extrasCategory.addField(fieldWidget);
listOfMetadataFields.add(fieldWidget);
} catch (Exception e) {
@ -543,7 +541,7 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
@UiHandler("addCustomFieldButton")
void addCustomFieldEvent(ClickEvent e){
CustomFieldEntry toAdd = new CustomFieldEntry(eventBus, "", "", true);
CustomFieldEntry toAdd = new CustomFieldEntry(uiBus, "", "", true);
customFieldEntriesList.add(toAdd);
customFields.add(toAdd);
@ -672,7 +670,17 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
* @return true, if is form data valid
*/
public boolean isFormDataValid() {
return areProfileDataValid() == null;
//means no error
if(areProfileDataValid() == null) {
//means created button already fired
if(formDataBean != null) {
return true;
}else {
alertOnCreate("Please press the button 'Create' to confirm your data entries", AlertType.ERROR, true);
}
}
return false;
}
@ -925,9 +933,9 @@ public class CreateMetadataForm extends Composite implements HasGenericFormListe
*
* @return the creates the button
*/
public Button getCreateButton() {
return createButton;
}
// public Button getCreateButton() {
// return createButton;
// }
/**