Added Manage Resources
This commit is contained in:
parent
ee7ea99740
commit
0417f98149
|
@ -19,7 +19,7 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCu
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCustomFieldEventHandler;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCustomFieldEventHandler;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.metadata.CustomFieldEntry;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.metadata.CustomFieldEntry;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.AddResourceToDataset;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.AddResourceToDataset;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.AddedResourcesSummary;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.ManageResources;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.InfoIconsLabels;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.InfoIconsLabels;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.WizardCreator;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.WizardCreator;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.workspace.SelectResourceByWEMainPanel;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.workspace.SelectResourceByWEMainPanel;
|
||||||
|
@ -29,7 +29,6 @@ import org.gcube.portlets.widgets.mpformbuilder.client.form.MetaDataField;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm.OPERATION;
|
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm.OPERATION;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.CategoryPanel;
|
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.CategoryPanel;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton;
|
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.resources.AddResourceContainer;
|
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.tags.TagsPanel;
|
import org.gcube.portlets.widgets.mpformbuilder.client.ui.tags.TagsPanel;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.shared.license.LicenseBean;
|
import org.gcube.portlets.widgets.mpformbuilder.shared.license.LicenseBean;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.CategoryWrapper;
|
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.CategoryWrapper;
|
||||||
|
@ -44,7 +43,6 @@ import com.github.gwtbootstrap.client.ui.Icon;
|
||||||
import com.github.gwtbootstrap.client.ui.ListBox;
|
import com.github.gwtbootstrap.client.ui.ListBox;
|
||||||
import com.github.gwtbootstrap.client.ui.Paragraph;
|
import com.github.gwtbootstrap.client.ui.Paragraph;
|
||||||
import com.github.gwtbootstrap.client.ui.Popover;
|
import com.github.gwtbootstrap.client.ui.Popover;
|
||||||
import com.github.gwtbootstrap.client.ui.Tab;
|
|
||||||
import com.github.gwtbootstrap.client.ui.TabPanel;
|
import com.github.gwtbootstrap.client.ui.TabPanel;
|
||||||
import com.github.gwtbootstrap.client.ui.TextArea;
|
import com.github.gwtbootstrap.client.ui.TextArea;
|
||||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||||
|
@ -52,7 +50,6 @@ import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
|
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.ResizeType;
|
import com.github.gwtbootstrap.client.ui.constants.ResizeType;
|
||||||
import com.github.gwtbootstrap.client.ui.resources.Bootstrap.Tabs;
|
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.dom.client.SelectElement;
|
import com.google.gwt.dom.client.SelectElement;
|
||||||
import com.google.gwt.dom.client.Style.Unit;
|
import com.google.gwt.dom.client.Style.Unit;
|
||||||
|
@ -288,9 +285,6 @@ public class CreateDatasetForm extends Composite {
|
||||||
// dataset metadata bean
|
// dataset metadata bean
|
||||||
private DatasetBean receivedBean;
|
private DatasetBean receivedBean;
|
||||||
|
|
||||||
// the owner
|
|
||||||
private String owner;
|
|
||||||
|
|
||||||
// workspace request?
|
// workspace request?
|
||||||
private boolean isWorkspaceRequest = false;
|
private boolean isWorkspaceRequest = false;
|
||||||
|
|
||||||
|
@ -862,13 +856,7 @@ public class CreateDatasetForm extends Composite {
|
||||||
|
|
||||||
if (categories == null || categories.isEmpty()) {
|
if (categories == null || categories.isEmpty()) {
|
||||||
for (MetadataFieldWrapper field : fields) {
|
for (MetadataFieldWrapper field : fields) {
|
||||||
/*
|
|
||||||
* MetaDataFieldSkeleton fieldWidget; try { fieldWidget = new
|
|
||||||
* MetaDataFieldSkeleton(field, eventBus); metadataFieldsPanel.add(fieldWidget);
|
|
||||||
* listOfMetadataFields.add(fieldWidget); } catch (Exception e) {
|
|
||||||
* GWT.log("Unable to build such widget", e); }
|
|
||||||
*/
|
|
||||||
|
|
||||||
MetaDataField fieldWidget;
|
MetaDataField fieldWidget;
|
||||||
try {
|
try {
|
||||||
fieldWidget = new MetaDataField(field, eventBus, operation);
|
fieldWidget = new MetaDataField(field, eventBus, operation);
|
||||||
|
@ -893,13 +881,6 @@ public class CreateDatasetForm extends Composite {
|
||||||
|
|
||||||
for (MetadataFieldWrapper metadataFieldWrapper : fieldsForThisCategory) {
|
for (MetadataFieldWrapper metadataFieldWrapper : fieldsForThisCategory) {
|
||||||
|
|
||||||
/*
|
|
||||||
* MetaDataFieldSkeleton fieldWidget; try { fieldWidget = new
|
|
||||||
* MetaDataFieldSkeleton(metadataFieldWrapper, eventBus);
|
|
||||||
* cp.addField(fieldWidget); listOfMetadataFields.add(fieldWidget); } catch
|
|
||||||
* (Exception e) { GWT.log("Unable to build such widget", e); }
|
|
||||||
*/
|
|
||||||
|
|
||||||
MetaDataField fieldWidget;
|
MetaDataField fieldWidget;
|
||||||
try {
|
try {
|
||||||
fieldWidget = new MetaDataField(metadataFieldWrapper, eventBus, operation);
|
fieldWidget = new MetaDataField(metadataFieldWrapper, eventBus, operation);
|
||||||
|
@ -917,13 +898,6 @@ public class CreateDatasetForm extends Composite {
|
||||||
CategoryPanel extrasCategory = new CategoryPanel("Other", null);
|
CategoryPanel extrasCategory = new CategoryPanel("Other", null);
|
||||||
for (MetadataFieldWrapper field : fields) {
|
for (MetadataFieldWrapper field : fields) {
|
||||||
|
|
||||||
/*
|
|
||||||
* MetaDataFieldSkeleton fieldWidget; try { fieldWidget = new
|
|
||||||
* MetaDataFieldSkeleton(field, eventBus); extrasCategory.addField(fieldWidget);
|
|
||||||
* listOfMetadataFields.add(fieldWidget); } catch (Exception e) {
|
|
||||||
* GWT.log("Unable to build such widget", e); }
|
|
||||||
*/
|
|
||||||
|
|
||||||
MetaDataField fieldWidget;
|
MetaDataField fieldWidget;
|
||||||
try {
|
try {
|
||||||
fieldWidget = new MetaDataField(field, eventBus, operation);
|
fieldWidget = new MetaDataField(field, eventBus, operation);
|
||||||
|
@ -1278,38 +1252,8 @@ public class CreateDatasetForm extends Composite {
|
||||||
|
|
||||||
// remove content of the main panel
|
// remove content of the main panel
|
||||||
createDatasetMainPanel.clear();
|
createDatasetMainPanel.clear();
|
||||||
|
ManageResources manageResources = new ManageResources(eventBus, createdDatasetBean, datasetUrl);
|
||||||
// TabPanelException
|
createDatasetMainPanel.add(manageResources);
|
||||||
tabPanel = new TabPanel(Tabs.LEFT);
|
|
||||||
tabPanel.setWidth("100%");
|
|
||||||
|
|
||||||
// add the form
|
|
||||||
|
|
||||||
resourceForm = new AddResourceToDataset(eventBus, createdDatasetBean.getId(),
|
|
||||||
createdDatasetBean.getTitle(),
|
|
||||||
createdDatasetBean.getSelectedOrganization(), owner, datasetUrl);
|
|
||||||
|
|
||||||
// tab for the form
|
|
||||||
Tab formContainer = new Tab();
|
|
||||||
formContainer.add(resourceForm);
|
|
||||||
formContainer.setHeading("Add New Resource");
|
|
||||||
tabPanel.add(formContainer);
|
|
||||||
|
|
||||||
// tab for the added resources
|
|
||||||
Tab addedResources = new Tab();
|
|
||||||
addedResources.add(new AddedResourcesSummary(eventBus));
|
|
||||||
addedResources.setHeading("Added Resource");
|
|
||||||
tabPanel.add(addedResources);
|
|
||||||
|
|
||||||
// form container
|
|
||||||
AddResourceContainer container = new AddResourceContainer(datasetUrl);
|
|
||||||
container.add(tabPanel);
|
|
||||||
|
|
||||||
// add the new content of the main panel
|
|
||||||
createDatasetMainPanel.add(container);
|
|
||||||
|
|
||||||
// add tabs to resources panel
|
|
||||||
tabPanel.selectTab(0);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (Exception e2) {
|
} catch (Exception e2) {
|
||||||
|
|
|
@ -20,7 +20,7 @@ import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCu
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCustomFieldEventHandler;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.DeleteCustomFieldEventHandler;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.metadata.CustomFieldEntry;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.metadata.CustomFieldEntry;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.AddResourceToDataset;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.AddResourceToDataset;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.AddedResourcesSummary;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources.ManageResources;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.InfoIconsLabels;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.InfoIconsLabels;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.WizardCreator;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.utils.WizardCreator;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.workspace.SelectResourceByWEMainPanel;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.workspace.SelectResourceByWEMainPanel;
|
||||||
|
@ -32,7 +32,6 @@ import org.gcube.portlets.widgets.mpformbuilder.client.form.MetaDataField;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm.OPERATION;
|
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm.OPERATION;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.CategoryPanel;
|
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.CategoryPanel;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton;
|
import org.gcube.portlets.widgets.mpformbuilder.client.ui.metadata.MetaDataFieldSkeleton;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.resources.AddResourceContainer;
|
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.tags.TagsPanel;
|
import org.gcube.portlets.widgets.mpformbuilder.client.ui.tags.TagsPanel;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.shared.license.LicenseBean;
|
import org.gcube.portlets.widgets.mpformbuilder.shared.license.LicenseBean;
|
||||||
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.CategoryWrapper;
|
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.CategoryWrapper;
|
||||||
|
@ -45,17 +44,15 @@ import com.github.gwtbootstrap.client.ui.ControlGroup;
|
||||||
import com.github.gwtbootstrap.client.ui.Form;
|
import com.github.gwtbootstrap.client.ui.Form;
|
||||||
import com.github.gwtbootstrap.client.ui.Icon;
|
import com.github.gwtbootstrap.client.ui.Icon;
|
||||||
import com.github.gwtbootstrap.client.ui.ListBox;
|
import com.github.gwtbootstrap.client.ui.ListBox;
|
||||||
|
import com.github.gwtbootstrap.client.ui.NavPills;
|
||||||
import com.github.gwtbootstrap.client.ui.Paragraph;
|
import com.github.gwtbootstrap.client.ui.Paragraph;
|
||||||
import com.github.gwtbootstrap.client.ui.Popover;
|
import com.github.gwtbootstrap.client.ui.Popover;
|
||||||
import com.github.gwtbootstrap.client.ui.Tab;
|
|
||||||
import com.github.gwtbootstrap.client.ui.TabPanel;
|
|
||||||
import com.github.gwtbootstrap.client.ui.TextArea;
|
import com.github.gwtbootstrap.client.ui.TextArea;
|
||||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
|
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.ResizeType;
|
import com.github.gwtbootstrap.client.ui.constants.ResizeType;
|
||||||
import com.github.gwtbootstrap.client.ui.resources.Bootstrap.Tabs;
|
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.core.client.Scheduler;
|
import com.google.gwt.core.client.Scheduler;
|
||||||
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||||
|
@ -286,7 +283,7 @@ public class UpdateDatasetForm extends Composite {
|
||||||
protected static final String MISSING_PUBLISH_RIGHTS = "It seems you are not authorized to edit this item. Either you must be the author item or Catalogue Admininistrator in the organization";
|
protected static final String MISSING_PUBLISH_RIGHTS = "It seems you are not authorized to edit this item. Either you must be the author item or Catalogue Admininistrator in the organization";
|
||||||
|
|
||||||
// tab panel
|
// tab panel
|
||||||
private TabPanel tabPanel;
|
private NavPills tabPanel;
|
||||||
|
|
||||||
// add resource form
|
// add resource form
|
||||||
private AddResourceToDataset resourceForm;
|
private AddResourceToDataset resourceForm;
|
||||||
|
@ -304,16 +301,7 @@ public class UpdateDatasetForm extends Composite {
|
||||||
private List<MetaDataField> listOfMetadataFields = new ArrayList<MetaDataField>();
|
private List<MetaDataField> listOfMetadataFields = new ArrayList<MetaDataField>();
|
||||||
|
|
||||||
// dataset metadata bean
|
// dataset metadata bean
|
||||||
private DatasetBean receivedBean;
|
private DatasetBean theDatasetBean;
|
||||||
|
|
||||||
// the owner
|
|
||||||
private String owner;
|
|
||||||
|
|
||||||
// workspace request?
|
|
||||||
// private boolean isWorkspaceRequest = false;
|
|
||||||
|
|
||||||
// resource table
|
|
||||||
// private TwinColumnSelectionMainPanel resourcesTwinPanel;
|
|
||||||
|
|
||||||
// resource table
|
// resource table
|
||||||
private SelectResourceByWEMainPanel resourcesSelectByWEMainPanel;
|
private SelectResourceByWEMainPanel resourcesSelectByWEMainPanel;
|
||||||
|
@ -328,7 +316,7 @@ public class UpdateDatasetForm extends Composite {
|
||||||
|
|
||||||
private boolean isWorkspaceRequest = false;
|
private boolean isWorkspaceRequest = false;
|
||||||
private String datasetIdOrName = null;
|
private String datasetIdOrName = null;
|
||||||
private DatasetBean theDataset = null;
|
// private DatasetBean theDataset = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new update dataset form.
|
* Instantiates a new update dataset form.
|
||||||
|
@ -423,15 +411,12 @@ public class UpdateDatasetForm extends Composite {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(final DatasetBean datasetBean) {
|
public void onSuccess(final DatasetBean datasetBean) {
|
||||||
GWT.log("getDatasetBeanForUpdate returns: " + datasetBean);
|
GWT.log("getDatasetBeanForUpdate returns: " + datasetBean);
|
||||||
theDataset = datasetBean;
|
|
||||||
|
|
||||||
if (datasetBean == null) {
|
if (datasetBean == null) {
|
||||||
|
|
||||||
setAlertBlock("Error while retrieving information.", AlertType.ERROR, true);
|
setAlertBlock("Error while retrieving information.", AlertType.ERROR, true);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// save it
|
// save it
|
||||||
receivedBean = datasetBean;
|
theDatasetBean = datasetBean;
|
||||||
|
|
||||||
// fill the form
|
// fill the form
|
||||||
titleTextBox.setText(datasetBean.getTitle());
|
titleTextBox.setText(datasetBean.getTitle());
|
||||||
|
@ -489,19 +474,6 @@ public class UpdateDatasetForm extends Composite {
|
||||||
// set it as visible anyway
|
// set it as visible anyway
|
||||||
tagsPanel.setVisible(true);
|
tagsPanel.setVisible(true);
|
||||||
|
|
||||||
// if (isWorkspaceRequest) {
|
|
||||||
// // if there are not resources, for now just checked it ( and hide so that the
|
|
||||||
// // step will be skipped)
|
|
||||||
// if (hideManageResources()) {
|
|
||||||
// alertNoResources.setType(AlertType.WARNING);
|
|
||||||
// alertNoResources.setVisible(true);
|
|
||||||
// } else
|
|
||||||
// // resourcesSelectByWEMainPanel = new
|
|
||||||
// // TwinColumnSelectionMainPanel(bean.getResourceRoot());
|
|
||||||
// resourcesSelectByWEMainPanel = new SelectResourceByWEMainPanel(
|
|
||||||
// bean.getResourceRoot());
|
|
||||||
// }
|
|
||||||
|
|
||||||
// The resource root is the folder id. Es. ID of the Workspace Root folder.
|
// The resource root is the folder id. Es. ID of the Workspace Root folder.
|
||||||
if (datasetBean.getResourceRoot() != null) {
|
if (datasetBean.getResourceRoot() != null) {
|
||||||
resourcesSelectByWEMainPanel = new SelectResourceByWEMainPanel(
|
resourcesSelectByWEMainPanel = new SelectResourceByWEMainPanel(
|
||||||
|
@ -532,38 +504,16 @@ public class UpdateDatasetForm extends Composite {
|
||||||
// get the name of the organization from the title
|
// get the name of the organization from the title
|
||||||
final String orgName = nameTitleOrganizationMap
|
final String orgName = nameTitleOrganizationMap
|
||||||
.get(organizationsListbox.getSelectedItemText());
|
.get(organizationsListbox.getSelectedItemText());
|
||||||
|
|
||||||
//Putting the selected Organization into bena
|
|
||||||
theDataset.setSelectedOrganization(orgName);
|
|
||||||
|
|
||||||
// force tags
|
// Putting the selected Organization into bena
|
||||||
// setAlertBlock("Checking for tags vocabulary, please wait...", AlertType.INFO, true);
|
theDatasetBean.setSelectedOrganization(orgName);
|
||||||
// ckanServices.getTagsForOrganization(orgName, new AsyncCallback<List<String>>() {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onSuccess(List<String> vocabulary) {
|
|
||||||
//
|
|
||||||
// tagsPanel.setVocabulary(vocabulary);
|
|
||||||
// tagsPanel.setVisible(true);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onFailure(Throwable arg0) {
|
|
||||||
//
|
|
||||||
// setAlertBlock(
|
|
||||||
// "Error while checking if a vocabulary of tags is defined in the selected organization.",
|
|
||||||
// AlertType.ERROR, true);
|
|
||||||
// tagsPanel.setVisible(true);
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// try to retrieve the profiles
|
// try to retrieve the profiles
|
||||||
setAlertBlock("Retrieving types, please wait...", AlertType.INFO, true);
|
setAlertBlock("Retrieving types, please wait...", AlertType.INFO, true);
|
||||||
|
|
||||||
// perform remote request of profiles for the selected organization
|
// perform remote request of profiles for the selected organization
|
||||||
ckanServices.getProfileForUpdate(orgName, datasetBean.getChosenType(), datasetBean.getId(),
|
ckanServices.getProfileForUpdate(orgName, datasetBean.getChosenType(),
|
||||||
new AsyncCallback<MetadataProfileBeanForUpdate>() {
|
datasetBean.getId(), new AsyncCallback<MetadataProfileBeanForUpdate>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
|
@ -592,8 +542,8 @@ public class UpdateDatasetForm extends Composite {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
receivedBean.setMetadataList(profiles);
|
theDatasetBean.setMetadataList(profiles);
|
||||||
prepareMetadataList(receivedBean, operation);
|
prepareMetadataList(theDatasetBean, operation);
|
||||||
addCustomField(metadataProfileForUpdate.getCustomFields());
|
addCustomField(metadataProfileForUpdate.getCustomFields());
|
||||||
organizationsListbox.setEnabled(true);
|
organizationsListbox.setEnabled(true);
|
||||||
metadataTypeListbox.setEnabled(true);
|
metadataTypeListbox.setEnabled(true);
|
||||||
|
@ -659,10 +609,11 @@ public class UpdateDatasetForm extends Composite {
|
||||||
false);
|
false);
|
||||||
continueButton.setEnabled(true);
|
continueButton.setEnabled(true);
|
||||||
resetButton.setEnabled(true);
|
resetButton.setEnabled(true);
|
||||||
addResourcesButtonStep1.setEnabled(true);
|
addResourcesButtonStep1
|
||||||
|
.setEnabled(true);
|
||||||
|
|
||||||
manageAddResources(datasetBean,
|
bindManageResources(datasetBean,
|
||||||
datasetIdOrName);
|
datasetIdOrName, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -744,8 +695,8 @@ public class UpdateDatasetForm extends Composite {
|
||||||
// get the name of the organization from the title
|
// get the name of the organization from the title
|
||||||
String selectedOrganizationTitle = organizationsListbox.getSelectedItemText();
|
String selectedOrganizationTitle = organizationsListbox.getSelectedItemText();
|
||||||
final String orgName = nameTitleOrganizationMap.get(selectedOrganizationTitle);
|
final String orgName = nameTitleOrganizationMap.get(selectedOrganizationTitle);
|
||||||
|
|
||||||
theDataset.setSelectedOrganization(orgName);
|
theDatasetBean.setSelectedOrganization(orgName);
|
||||||
|
|
||||||
// try to retrieve the profiles
|
// try to retrieve the profiles
|
||||||
setAlertBlock("Retrieving types, please wait...", AlertType.INFO, true);
|
setAlertBlock("Retrieving types, please wait...", AlertType.INFO, true);
|
||||||
|
@ -766,8 +717,8 @@ public class UpdateDatasetForm extends Composite {
|
||||||
|
|
||||||
if (profiles != null) {
|
if (profiles != null) {
|
||||||
|
|
||||||
receivedBean.setMetadataList(profiles);
|
theDatasetBean.setMetadataList(profiles);
|
||||||
prepareMetadataList(receivedBean, operation);
|
prepareMetadataList(theDatasetBean, operation);
|
||||||
organizationsListbox.setEnabled(true);
|
organizationsListbox.setEnabled(true);
|
||||||
metadataTypeListbox.setEnabled(true);
|
metadataTypeListbox.setEnabled(true);
|
||||||
|
|
||||||
|
@ -847,8 +798,8 @@ public class UpdateDatasetForm extends Composite {
|
||||||
/**
|
/**
|
||||||
* Add the items to the listbox and put data into the metadataPanel.
|
* Add the items to the listbox and put data into the metadataPanel.
|
||||||
*
|
*
|
||||||
* @param receivedBean the received bean
|
* @param theDatasetBean the received bean
|
||||||
* @param operation the operation
|
* @param operation the operation
|
||||||
*/
|
*/
|
||||||
private void prepareMetadataList(final DatasetBean receivedBean, OPERATION operation) {
|
private void prepareMetadataList(final DatasetBean receivedBean, OPERATION operation) {
|
||||||
|
|
||||||
|
@ -929,7 +880,7 @@ public class UpdateDatasetForm extends Composite {
|
||||||
*/
|
*/
|
||||||
protected void addFields(String selectedItem, OPERATION operation) {
|
protected void addFields(String selectedItem, OPERATION operation) {
|
||||||
|
|
||||||
for (MetaDataProfileBean bean : receivedBean.getMetadataList()) {
|
for (MetaDataProfileBean bean : theDatasetBean.getMetadataList()) {
|
||||||
if (bean.getType().equals(selectedItem)) {
|
if (bean.getType().equals(selectedItem)) {
|
||||||
|
|
||||||
// clear old data
|
// clear old data
|
||||||
|
@ -1207,7 +1158,7 @@ public class UpdateDatasetForm extends Composite {
|
||||||
Set<String> tags = new HashSet<String>(tagsPanel.getTags());
|
Set<String> tags = new HashSet<String>(tagsPanel.getTags());
|
||||||
|
|
||||||
// we need to retrieve the organization's name from this title
|
// we need to retrieve the organization's name from this title
|
||||||
List<OrganizationBean> orgs = receivedBean.getOrganizationList();
|
List<OrganizationBean> orgs = theDatasetBean.getOrganizationList();
|
||||||
String chosenOrganization = null;
|
String chosenOrganization = null;
|
||||||
for (OrganizationBean organizationBean : orgs) {
|
for (OrganizationBean organizationBean : orgs) {
|
||||||
if (chosenOrganizationTitle.equals(organizationBean.getTitle())) {
|
if (chosenOrganizationTitle.equals(organizationBean.getTitle())) {
|
||||||
|
@ -1284,25 +1235,25 @@ public class UpdateDatasetForm extends Composite {
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill the bean
|
// fill the bean
|
||||||
receivedBean.setAuthorFullName(author);
|
theDatasetBean.setAuthorFullName(author);
|
||||||
receivedBean.setAuthorEmail(authorEmail);
|
theDatasetBean.setAuthorEmail(authorEmail);
|
||||||
receivedBean.setDescription(description);
|
theDatasetBean.setDescription(description);
|
||||||
receivedBean.setLicense(selectedLicense);
|
theDatasetBean.setLicense(selectedLicense);
|
||||||
receivedBean.setMaintainer(maintainer);
|
theDatasetBean.setMaintainer(maintainer);
|
||||||
receivedBean.setMaintainerEmail(maintainerEmail);
|
theDatasetBean.setMaintainerEmail(maintainerEmail);
|
||||||
receivedBean.setVersion(version);
|
theDatasetBean.setVersion(version);
|
||||||
receivedBean.setVisibile(visibility.equals("Public"));
|
theDatasetBean.setVisibile(visibility.equals("Public"));
|
||||||
receivedBean.setTitle(title);
|
theDatasetBean.setTitle(title);
|
||||||
receivedBean.setTags(new ArrayList<String>(tags));
|
theDatasetBean.setTags(new ArrayList<String>(tags));
|
||||||
receivedBean.setSelectedOrganization(chosenOrganization);
|
theDatasetBean.setSelectedOrganization(chosenOrganization);
|
||||||
receivedBean.setGroups(groups);
|
theDatasetBean.setGroups(groups);
|
||||||
receivedBean.setGroupsForceCreation(groupsToForceCreation);
|
theDatasetBean.setGroupsForceCreation(groupsToForceCreation);
|
||||||
|
|
||||||
if (resourcesSelectByWEMainPanel != null) {
|
if (resourcesSelectByWEMainPanel != null) {
|
||||||
receivedBean.setResourceRoot(resourcesSelectByWEMainPanel.getResourcesToPublish());
|
theDatasetBean.setResourceRoot(resourcesSelectByWEMainPanel.getResourcesToPublish());
|
||||||
}
|
}
|
||||||
|
|
||||||
receivedBean.setCustomFields(customFieldsMap);
|
theDatasetBean.setCustomFields(customFieldsMap);
|
||||||
|
|
||||||
// alert
|
// alert
|
||||||
alertOnCreate(TRYING_TO_UPDATE_PRODUCT, true, AlertType.INFO, false);
|
alertOnCreate(TRYING_TO_UPDATE_PRODUCT, true, AlertType.INFO, false);
|
||||||
|
@ -1311,7 +1262,7 @@ public class UpdateDatasetForm extends Composite {
|
||||||
updateButton.setEnabled(false);
|
updateButton.setEnabled(false);
|
||||||
goBackButtonSecondStep.setEnabled(false);
|
goBackButtonSecondStep.setEnabled(false);
|
||||||
|
|
||||||
ckanServices.updateCKANDataset(receivedBean, new AsyncCallback<DatasetBean>() {
|
ckanServices.updateCKANDataset(theDatasetBean, new AsyncCallback<DatasetBean>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(final DatasetBean createdDatasetBean) {
|
public void onSuccess(final DatasetBean createdDatasetBean) {
|
||||||
|
@ -1362,7 +1313,7 @@ public class UpdateDatasetForm extends Composite {
|
||||||
updateButton.setVisible(false);
|
updateButton.setVisible(false);
|
||||||
|
|
||||||
// if we are in the "general case" we need to show a form for adding resources
|
// if we are in the "general case" we need to show a form for adding resources
|
||||||
manageAddResources(createdDatasetBean, datasetUrl);
|
bindManageResources(createdDatasetBean, datasetUrl, 3);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -1381,100 +1332,63 @@ public class UpdateDatasetForm extends Composite {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void manageAddResources(final DatasetBean theDatasetBean, final String datasetUrl) {
|
private void bindManageResources(final DatasetBean theDatasetBean, final String datasetUrl, int step) {
|
||||||
|
GWT.log("bindManageResources on dataset: " + theDatasetBean.getCkanName());
|
||||||
|
|
||||||
// if we are in the "general case" we need to show a form for adding resources
|
if (step == 1) {
|
||||||
if (!isWorkspaceRequest) {
|
//addResourcesButtonStep1.clear();
|
||||||
|
addResourcesButtonStep1.setVisible(true);
|
||||||
|
addResourcesButtonStep1.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
try {
|
@Override
|
||||||
// show the add resources button
|
public void onClick(ClickEvent event) {
|
||||||
addResourcesButtonStep1.setVisible(true);
|
GWT.log("Clicked addResourcesButtonStep1");
|
||||||
addResourcesButtonStep3.setVisible(true);
|
|
||||||
|
|
||||||
final AddedResourcesSummary addedResourcesSummary = initTabManageResourcePanel(theDatasetBean,
|
manageResourcesOnFire(theDatasetBean, datasetUrl);
|
||||||
datasetUrl);
|
|
||||||
|
|
||||||
final List<ResourceElementBean> resources = theDatasetBean.getCkanResources();
|
|
||||||
GWT.log("Resources are: " + resources);
|
|
||||||
|
|
||||||
if (resources != null && resources.size() > 0) {
|
|
||||||
GWT.log("Executing are: " + resources);
|
|
||||||
for (ResourceElementBean reb : theDatasetBean.getCkanResources()) {
|
|
||||||
addedResourcesSummary.getEventBus().fireEvent(new AddResourceEvent(reb));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
addResourcesButtonStep1.addClickHandler(new ClickHandler() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(ClickEvent event) {
|
|
||||||
|
|
||||||
manageResourcesOnFire(datasetUrl);
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
addResourcesButtonStep3.addClickHandler(new ClickHandler() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(ClickEvent event) {
|
|
||||||
|
|
||||||
manageResourcesOnFire(datasetUrl);
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
} catch (Exception e2) {
|
|
||||||
// silent
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (step == 3) {
|
||||||
|
//addResourcesButtonStep3.clear();
|
||||||
|
addResourcesButtonStep3.setVisible(true);
|
||||||
|
addResourcesButtonStep3.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
GWT.log("Clicked addResourcesButtonStep3");
|
||||||
|
|
||||||
|
manageResourcesOnFire(theDatasetBean, datasetUrl);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void manageResourcesOnFire(String datasetUrl) {
|
private void manageResourcesOnFire(final DatasetBean theDatasetBean, String datasetUrl) {
|
||||||
|
|
||||||
// remove content of the main panel
|
// remove content of the main panel
|
||||||
createDatasetMainPanel.clear();
|
createDatasetMainPanel.clear();
|
||||||
|
|
||||||
|
ManageResources manageResources = new ManageResources(eventBus, theDatasetBean, datasetUrl);
|
||||||
|
|
||||||
// form container
|
// form container
|
||||||
AddResourceContainer container = new AddResourceContainer(datasetUrl);
|
// AddResourceContainer container = new AddResourceContainer(datasetUrl);
|
||||||
container.add(tabPanel);
|
// container.add(tabPanel);
|
||||||
|
|
||||||
// add the new content of the main panel
|
// add the new content of the main panel
|
||||||
createDatasetMainPanel.add(container);
|
createDatasetMainPanel.add(manageResources);
|
||||||
|
|
||||||
tabPanel.selectTab(0);
|
final List<ResourceElementBean> resources = theDatasetBean.getCkanResources();
|
||||||
}
|
|
||||||
|
|
||||||
private AddedResourcesSummary initTabManageResourcePanel(final DatasetBean theDatasetBean, String datasetUrl) {
|
if (resources != null && resources.size() > 0) {
|
||||||
// TabPanelException
|
GWT.log("Executing are: " + resources);
|
||||||
|
for (ResourceElementBean reb : theDatasetBean.getCkanResources()) {
|
||||||
|
manageResources.getEventBus().fireEvent(new AddResourceEvent(reb));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (tabPanel != null)
|
// ((NavLink) tabPanel.getWidget(1)).setActive(true);
|
||||||
tabPanel.clear();
|
|
||||||
|
|
||||||
tabPanel = new TabPanel(Tabs.LEFT);
|
|
||||||
tabPanel.setWidth("100%");
|
|
||||||
|
|
||||||
// add the form
|
|
||||||
|
|
||||||
resourceForm = new AddResourceToDataset(eventBus, theDatasetBean.getId(), theDatasetBean.getTitle(),
|
|
||||||
theDatasetBean.getSelectedOrganization(), owner, datasetUrl);
|
|
||||||
|
|
||||||
// tab for the form
|
|
||||||
Tab formContainer = new Tab();
|
|
||||||
formContainer.add(resourceForm);
|
|
||||||
formContainer.setHeading("Add New Resource");
|
|
||||||
tabPanel.add(formContainer);
|
|
||||||
|
|
||||||
// tab for the added resources
|
|
||||||
Tab addedResources = new Tab();
|
|
||||||
AddedResourcesSummary addedResourcesSummary = new AddedResourcesSummary(eventBus);
|
|
||||||
addedResources.add(addedResourcesSummary);
|
|
||||||
addedResources.setHeading("Added Resource");
|
|
||||||
tabPanel.add(addedResources);
|
|
||||||
|
|
||||||
return addedResourcesSummary;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1868,9 +1782,9 @@ public class UpdateDatasetForm extends Composite {
|
||||||
*/
|
*/
|
||||||
private boolean hideManageResources() {
|
private boolean hideManageResources() {
|
||||||
|
|
||||||
return receivedBean.getResourceRoot() == null || receivedBean.getResourceRoot().isFolder()
|
return theDatasetBean.getResourceRoot() == null || theDatasetBean.getResourceRoot().isFolder()
|
||||||
&& (receivedBean.getResourceRoot().getChildrenSize() == null
|
&& (theDatasetBean.getResourceRoot().getChildrenSize() == null
|
||||||
|| receivedBean.getResourceRoot().getChildrenSize() == 0);
|
|| theDatasetBean.getResourceRoot().getChildrenSize() == 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -61,7 +61,7 @@ public class AddResourceToDataset extends Composite{
|
||||||
@UiField ControlGroup nameControlGroup;
|
@UiField ControlGroup nameControlGroup;
|
||||||
@UiField FlowPanel infoPanel;
|
@UiField FlowPanel infoPanel;
|
||||||
|
|
||||||
public AddResourceToDataset(HandlerManager eventBus, final String datasetId, String datasetTitle, final String datasetOrg, String owner, final String datasetUrl) {
|
public AddResourceToDataset(HandlerManager eventBus, final String datasetId, String datasetTitle, final String datasetOrg, final String datasetUrl) {
|
||||||
initWidget(uiBinder.createAndBindUi(this));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
// save bus
|
// save bus
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
|
|
|
@ -17,7 +17,10 @@ import com.github.gwtbootstrap.client.ui.AccordionGroup;
|
||||||
import com.github.gwtbootstrap.client.ui.Alert;
|
import com.github.gwtbootstrap.client.ui.Alert;
|
||||||
import com.github.gwtbootstrap.client.ui.Button;
|
import com.github.gwtbootstrap.client.ui.Button;
|
||||||
import com.github.gwtbootstrap.client.ui.Paragraph;
|
import com.github.gwtbootstrap.client.ui.Paragraph;
|
||||||
|
import com.github.gwtbootstrap.client.ui.Tab;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||||
|
import com.github.gwtbootstrap.client.ui.constants.IconPosition;
|
||||||
|
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
|
@ -32,14 +35,23 @@ import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A summary of the resources added by the user.
|
* The Class AddedResourcesSummary.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
*
|
*
|
||||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
* Feb 13, 2024
|
||||||
*/
|
*/
|
||||||
public class AddedResourcesSummary extends Composite {
|
public class AddedResourcesSummary extends Composite {
|
||||||
|
|
||||||
private static AddedResourcesSummaryUiBinder uiBinder = GWT.create(AddedResourcesSummaryUiBinder.class);
|
private static AddedResourcesSummaryUiBinder uiBinder = GWT.create(AddedResourcesSummaryUiBinder.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Interface AddedResourcesSummaryUiBinder.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Feb 13, 2024
|
||||||
|
*/
|
||||||
interface AddedResourcesSummaryUiBinder extends UiBinder<Widget, AddedResourcesSummary> {
|
interface AddedResourcesSummaryUiBinder extends UiBinder<Widget, AddedResourcesSummary> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,26 +59,44 @@ public class AddedResourcesSummary extends Composite {
|
||||||
private HandlerManager eventBus;
|
private HandlerManager eventBus;
|
||||||
|
|
||||||
// list of added resources (beans)
|
// list of added resources (beans)
|
||||||
List<ResourceElementBean> addedResources;
|
private List<ResourceElementBean> addedResources;
|
||||||
|
|
||||||
LinkedHashMap<Integer, Accordion> mapAddedResources = new LinkedHashMap<Integer, Accordion>();
|
private LinkedHashMap<Integer, Accordion> mapAddedResources = new LinkedHashMap<Integer, Accordion>();
|
||||||
|
|
||||||
@UiField
|
@UiField
|
||||||
VerticalPanel addResourcesPanel;
|
VerticalPanel addResourcesPanel;
|
||||||
|
|
||||||
@UiField
|
@UiField
|
||||||
Alert alertMessage;
|
Alert alertMessage;
|
||||||
|
|
||||||
FlowPanel alertPanel = new FlowPanel();
|
|
||||||
|
|
||||||
public AddedResourcesSummary(HandlerManager eventBus) {
|
@UiField
|
||||||
|
Alert alertNoResource;
|
||||||
|
|
||||||
|
private FlowPanel alertPanel = new FlowPanel();
|
||||||
|
|
||||||
|
private Tab tabAddedResources;
|
||||||
|
|
||||||
|
private IconType addedResourcesIcons;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new added resources summary.
|
||||||
|
*
|
||||||
|
* @param eventBus the event bus
|
||||||
|
*/
|
||||||
|
public AddedResourcesSummary(HandlerManager eventBus, Tab tabAddedResources, IconType addedResourcesIcons) {
|
||||||
initWidget(uiBinder.createAndBindUi(this));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
|
this.tabAddedResources = tabAddedResources;
|
||||||
|
this.addedResourcesIcons = addedResourcesIcons;
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
|
||||||
alertMessage.setType(AlertType.ERROR);
|
alertMessage.setType(AlertType.ERROR);
|
||||||
alertMessage.setClose(true);
|
alertMessage.setClose(true);
|
||||||
alertMessage.add(alertPanel);
|
alertMessage.add(alertPanel);
|
||||||
// save bus
|
|
||||||
this.eventBus = eventBus;
|
alertNoResource.setType(AlertType.WARNING);
|
||||||
|
alertNoResource.setClose(false);
|
||||||
|
alertNoResource.setText("No Resources");
|
||||||
|
checkNoResources();
|
||||||
// bind on add resource event
|
// bind on add resource event
|
||||||
bind();
|
bind();
|
||||||
// init list
|
// init list
|
||||||
|
@ -74,7 +104,7 @@ public class AddedResourcesSummary extends Composite {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind on add/delete resource event
|
* Bind on add/delete resource event.
|
||||||
*/
|
*/
|
||||||
private void bind() {
|
private void bind() {
|
||||||
|
|
||||||
|
@ -84,6 +114,8 @@ public class AddedResourcesSummary extends Composite {
|
||||||
@Override
|
@Override
|
||||||
public void onAddedResource(AddResourceEvent addResourceEvent) {
|
public void onAddedResource(AddResourceEvent addResourceEvent) {
|
||||||
GWT.log("Added resource event: " + addResourceEvent);
|
GWT.log("Added resource event: " + addResourceEvent);
|
||||||
|
tabAddedResources.setIcon(addedResourcesIcons);
|
||||||
|
tabAddedResources.setIconPosition(IconPosition.RIGHT);
|
||||||
|
|
||||||
// get the resource
|
// get the resource
|
||||||
final ResourceElementBean justAddedResource = addResourceEvent.getResource();
|
final ResourceElementBean justAddedResource = addResourceEvent.getResource();
|
||||||
|
@ -92,7 +124,7 @@ public class AddedResourcesSummary extends Composite {
|
||||||
final Accordion accordion = new Accordion();
|
final Accordion accordion = new Accordion();
|
||||||
AccordionGroup accordionGroup = new AccordionGroup();
|
AccordionGroup accordionGroup = new AccordionGroup();
|
||||||
accordionGroup.setHeading("* " + justAddedResource.getName());
|
accordionGroup.setHeading("* " + justAddedResource.getName());
|
||||||
accordionGroup.getHeading().getElement().getStyle().setBackgroundColor("#f1f3f9");
|
accordionGroup.getHeading().addStyleName("accordion-resource-added");
|
||||||
accordion.add(accordionGroup);
|
accordion.add(accordionGroup);
|
||||||
|
|
||||||
// add sub-info such as url and description
|
// add sub-info such as url and description
|
||||||
|
@ -130,6 +162,7 @@ public class AddedResourcesSummary extends Composite {
|
||||||
addResourcesPanel.add(accordion);
|
addResourcesPanel.add(accordion);
|
||||||
|
|
||||||
mapAddedResources.put(justAddedResource.getBeanID(), accordion);
|
mapAddedResources.put(justAddedResource.getBeanID(), accordion);
|
||||||
|
checkNoResources();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -166,16 +199,16 @@ public class AddedResourcesSummary extends Composite {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Boolean result) {
|
public void onSuccess(Boolean result) {
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
setAlertMessage(null, "The resource described by " + toDelete.getName()
|
setAlertMessage(null, "The resource described by '" + toDelete.getName()
|
||||||
+ " has been deleted!", AlertType.SUCCESS, true);
|
+ "' has been deleted!", AlertType.SUCCESS, true);
|
||||||
// remove from the list
|
// remove from the list
|
||||||
addedResources.remove(toDelete);
|
addedResources.remove(toDelete);
|
||||||
addResourcesPanel.remove(toDeleteAccordion);
|
addResourcesPanel.remove(toDeleteAccordion);
|
||||||
|
checkNoResources();
|
||||||
} else {
|
} else {
|
||||||
setAlertMessage(null, "Sorry, the resource described by "
|
setAlertMessage(null, "Sorry, the resource described by '"
|
||||||
+ toDelete.getName() + " cannot be deleted", AlertType.SUCCESS,
|
+ toDelete.getName() + "' cannot be deleted", AlertType.SUCCESS,
|
||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,6 +217,7 @@ public class AddedResourcesSummary extends Composite {
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
toDeleteButton.setEnabled(false);
|
toDeleteButton.setEnabled(false);
|
||||||
setAlertMessage(null, caught.getMessage(), AlertType.ERROR, true);
|
setAlertMessage(null, caught.getMessage(), AlertType.ERROR, true);
|
||||||
|
checkNoResources();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -194,6 +228,23 @@ public class AddedResourcesSummary extends Composite {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkNoResources() {
|
||||||
|
|
||||||
|
if (addedResources != null && addedResources.size() > 0) {
|
||||||
|
alertNoResource.setVisible(false);
|
||||||
|
} else {
|
||||||
|
alertNoResource.setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the alert message.
|
||||||
|
*
|
||||||
|
* @param loader the loader
|
||||||
|
* @param message the message
|
||||||
|
* @param type the type
|
||||||
|
* @param visible the visible
|
||||||
|
*/
|
||||||
private void setAlertMessage(LoaderIcon loader, String message, AlertType type, boolean visible) {
|
private void setAlertMessage(LoaderIcon loader, String message, AlertType type, boolean visible) {
|
||||||
|
|
||||||
alertPanel.clear();
|
alertPanel.clear();
|
||||||
|
@ -209,6 +260,11 @@ public class AddedResourcesSummary extends Composite {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the event bus.
|
||||||
|
*
|
||||||
|
* @return the event bus
|
||||||
|
*/
|
||||||
public HandlerManager getEventBus() {
|
public HandlerManager getEventBus() {
|
||||||
return eventBus;
|
return eventBus;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
<g:VerticalPanel ui:field="addResourcesPanel"
|
<g:VerticalPanel ui:field="addResourcesPanel"
|
||||||
width="100%">
|
width="100%">
|
||||||
<b:Alert visible="false" ui:field="alertMessage"></b:Alert>
|
<b:Alert visible="false" ui:field="alertMessage"></b:Alert>
|
||||||
|
<b:Alert visible="false" ui:field="alertNoResource"></b:Alert>
|
||||||
</g:VerticalPanel>
|
</g:VerticalPanel>
|
||||||
</g:HTMLPanel>
|
</g:HTMLPanel>
|
||||||
</ui:UiBinder>
|
</ui:UiBinder>
|
|
@ -0,0 +1,78 @@
|
||||||
|
package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.resources;
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.DatasetBean;
|
||||||
|
|
||||||
|
import com.github.gwtbootstrap.client.ui.Tab;
|
||||||
|
import com.github.gwtbootstrap.client.ui.TabPanel;
|
||||||
|
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
||||||
|
import com.github.gwtbootstrap.client.ui.resources.Bootstrap.Tabs;
|
||||||
|
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 ManageResources extends Composite {
|
||||||
|
|
||||||
|
private static ManageResourcesUiBinder uiBinder = GWT.create(ManageResourcesUiBinder.class);
|
||||||
|
|
||||||
|
interface ManageResourcesUiBinder extends UiBinder<Widget, ManageResources> {
|
||||||
|
}
|
||||||
|
|
||||||
|
@UiField
|
||||||
|
Tab addResources;
|
||||||
|
|
||||||
|
@UiField
|
||||||
|
Tab addedResources;
|
||||||
|
|
||||||
|
@UiField
|
||||||
|
TabPanel tabPanel;
|
||||||
|
|
||||||
|
private AddedResourcesSummary addedResourcesSummary;
|
||||||
|
|
||||||
|
private AddResourceToDataset resourceForm;
|
||||||
|
|
||||||
|
private HandlerManager eventBus;
|
||||||
|
|
||||||
|
private IconType addedResourcesIcon = IconType.CIRCLE;
|
||||||
|
|
||||||
|
public ManageResources(HandlerManager eventBus, final DatasetBean theDatasetBean, String datasetUrl) {
|
||||||
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
|
||||||
|
resourceForm = new AddResourceToDataset(eventBus, theDatasetBean.getId(), theDatasetBean.getTitle(),
|
||||||
|
theDatasetBean.getSelectedOrganization(), datasetUrl);
|
||||||
|
|
||||||
|
addedResourcesSummary = new AddedResourcesSummary(eventBus, addedResources, addedResourcesIcon);
|
||||||
|
|
||||||
|
// tab for the form
|
||||||
|
addResources.add(resourceForm);
|
||||||
|
addedResources.add(addedResourcesSummary);
|
||||||
|
|
||||||
|
tabPanel.setTabPosition(Tabs.LEFT.name());
|
||||||
|
tabPanel.selectTab(0);
|
||||||
|
|
||||||
|
bind();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void bind() {
|
||||||
|
|
||||||
|
addedResources.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
addedResources.setIcon(null);
|
||||||
|
//addedResources.removeStyle(addedResourcesIcon);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public HandlerManager getEventBus() {
|
||||||
|
return eventBus;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
||||||
|
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
||||||
|
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"
|
||||||
|
xmlns:g="urn:import:com.google.gwt.user.client.ui">
|
||||||
|
<ui:style>
|
||||||
|
.important {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
</ui:style>
|
||||||
|
<g:HTMLPanel>
|
||||||
|
<b:TabPanel ui:field="tabPanel">
|
||||||
|
<b:Tab ui:field="addResources" heading="Add Resource"></b:Tab>
|
||||||
|
<b:Tab ui:field="addedResources" heading="Added Resources"></b:Tab>
|
||||||
|
</b:TabPanel>
|
||||||
|
</g:HTMLPanel>
|
||||||
|
</ui:UiBinder>
|
|
@ -133,3 +133,10 @@
|
||||||
.wizard-creator .current:after {
|
.wizard-creator .current:after {
|
||||||
border-left-color: #007ACC;
|
border-left-color: #007ACC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.accordion-resource-added {
|
||||||
|
background-color: #f1f3f9;
|
||||||
|
padding: 2px;
|
||||||
|
box-shadow: 3px 3px #888;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
Loading…
Reference in New Issue