ckan2zenodo-publisher-widget/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/publishfile/PublishFilesFormView.java

112 lines
2.7 KiB
Java
Raw Normal View History

2019-12-17 11:37:56 +01:00
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.publishfile;
import java.util.ArrayList;
import java.util.List;
2020-01-28 12:00:22 +01:00
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile;
2019-12-17 11:37:56 +01:00
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;
2020-01-28 12:00:22 +01:00
import com.google.gwt.user.client.ui.Label;
2020-02-07 15:12:02 +01:00
import com.google.gwt.user.client.ui.VerticalPanel;
2019-12-17 11:37:56 +01:00
import com.google.gwt.user.client.ui.Widget;
2020-01-28 12:00:22 +01:00
2019-12-17 11:37:56 +01:00
/**
* The Class PublishFilesFormView.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
2020-01-28 12:00:22 +01:00
* Jan 28, 2020
2019-12-17 11:37:56 +01:00
*/
public class PublishFilesFormView extends Composite {
private static PublishFilesFormViewUiBinder uiBinder = GWT.create(PublishFilesFormViewUiBinder.class);
2020-01-28 12:00:22 +01:00
2019-12-17 11:37:56 +01:00
@UiField
Fieldset field_form_files;
2020-01-28 12:00:22 +01:00
@UiField
Fieldset field_form_files_already_published;
2019-12-17 11:37:56 +01:00
2020-01-28 12:00:22 +01:00
@UiField
2020-02-07 15:12:02 +01:00
VerticalPanel panelOfFilesPublished;
2020-01-28 12:00:22 +01:00
2019-12-17 11:37:56 +01:00
private List<PublishFileView> lstPFV = new ArrayList<PublishFileView>();
2020-01-28 12:00:22 +01:00
private List<ZenodoFile> alreadyPublished = new ArrayList<ZenodoFile>();
2019-12-17 11:37:56 +01:00
/**
* The Interface PublishFilesFormViewUiBinder.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
2020-01-28 12:00:22 +01:00
* Dec 17, 2019
2019-12-17 11:37:56 +01:00
*/
interface PublishFilesFormViewUiBinder extends UiBinder<Widget, PublishFilesFormView> {
}
/**
* Instantiates a new publish files form view.
2020-01-28 12:00:22 +01:00
*
* @param tabIndex the tab index
2019-12-17 11:37:56 +01:00
*/
2019-12-19 17:41:50 +01:00
public PublishFilesFormView(int tabIndex) {
2019-12-17 11:37:56 +01:00
initWidget(uiBinder.createAndBindUi(this));
2020-01-28 12:00:22 +01:00
}
/**
* Gets the list of publishing file view.
*
* @return the list of publishing file view
*/
public List<PublishFileView> getListOfPublishingFileView() {
return lstPFV;
2019-12-17 11:37:56 +01:00
}
/**
* Adds the file.
*
2020-01-28 12:00:22 +01:00
* @param file the file
* @return the publish file view if is a file to publish
2019-12-17 11:37:56 +01:00
*/
2020-01-28 12:00:22 +01:00
public PublishFileView addFile(ZenodoFile file) {
PublishFileView pv = null;
if (file.getIsAlreadyPublished()) {
2020-02-07 15:23:53 +01:00
2020-01-28 12:00:22 +01:00
Label alert = new Label();
alert.setText(file.getFilename());
panelOfFilesPublished.add(alert);
field_form_files_already_published.setVisible(true);
alreadyPublished.add(file);
}else {
pv = new PublishFileView(file);
pv.getField_file_name().setValue(file.getFilename());
pv.getSwitchButton().setValue(true);
lstPFV.add(pv);
field_form_files.add(pv);
}
return pv;
2019-12-17 11:37:56 +01:00
}
/**
2020-01-28 12:00:22 +01:00
* Gets the already published.
2019-12-17 11:37:56 +01:00
*
2020-01-28 12:00:22 +01:00
* @return the already published
2019-12-17 11:37:56 +01:00
*/
2020-01-28 12:00:22 +01:00
public List<ZenodoFile> getAlreadyPublished() {
return alreadyPublished;
}
public Fieldset getField_form_files_already_published() {
return field_form_files_already_published;
2019-12-17 11:37:56 +01:00
}
}