new progresses #18236
This commit is contained in:
parent
ed39d4eb1a
commit
8286049ec9
|
@ -9,6 +9,7 @@
|
|||
<!--<inherits name='com.google.gwt.user.theme.standard.Standard' />-->
|
||||
|
||||
<inherits name='org.gcube.portlets.widgets.switchbutton.SwitchButton' />
|
||||
<inherits name='com.github.gwtbootstrap.datepicker.Datepicker' />
|
||||
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
|
||||
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client;
|
||||
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.AccordionBasicPanel;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.Ckan2ZenodoViewManager;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.uibinder.AccordionBasicPanel;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.uibinder;
|
||||
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
||||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.AccordionGroup;
|
||||
import com.google.gwt.core.client.GWT;
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.uibinder;
|
||||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.authors;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||
import com.google.gwt.core.client.GWT;
|
|
@ -1,16 +1,11 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.uibinder;
|
||||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.basicinformation;
|
||||
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Fieldset;
|
||||
import com.github.gwtbootstrap.client.ui.Label;
|
||||
import com.github.gwtbootstrap.client.ui.Pager;
|
||||
import com.github.gwtbootstrap.client.ui.TextArea;
|
||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||
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.shared.HandlerManager;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
|
@ -2,7 +2,8 @@
|
|||
<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:citem="urn:import:org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.uibinder">
|
||||
xmlns:citem="urn:import:org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.authors"
|
||||
xmlns:b2="urn:import:com.github.gwtbootstrap.datepicker.client.ui">
|
||||
<ui:style>
|
||||
.noBorder {
|
||||
border: 0px;
|
||||
|
@ -11,54 +12,82 @@
|
|||
.margin-left-100 {
|
||||
margin-left: 80px;
|
||||
}
|
||||
|
||||
.legend-style {
|
||||
width: auto;
|
||||
padding: 10px;
|
||||
margin-bottom: 0px;
|
||||
font-size: 16px;
|
||||
}
|
||||
</ui:style>
|
||||
<g:HTMLPanel>
|
||||
<g:HTMLPanel ui:field="html_panel_field">
|
||||
<b:Form type="HORIZONTAL">
|
||||
<b:Fieldset styleName="{style.noBorder}"
|
||||
ui:field="to_zenodo_form_unit_fields">
|
||||
<b:Legend styleName="{style.legend-style}">
|
||||
Basic Information
|
||||
<small>
|
||||
<span style="color:red;">*</span>
|
||||
is required
|
||||
</small>
|
||||
</b:Legend>
|
||||
<!-- <b:Label type="INFO" -->
|
||||
<!-- addStyleNames="{style.margin-left-100}">Basic Information</b:Label> -->
|
||||
<b:ControlGroup ui:field="cg_record_url">
|
||||
<b:ControlLabel for="cl_record_url">Digital Object Identifier
|
||||
(DOI)</b:ControlLabel>
|
||||
<b:ControlLabel for="cl_record_url">Digital Object Identifier</b:ControlLabel>
|
||||
<b:Controls>
|
||||
|
||||
<b:TextBox name="DOI" b:id="field_doi"
|
||||
ui:field="field_record_url"
|
||||
addStyleNames="my-external-select-width" readOnly="true">
|
||||
</b:TextBox>
|
||||
|
||||
</b:Controls>
|
||||
</b:ControlGroup>
|
||||
<b:ControlGroup ui:field="cg_title">
|
||||
<b:ControlLabel for="cl_title">Title</b:ControlLabel>
|
||||
<b:ControlLabel for="cl_title">
|
||||
<font color="red">*</font>
|
||||
Title
|
||||
</b:ControlLabel>
|
||||
<b:Controls>
|
||||
<b:InputAddOn prependIcon="BOOK">
|
||||
<b:TextBox name="Title" b:id="field_title"
|
||||
ui:field="field_title" addStyleNames="my-external-select-width">
|
||||
</b:TextBox>
|
||||
</b:InputAddOn>
|
||||
<!-- <b:InputAddOn prependIcon="BOOK"> -->
|
||||
<b:TextBox name="Title" b:id="field_title"
|
||||
ui:field="field_title" addStyleNames="my-external-select-width">
|
||||
</b:TextBox>
|
||||
<!-- </b:InputAddOn> -->
|
||||
</b:Controls>
|
||||
</b:ControlGroup>
|
||||
<b:ControlGroup ui:field="cg_description">
|
||||
<b:ControlLabel for="cl_description">Description</b:ControlLabel>
|
||||
<b:ControlLabel for="cl_description">
|
||||
<font color="red">*</font>
|
||||
Description
|
||||
</b:ControlLabel>
|
||||
<b:Controls>
|
||||
<b:InputAddOn prependIcon="PENCIL">
|
||||
<b:TextArea name="Description"
|
||||
ui:field="field_description"
|
||||
addStyleNames="my-external-select-width"></b:TextArea>
|
||||
</b:InputAddOn>
|
||||
<!-- <b:InputAddOn prependIcon="PENCIL"> -->
|
||||
<b:TextArea name="Description"
|
||||
ui:field="field_description"
|
||||
addStyleNames="my-external-select-width"></b:TextArea>
|
||||
<!-- </b:InputAddOn> -->
|
||||
</b:Controls>
|
||||
</b:ControlGroup>
|
||||
<b:ControlGroup ui:field="cg_authors">
|
||||
<b:ControlLabel for="cl_authors">Authors</b:ControlLabel>
|
||||
<b:ControlLabel for="cl_authors">
|
||||
<font color="red">*</font>
|
||||
Authors
|
||||
</b:ControlLabel>
|
||||
<b:Controls>
|
||||
<b:InputAddOn prependIcon="USER">
|
||||
<citem:CreatorView ui:field="field_authors"></citem:CreatorView>
|
||||
</b:InputAddOn>
|
||||
</b:Controls>
|
||||
|
||||
</b:ControlGroup>
|
||||
<b:ControlGroup ui:field="cg_publication_date">
|
||||
<b:ControlLabel for="cl_publication_date">
|
||||
Publication date
|
||||
</b:ControlLabel>
|
||||
<b:Controls>
|
||||
<b2:DateBox format="dd/mm/yyyy" autoClose="true"
|
||||
ui:field="field_publication_date" />
|
||||
</b:Controls>
|
||||
</b:ControlGroup>
|
||||
<!-- <b:Label type="INFO" ui:field="label_files" -->
|
||||
<!-- addStyleNames="{style.margin-left-100}" visible="false">File/s</b:Label> -->
|
|
@ -1,9 +1,6 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.uibinder;
|
||||
|
||||
import java.util.List;
|
||||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.publishfile;
|
||||
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
||||
import org.gcube.portlets.widgets.switchbutton.client.SwitchButton;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
|
@ -10,25 +10,27 @@
|
|||
}
|
||||
|
||||
.internal-width {
|
||||
width: 295px !important;
|
||||
/*width: 600px !important;*/
|
||||
|
||||
}
|
||||
</ui:style>
|
||||
|
||||
|
||||
<b:ControlGroup>
|
||||
<!-- <b:Well> -->
|
||||
<b:ControlLabel
|
||||
addStyleNames="{style.padding-left-10}">Publish</b:ControlLabel>
|
||||
<b:Controls>
|
||||
<!-- <b:Well> -->
|
||||
<b:Controls>
|
||||
<g:VerticalPanel>
|
||||
<b:TextBox name="File Name" ui:field="field_file_name"
|
||||
addStyleNames="{style.internal-width}">
|
||||
</b:TextBox>
|
||||
<g:HorizontalPanel>
|
||||
<b:TextBox name="File Name" ui:field="field_file_name"
|
||||
addStyleNames="{style.internal-width}">
|
||||
</b:TextBox>
|
||||
<b:Label>publish</b:Label>
|
||||
<citem:SwitchButton ui:field="switchButton"
|
||||
addStyleNames="{style.padding-left-10}"></citem:SwitchButton>
|
||||
</g:HorizontalPanel>
|
||||
</g:VerticalPanel>
|
||||
|
||||
</b:Controls>
|
||||
<!-- </b:Well> -->
|
||||
</b:Controls>
|
||||
<!-- </b:Well> -->
|
||||
</b:ControlGroup>
|
||||
</ui:UiBinder>
|
|
@ -0,0 +1,66 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.publishfile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Fieldset;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
/**
|
||||
* The Class PublishFilesFormView.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Dec 17, 2019
|
||||
*/
|
||||
public class PublishFilesFormView extends Composite {
|
||||
|
||||
private static PublishFilesFormViewUiBinder uiBinder = GWT.create(PublishFilesFormViewUiBinder.class);
|
||||
|
||||
@UiField
|
||||
Fieldset field_form_files;
|
||||
|
||||
private List<PublishFileView> lstPFV = new ArrayList<PublishFileView>();
|
||||
|
||||
/**
|
||||
* The Interface PublishFilesFormViewUiBinder.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Dec 17, 2019
|
||||
*/
|
||||
interface PublishFilesFormViewUiBinder extends UiBinder<Widget, PublishFilesFormView> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new publish files form view.
|
||||
*/
|
||||
public PublishFilesFormView() {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the file.
|
||||
*
|
||||
* @param fileVP the file VP
|
||||
*/
|
||||
public void addFile(PublishFileView fileVP) {
|
||||
lstPFV.add(fileVP);
|
||||
field_form_files.add(fileVP);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the list of publishing file view.
|
||||
*
|
||||
* @return the list of publishing file view
|
||||
*/
|
||||
List<PublishFileView> getListOfPublishingFileView(){
|
||||
return lstPFV;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
<!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>
|
||||
.important {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.noBorder {
|
||||
border: 0px;
|
||||
}
|
||||
|
||||
.margin-left-100 {
|
||||
margin-left: 80px;
|
||||
}
|
||||
|
||||
.legend-style {
|
||||
width: auto;
|
||||
padding: 10px;
|
||||
margin-bottom: 0px;
|
||||
font-size: 16px;
|
||||
}
|
||||
</ui:style>
|
||||
<g:HTMLPanel ui:field="html_panel_field">
|
||||
<b:Form type="HORIZONTAL">
|
||||
<b:Fieldset styleName="{style.noBorder}"
|
||||
ui:field="field_form_files">
|
||||
<b:Legend styleName="{style.legend-style}">
|
||||
The Files
|
||||
</b:Legend>
|
||||
</b:Fieldset>
|
||||
</b:Form>
|
||||
</g:HTMLPanel>
|
||||
</ui:UiBinder>
|
|
@ -0,0 +1,279 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.tags;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.gcubewidgets.client.elements.Span;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.utils.InfoIconsLabels;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
||||
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.github.gwtbootstrap.client.ui.base.ListItem;
|
||||
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Panel for tags.
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
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;
|
||||
@UiField ControlGroup tagsInsertGroup;
|
||||
@UiField ListBox tagsEnterListBox;
|
||||
|
||||
// regular expression for tags
|
||||
private static final String REGEX_TAG = "^[a-zA-Z0-9]*$";
|
||||
|
||||
// tags list
|
||||
private List<String> tagsList = new ArrayList<String>();
|
||||
|
||||
// vocabulary
|
||||
private List<String> vocabulary;
|
||||
|
||||
public TagsPanel() {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
tagsEnterListBox.setVisible(false);
|
||||
tagsList.clear();
|
||||
tagsPanel.clear();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Since we have a controlled vocabulary, we swap to a listbox with multiple selection
|
||||
* @param vocabularyTags
|
||||
*/
|
||||
public void setVocabulary(List<String> vocabularyTags) {
|
||||
|
||||
GWT.log("Vocabulary of tags is " + vocabularyTags);
|
||||
|
||||
if(vocabularyTags == null || vocabularyTags.isEmpty()){
|
||||
vocabulary = null;
|
||||
tagsEnterListBox.setVisible(false);
|
||||
tagsPanel.setVisible(true);
|
||||
tagsEnterTextBox.setVisible(true);
|
||||
}else{
|
||||
vocabulary = vocabularyTags;
|
||||
tagsEnterListBox.clear();
|
||||
tagsPanel.clear();
|
||||
tagsList.clear();
|
||||
for (String vocabularyTag : vocabularyTags) {
|
||||
tagsEnterListBox.addItem(vocabularyTag, vocabularyTag);
|
||||
}
|
||||
tagsPanel.setVisible(false);
|
||||
tagsEnterTextBox.setVisible(false);
|
||||
tagsEnterListBox.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
);
|
||||
}
|
||||
|
||||
@UiHandler("tagsEnterTextBox")
|
||||
void onAddTag(KeyDownEvent event){
|
||||
|
||||
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
|
||||
if (!tagsEnterTextBox.getValue().trim().isEmpty()) {
|
||||
|
||||
addTagElement(tagsEnterTextBox);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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().trim().split(" ");
|
||||
if(subTags.length == 1){
|
||||
if(!subTags[0].matches(REGEX_TAG))
|
||||
return;
|
||||
if(subTags[0].length() <= 1)
|
||||
return;
|
||||
}else{
|
||||
for (int i = 0; i < subTags.length; i++) {
|
||||
String subTag = subTags[i];
|
||||
if(!subTag.matches(REGEX_TAG))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final String value = itemBox.getValue().trim();
|
||||
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.trim().split(" ");
|
||||
if(subTags.length == 1){
|
||||
if(!subTags[0].matches(REGEX_TAG))
|
||||
return;
|
||||
if(subTags[0].length() <= 1)
|
||||
return;
|
||||
}else{
|
||||
for (int i = 0; i < subTags.length; i++) {
|
||||
String subTag = subTags[i];
|
||||
if(!subTag.matches(REGEX_TAG))
|
||||
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.trim());
|
||||
tagsPanel.remove(displayItem);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all inserted tags
|
||||
*/
|
||||
public void removeTags(){
|
||||
|
||||
tagsList.clear();
|
||||
tagsPanel.clear();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the tag list
|
||||
* @return
|
||||
*/
|
||||
public List<String> getTags() {
|
||||
|
||||
if(vocabulary == null){
|
||||
return tagsList;
|
||||
}else{
|
||||
|
||||
List<String> selected = new ArrayList<String>();
|
||||
for(int i = 0; i < tagsEnterListBox.getItemCount(); i++){
|
||||
if(tagsEnterListBox.isItemSelected(i))
|
||||
selected.add(tagsEnterListBox.getItemText(i));
|
||||
}
|
||||
return selected;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Freeze tags
|
||||
*/
|
||||
public void freeze() {
|
||||
tagsEnterTextBox.setEnabled(false);
|
||||
tagsEnterListBox.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();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tag group panel type
|
||||
* @param none
|
||||
*/
|
||||
public void setGroupPanelType(ControlGroupType type) {
|
||||
tagsInsertGroup.setType(type);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
<!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 ui:field="tagsInsertGroup">
|
||||
<b:ControlLabel for="tags" title="Item tag">
|
||||
<font color="red">*</font>
|
||||
Tag:
|
||||
</b:ControlLabel>
|
||||
<b:Controls ui:field="controlAsTextBox">
|
||||
<b:TextBox width="90%" placeholder="Write a tag here (push ENTER to attach it to the Item)"
|
||||
b:id="tags" ui:field="tagsEnterTextBox" maxLength="100"/>
|
||||
<b:ListBox width="91%" title="HOLD CTRL or CMD for multiple selection"
|
||||
b:id="tags" ui:field="tagsEnterListBox" multipleSelect="true"/>
|
||||
<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>
|
|
@ -0,0 +1,141 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.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.DialogBox;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* The Class InfoIconsLabels.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Dec 17, 2019
|
||||
*/
|
||||
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 "
|
||||
+ "item and by means of them it can be retrieved. A tag can contain only alphanumeric characters. "
|
||||
+ "If the tag is composed by a single word it must have a size of at least two characters."
|
||||
+ "Examples of good tags: \"This is a sample tag\", \"tagY\". Example of bad tag: \"c\"."
|
||||
+ " You must push ENTER for attaching a tag, or use the provided list of predefined tags. In the latter case"
|
||||
+ " hold down the CTRL or CMD button to select multiple options.";
|
||||
|
||||
/**
|
||||
* Prepare the popover and the gcube popup panel for information.
|
||||
*
|
||||
* @param popupId the popup id
|
||||
* @param text the text
|
||||
* @param captionText the caption text
|
||||
* @param iconElement the icon element
|
||||
* @param popover the popover
|
||||
* @param focusPanel the focus panel
|
||||
* @param popupOpenedIds the popup opened ids
|
||||
*/
|
||||
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
|
||||
DialogBox popup = null;
|
||||
try {
|
||||
Element element = DOM.getElementById(popupId);
|
||||
popup = (DialogBox) Widget.asWidgetOrNull(getWidget(element));
|
||||
} catch (Exception e) {
|
||||
GWT.log("ERROR", e);
|
||||
}
|
||||
|
||||
// if it doesn't exist, create it
|
||||
if (popup == null) {
|
||||
|
||||
popup = new DialogBox();
|
||||
popup.setText(captionText);
|
||||
popup.add(new HTML(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 the element
|
||||
* @return the widget
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param popupOpenedIds the popup opened ids
|
||||
*/
|
||||
public static void closeDialogBox(List<String> popupOpenedIds) {
|
||||
|
||||
for (String popupid : popupOpenedIds) {
|
||||
DialogBox popup = null;
|
||||
try {
|
||||
Element element = DOM.getElementById(popupid);
|
||||
popup = (DialogBox) Widget.asWidgetOrNull(getWidget(element));
|
||||
popup.hide();
|
||||
} catch (Exception e) {
|
||||
GWT.log("ERROR", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -3,9 +3,9 @@ package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.uibinder.AccordionBasicPanel;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.uibinder.BasicInformationView;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.uibinder.PublishFileView;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.AccordionBasicPanel;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.basicinformation.BasicInformationView;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.publishfile.PublishFileView;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
||||
|
||||
|
@ -42,27 +42,11 @@ public class Ckan2ZenodoViewManager {
|
|||
|
||||
basePanel.getAcc_basic_info().add(basicForm);
|
||||
|
||||
PublishFileViewManager vm = new PublishFileViewManager(zenodoItem.getFiles());
|
||||
basePanel.getAcc_files().add(vm.getView());
|
||||
|
||||
if(zenodoItem.getFiles()!=null) {
|
||||
List<PublishFileView> lstPFV = new ArrayList<PublishFileView>();
|
||||
VerticalPanel fileVP = new VerticalPanel();
|
||||
for (ZenodoFile file : zenodoItem.getFiles()) {
|
||||
PublishFileView pfv = addFileForPublishing(file);
|
||||
lstPFV.add(pfv);
|
||||
fileVP.add(pfv);
|
||||
}
|
||||
basePanel.getAcc_files().add(fileVP);
|
||||
}
|
||||
return basePanel;
|
||||
|
||||
}
|
||||
|
||||
private PublishFileView addFileForPublishing(ZenodoFile file) {
|
||||
PublishFileView pv = new PublishFileView(file);
|
||||
pv.getField_file_name().setValue(file.getFilename());
|
||||
pv.getSwitchButton().setValue(true);
|
||||
return pv;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.publishfile.PublishFileView;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.publishfile.PublishFilesFormView;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile;
|
||||
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
|
||||
public class PublishFileViewManager {
|
||||
|
||||
private List<ZenodoFile> listFiles;
|
||||
private PublishFilesFormView publishFileFormView = new PublishFilesFormView();
|
||||
|
||||
public PublishFileViewManager(List<ZenodoFile> listFiles) {
|
||||
this.listFiles = listFiles;
|
||||
addFilesToView();
|
||||
}
|
||||
|
||||
private void addFilesToView() {
|
||||
|
||||
if (listFiles != null) {
|
||||
for (ZenodoFile file : listFiles) {
|
||||
PublishFileView pfv = addFileForPublishing(file);
|
||||
publishFileFormView.addFile(pfv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private PublishFileView addFileForPublishing(ZenodoFile file) {
|
||||
PublishFileView pv = new PublishFileView(file);
|
||||
pv.getField_file_name().setValue(file.getFilename());
|
||||
pv.getSwitchButton().setValue(true);
|
||||
return pv;
|
||||
}
|
||||
|
||||
public Composite getView(){
|
||||
return publishFileFormView;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,15 +1,15 @@
|
|||
/** Add css rules here for your application. */
|
||||
|
||||
.ckan2zenodo-modal-style {
|
||||
width: 800px !important;
|
||||
margin-left: -400px !important;
|
||||
width: 1200px !important;
|
||||
margin-left: -600px !important;
|
||||
}
|
||||
|
||||
.ckan2zenodo-modal-style input, textarea {
|
||||
width: 400px;
|
||||
max-width: 400px;
|
||||
width: 800px;
|
||||
max-width: 800px;
|
||||
}
|
||||
|
||||
.ckan2zenodo-modal-style .modal-body{
|
||||
max-height: 550px;
|
||||
max-height: 800px;
|
||||
}
|
|
@ -9,6 +9,7 @@
|
|||
<!--<inherits name='com.google.gwt.user.theme.standard.Standard' />-->
|
||||
|
||||
<inherits name='org.gcube.portlets.widgets.switchbutton.SwitchButton' />
|
||||
<inherits name='com.github.gwtbootstrap.datepicker.Datepicker' />
|
||||
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
|
||||
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
|
||||
|
||||
|
|
Loading…
Reference in New Issue