in progress on 18236

This commit is contained in:
Francesco Mangiacrapa 2019-12-18 11:58:49 +01:00
parent 8286049ec9
commit 99817d9bfd
16 changed files with 353 additions and 81 deletions

View File

@ -0,0 +1,33 @@
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.events;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.authors.CreatorView;
import com.google.gwt.event.shared.GwtEvent;
public class RemoveCreatorEvent extends GwtEvent<RemoveCreatorEventHandler> {
public static Type<RemoveCreatorEventHandler> TYPE = new Type<RemoveCreatorEventHandler>();
private CreatorView creatorView;
public RemoveCreatorEvent(CreatorView view) {
this.creatorView = view;
}
@Override
public Type<RemoveCreatorEventHandler> getAssociatedType() {
return TYPE;
}
/* (non-Javadoc)
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
*/
@Override
protected void dispatch(RemoveCreatorEventHandler handler) {
handler.onAddedResource(this);
}
public CreatorView getCreatorView() {
return creatorView;
}
}

View File

@ -0,0 +1,11 @@
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* Added resource handler interface
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public interface RemoveCreatorEventHandler extends EventHandler {
void onAddedResource(RemoveCreatorEvent addResourceEvent);
}

View File

@ -0,0 +1,7 @@
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui;
public interface ValidateForm {
boolean isValidForm();
}

View File

@ -1,23 +1,27 @@
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.authors;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.events.RemoveCreatorEvent;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.TextBox;
import com.github.gwtbootstrap.client.ui.constants.IconType;
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;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
public class CreatorView extends Composite {
private static CreatorViewUiBinder uiBinder = GWT.create(CreatorViewUiBinder.class);
interface CreatorViewUiBinder extends UiBinder<Widget, CreatorView> {
}
public CreatorView() {
initWidget(uiBinder.createAndBindUi(this));
}
@UiField
TextBox field_name;
@ -26,32 +30,61 @@ public class CreatorView extends Composite {
@UiField
TextBox field_orcid;
@UiField
Button remove_author;
private HandlerManager eventBus;
public CreatorView() {
initWidget(uiBinder.createAndBindUi(this));
}
public CreatorView(final HandlerManager eventBus) {
this();
this.eventBus = eventBus;
remove_author.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
CreatorView.this.eventBus.fireEvent(new RemoveCreatorEvent(CreatorView.this));
}
});
}
/**
* Sets the visible remove creator.
*
* @param visible the new visible remove creator
*/
public void setVisibleRemoveCreator(boolean visible) {
remove_author.setVisible(visible);
}
public TextBox getField_name() {
return field_name;
}
public void setField_name(TextBox field_name) {
this.field_name = field_name;
public void setField_name(String field_name) {
this.field_name.setValue(field_name);
}
public TextBox getField_affiliation() {
return field_affiliation;
}
public void setField_affiliation(TextBox field_affiliation) {
this.field_affiliation = field_affiliation;
public void setField_affiliation(String field_affiliation) {
this.field_affiliation.setValue(field_affiliation);
}
public TextBox getField_orcid() {
return field_orcid;
}
public void setField_orcid(TextBox field_orcid) {
this.field_orcid = field_orcid;
public void setField_orcid(String field_orcid) {
this.field_orcid.setValue(field_orcid);
}
}

View File

@ -7,12 +7,23 @@
font-weight: bold;
}
</ui:style>
<g:VerticalPanel>
<b:TextBox alternateSize="SMALL" placeholder="Name"
ui:field="field_name" />
<b:TextBox alternateSize="SMALL" placeholder="Affiliation"
ui:field="field_affiliation" />
<b:TextBox alternateSize="SMALL" placeholder="ORCID"
ui:field="field_orcid" />
</g:VerticalPanel>
<b:ControlGroup ui:field="cg_authors">
<b:ControlLabel for="cl_authors">
<font color="red">*</font>
Author
</b:ControlLabel>
<b:Controls>
<!-- -->
<g:VerticalPanel>
<b:TextBox alternateSize="SMALL" placeholder="Name"
ui:field="field_name" />
<b:TextBox alternateSize="SMALL" placeholder="Affiliation"
ui:field="field_affiliation" />
<b:TextBox alternateSize="SMALL" placeholder="ORCID"
ui:field="field_orcid" />
<b:Button icon="REMOVE" text="Remove Author" visible="false" ui:field="remove_author" type="LINK"></b:Button>
</g:VerticalPanel>
<!-- -->
</b:Controls>
</b:ControlGroup>
</ui:UiBinder>

View File

@ -0,0 +1,151 @@
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.authors;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.events.RemoveCreatorEvent;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.events.RemoveCreatorEventHandler;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.ValidateForm;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.utils.InfoTextAndLabels;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoCreator;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.Fieldset;
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;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
/**
* The Class CreatorsFormView.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Dec 17, 2019
*/
public class CreatorsFormView extends Composite implements ValidateForm{
private static CreatorsFormViewUiBinder uiBinder = GWT.create(CreatorsFormViewUiBinder.class);
// event bus
private HandlerManager eventBus = new HandlerManager(null);
/**
* The Interface CreatorsFormViewUiBinder.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Dec 17, 2019
*/
interface CreatorsFormViewUiBinder extends UiBinder<Widget, CreatorsFormView> {
}
@UiField
VerticalPanel fieldset_authors;
@UiField
Button button_add_author;
private List<ZenodoCreator> listCreators;
private List<CreatorView> listCreatorView;
/**
* Instantiates a new creators form view.
*
* @param listCreators the list creators
*/
public CreatorsFormView(List<ZenodoCreator> listCreators) {
initWidget(uiBinder.createAndBindUi(this));
this.listCreators = listCreators;
button_add_author.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
addEmptyCreator();
}
});
eventBus.addHandler(RemoveCreatorEvent.TYPE, new RemoveCreatorEventHandler() {
@Override
public void onAddedResource(RemoveCreatorEvent addResourceEvent) {
try {
boolean removed = listCreatorView.remove(addResourceEvent.getCreatorView());
GWT.log("removed creator: "+removed);
fieldset_authors.remove(addResourceEvent.getCreatorView());
}catch (Exception e) {
// TODO: handle exception
}
}
});
addCreatorsToView();
}
@Override
public boolean isValidForm() {
return false;
}
/**
* Adds the creators to view.
*/
private void addCreatorsToView() {
if(listCreatorView==null)
listCreatorView = new ArrayList<CreatorView>();
if(listCreators!=null && listCreators.size()>0) {
for (ZenodoCreator creator : listCreators) {
CreatorView view = new CreatorView(eventBus);
view.setField_name(InfoTextAndLabels.validValue(creator.getName()));
view.setField_affiliation(InfoTextAndLabels.validValue(creator.getAffiliation()));
view.setField_orcid(InfoTextAndLabels.validValue(creator.getOrcid()));
listCreatorView.add(view);
fieldset_authors.add(view);
}
setRemovableCreators();
}else {
//ADDING EMPTY CREATOR
addEmptyCreator();
}
}
public List<CreatorView> getListCreatorView() {
return listCreatorView;
}
private void addEmptyCreator() {
if(listCreatorView==null)
listCreatorView = new ArrayList<CreatorView>();
CreatorView view = new CreatorView(eventBus);
listCreatorView.add(view);
fieldset_authors.add(view);
setRemovableCreators();
}
private void setRemovableCreators() {
for (int i=0; i<listCreatorView.size(); i++) {
CreatorView creator = listCreatorView.get(i);
boolean removableCreator = i==0?false:true;
creator.setVisibleRemoveCreator(removableCreator);
}
}
}

View File

@ -0,0 +1,24 @@
<!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"
xmlns:citem="urn:import:org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.authors">
<ui:style>
.noBorder {
border: 0px;
}
.float-right{
float: right;
}
</ui:style>
<g:HTMLPanel>
<g:VerticalPanel>
<g:VerticalPanel styleName="{style.noBorder}"
ui:field="fieldset_authors">
<!-- <citem:CreatorView ui:field="field_authors"></citem:CreatorView> -->
</g:VerticalPanel>
<b:Button text="Add another Author"
ui:field="button_add_author" type="LINK" icon="PLUS" addStyleNames="{style.float-right}"></b:Button>
</g:VerticalPanel>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.basicinformation;
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.authors.CreatorsFormView;
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
import com.github.gwtbootstrap.client.ui.Fieldset;
@ -21,6 +22,8 @@ public abstract class BasicInformationView extends Composite {
/** The ui binder. */
private static BasicInformationViewUiBinder uiBinder = GWT.create(BasicInformationViewUiBinder.class);
private CreatorsFormView creatorsView;
/**
* The Interface CreateTaskConfigurationViewUiBinder.
@ -47,7 +50,7 @@ public abstract class BasicInformationView extends Composite {
// VerticalPanel vp_list_of_files;
@UiField
Fieldset to_zenodo_form_unit_fields;
Fieldset fieldset_basic_informations;
//@UiField
//Label label_files;
@ -124,6 +127,12 @@ public abstract class BasicInformationView extends Composite {
field_description.setValue(zenodoItem.getMetadata().getDescription());
field_record_url.setValue(zenodoItem.getRecord_url().toString());
if(zenodoItem.getMetadata()!=null) {
creatorsView = new CreatorsFormView(zenodoItem.getMetadata().getCreators());
}
fieldset_basic_informations.add(creatorsView);
// if(zenodoItem.getFiles()!=null) {
// label_files.setVisible(true);
// for (ZenodoFile file : zenodoItem.getFiles()) {

View File

@ -12,20 +12,13 @@
.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}">
ui:field="fieldset_basic_informations">
<b:Legend addStyleNames="legend-style">
Basic Information
<small>
<span style="color:red;">*</span>
@ -69,17 +62,17 @@
<!-- </b:InputAddOn> -->
</b:Controls>
</b:ControlGroup>
<b:ControlGroup ui:field="cg_authors">
<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_authors" visible="false"> -->
<!-- <b:ControlLabel for="cl_authors"> -->
<!-- Author/s date -->
<!-- </b:ControlLabel> -->
<!-- <b:Controls> -->
<!-- <b2:DateBox format="dd/mm/yyyy" autoClose="true" -->
<!-- ui:field="field_publication_date" /> -->
<!-- </b:Controls> -->
<!-- </b:ControlGroup> -->
<b:ControlGroup ui:field="cg_publication_date">
<b:ControlLabel for="cl_publication_date">
Publication date

View File

@ -8,20 +8,12 @@
.padding-left-10 {
padding-left: 10px;
}
.internal-width {
/*width: 600px !important;*/
}
</ui:style>
<b:ControlGroup>
<!-- <b:Well> -->
<b:Controls>
<g:VerticalPanel>
<b:TextBox name="File Name" ui:field="field_file_name"
addStyleNames="{style.internal-width}">
<b:TextBox name="File Name" ui:field="field_file_name">
</b:TextBox>
<g:HorizontalPanel>
<b:Label>publish</b:Label>
@ -31,6 +23,5 @@
</g:VerticalPanel>
</b:Controls>
<!-- </b:Well> -->
</b:ControlGroup>
</ui:UiBinder>

View File

@ -15,19 +15,13 @@
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 addStyleNames="legend-style">
The File/s
</b:Legend>
</b:Fieldset>
</b:Form>

View File

@ -5,7 +5,7 @@ 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 org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.utils.InfoTextAndLabels;
import com.github.gwtbootstrap.client.ui.ControlGroup;
import com.github.gwtbootstrap.client.ui.Icon;
@ -96,10 +96,10 @@ public class TagsPanel extends Composite{
* @param popupOpenedIds
*/
public void prepareIcon(List<String> popupOpenedIds) {
InfoIconsLabels.preparePopupPanelAndPopover(
InfoIconsLabels.TAGS_INFO_ID_POPUP,
InfoIconsLabels.TAGS_INFO_TEXT,
InfoIconsLabels.TAGS_INFO_CAPTION,
InfoTextAndLabels.preparePopupPanelAndPopover(
InfoTextAndLabels.TAGS_INFO_ID_POPUP,
InfoTextAndLabels.TAGS_INFO_TEXT,
InfoTextAndLabels.TAGS_INFO_CAPTION,
infoIconTags,
popoverTags,
focusPanelTags,

View File

@ -19,13 +19,13 @@ import com.google.gwt.user.client.ui.Widget;
/**
* The Class InfoIconsLabels.
* The Class InfoTextAndLabels.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Dec 17, 2019
*/
public class InfoIconsLabels {
public class InfoTextAndLabels {
// TAGS
public static final String TAGS_INFO_ID_POPUP = "tags-popup-panel-info";
@ -137,5 +137,19 @@ public class InfoIconsLabels {
}
}
}
/**
* Valid value.
*
* @param value the value
* @return the string
*/
public static String validValue(String value) {
if(value==null || value.isEmpty())
return "";
return value;
}
}

View File

@ -1,20 +1,13 @@
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view;
import java.util.ArrayList;
import java.util.List;
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;
import com.google.gwt.user.client.ui.VerticalPanel;
public class Ckan2ZenodoViewManager {
AccordionBasicPanel basePanel;
private AccordionBasicPanel basePanel;
public Ckan2ZenodoViewManager() {
@ -24,6 +17,7 @@ public class Ckan2ZenodoViewManager {
public AccordionBasicPanel viewForPublishing(final ZenodoItem zenodoItem){
basePanel = new AccordionBasicPanel();
//Basic Information
BasicInformationView basicForm = new BasicInformationView(zenodoItem) {
@ -42,6 +36,7 @@ public class Ckan2ZenodoViewManager {
basePanel.getAcc_basic_info().add(basicForm);
//Files
PublishFileViewManager vm = new PublishFileViewManager(zenodoItem.getFiles());
basePanel.getAcc_files().add(vm.getView());

View File

@ -1,5 +1,4 @@
/** Add css rules here for your application. */
.ckan2zenodo-modal-style {
width: 1200px !important;
margin-left: -600px !important;
@ -10,6 +9,14 @@
max-width: 800px;
}
.ckan2zenodo-modal-style .modal-body{
.ckan2zenodo-modal-style .modal-body {
max-height: 800px;
}
.legend-style {
width: auto;
padding: 10px;
margin-bottom: 0px;
font-size: 16px;
color: gray;
}

View File

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.gcube.data.publishing.ckan2zenodo.Ckan2ZenodoImpl;
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.Creator;
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata;
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata.AccessRights;
@ -37,7 +36,7 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
try {
Ckan2ZenodoImpl.publish(item.getItemName());
//Ckan2ZenodoImpl.publish(item.getItemName());
return null;
} catch (Exception e) {