217 lines
5.5 KiB
Java
217 lines
5.5 KiB
Java
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.uibinder;
|
|
|
|
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;
|
|
import com.google.gwt.user.client.ui.Composite;
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
|
|
/**
|
|
* The Class CreateTaskConfigurationView.
|
|
*
|
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it May 4, 2018
|
|
*/
|
|
public abstract class BasicInformationView extends Composite {
|
|
|
|
/** The ui binder. */
|
|
private static BasicInformationViewUiBinder uiBinder = GWT.create(BasicInformationViewUiBinder.class);
|
|
|
|
/**
|
|
* The Interface CreateTaskConfigurationViewUiBinder.
|
|
*
|
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it May 4, 2018
|
|
*/
|
|
interface BasicInformationViewUiBinder extends UiBinder<Widget, BasicInformationView> {
|
|
}
|
|
|
|
/** The pager. */
|
|
@UiField
|
|
Pager pager;
|
|
|
|
@UiField
|
|
TextBox field_title;
|
|
|
|
@UiField
|
|
TextBox field_record_url;
|
|
|
|
// @UiField
|
|
// ControlGroup cg_list_of_files;
|
|
//
|
|
// @UiField
|
|
// VerticalPanel vp_list_of_files;
|
|
|
|
@UiField
|
|
Fieldset to_zenodo_form_unit_fields;
|
|
|
|
@UiField
|
|
Label label_files;
|
|
|
|
@UiField
|
|
TextArea field_description;
|
|
|
|
public final static HandlerManager eventBus = new HandlerManager(null);
|
|
|
|
|
|
private boolean isEditConfiguration;
|
|
|
|
private ZenodoItem zenodoItem;
|
|
|
|
/**
|
|
* Submit handler.
|
|
*/
|
|
public abstract void submitHandler();
|
|
|
|
/**
|
|
* Sets the error.
|
|
*
|
|
* @param visible the visible
|
|
* @param error the error
|
|
*/
|
|
public abstract void setError(boolean visible, String error);
|
|
|
|
/**
|
|
* Sets the confirm.
|
|
*
|
|
* @param visible the visible
|
|
* @param msg the msg
|
|
*/
|
|
public abstract void setConfirm(boolean visible, String msg);
|
|
|
|
/**
|
|
* Because this class has a default constructor, it can be used as a binder
|
|
* template. In other words, it can be used in other *.ui.xml files as follows:
|
|
* <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g=
|
|
* "urn:import:**user's package**">
|
|
* <g:**UserClassName**>Hello!</g:**UserClassName> </ui:UiBinder> Note that
|
|
* depending on the widget that is used, it may be necessary to implement
|
|
* HasHTML instead of HasText.
|
|
*
|
|
* @param zenodoItem the zenodo item
|
|
*/
|
|
public BasicInformationView(final ZenodoItem zenodoItem) {
|
|
initWidget(uiBinder.createAndBindUi(this));
|
|
this.zenodoItem = zenodoItem;
|
|
// if(conf!=null)
|
|
// this.isEditConfiguration = true;
|
|
// this.editConfiguration = conf;
|
|
|
|
bindEvents();
|
|
pager.getLeft().setVisible(false);
|
|
fillForm();
|
|
|
|
if (isEditConfiguration) {
|
|
pager.getRight().setText("Update Configuration");
|
|
} else {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* Fill parameters to operator.
|
|
*
|
|
* @param taskOperator the task operator
|
|
*/
|
|
private void fillForm() {
|
|
|
|
field_title.setValue(zenodoItem.getTitle());
|
|
field_description.setValue(zenodoItem.getMetadata().getDescription());
|
|
field_record_url.setValue(zenodoItem.getRecord_url().toString());
|
|
|
|
if(zenodoItem.getFiles()!=null) {
|
|
label_files.setVisible(true);
|
|
for (ZenodoFile file : zenodoItem.getFiles()) {
|
|
addFileForPublishing(file);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void addFileForPublishing(ZenodoFile file) {
|
|
PublishFileView pv = new PublishFileView();
|
|
pv.getField_file_name().setValue(file.getFilename());
|
|
pv.getSwitchButton().setValue(true);
|
|
to_zenodo_form_unit_fields.add(pv);
|
|
}
|
|
|
|
/**
|
|
* Bind events.
|
|
*/
|
|
private void bindEvents() {
|
|
|
|
pager.getLeft().addClickHandler(new ClickHandler() {
|
|
|
|
@Override
|
|
public void onClick(ClickEvent event) {
|
|
|
|
}
|
|
});
|
|
|
|
pager.getRight().addClickHandler(new ClickHandler() {
|
|
|
|
@Override
|
|
public void onClick(ClickEvent event) {
|
|
setError(false, "");
|
|
boolean isValid = validateSubmit();
|
|
if (isValid)
|
|
submitHandler();
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Validate submit.
|
|
*
|
|
* @return true, if successful
|
|
*/
|
|
protected boolean validateSubmit() {
|
|
|
|
/*
|
|
* cg_select_task_id.setType(ControlGroupType.NONE);
|
|
* //cg_parameters_control.setType(ControlGroupType.NONE);
|
|
* //cg_remote_path.setType(ControlGroupType.NONE);
|
|
*
|
|
* if(field_select_scope.getSelectedItemText()==null){
|
|
* cg_select_vre.setType(ControlGroupType.ERROR); setError(true,
|
|
* "You must select a Scope!"); return false; }
|
|
*
|
|
* if(field_select_scope.getSelectedItemText() == null ||
|
|
* field_select_scope.getSelectedItemText().isEmpty()){
|
|
* cg_select_task_id.setType(ControlGroupType.ERROR); setError(true,
|
|
* "You must select an Algorithm!"); return false; }
|
|
*
|
|
* for (CustomFieldEntry cFE : customFieldEntriesList) {
|
|
* cFE.getControlGroup().setType(ControlGroupType.NONE); if(cFE.getKey()==null
|
|
* || cFE.getKey().isEmpty()){
|
|
* cFE.getControlGroup().setType(ControlGroupType.ERROR);
|
|
* //cg_parameters_control.setType(ControlGroupType.ERROR); setError(true,
|
|
* "You must type a valid key parameter!"); return false; } }
|
|
*/
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
/**
|
|
* Checks if is edits the configuration.
|
|
*
|
|
* @return the isEditConfiguration
|
|
*/
|
|
public boolean isEditConfiguration() {
|
|
|
|
return isEditConfiguration;
|
|
}
|
|
|
|
}
|