You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
140 lines
3.7 KiB
Java
140 lines
3.7 KiB
Java
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherService;
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.CKanPublisherServiceAsync;
|
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.LicensesBean;
|
|
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
|
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
|
import com.github.gwtbootstrap.client.ui.ListBox;
|
|
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.uibinder.client.UiBinder;
|
|
import com.google.gwt.uibinder.client.UiField;
|
|
import com.google.gwt.uibinder.client.UiHandler;
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
import com.google.gwt.user.client.ui.Composite;
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
|
|
/**
|
|
* Edit metadata form for ckan dataset.
|
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
|
*/
|
|
public class EditMetadataForm extends Composite{
|
|
|
|
/**
|
|
* Create a remote service proxy to talk to the server-side ckan service.
|
|
*/
|
|
private final CKanPublisherServiceAsync ckanServices = GWT.create(CKanPublisherService.class);
|
|
|
|
private static EditMetadataFormUiBinder uiBinder = GWT
|
|
.create(EditMetadataFormUiBinder.class);
|
|
|
|
interface EditMetadataFormUiBinder extends
|
|
UiBinder<Widget, EditMetadataForm> {
|
|
}
|
|
|
|
@UiField TextBox titleTextBox;
|
|
@UiField TextBox urlTextbox;
|
|
@UiField TextArea descriptionTextarea;
|
|
@UiField TextBox tagsTextbox;
|
|
@UiField ListBox licenseListbox;
|
|
@UiField ListBox visibilityListbox;
|
|
@UiField ListBox searchableListbox;
|
|
@UiField TextBox sourceTextbox;
|
|
@UiField TextBox versionTextbox;
|
|
@UiField TextBox authorTextbox;
|
|
@UiField TextBox authorEmailTextbox;
|
|
@UiField TextBox maintainerTextbox;
|
|
@UiField TextBox maintainerEmailTextbox;
|
|
@UiField ControlGroup customFields;
|
|
@UiField Button addCustomFieldButton;
|
|
@UiField Button createButton;
|
|
@UiField Button resetButton;
|
|
|
|
// the licenses
|
|
private LicensesBean licenseBean;
|
|
|
|
// added custom field entries
|
|
List<CustomFieldEntry> customFieldEntries = new ArrayList<CustomFieldEntry>();
|
|
|
|
public EditMetadataForm() {
|
|
initWidget(uiBinder.createAndBindUi(this));
|
|
|
|
// get back the licenses
|
|
ckanServices.getLicenses(new AsyncCallback<LicensesBean>() {
|
|
|
|
@Override
|
|
public void onSuccess(LicensesBean result) {
|
|
|
|
if(result != null && !result.getLicenses().isEmpty()){
|
|
|
|
licenseBean = result;
|
|
|
|
// fill the listbox
|
|
for(String license: licenseBean.getLicenses()){
|
|
|
|
licenseListbox.addItem(license);
|
|
|
|
}
|
|
|
|
}else
|
|
{
|
|
// TODO
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(Throwable caught) {
|
|
|
|
// TODO
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
@UiHandler("addCustomFieldButton")
|
|
void addCustomFieldEvent(ClickEvent e){
|
|
|
|
CustomFieldEntry toAdd = new CustomFieldEntry();
|
|
customFieldEntries.add(toAdd);
|
|
customFields.add(toAdd);
|
|
|
|
}
|
|
|
|
@UiHandler("createButton")
|
|
void createDatasetEvent(ClickEvent e){
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
@UiHandler("resetButton")
|
|
void resetFormEvent(ClickEvent e){
|
|
|
|
// reset main fields
|
|
titleTextBox.setText("");
|
|
urlTextbox.setText("");
|
|
descriptionTextarea.setText("");
|
|
tagsTextbox.setText("");
|
|
sourceTextbox.setText("");
|
|
versionTextbox.setText("");
|
|
authorTextbox.setText("");
|
|
authorEmailTextbox.setText("");
|
|
maintainerTextbox.setText("");
|
|
maintainerEmailTextbox.setText("");
|
|
|
|
// delete custom fields
|
|
for (CustomFieldEntry customField : customFieldEntries) {
|
|
customField.removeFromParent();
|
|
}
|
|
customFieldEntries.clear();
|
|
|
|
}
|
|
}
|