Improved info icons

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@130315 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-07-13 14:11:15 +00:00
parent 90b569f781
commit a24a923616
12 changed files with 649 additions and 125 deletions

View File

@ -20,6 +20,7 @@
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="${webappDirectory}/WEB-INF/classes" path="src/main/resources">

View File

@ -5,6 +5,9 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="gcube-widgets-2.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-widgets/gcube-widgets">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="context-root" value="ckan-metadata-publisher-widget"/>
<property name="java-output-path" value="/ckan-metadata-publisher-widget/target/ckan-metadata-publisher-widget-1.0.0-SNAPSHOT/WEB-INF/classes"/>
</wb-module>

View File

@ -13,6 +13,8 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherSe
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherServiceAsync;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCustomFieldEvent;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCustomFieldEventHandler;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.GcubeDialogExtended;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.InfoIconsLabels;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetMetadataBean;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.LicensesBean;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetaDataProfileBean;
@ -23,8 +25,10 @@ import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.CheckBox;
import com.github.gwtbootstrap.client.ui.ControlGroup;
import com.github.gwtbootstrap.client.ui.Form;
import com.github.gwtbootstrap.client.ui.Icon;
import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.Paragraph;
import com.github.gwtbootstrap.client.ui.Popover;
import com.github.gwtbootstrap.client.ui.Tab;
import com.github.gwtbootstrap.client.ui.TabPanel;
import com.github.gwtbootstrap.client.ui.TextArea;
@ -34,6 +38,8 @@ import com.github.gwtbootstrap.client.ui.constants.AlertType;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.github.gwtbootstrap.client.ui.resources.Bootstrap.Tabs;
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.dom.client.Style.Display;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
@ -45,12 +51,18 @@ import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.EventListener;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Anchor;
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.HTML;
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.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
@ -109,6 +121,34 @@ public class CreateDatasetForm extends Composite{
@UiField SimplePanel workspaceResourcesContainer;
@UiField Button continueThirdStep;
@UiField Button goBackButtonFirstStep;
@UiField Anchor licenseUrlAnchor;
@UiField Paragraph unavailableUrl;
// info panels
@UiField Icon infoIconTags;
@UiField FocusPanel focusPanelTags;
@UiField Popover popoverTags;
@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;
// tab panel
private TabPanel tabPanel;
@ -155,6 +195,9 @@ public class CreateDatasetForm extends Composite{
// bind on events
bind();
// prepare info icons
prepareInfoIcons();
// set info block
setAlertBlock("Retrieving information, please wait...", AlertType.INFO, true);
@ -175,9 +218,9 @@ public class CreateDatasetForm extends Composite{
// fill the form
versionTextbox.setText(String.valueOf(bean.getVersion()));
authorTextbox.setText(bean.getAuthor());
authorTextbox.setText(bean.getAuthorSurname() + " " + bean.getAuthorName());
authorEmailTextbox.setText(bean.getAuthorEmail());
maintainerTextbox.setText(bean.getMaintainer());
maintainerTextbox.setText(bean.getAuthorSurname() + " " + bean.getAuthorName());
maintainerEmailTextbox.setText(bean.getMaintainerEmail());
prepareMetadataList(receivedBean);
@ -195,23 +238,23 @@ public class CreateDatasetForm extends Composite{
@Override
public void onSuccess(LicensesBean lBean) {
if(lBean != null && !lBean.getLicenses().isEmpty()){
if(lBean != null && !lBean.getLicenseTitles().isEmpty()){
licenseBean = lBean;
// sort the list
List<String> listOfNames = licenseBean.getLicenses();
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));
if(listOfNames.get(i).equals("Creative Commons Attribution"))
licenseListbox.setItemSelected(i, true);
}
// set the url of the license, if any
showLicenseUrl();
// everything went ok
setAlertBlock("", AlertType.ERROR, false);
continueButton.setEnabled(true);
@ -247,6 +290,93 @@ public class CreateDatasetForm extends Composite{
}
/**
* 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
);
// 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
);
}
/**
* Invoked when the workspace is used.
* @param idFolderWorkspace
@ -285,9 +415,9 @@ public class CreateDatasetForm extends Composite{
titleTextBox.setText(bean.getTitle());
descriptionTextarea.setText(bean.getDescription());
versionTextbox.setText(String.valueOf(bean.getVersion()));
authorTextbox.setText(bean.getAuthor());
authorTextbox.setText(bean.getAuthorSurname() + " " + bean.getAuthorName());
authorEmailTextbox.setText(bean.getAuthorEmail());
maintainerTextbox.setText(bean.getMaintainer());
maintainerTextbox.setText(bean.getAuthorSurname() + " " + bean.getAuthorName());
maintainerEmailTextbox.setText(bean.getMaintainerEmail());
prepareMetadataList(receivedBean);
@ -344,23 +474,23 @@ public class CreateDatasetForm extends Composite{
@Override
public void onSuccess(LicensesBean lBean) {
if(lBean != null && !lBean.getLicenses().isEmpty()){
if(lBean != null && !lBean.getLicenseTitles().isEmpty()){
licenseBean = lBean;
// sort the list
List<String> listOfNames = licenseBean.getLicenses();
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));
if(listOfNames.get(i).equals("Creative Commons Attribution"))
licenseListbox.setItemSelected(i, true);
}
// set the url of the license, if any
showLicenseUrl();
// everything went ok
setAlertBlock("", AlertType.ERROR, false);
continueButton.setEnabled(true);
@ -562,9 +692,14 @@ public class CreateDatasetForm extends Composite{
@UiHandler("createButton")
void createDatasetEvent(ClickEvent e){
boolean profileDataValid = areProfileDataValid();
String errorMessage = areProfileDataValid();
if(profileDataValid){
if(errorMessage != null){
alertOnCreate("Please check the inserted values and the mandatory fields [" + errorMessage +"]", AlertType.ERROR);
}
else{
String title = titleTextBox.getValue();
String description = descriptionTextarea.getText();
@ -578,7 +713,7 @@ public class CreateDatasetForm extends Composite{
String chosenOrganization = organizationsListbox.getSelectedItemText();
// fill the bean
receivedBean.setAuthor(author);
receivedBean.setAuthorFullName(author);
receivedBean.setAuthorEmail(authorEmail);
receivedBean.setDescription(description);
receivedBean.setLicense(selectedLicense);
@ -715,10 +850,6 @@ public class CreateDatasetForm extends Composite{
}
});
}else{
alertOnCreate("Please check the inserted values and the mandatory fields", AlertType.ERROR);
}
}
@ -726,15 +857,15 @@ public class CreateDatasetForm extends Composite{
* Test if profile data are valid
* @return
*/
private boolean areProfileDataValid() {
private String areProfileDataValid() {
for (MetaDataFieldSkeleton field : listOfMetadataFields) {
if(!field.isFieldValueValid())
return false;
return field.getFieldName() + " is not valid";
}
return true;
return null;
}
/**
@ -815,13 +946,6 @@ public class CreateDatasetForm extends Composite{
}
// name reg expression
String regexName = "^[a-zA-Z\\s]+";
if(!validateByRegExpression(maintainerTextbox.getText(), regexName)){
errorMessage = "Not valid maintainer name";
return errorMessage;
}
// email reg expression
String regexMail = "\\b[\\w.%-]+@[-.\\w]+\\.[A-Za-z]{2,4}\\b";
if(!validateByRegExpression(maintainerEmailTextbox.getText(), regexMail)){
@ -965,6 +1089,40 @@ public class CreateDatasetForm extends Composite{
}
@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);
}
/**
* Add the tag as an element
*/
@ -1052,4 +1210,82 @@ public class CreateDatasetForm extends Composite{
tagsPanel.clear();
}
/**
* 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");
}
// if it doesn't exist, create it
if(popup == null){
popup = new GcubeDialogExtended(captionText, text);
popup.getElement().setId(popupId);
popup.setModal(false);
}
// 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;
}
}

View File

@ -62,7 +62,7 @@
</b:ControlLabel>
<b:Controls>
<b:TextBox alternateSize="LARGE" placeholder="Product title"
b:id="title" title="Product title" ui:field="titleTextBox" />
width="95%" b:id="title" title="Product title" ui:field="titleTextBox" />
</b:Controls>
</b:ControlGroup>
@ -72,7 +72,7 @@
</b:ControlLabel>
<b:Controls>
<b:TextArea placeholder="eg. Some useful notes about the product"
alternateSize="LARGE" b:id="description" title="Product description"
width="95%" alternateSize="LARGE" b:id="description" title="Product description"
ui:field="descriptionTextarea"></b:TextArea>
</b:Controls>
</b:ControlGroup>
@ -84,16 +84,15 @@
Tags:
</b:ControlLabel>
<b:Controls>
<b:TextBox width="70%" placeholder="Enter one or more tag for the product"
<b:TextBox width="90%" placeholder="Enter one or more tag for the product"
b:id="tags" ui:field="tagsEnterTextBox" />
<span style="float:right; width:256px; color: #aaaaaa;">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" />
Tags are meaningful information that can be associated to the
product and by means of them
it can be retrieved. A tag cannot
contain white spaces and can contain only alphanumeric
characters.
It must be at least of two characters.
<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>
@ -108,48 +107,61 @@
<b:ControlLabel for="licenses" title="License">License:</b:ControlLabel>
<b:Controls>
<b:ListBox b:id="licenses" title="Product license"
width="60%" ui:field="licenseListbox">
width="91%" ui:field="licenseListbox">
</b:ListBox>
<span style="float:right; width:256px; color: #aaaaaa;">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" />
License definitions and additional information can be found at
<a href="http://opendefinition.org/licenses/">opendefinition.org</a>
</span>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup>
<b:ControlLabel for="visibility" title="Visibility">Visibility:</b:ControlLabel>
<b:ControlLabel for="licenseUrl" title="Selected License'url">Selected
License Url:</b:ControlLabel>
<b:Controls>
<b:Paragraph ui:field="unavailableUrl" visible="true">
<b>Unavailable</b>
</b:Paragraph>
<g:Anchor ui:field="licenseUrlAnchor" target="_blank"
visible="false"></g:Anchor>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup>
<b:ControlLabel for="visibility" title="Visibility of the product">Visibility:</b:ControlLabel>
<b:Controls>
<b:ListBox b:id="visibility" title="Product visibility"
width="60%" ui:field="visibilityListbox">
<g:item title="private">Private</g:item>
width="91%" ui:field="visibilityListbox">
<g:item title="restricted">Restricted</g:item>
<g:item enabled="true" title="public">Public</g:item>
</b:ListBox>
<span style="float:right; width:256px; color: #aaaaaa;">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" />
Private products can only be accessed by certain users, while
public products can be accessed by anyone.
<span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverVisibility" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelVisibility">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconVisibility" />
</g:FocusPanel>
</b:Popover>
</span>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup>
<b:ControlLabel for="organization" title="Organizations">Publish in:</b:ControlLabel>
<b:ControlLabel for="organization"
title="Select the organizations in which you want
to publish the product">Publish in:</b:ControlLabel>
<b:Controls>
<b:ListBox b:id="organization" alternateSize="LARGE"
title="Publish in this organization" ui:field="organizationsListbox">
width="96%" title="Publish in this organization" ui:field="organizationsListbox">
</b:ListBox>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup>
<b:ControlLabel for="version" title="Product version">
<b:ControlLabel for="version"
title="Product version expressed as positive integer number">
Version:
</b:ControlLabel>
<b:Controls>
<b:TextBox alternateSize="LARGE" placeholder="1.0" b:id="version"
title="Product version" ui:field="versionTextbox" />
width="90%" title="Product version" ui:field="versionTextbox" />
</b:Controls>
</b:ControlGroup>
@ -159,8 +171,17 @@
Author:
</b:ControlLabel>
<b:Controls>
<b:TextBox alternateSize="LARGE" placeholder="Joe Bloggs"
enabled="false" b:id="author" title="Product author" ui:field="authorTextbox" />
<b:TextBox alternateSize="LARGE" width="90%"
placeholder="Joe Bloggs" enabled="false" b:id="author" title="Product author"
ui:field="authorTextbox" />
<span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverAuthor" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelAuthor">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconAuthor" />
</g:FocusPanel>
</b:Popover>
</span>
</b:Controls>
</b:ControlGroup>
@ -170,8 +191,17 @@
Author Email:
</b:ControlLabel>
<b:Controls>
<b:TextBox alternateSize="LARGE" placeholder="joe.bloggs@example.com"
enabled="false" b:id="email" title="Product author" ui:field="authorEmailTextbox" />
<b:TextBox alternateSize="LARGE" width="90%"
placeholder="joe.bloggs@example.com" enabled="false" b:id="email"
title="Product author" ui:field="authorEmailTextbox" />
<span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverAuthorEmail" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelAuthorEmail">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconAuthorEmail" />
</g:FocusPanel>
</b:Popover>
</span>
</b:Controls>
</b:ControlGroup>
@ -181,7 +211,16 @@
</b:ControlLabel>
<b:Controls>
<b:TextBox alternateSize="LARGE" placeholder="Joe Bloggs"
b:id="maintainer" title="Product maintainer" ui:field="maintainerTextbox" />
width="90%" b:id="maintainer" title="Product maintainer"
ui:field="maintainerTextbox" />
<span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverMaintainer" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelMaintainer">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconMaintainer" />
</g:FocusPanel>
</b:Popover>
</span>
</b:Controls>
</b:ControlGroup>
@ -191,7 +230,16 @@
</b:ControlLabel>
<b:Controls>
<b:TextBox alternateSize="LARGE" placeholder="maintainer@example.com"
b:id="emailMaintaner" title="Product author" ui:field="maintainerEmailTextbox" />
width="90%" b:id="emailMaintaner" title="Product author"
ui:field="maintainerEmailTextbox" />
<span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverMaintainerEmail" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelMaintainerEmail">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconMaintainerEmail" />
</g:FocusPanel>
</b:Popover>
</span>
</b:Controls>
</b:ControlGroup>
@ -200,9 +248,18 @@
Profile:</b:ControlLabel>
<b:Controls>
<b:ListBox b:id="metadataProfilesFormat" alternateSize="LARGE"
title="The product profile format to be used" ui:field="metadataProfilesFormatListbox">
width="91%" title="The product profile format to be used"
ui:field="metadataProfilesFormatListbox">
<g:item enabled="true" title="None">none</g:item>
</b:ListBox>
<span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverProfiles" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelProfiles">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconProfiles" />
</g:FocusPanel>
</b:Popover>
</span>
</b:Controls>
</b:ControlGroup>
@ -219,9 +276,13 @@
checked="true" ui:field="addResourcesCheckBox">
<b>Add folder content as resources</b>
</b:CheckBox>
<span style="float:right; width:256px; color: #aaaaaa;">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" />
Automatically add folder content as resources of the product
<span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverResources" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelResources">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconResources" />
</g:FocusPanel>
</b:Popover>
</span>
</b:Controls>
</b:ControlGroup>
@ -267,7 +328,6 @@
<b:Form type="HORIZONTAL" styleName="{style.form-main-style}"
ui:field="formThirdStep" visible="false">
<b:Fieldset styleName="{style.fieldset-border-style}">
<b:Legend styleName="{style.legend-style}">
Insert Product Profile Information
<small>
@ -289,14 +349,13 @@
<b:ControlGroup>
<b:Controls>
<span style="float:right; width:256px; color: #aaaaaa;">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" />
Custom fields are customable metadata that will be added to the
product.
You have to choose a unique key for the field and a value
for this. You
can remove them at any time until you create the
product.
<span style="float:right; width:5%; color: #aaaaaa;">
<b:Popover ui:field="popoverCustomFields" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelCustomFields">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIconCustomFields" />
</g:FocusPanel>
</b:Popover>
</span>
<b:Button icon="PLUS_SIGN" title="Add Custom Field"
ui:field="addCustomFieldButton"></b:Button>

View File

@ -2,22 +2,32 @@ package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui;
import java.util.List;
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.GcubeDialogExtended;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.MetadataFieldWrapper;
import com.github.gwtbootstrap.client.ui.CheckBox;
import com.github.gwtbootstrap.client.ui.ControlLabel;
import com.github.gwtbootstrap.client.ui.Controls;
import com.github.gwtbootstrap.client.ui.Icon;
import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.Popover;
import com.github.gwtbootstrap.client.ui.TextBox;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.SpanElement;
import com.google.gwt.dom.client.Style.Cursor;
import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.logical.shared.ResizeEvent;
import com.google.gwt.event.logical.shared.ResizeHandler;
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.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.InlineLabel;
import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
@ -34,9 +44,11 @@ public class MetaDataFieldSkeleton extends Composite{
@UiField SpanElement name;
@UiField SimplePanel elementPanel;
@UiField FlowPanel noteFieldContainer;
@UiField InlineLabel noteField;
@UiField Popover noteFieldPopover;
@UiField ControlLabel controlLabel;
@UiField Controls controls;
@UiField Icon infoIcon;
@UiField FocusPanel focusPanelIconContainer;
// the element that holds the value (it could be a checkbox, textbox or listbox)
private Widget holder;
@ -44,12 +56,15 @@ public class MetaDataFieldSkeleton extends Composite{
// the field this object represents
private MetadataFieldWrapper field;
// the dialog box for this metadata
private GcubeDialogExtended dialog;
public MetaDataFieldSkeleton(MetadataFieldWrapper field) {
initWidget(uiBinder.createAndBindUi(this));
// prepare information
this.field = field;
// add custom css properties
controls.addStyleName("form-controls-custom");
controlLabel.addStyleName("form-control-label-custom");
@ -108,21 +123,54 @@ public class MetaDataFieldSkeleton extends Composite{
elementPanel.add(holder);
}
}
// set holder width
holder.setWidth("90%");
if(holder.getClass().equals(ListBox.class))
holder.setWidth("96%");
else
holder.setWidth("95%");
// set the notes, if any
// set the notes, if any, and the popover
if(field.getNote() != null && !field.getNote().isEmpty()){
noteField.setText(field.getNote());
noteFieldPopover.setText(new HTML("<p style='color:initial'>" + field.getNote() +"</p>").getHTML());
noteFieldPopover.setHeading(new HTML("<b>" + field.getFieldName() +"</b>").getHTML());
infoIcon.getElement().getStyle().setCursor(Cursor.HELP);
noteFieldPopover.setHtml(true);
noteFieldContainer.setVisible(true);
}else{
noteFieldContainer.setVisible(false);
}
// add a resize handler to center the dialog box if it's not null
Window.addResizeHandler(new ResizeHandler() {
@Override
public void onResize(ResizeEvent event) {
if(dialog != null)
dialog.center();
}
});
}
@UiHandler("focusPanelIconContainer")
void onInfoIconClick(ClickEvent c){
if(dialog == null){
// create the dialog box
dialog = new GcubeDialogExtended(field.getFieldName(), field.getNote());
// set as non modal
dialog.setModal(false);
}
// else just show and center
dialog.center();
dialog.show();
}
/**
@ -130,8 +178,10 @@ public class MetaDataFieldSkeleton extends Composite{
* @return
*/
public boolean isFieldValueValid() {
String validator = field.getValidator();
GWT.log("Validator is " + validator);
// if validator is not present and it is not a textbox
if((validator == null || validator.isEmpty()) && !(holder.getClass().equals(TextBox.class) && field.getMandatory()))
@ -145,7 +195,7 @@ public class MetaDataFieldSkeleton extends Composite{
value = ((ListBox)holder).getSelectedItemText();
else if(holder.getClass().equals(TextBox.class)){
value = ((TextBox)holder).getText();
// if there is not a validator...
if(validator == null){
if(value.isEmpty() && field.getMandatory())

View File

@ -6,7 +6,7 @@
.note-container {
display: inline-block;
float: right;
width: 20%;
width: 5%;
color: #aaaaaa;
}
@ -21,21 +21,25 @@
display: inline-block;
}
</ui:style>
<g:HTMLPanel>
<g:HTMLPanel width="100%">
<b:ControlGroup>
<b:ControlLabel ui:field="controlLabel">
<font color="red" ui:field="mandatorySymbol">*</font>
<span ui:field="name"></span>
</b:ControlLabel>
<b:Controls ui:field="controls">
<g:FlowPanel width="90%">
<g:FlowPanel width="95%">
<g:SimplePanel ui:field="elementPanel" styleName="{style.element-panel}"
width="80%">
width="95%">
<!-- Listbox or Checkbox or Textbox according to isBoolean field -->
</g:SimplePanel>
<g:FlowPanel ui:field="noteFieldContainer" styleName="{style.note-container}">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" />
<g:InlineLabel ui:field="noteField" styleName="{style.note-field-text}"></g:InlineLabel>
<b:Popover ui:field="noteFieldPopover" html="true"
animation="true" placement="LEFT">
<g:FocusPanel ui:field="focusPanelIconContainer">
<b:Icon type="INFO_SIGN" size="TWO_TIMES" ui:field="infoIcon" />
</g:FocusPanel>
</b:Popover>
</g:FlowPanel>
</g:FlowPanel>
</b:Controls>

View File

@ -0,0 +1,68 @@
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils;
import org.gcube.portlets.user.gcubewidgets.client.popup.GCubeDialog;
import com.github.gwtbootstrap.client.ui.Paragraph;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.EventTarget;
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.ui.Anchor;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
/**
* Extended version of the GcubeDialog with close symbol on the caption
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class GcubeDialogExtended extends GCubeDialog {
public GcubeDialogExtended(String captionText, String text){
// add custom style
addStyleName("metadata-popup-panel");
// create an anchor to close the dialogbox
final Anchor closeAnchor = new Anchor("x");
closeAnchor.setTitle("Close");
// create a panel that will be put into the caption
FlexTable captionLayoutTable = new FlexTable();
captionLayoutTable.setText(0, 0, captionText);
captionLayoutTable.setWidget(0, 3, closeAnchor);
captionLayoutTable.getCellFormatter().setHorizontalAlignment(0, 3,
HasHorizontalAlignment.ALIGN_RIGHT);
captionLayoutTable.setWidth("100%");
HTML caption = (HTML) getCaption();
caption.getElement().getStyle().setCursor(Cursor.MOVE);
caption.getElement().appendChild(captionLayoutTable.getElement());
caption.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// get the event
EventTarget target = event.getNativeEvent().getEventTarget();
Element targetElement = (Element) target.cast();
// fire the event to the anchor
if (targetElement == closeAnchor.getElement()) {
closeAnchor.fireEvent(event);
}
}
});
closeAnchor.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
hide();
}
});
// set the text
add(new Paragraph(text));
}
}

View File

@ -0,0 +1,54 @@
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils;
/**
* Labels and texts for core ckan information
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class InfoIconsLabels {
// TAGS
public static final String TAGS_INFO_ID_POPUP = "tags-popup-panel-info";
public static final String TAGS_INFO_CAPTION = "Tags";
public static final String TAGS_INFO_TEXT = "Tags are meaningful information that can be associated to the product and by means of them it can be retrieved. A tag cannot contain white spaces and can contain only alphanumeric characters. It must be at least of two characters.";
// VISIBILITY
public static final String VISIBILITY_INFO_ID_POPUP = "visibility-popup-panel-info";
public static final String VISIBILITY_INFO_CAPTION = "Visibility";
public static final String VISIBILITY_INFO_TEXT = "Restricted products can only be accessed by certain users, while Public products can be accessed by anyone.";
// AUTHOR
public static final String AUTHOR_INFO_ID_POPUP = "author-popup-panel-info";
public static final String AUTHOR_INFO_CAPTION = "Author's fullname";
public static final String AUTHOR_INFO_TEXT = "The author of this product. Example: Joe Bloggs.";
// AUTHOR EMAIL
public static final String AUTHOR_EMAIL_INFO_ID_POPUP = "author-email-popup-panel-info";
public static final String AUTHOR_EMAIL_INFO_CAPTION = "Author's email";
public static final String AUTHOR_EMAIL_INFO_TEXT = "The author's email. Example: joe.bloggs@catalogue.com";
// MAINTAINER
public static final String MAINTAINER_INFO_ID_POPUP = "maintainer-popup-panel-info";
public static final String MAINTAINER_INFO_CAPTION = "Maintainer";
public static final String MAINTAINER_INFO_TEXT = "The maintainer of this product (a person or an organization). Examples: Joe Bloggs, D4Science";
// MAINTAINER EMAIL
public static final String MAINTAINER_EMAIL_INFO_ID_POPUP = "maintainer-email-popup-panel-info";
public static final String MAINTAINER_EMAIL_INFO_CAPTION = "Maintainer's email";
public static final String MAINTAINER_EMAIL_INFO_TEXT = "The maintainer's email. Example: joe.bloggs@catalogue.com";
// PROFILES
public static final String PROFILES_INFO_ID_POPUP = "product-profiles-popup-panel-info";
public static final String PROFILES_INFO_CAPTION = "Product Profiles";
public static final String PROFILES_INFO_TEXT = "Select a profile, different from none, for your product among the ones available";
// RESOURCES
public static final String RESOURCES_INFO_ID_POPUP = "resouces-popup-panel-info";
public static final String RESOURCES_INFO_CAPTION = "Product Resources";
public static final String RESOURCES_INFO_TEXT = "Automatically add folder content as resources of the product";
// CUSTOM FIELDS
public static final String CUSTOM_FIELDS_INFO_ID_POPUP = "custom-fields-popup-panel-info";
public static final String CUSTOM_FIELDS_INFO_CAPTION = "Product Custom Fields";
public static final String CUSTOM_FIELDS_INFO_TEXT = "Custom fields are customable metadata that will be added to the product. You have to choose a unique key for the field and a value for this. You can remove them at any time until you create theproduct.";
}

View File

@ -30,4 +30,9 @@
.form-control-label-custom {
width: 16% !important;
}
/** for the popup panels **/
.metadata-popup-panel {
max-width: 30%;
}

View File

@ -44,6 +44,8 @@ import org.slf4j.LoggerFactory;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.liferay.portal.service.UserLocalServiceUtil;
import eu.trentorise.opendata.jackan.model.CkanLicense;
/**
* Server side of the data publisher.
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
@ -332,8 +334,16 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
logger.debug("List of licenses was into session");
}
else{
List<String> titlesLicenses = getCkanUtilsObj().getLicenseTitles();
licensesBean = new LicensesBean(titlesLicenses);
List<CkanLicense> titlesLicenses = getCkanUtilsObj().getLicenses();
List<String> titles = new ArrayList<String>();
List<String> urls = new ArrayList<String>();
for (CkanLicense license : titlesLicenses) {
titles.add(license.getTitle());
String url = (license.getUrl() != null && !license.getUrl().isEmpty()) ? license.getUrl() : "";
urls.add(url);
}
licensesBean = new LicensesBean(titles, urls);
httpSession.setAttribute(keyPerScope, licensesBean);
logger.debug("List of licenses has been saved into session");
}
@ -373,7 +383,8 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
bean.setId(folderId);
bean.setOwnerIdentifier(owner);
bean.setVersion(1);
bean.setAuthor(userOwner.getFullname());
bean.setAuthorName(userOwner.getFirstName());
bean.setAuthorSurname(userOwner.getLastName());
bean.setAuthorEmail(userOwner.getEmail());
bean.setMaintainer(userOwner.getFullname());
bean.setMaintainerEmail(userOwner.getEmail());
@ -427,7 +438,8 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
bean.setVersion(1);
String onlyAlphanumeric = "test-creation-blablabla".replaceAll("[^A-Za-z0-9]", "");
bean.setTitle(onlyAlphanumeric + Calendar.getInstance().getTimeInMillis());
bean.setAuthor("Costantino Perciante");
bean.setAuthorName("Costantino");
bean.setAuthorSurname("Perciante");
bean.setAuthorEmail("costantino.perciante@isti.cnr.it");
bean.setMaintainer("Costantino Perciante");
bean.setMaintainerEmail("costantino.perciante@isti.cnr.it");
@ -515,7 +527,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
String title = toCreate.getTitle();
String organizationNameOrId = toCreate.getSelectedOrganization();
String author = toCreate.getAuthor();
String author = toCreate.getAuthorFullName();
String authorMail = toCreate.getAuthorEmail();
String maintainer = toCreate.getMaintainer();
String maintainerMail = toCreate.getMaintainerEmail();

View File

@ -36,7 +36,9 @@ public class DatasetMetadataBean implements Serializable {
private boolean visibility; // Private (false) or Public(true)
private String source; // url of the folder in the workspace
private long version; // version 1, 2 ...
private String author; // folder's owner fullname
private String authorName; // author name
private String authorSurname; // author surname
private String authorFullName;
private String authorEmail; // folder's email owner
private String maintainer;
private String maintainerEmail;
@ -74,7 +76,7 @@ public class DatasetMetadataBean implements Serializable {
public DatasetMetadataBean(String id, String title, String description,
Map<String, String> customFields, List<String> tags,
String license, boolean visibility, String source, long version,
String author, String authorEmail, String maintainer,
String authorName, String authorSurname, String authorEmail, String maintainer,
String maintainerEmail, String ownerIdentifier,
List<String> organizationList, String selectedOrganization,
List<ResourceBeanWrapper> resources,
@ -89,7 +91,8 @@ public class DatasetMetadataBean implements Serializable {
this.visibility = visibility;
this.source = source;
this.version = version;
this.author = author;
this.authorName = authorName;
this.authorSurname = authorSurname;
this.authorEmail = authorEmail;
this.maintainer = maintainer;
this.maintainerEmail = maintainerEmail;
@ -188,12 +191,20 @@ public class DatasetMetadataBean implements Serializable {
this.version = version;
}
public String getAuthor() {
return author;
public String getAuthorName() {
return authorName;
}
public void setAuthor(String author) {
this.author = author;
public void setAuthorName(String authorName) {
this.authorName = authorName;
}
public String getAuthorSurname() {
return authorSurname;
}
public void setAuthorSurname(String authorSurname) {
this.authorSurname = authorSurname;
}
public String getAuthorEmail() {
@ -243,6 +254,14 @@ public class DatasetMetadataBean implements Serializable {
public void setResources(List<ResourceBeanWrapper> resources) {
this.resources = resources;
}
public String getAuthorFullName() {
return authorFullName;
}
public void setAuthorFullName(String authorFullName) {
this.authorFullName = authorFullName;
}
@Override
public String toString() {
@ -250,12 +269,14 @@ public class DatasetMetadataBean implements Serializable {
+ ", description=" + description + ", customFields="
+ customFields + ", tags=" + tags + ", license=" + license
+ ", visibility=" + visibility + ", source=" + source
+ ", version=" + version + ", author=" + author
+ ", authorEmail=" + authorEmail + ", maintainer=" + maintainer
+ ", maintainerEmail=" + maintainerEmail + ", ownerIdentifier="
+ ownerIdentifier + ", organizationList=" + organizationList
+ ", version=" + version + ", authorName=" + authorName
+ ", authorSurname=" + authorSurname + ", authorFullName="
+ authorFullName + ", authorEmail=" + authorEmail
+ ", maintainer=" + maintainer + ", maintainerEmail="
+ maintainerEmail + ", ownerIdentifier=" + ownerIdentifier
+ ", organizationList=" + organizationList
+ ", selectedOrganization=" + selectedOrganization
+ ", resources=" + resources + ", metadataList=" + metadataList + "]";
+ ", resources=" + resources + ", metadataList=" + metadataList
+ "]";
}
}

View File

@ -10,8 +10,9 @@ import java.util.List;
@SuppressWarnings("serial")
public class LicensesBean implements Serializable{
List<String> licenses;
private List<String> licenseTitles;
private List<String> licenseUrls;
public LicensesBean() {
super();
}
@ -19,21 +20,31 @@ public class LicensesBean implements Serializable{
/**
* @param licenses
*/
public LicensesBean(List<String> licenses) {
public LicensesBean(List<String> licenseTitles, List<String> licenseUrls) {
super();
this.licenses = licenses;
this.licenseTitles = licenseTitles;
this.licenseUrls = licenseUrls;
}
public List<String> getLicenses() {
return licenses;
public List<String> getLicenseTitles() {
return licenseTitles;
}
public void setLicenses(List<String> licenses) {
this.licenses = licenses;
public void setLicenseTitles(List<String> licenseTitles) {
this.licenseTitles = licenseTitles;
}
public List<String> getLicenseUrls() {
return licenseUrls;
}
public void setLicenseUrls(List<String> licenseUrls) {
this.licenseUrls = licenseUrls;
}
@Override
public String toString() {
return "LicensesBean [licenses=" + licenses + "]";
return "LicensesBean [licenseTitles=" + licenseTitles
+ ", licenseUrls=" + licenseUrls + "]";
}
}