2016-05-26 18:12:53 +02:00
|
|
|
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2016-06-27 12:36:45 +02:00
|
|
|
import java.util.Collections;
|
2016-05-27 19:08:03 +02:00
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Iterator;
|
2016-05-26 18:12:53 +02:00
|
|
|
import java.util.List;
|
2016-05-27 19:08:03 +02:00
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map.Entry;
|
2016-05-26 18:12:53 +02:00
|
|
|
|
2016-06-06 17:24:52 +02:00
|
|
|
import org.gcube.portlets.user.gcubewidgets.client.elements.Span;
|
2016-05-26 18:12:53 +02:00
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherService;
|
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherServiceAsync;
|
2016-07-14 12:14:33 +02:00
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.CloseCreationFormEvent;
|
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.CloseCreationFormEventHandler;
|
2016-05-27 19:08:03 +02:00
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCustomFieldEvent;
|
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCustomFieldEventHandler;
|
2016-09-28 16:41:55 +02:00
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.dataset.resources.AddResourceContainer;
|
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.dataset.resources.AddResourceToDataset;
|
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.dataset.resources.AddedResourcesSummary;
|
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.dataset.resources.ResourcesTable;
|
2016-07-13 16:11:15 +02:00
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.GcubeDialogExtended;
|
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.InfoIconsLabels;
|
2016-09-14 16:29:52 +02:00
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DataType;
|
2016-05-27 19:08:03 +02:00
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetMetadataBean;
|
2016-05-26 18:12:53 +02:00
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.LicensesBean;
|
2016-06-09 18:58:19 +02:00
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetaDataProfileBean;
|
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetadataFieldWrapper;
|
2016-07-20 22:41:15 +02:00
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean;
|
2016-05-26 18:12:53 +02:00
|
|
|
|
2016-05-27 19:08:03 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.AlertBlock;
|
2016-05-26 18:12:53 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
|
|
|
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
2016-06-09 18:58:19 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.Form;
|
2016-07-13 16:11:15 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.Icon;
|
2016-05-26 18:12:53 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.ListBox;
|
2016-06-09 18:58:19 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.Paragraph;
|
2016-07-13 16:11:15 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.Popover;
|
2016-06-07 17:50:33 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.Tab;
|
|
|
|
import com.github.gwtbootstrap.client.ui.TabPanel;
|
2016-05-26 18:12:53 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.TextArea;
|
|
|
|
import com.github.gwtbootstrap.client.ui.TextBox;
|
2016-05-27 19:08:03 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.base.ListItem;
|
|
|
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
2016-06-10 12:10:18 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
2016-09-16 17:40:32 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
|
2016-06-07 17:50:33 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.resources.Bootstrap.Tabs;
|
2016-05-26 18:12:53 +02:00
|
|
|
import com.google.gwt.core.client.GWT;
|
2016-07-13 16:11:15 +02:00
|
|
|
import com.google.gwt.dom.client.Element;
|
|
|
|
import com.google.gwt.dom.client.Style.Cursor;
|
2016-06-09 18:58:19 +02:00
|
|
|
import com.google.gwt.event.dom.client.ChangeEvent;
|
|
|
|
import com.google.gwt.event.dom.client.ChangeHandler;
|
2016-05-26 18:12:53 +02:00
|
|
|
import com.google.gwt.event.dom.client.ClickEvent;
|
2016-05-27 19:08:03 +02:00
|
|
|
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
|
import com.google.gwt.event.dom.client.KeyCodes;
|
|
|
|
import com.google.gwt.event.dom.client.KeyDownEvent;
|
|
|
|
import com.google.gwt.event.shared.HandlerManager;
|
2016-05-26 18:12:53 +02:00
|
|
|
import com.google.gwt.uibinder.client.UiBinder;
|
|
|
|
import com.google.gwt.uibinder.client.UiField;
|
|
|
|
import com.google.gwt.uibinder.client.UiHandler;
|
2016-07-13 16:11:15 +02:00
|
|
|
import com.google.gwt.user.client.DOM;
|
|
|
|
import com.google.gwt.user.client.EventListener;
|
2016-06-06 17:24:52 +02:00
|
|
|
import com.google.gwt.user.client.Timer;
|
2016-06-10 12:10:18 +02:00
|
|
|
import com.google.gwt.user.client.Window;
|
2016-05-26 18:12:53 +02:00
|
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
2016-07-13 16:11:15 +02:00
|
|
|
import com.google.gwt.user.client.ui.Anchor;
|
2016-05-26 18:12:53 +02:00
|
|
|
import com.google.gwt.user.client.ui.Composite;
|
2016-05-27 19:08:03 +02:00
|
|
|
import com.google.gwt.user.client.ui.FlowPanel;
|
2016-07-13 16:11:15 +02:00
|
|
|
import com.google.gwt.user.client.ui.FocusPanel;
|
|
|
|
import com.google.gwt.user.client.ui.HTML;
|
2016-06-10 12:10:18 +02:00
|
|
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
2016-07-13 16:11:15 +02:00
|
|
|
import com.google.gwt.user.client.ui.IsWidget;
|
2016-07-06 18:41:43 +02:00
|
|
|
import com.google.gwt.user.client.ui.SimplePanel;
|
2016-06-07 17:50:33 +02:00
|
|
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
2016-05-26 18:12:53 +02:00
|
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
|
|
|
|
|
|
/**
|
2016-09-28 16:41:55 +02:00
|
|
|
* Create metadata form for ckan product.
|
2016-05-26 18:12:53 +02:00
|
|
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
|
|
|
*/
|
2016-06-08 18:31:54 +02:00
|
|
|
public class CreateDatasetForm extends Composite{
|
2016-07-14 11:26:43 +02:00
|
|
|
|
2016-05-26 18:12:53 +02:00
|
|
|
private static EditMetadataFormUiBinder uiBinder = GWT
|
|
|
|
.create(EditMetadataFormUiBinder.class);
|
|
|
|
|
|
|
|
interface EditMetadataFormUiBinder extends
|
2016-06-08 18:31:54 +02:00
|
|
|
UiBinder<Widget, CreateDatasetForm> {
|
2016-05-26 18:12:53 +02:00
|
|
|
}
|
|
|
|
|
2016-06-10 12:10:18 +02:00
|
|
|
@UiField HTMLPanel createDatasetMainPanel;
|
2016-05-26 18:12:53 +02:00
|
|
|
@UiField TextBox titleTextBox;
|
|
|
|
@UiField TextArea descriptionTextarea;
|
2016-05-27 19:08:03 +02:00
|
|
|
@UiField TextBox tagsEnterTextBox;
|
|
|
|
@UiField FlowPanel tagsPanel;
|
2016-05-26 18:12:53 +02:00
|
|
|
@UiField ListBox licenseListbox;
|
|
|
|
@UiField ListBox visibilityListbox;
|
2016-06-06 17:24:52 +02:00
|
|
|
@UiField ListBox organizationsListbox;
|
2016-05-26 18:12:53 +02:00
|
|
|
@UiField TextBox versionTextbox;
|
|
|
|
@UiField TextBox authorTextbox;
|
|
|
|
@UiField TextBox authorEmailTextbox;
|
|
|
|
@UiField TextBox maintainerTextbox;
|
|
|
|
@UiField TextBox maintainerEmailTextbox;
|
|
|
|
@UiField ControlGroup customFields;
|
|
|
|
@UiField Button addCustomFieldButton;
|
|
|
|
@UiField Button createButton;
|
|
|
|
@UiField Button resetButton;
|
2016-05-27 19:08:03 +02:00
|
|
|
@UiField AlertBlock infoBlock;
|
2016-07-07 16:52:10 +02:00
|
|
|
@UiField AlertBlock alertNoResources;
|
2016-06-09 18:58:19 +02:00
|
|
|
@UiField AlertBlock onContinueAlertBlock;
|
2016-06-06 17:24:52 +02:00
|
|
|
@UiField AlertBlock onCreateAlertBlock;
|
2016-06-09 18:58:19 +02:00
|
|
|
@UiField VerticalPanel metadataFieldsPanel;
|
|
|
|
@UiField ListBox metadataProfilesFormatListbox;
|
|
|
|
@UiField Form formFirstStep;
|
|
|
|
@UiField Form formSecondStep;
|
2016-07-06 18:41:43 +02:00
|
|
|
@UiField Form formThirdStep;
|
2016-06-09 18:58:19 +02:00
|
|
|
@UiField Button continueButton;
|
2016-09-12 17:58:50 +02:00
|
|
|
@UiField Button goBackButtonSecondStep;
|
2016-06-09 18:58:19 +02:00
|
|
|
@UiField Paragraph selectedProfile;
|
2016-06-10 12:10:18 +02:00
|
|
|
@UiField Button goToDatasetButton;
|
|
|
|
@UiField Button addResourcesButton;
|
2016-07-06 18:41:43 +02:00
|
|
|
@UiField SimplePanel workspaceResourcesContainer;
|
|
|
|
@UiField Button continueThirdStep;
|
|
|
|
@UiField Button goBackButtonFirstStep;
|
2016-07-13 16:11:15 +02:00
|
|
|
@UiField Anchor licenseUrlAnchor;
|
|
|
|
@UiField Paragraph unavailableUrl;
|
|
|
|
|
|
|
|
// info panels
|
|
|
|
@UiField Icon infoIconTags;
|
|
|
|
@UiField FocusPanel focusPanelTags;
|
|
|
|
@UiField Popover popoverTags;
|
2016-07-14 16:47:17 +02:00
|
|
|
@UiField Icon infoIconLicenses;
|
|
|
|
@UiField FocusPanel focusPanelLicenses;
|
|
|
|
@UiField Popover popoverLicenses;
|
2016-07-13 16:11:15 +02:00
|
|
|
@UiField Icon infoIconVisibility;
|
|
|
|
@UiField FocusPanel focusPanelVisibility;
|
|
|
|
@UiField Popover popoverVisibility;
|
|
|
|
@UiField Icon infoIconAuthor;
|
|
|
|
@UiField FocusPanel focusPanelAuthor;
|
|
|
|
@UiField Popover popoverAuthor;
|
|
|
|
@UiField Icon infoIconMaintainerEmail;
|
|
|
|
@UiField FocusPanel focusPanelMaintainerEmail;
|
|
|
|
@UiField Popover popoverMaintainerEmail;
|
|
|
|
@UiField Icon infoIconAuthorEmail;
|
|
|
|
@UiField FocusPanel focusPanelAuthorEmail;
|
|
|
|
@UiField Popover popoverAuthorEmail;
|
|
|
|
@UiField Icon infoIconProfiles;
|
|
|
|
@UiField FocusPanel focusPanelProfiles;
|
|
|
|
@UiField Popover popoverProfiles;
|
|
|
|
@UiField Icon infoIconMaintainer;
|
|
|
|
@UiField FocusPanel focusPanelMaintainer;
|
|
|
|
@UiField Popover popoverMaintainer;
|
|
|
|
@UiField Icon infoIconCustomFields;
|
|
|
|
@UiField FocusPanel focusPanelCustomFields;
|
|
|
|
@UiField Popover popoverCustomFields;
|
2016-07-13 18:13:50 +02:00
|
|
|
@UiField Icon infoIconResources;
|
|
|
|
@UiField FocusPanel focusPanelResources;
|
|
|
|
@UiField Popover popoverResources;
|
2016-09-23 18:50:16 +02:00
|
|
|
@UiField Icon infoIconTitle;
|
|
|
|
@UiField FocusPanel focusPanelTitle;
|
|
|
|
@UiField Popover popoverTitle;
|
2016-07-19 21:24:42 +02:00
|
|
|
@UiField ControlGroup metadataProfilesControlGroup;
|
2016-09-16 17:40:32 +02:00
|
|
|
@UiField ControlGroup productTitleGroup;
|
|
|
|
@UiField ControlGroup maintainerControlGroup;
|
|
|
|
@UiField ControlGroup versionControlGroup;
|
|
|
|
@UiField ControlGroup organizationsGroup;
|
2016-07-14 11:26:43 +02:00
|
|
|
|
2016-09-26 12:15:05 +02:00
|
|
|
// Create a remote service proxy to talk to the server-side ckan service.
|
|
|
|
private final CKanPublisherServiceAsync ckanServices = GWT.create(CKanPublisherService.class);
|
|
|
|
|
|
|
|
private static final String REGEX_TITLE_PRODUCT_SUBWORD = "[^a-zA-Z0-9_.-]";
|
|
|
|
private static final String REGEX_MAIL = "\\b[\\w.%-]+@[-.\\w]+\\.[A-Za-z]{2,4}\\b";
|
|
|
|
|
2016-09-26 14:12:26 +02:00
|
|
|
// error/info messages
|
2016-07-13 18:35:46 +02:00
|
|
|
protected static final String ERROR_PRODUCT_CREATION = "There was an error while trying to publish your product, sorry.. Retry later";
|
2016-09-26 14:12:26 +02:00
|
|
|
protected static final String PRODUCT_CREATED_OK = "Product correctly created!";
|
|
|
|
private static final String TRYING_TO_CREATE_PRODUCT = "Trying to create product, please wait";
|
2016-06-07 17:50:33 +02:00
|
|
|
|
|
|
|
// tab panel
|
|
|
|
private TabPanel tabPanel;
|
|
|
|
|
|
|
|
// add resource form
|
2016-06-08 18:31:54 +02:00
|
|
|
private AddResourceToDataset resourceForm;
|
2016-05-27 19:08:03 +02:00
|
|
|
|
|
|
|
// tags list
|
|
|
|
private List<String> tagsList = new ArrayList<String>();
|
|
|
|
|
2016-05-26 18:12:53 +02:00
|
|
|
// the licenses
|
|
|
|
private LicensesBean licenseBean;
|
|
|
|
|
2016-05-27 19:08:03 +02:00
|
|
|
// event bus
|
2016-07-20 22:41:15 +02:00
|
|
|
private HandlerManager eventBus;
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-05-26 18:12:53 +02:00
|
|
|
// added custom field entries
|
2016-07-20 22:41:15 +02:00
|
|
|
private List<CustomFieldEntry> customFieldEntriesList = new ArrayList<CustomFieldEntry>();
|
2016-06-06 17:24:52 +02:00
|
|
|
|
2016-05-27 19:08:03 +02:00
|
|
|
// dataset metadata bean
|
|
|
|
private DatasetMetadataBean receivedBean;
|
2016-05-26 18:12:53 +02:00
|
|
|
|
2016-06-07 17:50:33 +02:00
|
|
|
// the owner
|
|
|
|
private String owner;
|
2016-06-06 17:24:52 +02:00
|
|
|
|
2016-06-08 18:31:54 +02:00
|
|
|
// workspace request?
|
|
|
|
private boolean isWorkspaceRequest = false;
|
|
|
|
|
2016-06-09 18:58:19 +02:00
|
|
|
// the list of MetaDataFieldSkeleton added
|
2016-07-20 22:41:15 +02:00
|
|
|
private List<MetaDataFieldSkeleton> listOfMetadataFields = new ArrayList<MetaDataFieldSkeleton>();
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-07-06 18:41:43 +02:00
|
|
|
// resource table
|
|
|
|
private ResourcesTable resourcesTable;
|
2016-07-19 21:24:42 +02:00
|
|
|
|
2016-07-14 12:14:33 +02:00
|
|
|
// List of opened popup'ids
|
2016-07-20 22:41:15 +02:00
|
|
|
private List<String> popupOpenedIds = new ArrayList<String>();
|
|
|
|
|
|
|
|
// map of organization name title
|
|
|
|
private Map<String, String> nameTitleOrganizationMap = new HashMap<String, String>();
|
2016-07-06 18:41:43 +02:00
|
|
|
|
2016-06-06 17:24:52 +02:00
|
|
|
/**
|
|
|
|
* Invoked in the most general case
|
2016-09-28 16:41:55 +02:00
|
|
|
* @param eventBus the event bus
|
2016-06-06 17:24:52 +02:00
|
|
|
*/
|
2016-09-23 18:50:16 +02:00
|
|
|
public CreateDatasetForm(HandlerManager eventBus) {
|
2016-06-06 17:24:52 +02:00
|
|
|
|
2016-09-23 18:50:16 +02:00
|
|
|
createDatasetFormBody(false, null, eventBus);
|
2016-07-20 19:14:20 +02:00
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
}
|
2016-06-06 17:24:52 +02:00
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
/**
|
2016-09-12 17:58:50 +02:00
|
|
|
* Invoked when the workspace is used
|
2016-07-20 22:41:15 +02:00
|
|
|
* @param idFolderWorkspace
|
2016-09-28 16:41:55 +02:00
|
|
|
* @param eventBus the event bus
|
2016-07-20 22:41:15 +02:00
|
|
|
*/
|
2016-09-23 18:50:16 +02:00
|
|
|
public CreateDatasetForm(String idFolderWorkspace, HandlerManager eventBus) {
|
2016-06-06 17:24:52 +02:00
|
|
|
|
2016-09-23 18:50:16 +02:00
|
|
|
createDatasetFormBody(true, idFolderWorkspace, eventBus);
|
2016-06-06 17:24:52 +02:00
|
|
|
|
2016-06-08 18:31:54 +02:00
|
|
|
}
|
|
|
|
|
2016-09-20 17:33:39 +02:00
|
|
|
/**
|
|
|
|
* Bind on events
|
|
|
|
*/
|
|
|
|
private void bind() {
|
|
|
|
|
|
|
|
// when a custom field is removed, remove it from the list
|
|
|
|
eventBus.addHandler(DeleteCustomFieldEvent.TYPE, new DeleteCustomFieldEventHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onRemoveEntry(DeleteCustomFieldEvent event) {
|
|
|
|
|
|
|
|
customFieldEntriesList.remove(event.getRemovedEntry());
|
|
|
|
customFields.remove(event.getRemovedEntry());
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// on close form
|
|
|
|
eventBus.addHandler(CloseCreationFormEvent.TYPE, new CloseCreationFormEventHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClose(CloseCreationFormEvent event) {
|
|
|
|
|
|
|
|
closeDialogBox();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
2016-07-20 22:41:15 +02:00
|
|
|
|
2016-06-06 17:24:52 +02:00
|
|
|
/**
|
2016-07-20 22:41:15 +02:00
|
|
|
* The real constructor
|
|
|
|
* @param isWorkspaceRequest
|
2016-06-06 17:24:52 +02:00
|
|
|
* @param idFolderWorkspace
|
|
|
|
* @param owner
|
2016-07-20 22:41:15 +02:00
|
|
|
* @param eventBus
|
2016-06-06 17:24:52 +02:00
|
|
|
*/
|
2016-09-23 18:50:16 +02:00
|
|
|
private void createDatasetFormBody(final boolean isWorkspaceRequest, String idFolderWorkspace, final HandlerManager eventBus){
|
2016-07-20 22:41:15 +02:00
|
|
|
|
2016-05-26 18:12:53 +02:00
|
|
|
initWidget(uiBinder.createAndBindUi(this));
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-07-14 12:14:33 +02:00
|
|
|
// save event bus
|
|
|
|
this.eventBus = eventBus;
|
2016-06-07 17:50:33 +02:00
|
|
|
|
2016-06-08 18:31:54 +02:00
|
|
|
// workspace request
|
2016-07-20 22:41:15 +02:00
|
|
|
this.isWorkspaceRequest = isWorkspaceRequest;
|
2016-06-08 18:31:54 +02:00
|
|
|
|
2016-05-27 19:08:03 +02:00
|
|
|
// bind on events
|
|
|
|
bind();
|
2016-06-06 17:24:52 +02:00
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
// prepare info icons
|
|
|
|
prepareInfoIcons();
|
|
|
|
|
2016-06-09 18:58:19 +02:00
|
|
|
// disable continue button
|
|
|
|
continueButton.setEnabled(false);
|
2016-06-06 17:24:52 +02:00
|
|
|
resetButton.setEnabled(false);
|
2016-07-21 22:39:46 +02:00
|
|
|
|
2016-07-21 11:26:18 +02:00
|
|
|
// set info block
|
|
|
|
setAlertBlock("Retrieving information, please wait...", AlertType.INFO, true);
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-07-21 11:26:18 +02:00
|
|
|
// get back the licenses and the metadata information
|
2016-09-12 17:58:50 +02:00
|
|
|
ckanServices.getDatasetBean(idFolderWorkspace, new AsyncCallback<DatasetMetadataBean>() {
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
|
|
|
setAlertBlock("Error while retrieving information, try to refresh the page", AlertType.ERROR, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-05-26 18:12:53 +02:00
|
|
|
@Override
|
2016-07-06 18:41:43 +02:00
|
|
|
public void onSuccess(final DatasetMetadataBean bean) {
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
if(bean == null){
|
|
|
|
|
|
|
|
setAlertBlock("Error while retrieving information, try to refresh the page", AlertType.ERROR, true);
|
|
|
|
}
|
|
|
|
else{
|
2016-06-06 17:24:52 +02:00
|
|
|
|
2016-05-27 19:08:03 +02:00
|
|
|
// save it
|
|
|
|
receivedBean = bean;
|
|
|
|
|
|
|
|
// fill the form
|
|
|
|
titleTextBox.setText(bean.getTitle());
|
|
|
|
descriptionTextarea.setText(bean.getDescription());
|
|
|
|
versionTextbox.setText(String.valueOf(bean.getVersion()));
|
2016-07-13 16:11:15 +02:00
|
|
|
authorTextbox.setText(bean.getAuthorSurname() + " " + bean.getAuthorName());
|
2016-05-27 19:08:03 +02:00
|
|
|
authorEmailTextbox.setText(bean.getAuthorEmail());
|
2016-07-13 16:11:15 +02:00
|
|
|
maintainerTextbox.setText(bean.getAuthorSurname() + " " + bean.getAuthorName());
|
2016-05-27 19:08:03 +02:00
|
|
|
maintainerEmailTextbox.setText(bean.getMaintainerEmail());
|
|
|
|
|
|
|
|
// retrieve custom fields
|
|
|
|
Map<String, String> customFieldsMap = bean.getCustomFields();
|
|
|
|
|
2016-06-06 17:24:52 +02:00
|
|
|
if(customFieldsMap != null){
|
2016-05-27 19:08:03 +02:00
|
|
|
|
|
|
|
// get the keys and put them as tags
|
|
|
|
Iterator<Entry<String, String>> iteratorOverCustomField = customFieldsMap.entrySet().iterator();
|
|
|
|
|
|
|
|
while (iteratorOverCustomField.hasNext()) {
|
|
|
|
Map.Entry<String, String> entry = (Map.Entry<String, String>) iteratorOverCustomField
|
|
|
|
.next();
|
|
|
|
|
|
|
|
// these are fixed key, variable value custom fields
|
2016-06-06 17:24:52 +02:00
|
|
|
CustomFieldEntry toAdd = new CustomFieldEntry(eventBus, entry.getKey(), entry.getValue(), false);
|
|
|
|
customFieldEntriesList.add(toAdd);
|
2016-05-27 19:08:03 +02:00
|
|
|
customFields.add(toAdd);
|
|
|
|
|
2016-06-06 17:24:52 +02:00
|
|
|
// add as tag
|
|
|
|
addTagElement(entry.getKey());
|
2016-05-27 19:08:03 +02:00
|
|
|
|
|
|
|
}
|
2016-05-26 18:12:53 +02:00
|
|
|
}
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-07-21 11:26:18 +02:00
|
|
|
if(isWorkspaceRequest){
|
2016-07-07 16:52:10 +02:00
|
|
|
|
2016-07-21 11:26:18 +02:00
|
|
|
resourcesTable = new ResourcesTable(bean.getResources());
|
2016-07-07 16:52:10 +02:00
|
|
|
|
2016-07-21 11:26:18 +02:00
|
|
|
// if there are not resources, for now just checked it ( and hide so that the step will be skipped) TODO
|
|
|
|
if(bean.getResources() == null || bean.getResources().isEmpty()){
|
|
|
|
|
|
|
|
alertNoResources.setType(AlertType.WARNING);
|
|
|
|
alertNoResources.setVisible(true);
|
2016-09-14 16:29:52 +02:00
|
|
|
|
2016-07-21 11:26:18 +02:00
|
|
|
}
|
2016-07-07 16:52:10 +02:00
|
|
|
|
2016-07-21 11:26:18 +02:00
|
|
|
}
|
2016-07-21 22:39:46 +02:00
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
// set organizations
|
|
|
|
List<OrganizationBean> organizations = bean.getOrganizationList();
|
|
|
|
|
|
|
|
for (OrganizationBean organization : organizations) {
|
|
|
|
organizationsListbox.addItem(organization.getTitle());
|
|
|
|
nameTitleOrganizationMap.put(organization.getTitle(), organization.getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
// force the selection of the first one, and retrieve the list of profiles
|
|
|
|
organizationsListbox.setSelectedIndex(0);
|
|
|
|
|
|
|
|
// add change handler to dinamycally retrieve the list of profiles
|
|
|
|
organizationsListbox.addChangeHandler(new ChangeHandler() {
|
2016-05-27 19:08:03 +02:00
|
|
|
|
|
|
|
@Override
|
2016-07-20 22:41:15 +02:00
|
|
|
public void onChange(ChangeEvent event) {
|
2016-07-22 12:51:19 +02:00
|
|
|
event.preventDefault();
|
2016-07-20 22:41:15 +02:00
|
|
|
organizationsListboxChangeHandlerBody();
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
}
|
|
|
|
});
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
// try to retrieve the profiles
|
|
|
|
setAlertBlock("Retrieving profiles, please wait...", AlertType.INFO, true);
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
// get the name of the organization from the title
|
|
|
|
String orgName = nameTitleOrganizationMap.get(organizationsListbox.getSelectedItemText());
|
2016-07-07 16:52:10 +02:00
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
// perform remote request of profiles for the selected organization
|
|
|
|
ckanServices.getProfiles(orgName, new AsyncCallback<List<MetaDataProfileBean>>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
2016-07-13 16:11:15 +02:00
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
setAlertBlock("Error while retrieving profiles, try to refresh the page", AlertType.ERROR, true);
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
@Override
|
2016-07-20 22:41:15 +02:00
|
|
|
public void onSuccess(List<MetaDataProfileBean> result) {
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
if(result == null){
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
setAlertBlock("Error while retrieving profiles, try to refresh the page", AlertType.ERROR, true);
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
}
|
|
|
|
else{
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
receivedBean.setMetadataList(result);
|
|
|
|
prepareMetadataList(receivedBean);
|
|
|
|
organizationsListbox.setEnabled(true);
|
|
|
|
metadataProfilesFormatListbox.setEnabled(true);
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
// try to retrieve the licenses
|
|
|
|
setAlertBlock("Retrieving licenses, please wait...", AlertType.INFO, true);
|
|
|
|
ckanServices.getLicenses(new AsyncCallback<LicensesBean>() {
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught){
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
setAlertBlock("Error while retrieving licenses, try to refresh the page", AlertType.ERROR, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(LicensesBean lBean) {
|
|
|
|
|
|
|
|
if(lBean != null && !lBean.getLicenseTitles().isEmpty()){
|
|
|
|
|
|
|
|
licenseBean = lBean;
|
|
|
|
|
|
|
|
// sort the list
|
|
|
|
List<String> listOfNames = new ArrayList<String>();
|
|
|
|
Collections.copy(listOfNames, licenseBean.getLicenseTitles());
|
|
|
|
Collections.sort(listOfNames);
|
|
|
|
|
|
|
|
// fill the listbox
|
|
|
|
for(int i = 0; i < listOfNames.size(); i++){
|
|
|
|
licenseListbox.addItem(listOfNames.get(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
// set the url of the license, if any
|
|
|
|
showLicenseUrl();
|
|
|
|
|
|
|
|
// everything went ok
|
|
|
|
setAlertBlock("", AlertType.ERROR, false);
|
|
|
|
continueButton.setEnabled(true);
|
|
|
|
resetButton.setEnabled(true);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
setAlertBlock("Error while retrieving licenses, try to refresh the page", AlertType.ERROR, true);
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
|
|
|
});
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-07-20 19:14:20 +02:00
|
|
|
/**
|
|
|
|
* When the organization name is changed we need to retrieve the list of profiles
|
|
|
|
*/
|
|
|
|
private void organizationsListboxChangeHandlerBody() {
|
|
|
|
|
2016-07-22 12:51:19 +02:00
|
|
|
// remove any other product profiles
|
2016-07-20 19:14:20 +02:00
|
|
|
int presentItems = metadataProfilesFormatListbox.getItemCount();
|
2016-07-22 12:51:19 +02:00
|
|
|
for (int i = presentItems - 1; i >= 0; i--) {
|
|
|
|
metadataProfilesFormatListbox.removeItem(i);
|
2016-07-20 19:14:20 +02:00
|
|
|
}
|
2016-07-21 11:26:18 +02:00
|
|
|
|
2016-07-22 12:51:19 +02:00
|
|
|
// add "none" item again
|
|
|
|
metadataProfilesFormatListbox.addItem("none");
|
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
// select "none"
|
|
|
|
metadataProfilesFormatListbox.setSelectedIndex(0);
|
|
|
|
|
|
|
|
// get the name of the organization from the title
|
2016-07-22 12:51:19 +02:00
|
|
|
String selectedOrganizationTitle = organizationsListbox.getSelectedItemText();
|
|
|
|
String orgName = nameTitleOrganizationMap.get(selectedOrganizationTitle);
|
2016-07-21 11:26:18 +02:00
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
// try to retrieve the profiles
|
|
|
|
setAlertBlock("Retrieving profiles, please wait...", AlertType.INFO, true);
|
2016-07-20 19:14:20 +02:00
|
|
|
|
2016-07-22 12:51:19 +02:00
|
|
|
// disable the list of organizations name so that the user doesn't change it again
|
|
|
|
organizationsListbox.setEnabled(false);
|
|
|
|
metadataProfilesFormatListbox.setEnabled(false);
|
|
|
|
|
2016-07-20 19:14:20 +02:00
|
|
|
// perform remote request of profiles for the selected organization
|
2016-07-20 22:41:15 +02:00
|
|
|
ckanServices.getProfiles(orgName, new AsyncCallback<List<MetaDataProfileBean>>() {
|
2016-07-20 19:14:20 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(List<MetaDataProfileBean> result) {
|
|
|
|
|
|
|
|
if(result != null){
|
|
|
|
|
|
|
|
receivedBean.setMetadataList(result);
|
|
|
|
prepareMetadataList(receivedBean);
|
2016-07-22 12:51:19 +02:00
|
|
|
organizationsListbox.setEnabled(true);
|
|
|
|
metadataProfilesFormatListbox.setEnabled(true);
|
2016-07-21 11:26:18 +02:00
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
// everything went ok
|
2016-09-28 16:41:55 +02:00
|
|
|
setAlertBlock("", AlertType.DEFAULT, false);
|
2016-07-20 19:14:20 +02:00
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
}else
|
|
|
|
setAlertBlock("Error while retrieving profiles, sorry", AlertType.ERROR, true);
|
2016-07-20 19:14:20 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
2016-07-20 22:41:15 +02:00
|
|
|
setAlertBlock("Error while retrieving profiles, sorry", AlertType.ERROR, true);
|
2016-07-20 19:14:20 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
/**
|
|
|
|
* Add the items to the listbox and put data into the metadataPanel
|
|
|
|
* @param receivedBean
|
|
|
|
*/
|
2016-09-28 16:41:55 +02:00
|
|
|
private void prepareMetadataList(final DatasetMetadataBean receivedBean) {
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
List<MetaDataProfileBean> beans = receivedBean.getMetadataList();
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-07-19 21:24:42 +02:00
|
|
|
if(beans != null && !beans.isEmpty()){
|
|
|
|
for(MetaDataProfileBean metadataBean: beans){
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-07-19 21:24:42 +02:00
|
|
|
metadataProfilesFormatListbox.addItem(metadataBean.getType().getName());
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-07-19 21:24:42 +02:00
|
|
|
// add handler on select
|
|
|
|
metadataProfilesFormatListbox.addChangeHandler(new ChangeHandler() {
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-07-19 21:24:42 +02:00
|
|
|
@Override
|
|
|
|
public void onChange(ChangeEvent event) {
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-07-19 21:24:42 +02:00
|
|
|
String selectedItem = metadataProfilesFormatListbox.getSelectedItemText();
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-07-19 21:24:42 +02:00
|
|
|
if(selectedItem.equals("none")){
|
|
|
|
// hide the panel
|
|
|
|
metadataFieldsPanel.clear();
|
|
|
|
metadataFieldsPanel.setVisible(false);
|
2016-09-28 16:41:55 +02:00
|
|
|
receivedBean.setChosenProfile(null);
|
2016-07-19 21:24:42 +02:00
|
|
|
}else{
|
2016-09-28 16:41:55 +02:00
|
|
|
receivedBean.setChosenProfile(selectedItem);
|
2016-07-19 21:24:42 +02:00
|
|
|
metadataFieldsPanel.clear();
|
|
|
|
addFields(selectedItem);
|
|
|
|
}
|
2016-06-28 12:05:23 +02:00
|
|
|
}
|
2016-07-19 21:24:42 +02:00
|
|
|
});
|
|
|
|
}
|
2016-07-28 08:33:49 +02:00
|
|
|
metadataProfilesControlGroup.setVisible(true);
|
2016-07-19 21:24:42 +02:00
|
|
|
}else{
|
|
|
|
// just hide this listbox
|
2016-07-20 19:14:20 +02:00
|
|
|
metadataProfilesControlGroup.setVisible(false);
|
2016-07-28 10:21:22 +02:00
|
|
|
metadataFieldsPanel.clear();
|
|
|
|
listOfMetadataFields.clear();
|
2016-09-28 16:41:55 +02:00
|
|
|
receivedBean.setChosenProfile(null);
|
2016-06-09 18:58:19 +02:00
|
|
|
}
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-09-28 16:41:55 +02:00
|
|
|
/**
|
|
|
|
* Add fields of the selected metadata profile to the widget
|
|
|
|
* @param selectedItem
|
|
|
|
*/
|
2016-06-29 12:39:27 +02:00
|
|
|
protected void addFields(String selectedItem) {
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
for(MetaDataProfileBean bean: receivedBean.getMetadataList()){
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
if(bean.getType().getName().equals(selectedItem)){
|
|
|
|
|
|
|
|
// prepare the data
|
|
|
|
List<MetadataFieldWrapper> fields = bean.getMetadataFields();
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// clear old data
|
|
|
|
listOfMetadataFields.clear();
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
for (MetadataFieldWrapper field : fields) {
|
2016-09-14 16:29:52 +02:00
|
|
|
MetaDataFieldSkeleton fieldWidget;
|
|
|
|
try {
|
|
|
|
fieldWidget = new MetaDataFieldSkeleton(field, eventBus);
|
|
|
|
metadataFieldsPanel.add(fieldWidget);
|
|
|
|
listOfMetadataFields.add(fieldWidget);
|
|
|
|
} catch (Exception e) {
|
|
|
|
GWT.log("Unable to build such widget", e);
|
|
|
|
}
|
2016-06-28 12:05:23 +02:00
|
|
|
}
|
2016-06-29 12:39:27 +02:00
|
|
|
metadataFieldsPanel.setVisible(true);
|
|
|
|
}
|
2016-06-28 12:05:23 +02:00
|
|
|
}
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
2016-05-26 18:12:53 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
@UiHandler("addCustomFieldButton")
|
|
|
|
void addCustomFieldEvent(ClickEvent e){
|
|
|
|
|
|
|
|
CustomFieldEntry toAdd = new CustomFieldEntry(eventBus, "", "", true);
|
|
|
|
customFieldEntriesList.add(toAdd);
|
|
|
|
customFields.add(toAdd);
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@UiHandler("continueButton")
|
|
|
|
void onContinueButton(ClickEvent e){
|
2016-06-08 18:31:54 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// validate data
|
2016-09-26 12:15:05 +02:00
|
|
|
final String errorMsg = validateDataOnContinue();
|
|
|
|
|
|
|
|
if(errorMsg != null){
|
2016-06-08 18:31:54 +02:00
|
|
|
|
2016-09-26 12:15:05 +02:00
|
|
|
alertOnContinue("Please check inserted data [" + errorMsg + "]", AlertType.ERROR);
|
|
|
|
return;
|
2016-07-06 18:41:43 +02:00
|
|
|
|
2016-09-26 12:15:05 +02:00
|
|
|
}else{
|
2016-09-26 14:12:26 +02:00
|
|
|
|
2016-09-26 12:15:05 +02:00
|
|
|
alertOnContinue("Checking if a product with such title already exists, please wait...", AlertType.INFO);
|
2016-09-26 14:12:26 +02:00
|
|
|
|
2016-09-26 12:15:05 +02:00
|
|
|
// better check for title
|
|
|
|
ckanServices.datasetIdAlreadyExists(titleTextBox.getText(), new AsyncCallback<Boolean>() {
|
2016-07-06 18:41:43 +02:00
|
|
|
|
2016-09-26 12:15:05 +02:00
|
|
|
@Override
|
|
|
|
public void onSuccess(Boolean result) {
|
2016-07-06 18:41:43 +02:00
|
|
|
|
2016-09-26 12:15:05 +02:00
|
|
|
if(result){
|
2016-07-06 18:41:43 +02:00
|
|
|
|
2016-09-26 12:15:05 +02:00
|
|
|
alertOnContinue("Sorry but a product with such title already exists, try to change it", AlertType.WARNING);
|
2016-07-21 22:39:46 +02:00
|
|
|
|
2016-09-26 12:15:05 +02:00
|
|
|
}else{
|
2016-09-26 14:12:26 +02:00
|
|
|
// check what to do
|
|
|
|
if(isWorkspaceRequest){
|
2016-07-21 22:39:46 +02:00
|
|
|
|
2016-09-26 14:12:26 +02:00
|
|
|
// we need to show the page to handle resources one by one from the workspace
|
|
|
|
formFirstStep.setVisible(false);
|
|
|
|
boolean resourcesPresent = receivedBean.getResources() != null && receivedBean.getResources().size() > 0 ? true : false;
|
|
|
|
formSecondStep.setVisible(resourcesPresent);
|
|
|
|
formThirdStep.setVisible(!resourcesPresent);
|
2016-07-21 22:39:46 +02:00
|
|
|
|
2016-09-26 14:12:26 +02:00
|
|
|
// add the resources to the container panel
|
|
|
|
if(workspaceResourcesContainer.getWidget() == null)
|
|
|
|
workspaceResourcesContainer.add(resourcesTable);
|
2016-09-26 12:15:05 +02:00
|
|
|
|
2016-09-26 14:12:26 +02:00
|
|
|
}else{
|
2016-09-26 12:15:05 +02:00
|
|
|
|
2016-09-26 14:12:26 +02:00
|
|
|
// this is not a workspace request
|
|
|
|
formFirstStep.setVisible(false);
|
|
|
|
formThirdStep.setVisible(true);
|
2016-09-26 12:15:05 +02:00
|
|
|
|
2016-09-26 14:12:26 +02:00
|
|
|
}
|
2016-09-26 12:15:05 +02:00
|
|
|
|
2016-09-26 14:12:26 +02:00
|
|
|
if(metadataProfilesFormatListbox.getSelectedItemText().equals("none"))
|
|
|
|
selectedProfile.setText("");
|
|
|
|
else
|
|
|
|
selectedProfile.setText("Selected Profile is " + metadataProfilesFormatListbox.getSelectedItemText());
|
2016-09-26 12:15:05 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
2016-09-28 16:41:55 +02:00
|
|
|
alertOnContinue("Sorry but there was a problem while checking if the inserted data are correct", AlertType.ERROR);
|
2016-09-26 12:15:05 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
});
|
2016-06-28 12:05:23 +02:00
|
|
|
}
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-07-06 18:41:43 +02:00
|
|
|
|
|
|
|
@UiHandler("goBackButtonFirstStep")
|
|
|
|
void onGoBackButtonFirstStep(ClickEvent e){
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// swap forms
|
|
|
|
formFirstStep.setVisible(true);
|
|
|
|
formSecondStep.setVisible(false);
|
2016-07-06 18:41:43 +02:00
|
|
|
formThirdStep.setVisible(false);
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-07-06 18:41:43 +02:00
|
|
|
|
2016-09-12 17:58:50 +02:00
|
|
|
@UiHandler("goBackButtonSecondStep")
|
2016-07-06 18:41:43 +02:00
|
|
|
void onGoBackButton(ClickEvent e){
|
|
|
|
|
|
|
|
// swap forms
|
2016-09-12 17:58:50 +02:00
|
|
|
if(isWorkspaceRequest){
|
2016-09-20 17:33:39 +02:00
|
|
|
boolean resourcesPresent = receivedBean.getResources() != null && receivedBean.getResources().size() > 0 ? true : false;
|
|
|
|
formFirstStep.setVisible(!resourcesPresent);
|
|
|
|
formSecondStep.setVisible(resourcesPresent);
|
2016-07-06 18:41:43 +02:00
|
|
|
}else{
|
|
|
|
formFirstStep.setVisible(true);
|
|
|
|
formSecondStep.setVisible(false);
|
|
|
|
}
|
|
|
|
formThirdStep.setVisible(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@UiHandler("continueThirdStep")
|
|
|
|
void onContinueThirdStep(ClickEvent e){
|
|
|
|
|
|
|
|
// swap forms
|
|
|
|
formSecondStep.setVisible(false);
|
|
|
|
formThirdStep.setVisible(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
@UiHandler("createButton")
|
|
|
|
void createDatasetEvent(ClickEvent e){
|
|
|
|
|
2016-07-13 16:11:15 +02:00
|
|
|
String errorMessage = areProfileDataValid();
|
2016-06-29 12:39:27 +02:00
|
|
|
|
2016-07-13 16:11:15 +02:00
|
|
|
if(errorMessage != null){
|
|
|
|
|
2016-09-26 14:12:26 +02:00
|
|
|
alertOnCreate("Please check the inserted values and the mandatory fields [" + errorMessage +"]", AlertType.ERROR, true);
|
2016-07-13 16:11:15 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
else{
|
2016-06-29 12:39:27 +02:00
|
|
|
|
|
|
|
String title = titleTextBox.getValue();
|
|
|
|
String description = descriptionTextarea.getText();
|
|
|
|
String selectedLicense = licenseListbox.getSelectedItemText();
|
|
|
|
String visibility = visibilityListbox.getSelectedItemText();
|
|
|
|
long version = Long.valueOf(versionTextbox.getValue());
|
|
|
|
String author = authorTextbox.getValue();
|
|
|
|
String authorEmail = authorEmailTextbox.getValue();
|
|
|
|
String maintainer = maintainerTextbox.getValue();
|
|
|
|
String maintainerEmail = maintainerEmailTextbox.getValue();
|
2016-07-20 22:41:15 +02:00
|
|
|
String chosenOrganizationTitle = organizationsListbox.getSelectedItemText();
|
|
|
|
|
|
|
|
//we need to retrieve the organization's name from this title
|
|
|
|
List<OrganizationBean> orgs = receivedBean.getOrganizationList();
|
|
|
|
String chosenOrganization = null;
|
|
|
|
for (OrganizationBean organizationBean : orgs) {
|
|
|
|
if(chosenOrganizationTitle.equals(organizationBean.getTitle())){
|
|
|
|
chosenOrganization = organizationBean.getName();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-06-29 12:39:27 +02:00
|
|
|
|
|
|
|
// fill the bean
|
2016-07-13 16:11:15 +02:00
|
|
|
receivedBean.setAuthorFullName(author);
|
2016-06-29 12:39:27 +02:00
|
|
|
receivedBean.setAuthorEmail(authorEmail);
|
|
|
|
receivedBean.setDescription(description);
|
|
|
|
receivedBean.setLicense(selectedLicense);
|
|
|
|
receivedBean.setMaintainer(maintainer);
|
|
|
|
receivedBean.setMaintainerEmail(maintainerEmail);
|
|
|
|
receivedBean.setVersion(version);
|
|
|
|
receivedBean.setVisibility(visibility.equals("Public"));
|
|
|
|
receivedBean.setTitle(title);
|
|
|
|
receivedBean.setTags(tagsList);
|
|
|
|
receivedBean.setSelectedOrganization(chosenOrganization);
|
|
|
|
|
|
|
|
Map<String, String> customFieldsMap = new HashMap<String, String>();
|
|
|
|
|
|
|
|
// prepare custom fields
|
|
|
|
for (MetaDataFieldSkeleton field : listOfMetadataFields) {
|
2016-09-14 17:44:58 +02:00
|
|
|
|
2016-09-14 16:29:52 +02:00
|
|
|
MetadataFieldWrapper originalField = field.getField();
|
2016-09-14 17:44:58 +02:00
|
|
|
|
2016-09-14 16:29:52 +02:00
|
|
|
String value = originalField.getType().equals(DataType.Time_Interval) || originalField.getType().equals(DataType.Times_ListOf) ?
|
|
|
|
field.getTimeIntervalOrTimeListWithoutMissing() : field.getFieldCurrentValue();
|
|
|
|
|
2016-09-14 17:44:58 +02:00
|
|
|
if(!value.isEmpty())
|
|
|
|
customFieldsMap.put(field.getFieldName(), field.getFieldCurrentValue());
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
2016-06-06 17:24:52 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
for(CustomFieldEntry customEntry : customFieldEntriesList){
|
2016-06-14 12:35:10 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
String key = customEntry.getKey();
|
|
|
|
String value = customEntry.getValue();
|
2016-09-14 17:44:58 +02:00
|
|
|
if(value != null && !value.isEmpty())
|
|
|
|
customFieldsMap.put(key, value);
|
2016-06-06 17:24:52 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
2016-06-06 17:24:52 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
receivedBean.setCustomFields(customFieldsMap);
|
2016-06-06 17:24:52 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// alert
|
2016-09-26 14:12:26 +02:00
|
|
|
alertOnCreate(TRYING_TO_CREATE_PRODUCT, AlertType.INFO, false);
|
2016-06-06 17:24:52 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// invoke the create method
|
|
|
|
createButton.setEnabled(false);
|
2016-09-12 17:58:50 +02:00
|
|
|
goBackButtonSecondStep.setEnabled(false);
|
2016-06-06 17:24:52 +02:00
|
|
|
|
2016-09-15 14:56:35 +02:00
|
|
|
ckanServices.createCKanDataset(receivedBean, new AsyncCallback<DatasetMetadataBean>() {
|
2016-06-06 17:24:52 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
@Override
|
|
|
|
public void onSuccess(final DatasetMetadataBean createdDatasetBean) {
|
2016-06-10 17:16:42 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
if(createdDatasetBean != null){
|
2016-06-07 17:50:33 +02:00
|
|
|
|
2016-09-26 14:12:26 +02:00
|
|
|
alertOnCreate(PRODUCT_CREATED_OK, AlertType.SUCCESS, false);
|
2016-06-10 12:10:18 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// disable dataset fields
|
|
|
|
disableDatasetFields();
|
2016-06-10 12:10:18 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// disable reset
|
|
|
|
resetButton.setEnabled(false);
|
2016-06-13 17:40:19 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// show the go to dataset button
|
|
|
|
final String datasetUrl = createdDatasetBean.getSource();
|
|
|
|
goToDatasetButton.setVisible(true);
|
|
|
|
goToDatasetButton.addClickHandler(new ClickHandler() {
|
2016-06-10 12:10:18 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
@Override
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
Window.Location.assign(datasetUrl);
|
|
|
|
}
|
|
|
|
});
|
2016-06-10 12:10:18 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// if we are in the "general case" we need to show a form for adding resources
|
2016-09-26 14:12:26 +02:00
|
|
|
if(isWorkspaceRequest){
|
2016-06-29 12:39:27 +02:00
|
|
|
// leave to back button, but remove create and add go to dataset
|
|
|
|
createButton.removeFromParent();
|
2016-06-10 17:16:42 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// set go to dataset as primary
|
|
|
|
goToDatasetButton.setType(ButtonType.PRIMARY);
|
2016-06-07 17:50:33 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
}else{
|
2016-06-07 17:50:33 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// remove create button
|
|
|
|
createButton.removeFromParent();
|
2016-06-10 12:10:18 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// show the add resources button
|
|
|
|
addResourcesButton.setVisible(true);
|
2016-06-07 17:50:33 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
addResourcesButton.addClickHandler(new ClickHandler() {
|
2016-06-07 17:50:33 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
@Override
|
|
|
|
public void onClick(ClickEvent event) {
|
2016-06-07 17:50:33 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// remove content of the main panel
|
|
|
|
createDatasetMainPanel.clear();
|
2016-06-07 17:50:33 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// TabPanel
|
|
|
|
tabPanel = new TabPanel(Tabs.ABOVE);
|
|
|
|
tabPanel.setWidth("100%");
|
2016-06-07 17:50:33 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// add the form
|
2016-07-20 19:14:20 +02:00
|
|
|
resourceForm = new AddResourceToDataset(eventBus, createdDatasetBean.getId(), createdDatasetBean.getSelectedOrganization(), owner, datasetUrl);
|
2016-06-07 17:50:33 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// tab for the form
|
|
|
|
Tab formContainer = new Tab();
|
|
|
|
formContainer.add(resourceForm);
|
|
|
|
formContainer.setHeading("Add New Resource");
|
|
|
|
tabPanel.add(formContainer);
|
2016-06-08 18:31:54 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// tab for the added resources
|
|
|
|
Tab addedResources = new Tab();
|
2016-09-12 17:58:50 +02:00
|
|
|
addedResources.add(new AddedResourcesSummary(eventBus));
|
2016-06-29 12:39:27 +02:00
|
|
|
addedResources.setHeading("Added Resource");
|
|
|
|
tabPanel.add(addedResources);
|
2016-06-07 17:50:33 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// add tabs to resources panel
|
|
|
|
tabPanel.selectTab(0);
|
2016-06-10 12:10:18 +02:00
|
|
|
|
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// form container
|
|
|
|
AddResourceContainer container = new AddResourceContainer(datasetUrl);
|
|
|
|
container.add(tabPanel);
|
2016-06-07 17:50:33 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// add the new content of the main panel
|
|
|
|
createDatasetMainPanel.add(container);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2016-06-28 12:05:23 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
}else{
|
2016-09-26 14:12:26 +02:00
|
|
|
alertOnCreate(ERROR_PRODUCT_CREATION, AlertType.ERROR, true);
|
2016-06-06 17:24:52 +02:00
|
|
|
}
|
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
2016-06-06 17:24:52 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
2016-09-26 14:12:26 +02:00
|
|
|
alertOnCreate(ERROR_PRODUCT_CREATION, AlertType.ERROR, true);
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
|
|
|
});
|
2016-06-09 18:58:19 +02:00
|
|
|
}
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-07-13 18:13:50 +02:00
|
|
|
/**
|
|
|
|
* Prepare the info icons of all core metadata info
|
|
|
|
*/
|
|
|
|
private void prepareInfoIcons() {
|
|
|
|
|
|
|
|
// tags
|
|
|
|
preparePopupPanelAndPopover(
|
|
|
|
InfoIconsLabels.TAGS_INFO_ID_POPUP,
|
|
|
|
InfoIconsLabels.TAGS_INFO_TEXT,
|
|
|
|
InfoIconsLabels.TAGS_INFO_CAPTION,
|
|
|
|
infoIconTags,
|
|
|
|
popoverTags,
|
|
|
|
focusPanelTags
|
|
|
|
);
|
2016-07-19 21:24:42 +02:00
|
|
|
|
2016-07-14 16:47:17 +02:00
|
|
|
// licenses
|
|
|
|
preparePopupPanelAndPopover(
|
|
|
|
InfoIconsLabels.LICENSES_INFO_ID_POPUP,
|
|
|
|
InfoIconsLabels.LICENSES_INFO_TEXT,
|
|
|
|
InfoIconsLabels.LICENSES_INFO_CAPTION,
|
|
|
|
infoIconLicenses,
|
|
|
|
popoverLicenses,
|
|
|
|
focusPanelLicenses
|
|
|
|
);
|
2016-07-13 18:13:50 +02:00
|
|
|
|
|
|
|
// visibility
|
|
|
|
preparePopupPanelAndPopover(
|
|
|
|
InfoIconsLabels.VISIBILITY_INFO_ID_POPUP,
|
|
|
|
InfoIconsLabels.VISIBILITY_INFO_TEXT,
|
|
|
|
InfoIconsLabels.VISIBILITY_INFO_CAPTION,
|
|
|
|
infoIconVisibility,
|
|
|
|
popoverVisibility,
|
|
|
|
focusPanelVisibility
|
|
|
|
);
|
|
|
|
|
|
|
|
// author
|
|
|
|
preparePopupPanelAndPopover(
|
|
|
|
InfoIconsLabels.AUTHOR_INFO_ID_POPUP,
|
|
|
|
InfoIconsLabels.AUTHOR_INFO_TEXT,
|
|
|
|
InfoIconsLabels.AUTHOR_INFO_CAPTION,
|
|
|
|
infoIconAuthor,
|
|
|
|
popoverAuthor,
|
|
|
|
focusPanelAuthor
|
|
|
|
);
|
|
|
|
|
|
|
|
// author's email
|
|
|
|
preparePopupPanelAndPopover(
|
|
|
|
InfoIconsLabels.AUTHOR_EMAIL_INFO_ID_POPUP,
|
|
|
|
InfoIconsLabels.AUTHOR_EMAIL_INFO_TEXT,
|
|
|
|
InfoIconsLabels.AUTHOR_EMAIL_INFO_CAPTION,
|
|
|
|
infoIconAuthorEmail,
|
|
|
|
popoverAuthorEmail,
|
|
|
|
focusPanelAuthorEmail
|
|
|
|
);
|
|
|
|
|
|
|
|
// maintainer
|
|
|
|
preparePopupPanelAndPopover(
|
|
|
|
InfoIconsLabels.MAINTAINER_INFO_ID_POPUP,
|
|
|
|
InfoIconsLabels.MAINTAINER_INFO_TEXT,
|
|
|
|
InfoIconsLabels.MAINTAINER_INFO_CAPTION,
|
|
|
|
infoIconMaintainer,
|
|
|
|
popoverMaintainer,
|
|
|
|
focusPanelMaintainer
|
|
|
|
);
|
|
|
|
|
|
|
|
// maintainer's email
|
|
|
|
preparePopupPanelAndPopover(
|
|
|
|
InfoIconsLabels.MAINTAINER_EMAIL_INFO_ID_POPUP,
|
|
|
|
InfoIconsLabels.MAINTAINER_EMAIL_INFO_TEXT,
|
|
|
|
InfoIconsLabels.MAINTAINER_EMAIL_INFO_CAPTION,
|
|
|
|
infoIconMaintainerEmail,
|
|
|
|
popoverMaintainerEmail,
|
|
|
|
focusPanelMaintainerEmail
|
|
|
|
);
|
|
|
|
|
|
|
|
// profiles
|
|
|
|
preparePopupPanelAndPopover(
|
|
|
|
InfoIconsLabels.PROFILES_INFO_ID_POPUP,
|
|
|
|
InfoIconsLabels.PROFILES_INFO_TEXT,
|
|
|
|
InfoIconsLabels.PROFILES_INFO_CAPTION,
|
|
|
|
infoIconProfiles,
|
|
|
|
popoverProfiles,
|
|
|
|
focusPanelProfiles
|
|
|
|
);
|
|
|
|
|
|
|
|
// custom fields
|
|
|
|
preparePopupPanelAndPopover(
|
|
|
|
InfoIconsLabels.CUSTOM_FIELDS_INFO_ID_POPUP,
|
|
|
|
InfoIconsLabels.CUSTOM_FIELDS_INFO_TEXT,
|
|
|
|
InfoIconsLabels.CUSTOM_FIELDS_INFO_CAPTION,
|
|
|
|
infoIconCustomFields,
|
|
|
|
popoverCustomFields,
|
|
|
|
focusPanelCustomFields
|
|
|
|
);
|
|
|
|
|
|
|
|
// resources field
|
|
|
|
preparePopupPanelAndPopover(
|
|
|
|
InfoIconsLabels.RESOURCES_INFO_ID_POPUP,
|
|
|
|
InfoIconsLabels.RESOURCES_INFO_TEXT,
|
|
|
|
InfoIconsLabels.RESOURCES_INFO_CAPTION,
|
|
|
|
infoIconResources,
|
|
|
|
popoverResources,
|
|
|
|
focusPanelResources
|
|
|
|
);
|
|
|
|
|
2016-09-23 18:50:16 +02:00
|
|
|
// title
|
|
|
|
preparePopupPanelAndPopover(
|
|
|
|
InfoIconsLabels.TITLE_INFO_ID_POPUP,
|
|
|
|
InfoIconsLabels.TITLE_INFO_TEXT,
|
|
|
|
InfoIconsLabels.TITLE_INFO_CAPTION,
|
|
|
|
infoIconTitle,
|
|
|
|
popoverTitle,
|
|
|
|
focusPanelTitle
|
|
|
|
);
|
2016-07-13 18:13:50 +02:00
|
|
|
}
|
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
/**
|
|
|
|
* Test if profile data are valid
|
|
|
|
* @return
|
|
|
|
*/
|
2016-07-13 16:11:15 +02:00
|
|
|
private String areProfileDataValid() {
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
for (MetaDataFieldSkeleton field : listOfMetadataFields) {
|
2016-09-20 17:33:39 +02:00
|
|
|
|
2016-09-16 17:40:32 +02:00
|
|
|
field.removeError();
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-07-14 16:47:17 +02:00
|
|
|
String error = field.isFieldValueValid();
|
|
|
|
if(error != null){
|
2016-09-16 17:40:32 +02:00
|
|
|
field.showError();
|
2016-07-14 16:47:17 +02:00
|
|
|
return field.getFieldName() + " is not valid. Suggestion: " + error;
|
|
|
|
}
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-07-13 16:11:15 +02:00
|
|
|
return null;
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
/**
|
|
|
|
* On continue show alert box and enable buttons
|
|
|
|
* @param text
|
|
|
|
* @param type
|
|
|
|
*/
|
|
|
|
private void alertOnContinue(String text, AlertType type){
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
onContinueAlertBlock.setText(text);
|
|
|
|
onContinueAlertBlock.setType(type);
|
|
|
|
onContinueAlertBlock.setVisible(true);
|
|
|
|
continueButton.setEnabled(true);
|
|
|
|
resetButton.setEnabled(true);
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// hide after some seconds
|
|
|
|
Timer t = new Timer() {
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
@Override
|
|
|
|
public void run() {
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
onContinueAlertBlock.setVisible(false);
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
|
|
|
};
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
t.schedule(4000);
|
|
|
|
}
|
2016-06-06 17:24:52 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
/**
|
|
|
|
* On continue show alert box and enable buttons
|
|
|
|
* @param text
|
|
|
|
* @param type
|
|
|
|
*/
|
2016-09-26 14:12:26 +02:00
|
|
|
private void alertOnCreate(String text, AlertType type, boolean hideAfterAWhile){
|
2016-06-06 17:24:52 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
onCreateAlertBlock.setText(text);
|
|
|
|
onCreateAlertBlock.setType(type);
|
|
|
|
onCreateAlertBlock.setVisible(true);
|
|
|
|
createButton.setEnabled(true);
|
2016-09-12 17:58:50 +02:00
|
|
|
goBackButtonSecondStep.setEnabled(true);
|
2016-05-26 18:12:53 +02:00
|
|
|
|
2016-09-26 14:12:26 +02:00
|
|
|
if(hideAfterAWhile){
|
|
|
|
// hide after some seconds
|
|
|
|
Timer t = new Timer() {
|
2016-06-06 17:24:52 +02:00
|
|
|
|
2016-09-26 14:12:26 +02:00
|
|
|
@Override
|
|
|
|
public void run() {
|
2016-06-06 17:24:52 +02:00
|
|
|
|
2016-09-26 14:12:26 +02:00
|
|
|
onCreateAlertBlock.setVisible(false);
|
2016-06-06 17:24:52 +02:00
|
|
|
|
2016-09-26 14:12:26 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
t.schedule(10000);
|
|
|
|
}
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
2016-05-26 18:12:53 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
/**
|
|
|
|
* Validate data
|
|
|
|
* @return true on success, false otherwise
|
|
|
|
*/
|
|
|
|
private String validateDataOnContinue() {
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-09-16 17:40:32 +02:00
|
|
|
// remove errors
|
|
|
|
productTitleGroup.setType(ControlGroupType.NONE);
|
|
|
|
maintainerControlGroup.setType(ControlGroupType.NONE);
|
|
|
|
versionControlGroup.setType(ControlGroupType.NONE);
|
|
|
|
metadataProfilesControlGroup.setType(ControlGroupType.NONE);
|
|
|
|
organizationsGroup.setType(ControlGroupType.NONE);
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
if(titleTextBox.getText().isEmpty()){
|
2016-09-16 17:40:32 +02:00
|
|
|
productTitleGroup.setType(ControlGroupType.ERROR);
|
2016-09-23 18:50:16 +02:00
|
|
|
return "Missing title";
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
2016-06-27 12:36:45 +02:00
|
|
|
|
2016-09-23 18:50:16 +02:00
|
|
|
// better check for the title
|
|
|
|
String[] splittedTitle = titleTextBox.getText().split(" ");
|
2016-06-27 12:36:45 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
for (String word : splittedTitle) {
|
2016-09-26 12:15:05 +02:00
|
|
|
String replaced = word.replaceAll(REGEX_TITLE_PRODUCT_SUBWORD, "");
|
2016-09-23 18:50:16 +02:00
|
|
|
if(!replaced.equals(word)){
|
2016-09-16 17:40:32 +02:00
|
|
|
productTitleGroup.setType(ControlGroupType.ERROR);
|
2016-09-26 12:15:05 +02:00
|
|
|
return "Please note not all characters are allowed for the title";
|
2016-09-16 17:40:32 +02:00
|
|
|
}
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
2016-06-27 12:36:45 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// email reg expression
|
2016-09-28 16:41:55 +02:00
|
|
|
if(!maintainerEmailTextbox.getText().matches(REGEX_MAIL)){
|
2016-09-16 17:40:32 +02:00
|
|
|
maintainerControlGroup.setType(ControlGroupType.ERROR);
|
2016-09-23 18:50:16 +02:00
|
|
|
return "Not valid maintainer email";
|
2016-06-09 18:58:19 +02:00
|
|
|
}
|
|
|
|
|
2016-07-07 16:52:10 +02:00
|
|
|
// check if version is a number
|
|
|
|
try{
|
2016-09-23 18:50:16 +02:00
|
|
|
int number = Integer.valueOf(versionTextbox.getText());
|
|
|
|
if(number <= 0)
|
|
|
|
throw new Exception();
|
2016-07-07 16:52:10 +02:00
|
|
|
}catch(Exception e){
|
2016-09-16 17:40:32 +02:00
|
|
|
versionControlGroup.setType(ControlGroupType.ERROR);
|
2016-09-23 18:50:16 +02:00
|
|
|
return "Version must be a natural number greater than zero";
|
2016-07-07 16:52:10 +02:00
|
|
|
}
|
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// check if metadata profile is different from none and its mandatory fields have been fulfilled
|
|
|
|
if(checkSelectedMetaDataProfile()){
|
2016-09-16 17:40:32 +02:00
|
|
|
metadataProfilesControlGroup.setType(ControlGroupType.ERROR);
|
2016-09-23 18:50:16 +02:00
|
|
|
return "You must select a metadata profile different frome none";
|
2016-06-09 18:58:19 +02:00
|
|
|
}
|
2016-06-13 17:40:19 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
if(organizationsListbox.getSelectedItemText() == null){
|
2016-09-16 17:40:32 +02:00
|
|
|
organizationsGroup.setType(ControlGroupType.ERROR);
|
2016-09-23 18:50:16 +02:00
|
|
|
return "You must select an organization in which you want to publish";
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-09-23 18:50:16 +02:00
|
|
|
return null;
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
2016-05-26 18:12:53 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
/**
|
|
|
|
* Checks if a metadata profile has been chosen and its fields have been fulfilled
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
private boolean checkSelectedMetaDataProfile() {
|
2016-07-21 19:42:57 +02:00
|
|
|
return metadataProfilesFormatListbox.getSelectedItemText().equals("none") && (metadataProfilesFormatListbox.getItemCount() != 1);
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
@UiHandler("resetButton")
|
|
|
|
void resetFormEvent(ClickEvent e){
|
2016-05-26 18:12:53 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// reset main fields
|
|
|
|
titleTextBox.setText("");
|
|
|
|
descriptionTextarea.setText("");
|
|
|
|
versionTextbox.setText("");
|
|
|
|
maintainerTextbox.setText("");
|
|
|
|
maintainerEmailTextbox.setText("");
|
|
|
|
removeTags();
|
2016-05-26 18:12:53 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// delete custom fields
|
|
|
|
for (CustomFieldEntry customField : customFieldEntriesList) {
|
|
|
|
customField.removeFromParent();
|
|
|
|
}
|
|
|
|
customFieldEntriesList.clear();
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
/**
|
|
|
|
* Disable dataset editable fields once the dataset has been
|
|
|
|
* Successfully created.
|
|
|
|
*/
|
|
|
|
protected void disableDatasetFields() {
|
2016-06-08 18:31:54 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
titleTextBox.setEnabled(false);
|
|
|
|
descriptionTextarea.setEnabled(false);
|
|
|
|
versionTextbox.setEnabled(false);
|
|
|
|
maintainerTextbox.setEnabled(false);
|
|
|
|
maintainerEmailTextbox.setEnabled(false);
|
|
|
|
visibilityListbox.setEnabled(false);
|
|
|
|
tagsEnterTextBox.setEnabled(false);
|
|
|
|
licenseListbox.setEnabled(false);
|
|
|
|
organizationsListbox.setEnabled(false);
|
|
|
|
addCustomFieldButton.setEnabled(false);
|
2016-06-08 18:31:54 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// freeze tags
|
|
|
|
for(int i = 0; i < tagsList.size(); i++){
|
2016-06-08 18:31:54 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// get tag widget
|
|
|
|
ListItem tagWidget = (ListItem)tagsPanel.getWidget(i);
|
2016-06-08 18:31:54 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// get the "x" span
|
|
|
|
tagWidget.getWidget(1).removeFromParent();
|
2016-06-08 18:31:54 +02:00
|
|
|
|
|
|
|
}
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// disable profile fields
|
|
|
|
for (MetaDataFieldSkeleton field : listOfMetadataFields) {
|
2016-06-09 18:58:19 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
field.freeze();
|
2016-06-09 18:58:19 +02:00
|
|
|
|
|
|
|
}
|
2016-07-07 16:52:10 +02:00
|
|
|
|
2016-07-06 18:41:43 +02:00
|
|
|
// freeze table of resources
|
|
|
|
if(resourcesTable != null)
|
|
|
|
resourcesTable.freezeTable();
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
2016-06-07 17:50:33 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
/**
|
|
|
|
* change alert block behavior.
|
|
|
|
* @param textToShow
|
|
|
|
* @param type
|
|
|
|
* @param visible
|
|
|
|
*/
|
|
|
|
private void setAlertBlock(String textToShow, AlertType type, boolean visible){
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
infoBlock.setText(textToShow);
|
|
|
|
infoBlock.setType(type);
|
|
|
|
infoBlock.setVisible(visible);
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
@UiHandler("tagsEnterTextBox")
|
|
|
|
void onAddTag(KeyDownEvent event){
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
|
|
|
|
if (!"".equals(tagsEnterTextBox.getValue().trim())) {
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
addTagElement(tagsEnterTextBox);
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-07-13 16:11:15 +02:00
|
|
|
@UiHandler("licenseListbox")
|
|
|
|
void onSelectedLicenseChange(ChangeEvent c){
|
|
|
|
|
|
|
|
showLicenseUrl();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The body of the onSelectedLicenseChange
|
|
|
|
*/
|
|
|
|
private void showLicenseUrl(){
|
|
|
|
|
|
|
|
List<String> titles = licenseBean.getLicenseTitles();
|
|
|
|
String selectedLicense = licenseListbox.getSelectedItemText();
|
|
|
|
GWT.log("Selected license is " + selectedLicense);
|
|
|
|
for (int i = 0; i < titles.size(); i++) {
|
|
|
|
if(selectedLicense.equals(titles.get(i))){
|
|
|
|
|
|
|
|
if(licenseBean.getLicenseUrls().get(i).isEmpty())
|
|
|
|
break;
|
|
|
|
|
|
|
|
GWT.log("URL is " + licenseBean.getLicenseUrls().get(i));
|
|
|
|
|
|
|
|
licenseUrlAnchor.setText(licenseBean.getLicenseUrls().get(i));
|
|
|
|
licenseUrlAnchor.setHref(licenseBean.getLicenseUrls().get(i));
|
|
|
|
licenseUrlAnchor.setVisible(true);
|
|
|
|
unavailableUrl.setVisible(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
licenseUrlAnchor.setVisible(false);
|
|
|
|
unavailableUrl.setVisible(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
/**
|
2016-07-14 11:26:43 +02:00
|
|
|
* Add the tag as an element (inserted by the user)
|
2016-06-29 12:39:27 +02:00
|
|
|
*/
|
|
|
|
private void addTagElement(TextBox itemBox){
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
if (itemBox.getValue() != null && !"".equals(itemBox.getValue().trim())) {
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-07-14 11:26:43 +02:00
|
|
|
if(tagsList.contains(itemBox.getValue())){
|
|
|
|
itemBox.setValue("");
|
2016-06-29 12:39:27 +02:00
|
|
|
return;
|
2016-07-14 11:26:43 +02:00
|
|
|
}
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
// ckan accepts only alphanumeric values
|
2016-07-14 11:26:43 +02:00
|
|
|
String[] subTags = itemBox.getValue().split(" ");
|
2016-07-14 12:14:33 +02:00
|
|
|
if(subTags.length == 1){
|
|
|
|
if(!subTags[0].matches("^[a-zA-Z0-9]*$"))
|
2016-07-14 11:26:43 +02:00
|
|
|
return;
|
2016-07-14 12:14:33 +02:00
|
|
|
if(subTags[0].length() <= 1)
|
2016-07-14 11:26:43 +02:00
|
|
|
return;
|
2016-07-14 12:14:33 +02:00
|
|
|
}else{
|
|
|
|
for (int i = 0; i < subTags.length; i++) {
|
|
|
|
String subTag = subTags[i];
|
|
|
|
if(!subTag.matches("^[a-zA-Z0-9]*$"))
|
|
|
|
return;
|
|
|
|
}
|
2016-07-14 11:26:43 +02:00
|
|
|
}
|
2016-06-13 17:40:19 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
final String value = itemBox.getValue();
|
2016-05-27 19:08:03 +02:00
|
|
|
final ListItem displayItem = new ListItem();
|
|
|
|
displayItem.setStyleName("tag-style");
|
2016-06-29 12:39:27 +02:00
|
|
|
Span tagText = new Span(itemBox.getValue());
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
Span tagRemove = new Span("x");
|
|
|
|
tagRemove.setTitle("Remove this tag");
|
|
|
|
tagRemove.addClickHandler(new ClickHandler() {
|
2016-05-27 19:08:03 +02:00
|
|
|
public void onClick(ClickEvent clickEvent) {
|
2016-06-29 12:39:27 +02:00
|
|
|
removeTag(displayItem, value);
|
2016-05-27 19:08:03 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
tagRemove.setStyleName("tag-style-x");
|
|
|
|
displayItem.add(tagText);
|
|
|
|
displayItem.add(tagRemove);
|
|
|
|
itemBox.setValue("");
|
|
|
|
itemBox.setFocus(true);
|
2016-05-27 19:08:03 +02:00
|
|
|
tagsPanel.add(displayItem);
|
2016-06-29 12:39:27 +02:00
|
|
|
tagsList.add(value);
|
2016-05-27 19:08:03 +02:00
|
|
|
}
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-07-14 11:26:43 +02:00
|
|
|
* Add the tag as an element (when publishing from workspace)
|
2016-06-29 12:39:27 +02:00
|
|
|
*/
|
|
|
|
private void addTagElement(final String tag){
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
if(tagsList.contains(tag))
|
|
|
|
return;
|
2016-06-06 17:24:52 +02:00
|
|
|
|
2016-07-14 11:26:43 +02:00
|
|
|
// ckan accepts only alphanumeric values
|
|
|
|
String[] subTags = tag.split(" ");
|
2016-07-14 12:14:33 +02:00
|
|
|
if(subTags.length == 1){
|
|
|
|
if(!subTags[0].matches("^[a-zA-Z0-9]*$"))
|
2016-07-14 11:26:43 +02:00
|
|
|
return;
|
2016-07-14 12:14:33 +02:00
|
|
|
if(subTags[0].length() <= 1)
|
2016-07-14 11:26:43 +02:00
|
|
|
return;
|
2016-07-14 12:14:33 +02:00
|
|
|
}else{
|
|
|
|
for (int i = 0; i < subTags.length; i++) {
|
|
|
|
String subTag = subTags[i];
|
|
|
|
if(!subTag.matches("^[a-zA-Z0-9]*$"))
|
|
|
|
return;
|
|
|
|
}
|
2016-07-14 11:26:43 +02:00
|
|
|
}
|
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
final ListItem displayItem = new ListItem();
|
|
|
|
displayItem.setStyleName("tag-style");
|
|
|
|
Span p = new Span(tag);
|
2016-06-06 17:24:52 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
Span span = new Span("x");
|
|
|
|
span.setTitle("Remove this tag");
|
|
|
|
span.addClickHandler(new ClickHandler() {
|
|
|
|
public void onClick(ClickEvent clickEvent) {
|
|
|
|
removeTag(displayItem, tag);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
span.setStyleName("tag-style-x");
|
|
|
|
displayItem.add(p);
|
|
|
|
displayItem.add(span);
|
|
|
|
tagsPanel.add(displayItem);
|
|
|
|
tagsList.add(tag);
|
|
|
|
}
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
/**
|
|
|
|
* Remove a tag from the list
|
|
|
|
* @param displayItem
|
|
|
|
*/
|
|
|
|
private void removeTag(ListItem displayItem, String value) {
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-06-29 12:39:27 +02:00
|
|
|
tagsList.remove(value);
|
|
|
|
tagsPanel.remove(displayItem);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove all inserted tags
|
|
|
|
*/
|
|
|
|
private void removeTags(){
|
|
|
|
|
|
|
|
tagsList.clear();
|
|
|
|
tagsPanel.clear();
|
2016-05-27 19:08:03 +02:00
|
|
|
|
2016-05-26 18:12:53 +02:00
|
|
|
}
|
2016-07-19 21:24:42 +02:00
|
|
|
|
2016-07-14 12:14:33 +02:00
|
|
|
/**
|
|
|
|
* Close any dialog box opened
|
|
|
|
*/
|
|
|
|
private void closeDialogBox() {
|
2016-07-19 21:24:42 +02:00
|
|
|
|
2016-07-14 12:14:33 +02:00
|
|
|
for (String popupid : popupOpenedIds) {
|
|
|
|
GcubeDialogExtended popup = null;
|
|
|
|
try{
|
|
|
|
Element element = DOM.getElementById(popupid);
|
|
|
|
popup = (GcubeDialogExtended) Widget.asWidgetOrNull(getWidget(element));
|
|
|
|
popup.hide();
|
|
|
|
}catch(Exception e){
|
|
|
|
GWT.log("ERROR", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-07-13 16:11:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Prepare the popover and the gcube popup panel for information.
|
|
|
|
* @param text
|
|
|
|
* @param captionText
|
|
|
|
* @param iconElement
|
|
|
|
* @param popover
|
|
|
|
* @param focusPanel
|
|
|
|
*/
|
|
|
|
private void preparePopupPanelAndPopover(
|
|
|
|
final String popupId,
|
|
|
|
final String text,
|
|
|
|
final String captionText,
|
|
|
|
Icon iconElement,
|
|
|
|
Popover popover,
|
|
|
|
FocusPanel focusPanel){
|
|
|
|
|
|
|
|
// prepare the popover
|
|
|
|
popover.setText(new HTML("<p style='color:initial'>" + text +"</p>").getHTML());
|
|
|
|
popover.setHeading(new HTML("<b>" + captionText +"</b>").getHTML());
|
|
|
|
|
|
|
|
// set icon cursor
|
|
|
|
iconElement.getElement().getStyle().setCursor(Cursor.HELP);
|
|
|
|
|
|
|
|
// prepare the gcube dialog
|
|
|
|
focusPanel.addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
|
|
|
|
// Retrieve elemnt that should have this id
|
|
|
|
GcubeDialogExtended popup = null;
|
|
|
|
try{
|
|
|
|
Element element = DOM.getElementById(popupId);
|
|
|
|
popup = (GcubeDialogExtended) Widget.asWidgetOrNull(getWidget(element));
|
|
|
|
}catch(Exception e){
|
2016-07-14 11:38:21 +02:00
|
|
|
GWT.log("ERROR", e);
|
2016-07-13 16:11:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// if it doesn't exist, create it
|
|
|
|
if(popup == null){
|
|
|
|
|
|
|
|
popup = new GcubeDialogExtended(captionText, text);
|
|
|
|
popup.getElement().setId(popupId);
|
|
|
|
popup.setModal(false);
|
2016-07-19 21:24:42 +02:00
|
|
|
|
2016-07-14 12:14:33 +02:00
|
|
|
// add its id
|
|
|
|
popupOpenedIds.add(popupId);
|
2016-07-13 16:11:15 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// then center and show
|
|
|
|
popup.center();
|
|
|
|
popup.show();
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if an element of such type is actually a widget
|
|
|
|
* @param element
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public static IsWidget getWidget(Element element) {
|
|
|
|
EventListener listener = DOM
|
|
|
|
.getEventListener(element);
|
|
|
|
// No listener attached to the element, so no widget exist for this
|
|
|
|
// element
|
|
|
|
if (listener == null) {
|
|
|
|
GWT.log("Widget is NULL");
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
if (listener instanceof Widget) {
|
|
|
|
// GWT uses the widget as event listener
|
|
|
|
GWT.log("Widget is " + listener);
|
|
|
|
return (Widget) listener;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2016-06-29 12:39:27 +02:00
|
|
|
}
|