tags panel separated from the main one
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@132483 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ce69eaa9aa
commit
f671ef0280
|
@ -8,7 +8,6 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.gcube.portlets.user.gcubewidgets.client.elements.Span;
|
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherService;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherService;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherServiceAsync;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherServiceAsync;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.CloseCreationFormEvent;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.CloseCreationFormEvent;
|
||||||
|
@ -19,7 +18,7 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.dataset.reso
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.dataset.resources.AddResourceToDataset;
|
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.AddedResourcesSummary;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.dataset.resources.ResourcesTable;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.dataset.resources.ResourcesTable;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.GcubeDialogExtended;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.dataset.resources.TagsPanel;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.InfoIconsLabels;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.InfoIconsLabels;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DataType;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DataType;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetMetadataBean;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetMetadataBean;
|
||||||
|
@ -40,36 +39,26 @@ import com.github.gwtbootstrap.client.ui.Tab;
|
||||||
import com.github.gwtbootstrap.client.ui.TabPanel;
|
import com.github.gwtbootstrap.client.ui.TabPanel;
|
||||||
import com.github.gwtbootstrap.client.ui.TextArea;
|
import com.github.gwtbootstrap.client.ui.TextArea;
|
||||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||||
import com.github.gwtbootstrap.client.ui.base.ListItem;
|
|
||||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
|
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
|
||||||
import com.github.gwtbootstrap.client.ui.resources.Bootstrap.Tabs;
|
import com.github.gwtbootstrap.client.ui.resources.Bootstrap.Tabs;
|
||||||
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.Style.Cursor;
|
|
||||||
import com.google.gwt.event.dom.client.ChangeEvent;
|
import com.google.gwt.event.dom.client.ChangeEvent;
|
||||||
import com.google.gwt.event.dom.client.ChangeHandler;
|
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
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;
|
import com.google.gwt.event.shared.HandlerManager;
|
||||||
import com.google.gwt.uibinder.client.UiBinder;
|
import com.google.gwt.uibinder.client.UiBinder;
|
||||||
import com.google.gwt.uibinder.client.UiField;
|
import com.google.gwt.uibinder.client.UiField;
|
||||||
import com.google.gwt.uibinder.client.UiHandler;
|
import com.google.gwt.uibinder.client.UiHandler;
|
||||||
import com.google.gwt.user.client.DOM;
|
|
||||||
import com.google.gwt.user.client.EventListener;
|
|
||||||
import com.google.gwt.user.client.Timer;
|
import com.google.gwt.user.client.Timer;
|
||||||
import com.google.gwt.user.client.Window;
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.gwt.user.client.ui.Anchor;
|
import com.google.gwt.user.client.ui.Anchor;
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
|
||||||
import com.google.gwt.user.client.ui.FocusPanel;
|
import com.google.gwt.user.client.ui.FocusPanel;
|
||||||
import com.google.gwt.user.client.ui.HTML;
|
|
||||||
import com.google.gwt.user.client.ui.HTMLPanel;
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||||
import com.google.gwt.user.client.ui.IsWidget;
|
|
||||||
import com.google.gwt.user.client.ui.SimplePanel;
|
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;
|
||||||
|
@ -90,8 +79,6 @@ public class CreateDatasetForm extends Composite{
|
||||||
@UiField HTMLPanel createDatasetMainPanel;
|
@UiField HTMLPanel createDatasetMainPanel;
|
||||||
@UiField TextBox titleTextBox;
|
@UiField TextBox titleTextBox;
|
||||||
@UiField TextArea descriptionTextarea;
|
@UiField TextArea descriptionTextarea;
|
||||||
@UiField TextBox tagsEnterTextBox;
|
|
||||||
@UiField FlowPanel tagsPanel;
|
|
||||||
@UiField ListBox licenseListbox;
|
@UiField ListBox licenseListbox;
|
||||||
@UiField ListBox visibilityListbox;
|
@UiField ListBox visibilityListbox;
|
||||||
@UiField ListBox organizationsListbox;
|
@UiField ListBox organizationsListbox;
|
||||||
|
@ -123,11 +110,9 @@ public class CreateDatasetForm extends Composite{
|
||||||
@UiField Button goBackButtonFirstStep;
|
@UiField Button goBackButtonFirstStep;
|
||||||
@UiField Anchor licenseUrlAnchor;
|
@UiField Anchor licenseUrlAnchor;
|
||||||
@UiField Paragraph unavailableUrl;
|
@UiField Paragraph unavailableUrl;
|
||||||
|
@UiField TagsPanel tagsPanel;
|
||||||
|
|
||||||
// info panels
|
// info panels
|
||||||
@UiField Icon infoIconTags;
|
|
||||||
@UiField FocusPanel focusPanelTags;
|
|
||||||
@UiField Popover popoverTags;
|
|
||||||
@UiField Icon infoIconLicenses;
|
@UiField Icon infoIconLicenses;
|
||||||
@UiField FocusPanel focusPanelLicenses;
|
@UiField FocusPanel focusPanelLicenses;
|
||||||
@UiField Popover popoverLicenses;
|
@UiField Popover popoverLicenses;
|
||||||
|
@ -182,9 +167,6 @@ public class CreateDatasetForm extends Composite{
|
||||||
// add resource form
|
// add resource form
|
||||||
private AddResourceToDataset resourceForm;
|
private AddResourceToDataset resourceForm;
|
||||||
|
|
||||||
// tags list
|
|
||||||
private List<String> tagsList = new ArrayList<String>();
|
|
||||||
|
|
||||||
// the licenses
|
// the licenses
|
||||||
private LicensesBean licenseBean;
|
private LicensesBean licenseBean;
|
||||||
|
|
||||||
|
@ -259,7 +241,7 @@ public class CreateDatasetForm extends Composite{
|
||||||
@Override
|
@Override
|
||||||
public void onClose(CloseCreationFormEvent event) {
|
public void onClose(CloseCreationFormEvent event) {
|
||||||
|
|
||||||
closeDialogBox();
|
InfoIconsLabels.closeDialogBox(popupOpenedIds);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,7 +328,7 @@ public class CreateDatasetForm extends Composite{
|
||||||
customFields.add(toAdd);
|
customFields.add(toAdd);
|
||||||
|
|
||||||
// add as tag
|
// add as tag
|
||||||
addTagElement(entry.getKey());
|
tagsPanel.addTagElement(entry.getKey());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -760,7 +742,7 @@ public class CreateDatasetForm extends Composite{
|
||||||
receivedBean.setVersion(version);
|
receivedBean.setVersion(version);
|
||||||
receivedBean.setVisibility(visibility.equals("Public"));
|
receivedBean.setVisibility(visibility.equals("Public"));
|
||||||
receivedBean.setTitle(title);
|
receivedBean.setTitle(title);
|
||||||
receivedBean.setTags(tagsList);
|
receivedBean.setTags(tagsPanel.getTags());
|
||||||
receivedBean.setSelectedOrganization(chosenOrganization);
|
receivedBean.setSelectedOrganization(chosenOrganization);
|
||||||
|
|
||||||
Map<String, String> customFieldsMap = new HashMap<String, String>();
|
Map<String, String> customFieldsMap = new HashMap<String, String>();
|
||||||
|
@ -899,113 +881,116 @@ public class CreateDatasetForm extends Composite{
|
||||||
private void prepareInfoIcons() {
|
private void prepareInfoIcons() {
|
||||||
|
|
||||||
// tags
|
// tags
|
||||||
preparePopupPanelAndPopover(
|
tagsPanel.prepareIcon(popupOpenedIds);
|
||||||
InfoIconsLabels.TAGS_INFO_ID_POPUP,
|
|
||||||
InfoIconsLabels.TAGS_INFO_TEXT,
|
|
||||||
InfoIconsLabels.TAGS_INFO_CAPTION,
|
|
||||||
infoIconTags,
|
|
||||||
popoverTags,
|
|
||||||
focusPanelTags
|
|
||||||
);
|
|
||||||
|
|
||||||
// licenses
|
// licenses
|
||||||
preparePopupPanelAndPopover(
|
InfoIconsLabels.preparePopupPanelAndPopover(
|
||||||
InfoIconsLabels.LICENSES_INFO_ID_POPUP,
|
InfoIconsLabels.LICENSES_INFO_ID_POPUP,
|
||||||
InfoIconsLabels.LICENSES_INFO_TEXT,
|
InfoIconsLabels.LICENSES_INFO_TEXT,
|
||||||
InfoIconsLabels.LICENSES_INFO_CAPTION,
|
InfoIconsLabels.LICENSES_INFO_CAPTION,
|
||||||
infoIconLicenses,
|
infoIconLicenses,
|
||||||
popoverLicenses,
|
popoverLicenses,
|
||||||
focusPanelLicenses
|
focusPanelLicenses,
|
||||||
|
popupOpenedIds
|
||||||
);
|
);
|
||||||
|
|
||||||
// visibility
|
// visibility
|
||||||
preparePopupPanelAndPopover(
|
InfoIconsLabels.preparePopupPanelAndPopover(
|
||||||
InfoIconsLabels.VISIBILITY_INFO_ID_POPUP,
|
InfoIconsLabels.VISIBILITY_INFO_ID_POPUP,
|
||||||
InfoIconsLabels.VISIBILITY_INFO_TEXT,
|
InfoIconsLabels.VISIBILITY_INFO_TEXT,
|
||||||
InfoIconsLabels.VISIBILITY_INFO_CAPTION,
|
InfoIconsLabels.VISIBILITY_INFO_CAPTION,
|
||||||
infoIconVisibility,
|
infoIconVisibility,
|
||||||
popoverVisibility,
|
popoverVisibility,
|
||||||
focusPanelVisibility
|
focusPanelVisibility,
|
||||||
|
popupOpenedIds
|
||||||
);
|
);
|
||||||
|
|
||||||
// author
|
// author
|
||||||
preparePopupPanelAndPopover(
|
InfoIconsLabels.preparePopupPanelAndPopover(
|
||||||
InfoIconsLabels.AUTHOR_INFO_ID_POPUP,
|
InfoIconsLabels.AUTHOR_INFO_ID_POPUP,
|
||||||
InfoIconsLabels.AUTHOR_INFO_TEXT,
|
InfoIconsLabels.AUTHOR_INFO_TEXT,
|
||||||
InfoIconsLabels.AUTHOR_INFO_CAPTION,
|
InfoIconsLabels.AUTHOR_INFO_CAPTION,
|
||||||
infoIconAuthor,
|
infoIconAuthor,
|
||||||
popoverAuthor,
|
popoverAuthor,
|
||||||
focusPanelAuthor
|
focusPanelAuthor,
|
||||||
|
popupOpenedIds
|
||||||
);
|
);
|
||||||
|
|
||||||
// author's email
|
// author's email
|
||||||
preparePopupPanelAndPopover(
|
InfoIconsLabels.preparePopupPanelAndPopover(
|
||||||
InfoIconsLabels.AUTHOR_EMAIL_INFO_ID_POPUP,
|
InfoIconsLabels.AUTHOR_EMAIL_INFO_ID_POPUP,
|
||||||
InfoIconsLabels.AUTHOR_EMAIL_INFO_TEXT,
|
InfoIconsLabels.AUTHOR_EMAIL_INFO_TEXT,
|
||||||
InfoIconsLabels.AUTHOR_EMAIL_INFO_CAPTION,
|
InfoIconsLabels.AUTHOR_EMAIL_INFO_CAPTION,
|
||||||
infoIconAuthorEmail,
|
infoIconAuthorEmail,
|
||||||
popoverAuthorEmail,
|
popoverAuthorEmail,
|
||||||
focusPanelAuthorEmail
|
focusPanelAuthorEmail,
|
||||||
|
popupOpenedIds
|
||||||
);
|
);
|
||||||
|
|
||||||
// maintainer
|
// maintainer
|
||||||
preparePopupPanelAndPopover(
|
InfoIconsLabels.preparePopupPanelAndPopover(
|
||||||
InfoIconsLabels.MAINTAINER_INFO_ID_POPUP,
|
InfoIconsLabels.MAINTAINER_INFO_ID_POPUP,
|
||||||
InfoIconsLabels.MAINTAINER_INFO_TEXT,
|
InfoIconsLabels.MAINTAINER_INFO_TEXT,
|
||||||
InfoIconsLabels.MAINTAINER_INFO_CAPTION,
|
InfoIconsLabels.MAINTAINER_INFO_CAPTION,
|
||||||
infoIconMaintainer,
|
infoIconMaintainer,
|
||||||
popoverMaintainer,
|
popoverMaintainer,
|
||||||
focusPanelMaintainer
|
focusPanelMaintainer,
|
||||||
|
popupOpenedIds
|
||||||
);
|
);
|
||||||
|
|
||||||
// maintainer's email
|
// maintainer's email
|
||||||
preparePopupPanelAndPopover(
|
InfoIconsLabels.preparePopupPanelAndPopover(
|
||||||
InfoIconsLabels.MAINTAINER_EMAIL_INFO_ID_POPUP,
|
InfoIconsLabels.MAINTAINER_EMAIL_INFO_ID_POPUP,
|
||||||
InfoIconsLabels.MAINTAINER_EMAIL_INFO_TEXT,
|
InfoIconsLabels.MAINTAINER_EMAIL_INFO_TEXT,
|
||||||
InfoIconsLabels.MAINTAINER_EMAIL_INFO_CAPTION,
|
InfoIconsLabels.MAINTAINER_EMAIL_INFO_CAPTION,
|
||||||
infoIconMaintainerEmail,
|
infoIconMaintainerEmail,
|
||||||
popoverMaintainerEmail,
|
popoverMaintainerEmail,
|
||||||
focusPanelMaintainerEmail
|
focusPanelMaintainerEmail,
|
||||||
|
popupOpenedIds
|
||||||
);
|
);
|
||||||
|
|
||||||
// profiles
|
// profiles
|
||||||
preparePopupPanelAndPopover(
|
InfoIconsLabels.preparePopupPanelAndPopover(
|
||||||
InfoIconsLabels.PROFILES_INFO_ID_POPUP,
|
InfoIconsLabels.PROFILES_INFO_ID_POPUP,
|
||||||
InfoIconsLabels.PROFILES_INFO_TEXT,
|
InfoIconsLabels.PROFILES_INFO_TEXT,
|
||||||
InfoIconsLabels.PROFILES_INFO_CAPTION,
|
InfoIconsLabels.PROFILES_INFO_CAPTION,
|
||||||
infoIconProfiles,
|
infoIconProfiles,
|
||||||
popoverProfiles,
|
popoverProfiles,
|
||||||
focusPanelProfiles
|
focusPanelProfiles,
|
||||||
|
popupOpenedIds
|
||||||
);
|
);
|
||||||
|
|
||||||
// custom fields
|
// custom fields
|
||||||
preparePopupPanelAndPopover(
|
InfoIconsLabels.preparePopupPanelAndPopover(
|
||||||
InfoIconsLabels.CUSTOM_FIELDS_INFO_ID_POPUP,
|
InfoIconsLabels.CUSTOM_FIELDS_INFO_ID_POPUP,
|
||||||
InfoIconsLabels.CUSTOM_FIELDS_INFO_TEXT,
|
InfoIconsLabels.CUSTOM_FIELDS_INFO_TEXT,
|
||||||
InfoIconsLabels.CUSTOM_FIELDS_INFO_CAPTION,
|
InfoIconsLabels.CUSTOM_FIELDS_INFO_CAPTION,
|
||||||
infoIconCustomFields,
|
infoIconCustomFields,
|
||||||
popoverCustomFields,
|
popoverCustomFields,
|
||||||
focusPanelCustomFields
|
focusPanelCustomFields,
|
||||||
|
popupOpenedIds
|
||||||
);
|
);
|
||||||
|
|
||||||
// resources field
|
// resources field
|
||||||
preparePopupPanelAndPopover(
|
InfoIconsLabels.preparePopupPanelAndPopover(
|
||||||
InfoIconsLabels.RESOURCES_INFO_ID_POPUP,
|
InfoIconsLabels.RESOURCES_INFO_ID_POPUP,
|
||||||
InfoIconsLabels.RESOURCES_INFO_TEXT,
|
InfoIconsLabels.RESOURCES_INFO_TEXT,
|
||||||
InfoIconsLabels.RESOURCES_INFO_CAPTION,
|
InfoIconsLabels.RESOURCES_INFO_CAPTION,
|
||||||
infoIconResources,
|
infoIconResources,
|
||||||
popoverResources,
|
popoverResources,
|
||||||
focusPanelResources
|
focusPanelResources,
|
||||||
|
popupOpenedIds
|
||||||
);
|
);
|
||||||
|
|
||||||
// title
|
// title
|
||||||
preparePopupPanelAndPopover(
|
InfoIconsLabels.preparePopupPanelAndPopover(
|
||||||
InfoIconsLabels.TITLE_INFO_ID_POPUP,
|
InfoIconsLabels.TITLE_INFO_ID_POPUP,
|
||||||
InfoIconsLabels.TITLE_INFO_TEXT,
|
InfoIconsLabels.TITLE_INFO_TEXT,
|
||||||
InfoIconsLabels.TITLE_INFO_CAPTION,
|
InfoIconsLabels.TITLE_INFO_CAPTION,
|
||||||
infoIconTitle,
|
infoIconTitle,
|
||||||
popoverTitle,
|
popoverTitle,
|
||||||
focusPanelTitle
|
focusPanelTitle,
|
||||||
|
popupOpenedIds
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1162,7 +1147,7 @@ public class CreateDatasetForm extends Composite{
|
||||||
versionTextbox.setText("");
|
versionTextbox.setText("");
|
||||||
maintainerTextbox.setText("");
|
maintainerTextbox.setText("");
|
||||||
maintainerEmailTextbox.setText("");
|
maintainerEmailTextbox.setText("");
|
||||||
removeTags();
|
tagsPanel.removeTags();
|
||||||
|
|
||||||
// delete custom fields
|
// delete custom fields
|
||||||
for (CustomFieldEntry customField : customFieldEntriesList) {
|
for (CustomFieldEntry customField : customFieldEntriesList) {
|
||||||
|
@ -1184,22 +1169,11 @@ public class CreateDatasetForm extends Composite{
|
||||||
maintainerTextbox.setEnabled(false);
|
maintainerTextbox.setEnabled(false);
|
||||||
maintainerEmailTextbox.setEnabled(false);
|
maintainerEmailTextbox.setEnabled(false);
|
||||||
visibilityListbox.setEnabled(false);
|
visibilityListbox.setEnabled(false);
|
||||||
tagsEnterTextBox.setEnabled(false);
|
tagsPanel.freeze();
|
||||||
licenseListbox.setEnabled(false);
|
licenseListbox.setEnabled(false);
|
||||||
organizationsListbox.setEnabled(false);
|
organizationsListbox.setEnabled(false);
|
||||||
addCustomFieldButton.setEnabled(false);
|
addCustomFieldButton.setEnabled(false);
|
||||||
|
|
||||||
// freeze tags
|
|
||||||
for(int i = 0; i < tagsList.size(); i++){
|
|
||||||
|
|
||||||
// get tag widget
|
|
||||||
ListItem tagWidget = (ListItem)tagsPanel.getWidget(i);
|
|
||||||
|
|
||||||
// get the "x" span
|
|
||||||
tagWidget.getWidget(1).removeFromParent();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// disable profile fields
|
// disable profile fields
|
||||||
for (MetaDataFieldSkeleton field : listOfMetadataFields) {
|
for (MetaDataFieldSkeleton field : listOfMetadataFields) {
|
||||||
|
|
||||||
|
@ -1226,18 +1200,6 @@ public class CreateDatasetForm extends Composite{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@UiHandler("tagsEnterTextBox")
|
|
||||||
void onAddTag(KeyDownEvent event){
|
|
||||||
|
|
||||||
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
|
|
||||||
if (!tagsEnterTextBox.getValue().trim().isEmpty()) {
|
|
||||||
|
|
||||||
addTagElement(tagsEnterTextBox);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@UiHandler("licenseListbox")
|
@UiHandler("licenseListbox")
|
||||||
void onSelectedLicenseChange(ChangeEvent c){
|
void onSelectedLicenseChange(ChangeEvent c){
|
||||||
|
|
||||||
|
@ -1272,214 +1234,4 @@ public class CreateDatasetForm extends Composite{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add the tag as an element (inserted by the user)
|
|
||||||
*/
|
|
||||||
private void addTagElement(TextBox itemBox){
|
|
||||||
|
|
||||||
if (itemBox.getValue() != null && !itemBox.getValue().trim().isEmpty()) {
|
|
||||||
|
|
||||||
if(tagsList.contains(itemBox.getValue().trim())){
|
|
||||||
itemBox.setValue("");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ckan accepts only alphanumeric values
|
|
||||||
String[] subTags = itemBox.getValue().split(" ");
|
|
||||||
if(subTags.length == 1){
|
|
||||||
if(!subTags[0].matches("^[a-zA-Z0-9]*$"))
|
|
||||||
return;
|
|
||||||
if(subTags[0].length() <= 1)
|
|
||||||
return;
|
|
||||||
}else{
|
|
||||||
for (int i = 0; i < subTags.length; i++) {
|
|
||||||
String subTag = subTags[i];
|
|
||||||
if(!subTag.matches("^[a-zA-Z0-9]*$"))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final String value = itemBox.getValue();
|
|
||||||
final ListItem displayItem = new ListItem();
|
|
||||||
displayItem.setStyleName("tag-style");
|
|
||||||
Span tagText = new Span(itemBox.getValue());
|
|
||||||
|
|
||||||
Span tagRemove = new Span("x");
|
|
||||||
tagRemove.setTitle("Remove this tag");
|
|
||||||
tagRemove.addClickHandler(new ClickHandler() {
|
|
||||||
public void onClick(ClickEvent clickEvent) {
|
|
||||||
removeTag(displayItem, value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
tagRemove.setStyleName("tag-style-x");
|
|
||||||
displayItem.add(tagText);
|
|
||||||
displayItem.add(tagRemove);
|
|
||||||
itemBox.setValue("");
|
|
||||||
itemBox.setFocus(true);
|
|
||||||
tagsPanel.add(displayItem);
|
|
||||||
tagsList.add(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add the tag as an element (when publishing from workspace)
|
|
||||||
*/
|
|
||||||
private void addTagElement(final String tag){
|
|
||||||
|
|
||||||
if(tagsList.contains(tag))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// ckan accepts only alphanumeric values
|
|
||||||
String[] subTags = tag.split(" ");
|
|
||||||
if(subTags.length == 1){
|
|
||||||
if(!subTags[0].matches("^[a-zA-Z0-9]*$"))
|
|
||||||
return;
|
|
||||||
if(subTags[0].length() <= 1)
|
|
||||||
return;
|
|
||||||
}else{
|
|
||||||
for (int i = 0; i < subTags.length; i++) {
|
|
||||||
String subTag = subTags[i];
|
|
||||||
if(!subTag.matches("^[a-zA-Z0-9]*$"))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final ListItem displayItem = new ListItem();
|
|
||||||
displayItem.setStyleName("tag-style");
|
|
||||||
Span p = new Span(tag);
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove a tag from the list
|
|
||||||
* @param displayItem
|
|
||||||
*/
|
|
||||||
private void removeTag(ListItem displayItem, String value) {
|
|
||||||
|
|
||||||
tagsList.remove(value);
|
|
||||||
tagsPanel.remove(displayItem);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove all inserted tags
|
|
||||||
*/
|
|
||||||
private void removeTags(){
|
|
||||||
|
|
||||||
tagsList.clear();
|
|
||||||
tagsPanel.clear();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Close any dialog box opened
|
|
||||||
*/
|
|
||||||
private void closeDialogBox() {
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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){
|
|
||||||
GWT.log("ERROR", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
// if it doesn't exist, create it
|
|
||||||
if(popup == null){
|
|
||||||
|
|
||||||
popup = new GcubeDialogExtended(captionText, text);
|
|
||||||
popup.getElement().setId(popupId);
|
|
||||||
popup.setModal(false);
|
|
||||||
|
|
||||||
// add its id
|
|
||||||
popupOpenedIds.add(popupId);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<!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:m="urn:import:org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.dataset.resources">
|
||||||
<ui:style>
|
<ui:style>
|
||||||
.form-main-style {
|
.form-main-style {
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
|
@ -86,30 +87,7 @@
|
||||||
</b:ControlGroup>
|
</b:ControlGroup>
|
||||||
|
|
||||||
<!-- TAGS Panel -->
|
<!-- TAGS Panel -->
|
||||||
|
<m:TagsPanel ui:field="tagsPanel"></m:TagsPanel>
|
||||||
<b:ControlGroup>
|
|
||||||
<b:ControlLabel for="tags" title="Product tags">
|
|
||||||
Tags:
|
|
||||||
</b:ControlLabel>
|
|
||||||
<b:Controls>
|
|
||||||
<b:TextBox width="90%" placeholder="Enter one or more tag for the product"
|
|
||||||
b:id="tags" ui:field="tagsEnterTextBox" />
|
|
||||||
<span style="float:right; width:5%; color: #aaaaaa;">
|
|
||||||
<b:Popover ui:field="popoverTags" html="true"
|
|
||||||
animation="true" placement="LEFT">
|
|
||||||
<g:FocusPanel ui:field="focusPanelTags">
|
|
||||||
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconTags" />
|
|
||||||
</g:FocusPanel>
|
|
||||||
</b:Popover>
|
|
||||||
</span>
|
|
||||||
</b:Controls>
|
|
||||||
</b:ControlGroup>
|
|
||||||
|
|
||||||
<b:ControlGroup>
|
|
||||||
<b:Controls>
|
|
||||||
<g:FlowPanel ui:field="tagsPanel" styleName="{style.tagsPanelStyle}"></g:FlowPanel>
|
|
||||||
</b:Controls>
|
|
||||||
</b:ControlGroup>
|
|
||||||
|
|
||||||
<b:ControlGroup>
|
<b:ControlGroup>
|
||||||
<b:ControlLabel for="licenses" title="License">License:</b:ControlLabel>
|
<b:ControlLabel for="licenses" title="License">License:</b:ControlLabel>
|
||||||
|
|
|
@ -0,0 +1,209 @@
|
||||||
|
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.dataset.resources;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.gcubewidgets.client.elements.Span;
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.InfoIconsLabels;
|
||||||
|
|
||||||
|
import com.github.gwtbootstrap.client.ui.Icon;
|
||||||
|
import com.github.gwtbootstrap.client.ui.Popover;
|
||||||
|
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||||
|
import com.github.gwtbootstrap.client.ui.base.ListItem;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
|
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.uibinder.client.UiBinder;
|
||||||
|
import com.google.gwt.uibinder.client.UiField;
|
||||||
|
import com.google.gwt.uibinder.client.UiHandler;
|
||||||
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
|
import com.google.gwt.user.client.ui.FlowPanel;
|
||||||
|
import com.google.gwt.user.client.ui.FocusPanel;
|
||||||
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
|
public class TagsPanel extends Composite{
|
||||||
|
|
||||||
|
private static TagsPanelUiBinder uiBinder = GWT
|
||||||
|
.create(TagsPanelUiBinder.class);
|
||||||
|
|
||||||
|
interface TagsPanelUiBinder extends UiBinder<Widget, TagsPanel> {
|
||||||
|
}
|
||||||
|
|
||||||
|
@UiField TextBox tagsEnterTextBox;
|
||||||
|
@UiField FlowPanel tagsPanel;
|
||||||
|
@UiField Icon infoIconTags;
|
||||||
|
@UiField FocusPanel focusPanelTags;
|
||||||
|
@UiField Popover popoverTags;
|
||||||
|
|
||||||
|
// tags list
|
||||||
|
private List<String> tagsList = new ArrayList<String>();
|
||||||
|
|
||||||
|
public TagsPanel() {
|
||||||
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare icons
|
||||||
|
* @param popupOpenedIds
|
||||||
|
*/
|
||||||
|
public void prepareIcon(List<String> popupOpenedIds) {
|
||||||
|
InfoIconsLabels.preparePopupPanelAndPopover(
|
||||||
|
InfoIconsLabels.TAGS_INFO_ID_POPUP,
|
||||||
|
InfoIconsLabels.TAGS_INFO_TEXT,
|
||||||
|
InfoIconsLabels.TAGS_INFO_CAPTION,
|
||||||
|
infoIconTags,
|
||||||
|
popoverTags,
|
||||||
|
focusPanelTags,
|
||||||
|
popupOpenedIds
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the tag as an element (inserted by the user)
|
||||||
|
*/
|
||||||
|
private void addTagElement(TextBox itemBox){
|
||||||
|
|
||||||
|
if (itemBox.getValue() != null && !itemBox.getValue().trim().isEmpty()) {
|
||||||
|
|
||||||
|
if(tagsList.contains(itemBox.getValue().trim())){
|
||||||
|
itemBox.setValue("");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ckan accepts only alphanumeric values
|
||||||
|
String[] subTags = itemBox.getValue().split(" ");
|
||||||
|
if(subTags.length == 1){
|
||||||
|
if(!subTags[0].matches("^[a-zA-Z0-9]*$"))
|
||||||
|
return;
|
||||||
|
if(subTags[0].length() <= 1)
|
||||||
|
return;
|
||||||
|
}else{
|
||||||
|
for (int i = 0; i < subTags.length; i++) {
|
||||||
|
String subTag = subTags[i];
|
||||||
|
if(!subTag.matches("^[a-zA-Z0-9]*$"))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final String value = itemBox.getValue();
|
||||||
|
final ListItem displayItem = new ListItem();
|
||||||
|
displayItem.setStyleName("tag-style");
|
||||||
|
Span tagText = new Span(itemBox.getValue());
|
||||||
|
|
||||||
|
Span tagRemove = new Span("x");
|
||||||
|
tagRemove.setTitle("Remove this tag");
|
||||||
|
tagRemove.addClickHandler(new ClickHandler() {
|
||||||
|
public void onClick(ClickEvent clickEvent) {
|
||||||
|
removeTag(displayItem, value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tagRemove.setStyleName("tag-style-x");
|
||||||
|
displayItem.add(tagText);
|
||||||
|
displayItem.add(tagRemove);
|
||||||
|
itemBox.setValue("");
|
||||||
|
itemBox.setFocus(true);
|
||||||
|
tagsPanel.add(displayItem);
|
||||||
|
tagsList.add(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the tag as an element (when publishing from workspace)
|
||||||
|
*/
|
||||||
|
public void addTagElement(final String tag){
|
||||||
|
|
||||||
|
if(tagsList.contains(tag))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// ckan accepts only alphanumeric values
|
||||||
|
String[] subTags = tag.split(" ");
|
||||||
|
if(subTags.length == 1){
|
||||||
|
if(!subTags[0].matches("^[a-zA-Z0-9]*$"))
|
||||||
|
return;
|
||||||
|
if(subTags[0].length() <= 1)
|
||||||
|
return;
|
||||||
|
}else{
|
||||||
|
for (int i = 0; i < subTags.length; i++) {
|
||||||
|
String subTag = subTags[i];
|
||||||
|
if(!subTag.matches("^[a-zA-Z0-9]*$"))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final ListItem displayItem = new ListItem();
|
||||||
|
displayItem.setStyleName("tag-style");
|
||||||
|
Span p = new Span(tag);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a tag from the list
|
||||||
|
* @param displayItem
|
||||||
|
*/
|
||||||
|
private void removeTag(ListItem displayItem, String value) {
|
||||||
|
|
||||||
|
tagsList.remove(value);
|
||||||
|
tagsPanel.remove(displayItem);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all inserted tags
|
||||||
|
*/
|
||||||
|
public void removeTags(){
|
||||||
|
|
||||||
|
tagsList.clear();
|
||||||
|
tagsPanel.clear();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@UiHandler("tagsEnterTextBox")
|
||||||
|
void onAddTag(KeyDownEvent event){
|
||||||
|
|
||||||
|
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
|
||||||
|
if (!tagsEnterTextBox.getValue().trim().isEmpty()) {
|
||||||
|
|
||||||
|
addTagElement(tagsEnterTextBox);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getTags() {
|
||||||
|
return tagsList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Freeze tags
|
||||||
|
*/
|
||||||
|
public void freeze() {
|
||||||
|
|
||||||
|
tagsEnterTextBox.setEnabled(false);
|
||||||
|
for(int i = 0; i < tagsList.size(); i++){
|
||||||
|
|
||||||
|
// get tag widget
|
||||||
|
ListItem tagWidget = (ListItem)tagsPanel.getWidget(i);
|
||||||
|
|
||||||
|
// get the "x" span
|
||||||
|
tagWidget.getWidget(1).removeFromParent();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
||||||
|
<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">
|
||||||
|
<ui:style>
|
||||||
|
.tagsPanelStyle {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
</ui:style>
|
||||||
|
<g:HTMLPanel>
|
||||||
|
<b:ControlGroup>
|
||||||
|
<b:ControlLabel for="tags" title="Product tags">
|
||||||
|
Tags:
|
||||||
|
</b:ControlLabel>
|
||||||
|
<b:Controls>
|
||||||
|
<b:TextBox width="90%" placeholder="Enter one or more tag for the product"
|
||||||
|
b:id="tags" ui:field="tagsEnterTextBox" />
|
||||||
|
<span style="float:right; width:5%; color: #aaaaaa;">
|
||||||
|
<b:Popover ui:field="popoverTags" html="true" animation="true"
|
||||||
|
placement="LEFT">
|
||||||
|
<g:FocusPanel ui:field="focusPanelTags">
|
||||||
|
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconTags" />
|
||||||
|
</g:FocusPanel>
|
||||||
|
</b:Popover>
|
||||||
|
</span>
|
||||||
|
</b:Controls>
|
||||||
|
</b:ControlGroup>
|
||||||
|
|
||||||
|
<b:ControlGroup>
|
||||||
|
<b:Controls>
|
||||||
|
<g:FlowPanel ui:field="tagsPanel" styleName="{style.tagsPanelStyle}"></g:FlowPanel>
|
||||||
|
</b:Controls>
|
||||||
|
</b:ControlGroup>
|
||||||
|
</g:HTMLPanel>
|
||||||
|
</ui:UiBinder>
|
|
@ -1,5 +1,21 @@
|
||||||
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils;
|
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.github.gwtbootstrap.client.ui.Icon;
|
||||||
|
import com.github.gwtbootstrap.client.ui.Popover;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.dom.client.Element;
|
||||||
|
import com.google.gwt.dom.client.Style.Cursor;
|
||||||
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
|
import com.google.gwt.user.client.DOM;
|
||||||
|
import com.google.gwt.user.client.EventListener;
|
||||||
|
import com.google.gwt.user.client.ui.FocusPanel;
|
||||||
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
|
import com.google.gwt.user.client.ui.IsWidget;
|
||||||
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Labels and texts for core ckan information
|
* Labels and texts for core ckan information
|
||||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||||
|
@ -64,4 +80,104 @@ public class InfoIconsLabels {
|
||||||
public static final String TITLE_INFO_TEXT = "Product Title must contain only alphanumer characters, dots, underscore or hyphen minus. No others symbols are allowed.";
|
public static final String TITLE_INFO_TEXT = "Product Title must contain only alphanumer characters, dots, underscore or hyphen minus. No others symbols are allowed.";
|
||||||
public static final String TITLE_INFO_CAPTION = "Product Title";
|
public static final String TITLE_INFO_CAPTION = "Product Title";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the popover and the gcube popup panel for information.
|
||||||
|
* @param text
|
||||||
|
* @param captionText
|
||||||
|
* @param iconElement
|
||||||
|
* @param popover
|
||||||
|
* @param focusPanel
|
||||||
|
*/
|
||||||
|
public static void preparePopupPanelAndPopover(
|
||||||
|
final String popupId,
|
||||||
|
final String text,
|
||||||
|
final String captionText,
|
||||||
|
Icon iconElement,
|
||||||
|
Popover popover,
|
||||||
|
FocusPanel focusPanel,
|
||||||
|
final List<String> popupOpenedIds
|
||||||
|
){
|
||||||
|
|
||||||
|
// 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){
|
||||||
|
GWT.log("ERROR", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if it doesn't exist, create it
|
||||||
|
if(popup == null){
|
||||||
|
|
||||||
|
popup = new GcubeDialogExtended(captionText, text);
|
||||||
|
popup.getElement().setId(popupId);
|
||||||
|
popup.setModal(false);
|
||||||
|
|
||||||
|
// add its id
|
||||||
|
popupOpenedIds.add(popupId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close any dialog box opened
|
||||||
|
*/
|
||||||
|
public static void closeDialogBox(List<String> popupOpenedIds) {
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue