edit_facility_26115 #3
|
@ -32,6 +32,7 @@ import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetada
|
|||
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.tags.TagsPanel;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.client.ui.utils.LoaderIcon;
|
||||
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.MetaDataProfileBean;
|
||||
|
@ -68,7 +69,9 @@ import com.google.gwt.user.client.Window;
|
|||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Anchor;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
import com.google.gwt.user.client.ui.FocusPanel;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.SimplePanel;
|
||||
|
@ -266,12 +269,6 @@ public class CreateDatasetForm extends Composite {
|
|||
private static final String TRYING_TO_CREATE_PRODUCT = "Trying to publish the item, please wait...";
|
||||
protected static final String MISSING_PUBLISH_RIGHTS = "It seems you are not authorized to publish on catalogue. Request it to the VRE manager or the portal administrator.";
|
||||
|
||||
// tab panel
|
||||
private TabPanel tabPanel;
|
||||
|
||||
// add resource form
|
||||
private AddResourceToDataset resourceForm;
|
||||
|
||||
// the licenses
|
||||
private List<LicenseBean> licenseBean;
|
||||
|
||||
|
@ -307,6 +304,8 @@ public class CreateDatasetForm extends Composite {
|
|||
|
||||
private WizardCreator wizCreator;
|
||||
|
||||
private FlowPanel alertPanel = new FlowPanel();
|
||||
|
||||
/**
|
||||
* Invoked in the most general case
|
||||
*
|
||||
|
@ -356,7 +355,7 @@ public class CreateDatasetForm extends Composite {
|
|||
InfoIconsLabels.closeDialogBox(popupOpenedIds);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
eventBusPublisherWidget.addHandler(ReloadDatasetPageEvent.TYPE, new ReloadDatasetPageEventHandler() {
|
||||
|
||||
@Override
|
||||
|
@ -413,7 +412,8 @@ public class CreateDatasetForm extends Composite {
|
|||
tagsPanel.setVisible(false);
|
||||
|
||||
// check if the user has publishing rights
|
||||
setAlertBlock("Checking your permissions, please wait...", AlertType.INFO, true);
|
||||
LoaderIcon loader = new LoaderIcon("Checking your permissions, please wait...");
|
||||
setAlertBlock(null, loader, AlertType.INFO, true);
|
||||
|
||||
ckanServices.isPublisherUser(new AsyncCallback<Boolean>() {
|
||||
|
||||
|
@ -423,7 +423,8 @@ public class CreateDatasetForm extends Composite {
|
|||
if (result) {
|
||||
|
||||
// set info block
|
||||
setAlertBlock("Retrieving information, please wait...", AlertType.INFO, true);
|
||||
LoaderIcon loader = new LoaderIcon("Retrieving information, please wait...");
|
||||
setAlertBlock(null, loader, AlertType.INFO, true);
|
||||
|
||||
// get back the licenses and the metadata information
|
||||
ckanServices.getDatasetBean(idFolderOrFileWorkspace, new AsyncCallback<DatasetBean>() {
|
||||
|
@ -431,7 +432,7 @@ public class CreateDatasetForm extends Composite {
|
|||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
||||
setAlertBlock(caught.getMessage(), AlertType.ERROR, true);
|
||||
setAlertBlock(caught.getMessage(), null, AlertType.ERROR, true);
|
||||
|
||||
}
|
||||
|
||||
|
@ -439,8 +440,7 @@ public class CreateDatasetForm extends Composite {
|
|||
public void onSuccess(final DatasetBean bean) {
|
||||
|
||||
if (bean == null) {
|
||||
|
||||
setAlertBlock("Error while retrieving information.", AlertType.ERROR, true);
|
||||
setAlertBlock("Error while retrieving information.", null, AlertType.ERROR, true);
|
||||
} else {
|
||||
|
||||
// save it
|
||||
|
@ -455,7 +455,8 @@ public class CreateDatasetForm extends Composite {
|
|||
maintainerTextbox.setText(bean.getAuthorSurname() + " " + bean.getAuthorName());
|
||||
maintainerEmailTextbox.setText(bean.getMaintainerEmail());
|
||||
|
||||
setAlertBlock("Retrieving information, please wait...", AlertType.INFO, true);
|
||||
LoaderIcon loader = new LoaderIcon("Retrieving information, please wait...");
|
||||
setAlertBlock(null, loader, AlertType.INFO, true);
|
||||
|
||||
// vocabulary list of tags has preemption
|
||||
List<String> vocabularyTags = bean.getTagsVocabulary();
|
||||
|
@ -532,7 +533,8 @@ public class CreateDatasetForm extends Composite {
|
|||
.get(organizationsListbox.getSelectedItemText());
|
||||
|
||||
// force tags
|
||||
setAlertBlock("Checking for tags vocabulary, please wait...", AlertType.INFO, true);
|
||||
LoaderIcon loaderT = new LoaderIcon("Checking for tags vocabulary, please wait...");
|
||||
setAlertBlock(null, loader, AlertType.INFO, true);
|
||||
ckanServices.getTagsForOrganization(orgName, new AsyncCallback<List<String>>() {
|
||||
|
||||
@Override
|
||||
|
@ -547,21 +549,21 @@ public class CreateDatasetForm extends Composite {
|
|||
|
||||
setAlertBlock(
|
||||
"Error while checking if a vocabulary of tags is defined in the selected organization.",
|
||||
AlertType.ERROR, true);
|
||||
null, AlertType.ERROR, true);
|
||||
tagsPanel.setVisible(true);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// try to retrieve the profiles
|
||||
setAlertBlock("Retrieving types, please wait...", AlertType.INFO, true);
|
||||
LoaderIcon loaderTyp = new LoaderIcon("Retrieving types, please wait...");
|
||||
setAlertBlock(null, loaderTyp, AlertType.INFO, true);
|
||||
|
||||
// perform remote request of profiles for the selected organization
|
||||
ckanServices.getProfiles(orgName, new AsyncCallback<List<MetaDataProfileBean>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
setAlertBlock(caught.getMessage(), AlertType.ERROR, true);
|
||||
setAlertBlock(caught.getMessage(), null, AlertType.ERROR, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -569,7 +571,7 @@ public class CreateDatasetForm extends Composite {
|
|||
|
||||
if (profiles == null) {
|
||||
setAlertBlock("An unknow error occurred while retrieving types, sorry",
|
||||
AlertType.ERROR, true);
|
||||
null, AlertType.ERROR, true);
|
||||
} else {
|
||||
|
||||
GWT.log("Profile returned are: " + profiles.size());
|
||||
|
@ -586,12 +588,15 @@ public class CreateDatasetForm extends Composite {
|
|||
metadataTypeListbox.setEnabled(true);
|
||||
|
||||
// try to retrieve the licenses
|
||||
setAlertBlock("Retrieving licenses, please wait...", AlertType.INFO, true);
|
||||
LoaderIcon loaderLic = new LoaderIcon(
|
||||
"Retrieving licenses, please wait...");
|
||||
setAlertBlock(null, loaderLic, AlertType.INFO, true);
|
||||
|
||||
ckanServices.getLicenses(new AsyncCallback<List<LicenseBean>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
setAlertBlock(caught.getMessage(), AlertType.ERROR, true);
|
||||
setAlertBlock(caught.getMessage(), null, AlertType.ERROR, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -609,9 +614,10 @@ public class CreateDatasetForm extends Composite {
|
|||
// set the url of the license, if any
|
||||
showLicenseUrl();
|
||||
|
||||
// try to retrieve the licenses
|
||||
setAlertBlock("Retrieving groups, please wait...",
|
||||
AlertType.INFO, true);
|
||||
// try to retrieve groups
|
||||
LoaderIcon loaderLic = new LoaderIcon(
|
||||
"Retrieving groups, please wait...");
|
||||
setAlertBlock(null, loaderLic, AlertType.INFO, true);
|
||||
|
||||
// request groups
|
||||
ckanServices.getUserGroups(orgName,
|
||||
|
@ -623,7 +629,7 @@ public class CreateDatasetForm extends Composite {
|
|||
if (groups == null) {
|
||||
setAlertBlock(
|
||||
"Error while retrieving groups",
|
||||
AlertType.ERROR, true);
|
||||
null, AlertType.ERROR, true);
|
||||
} else {
|
||||
if (groups.isEmpty()) {
|
||||
groupsControlGroup.setVisible(false);
|
||||
|
@ -638,7 +644,8 @@ public class CreateDatasetForm extends Composite {
|
|||
hideGroupsAlreadyInProfile(profiles);
|
||||
}
|
||||
// everything went ok
|
||||
setAlertBlock("", AlertType.ERROR, false);
|
||||
setAlertBlock("", null, AlertType.ERROR,
|
||||
false);
|
||||
continueButton.setEnabled(true);
|
||||
resetButton.setEnabled(true);
|
||||
}
|
||||
|
@ -646,13 +653,13 @@ public class CreateDatasetForm extends Composite {
|
|||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
setAlertBlock(caught.getMessage(),
|
||||
setAlertBlock(caught.getMessage(), null,
|
||||
AlertType.ERROR, true);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
setAlertBlock("Error while retrieving licenses",
|
||||
setAlertBlock("Error while retrieving licenses", null,
|
||||
AlertType.ERROR, true);
|
||||
}
|
||||
}
|
||||
|
@ -665,14 +672,14 @@ public class CreateDatasetForm extends Composite {
|
|||
});
|
||||
|
||||
} else {
|
||||
setAlertBlock(MISSING_PUBLISH_RIGHTS, AlertType.ERROR, true);
|
||||
setAlertBlock(MISSING_PUBLISH_RIGHTS, null, AlertType.ERROR, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
setAlertBlock(MISSING_PUBLISH_RIGHTS, AlertType.ERROR, true);
|
||||
setAlertBlock(MISSING_PUBLISH_RIGHTS, null, AlertType.ERROR, true);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -698,7 +705,8 @@ public class CreateDatasetForm extends Composite {
|
|||
final String orgName = nameTitleOrganizationMap.get(selectedOrganizationTitle);
|
||||
|
||||
// try to retrieve the profiles
|
||||
setAlertBlock("Retrieving types, please wait...", AlertType.INFO, true);
|
||||
LoaderIcon loader = new LoaderIcon("Retrieving types, please wait...");
|
||||
setAlertBlock(null, loader, AlertType.INFO, true);
|
||||
|
||||
// disable the list of organizations name so that the user doesn't change it
|
||||
// again
|
||||
|
@ -721,8 +729,9 @@ public class CreateDatasetForm extends Composite {
|
|||
organizationsListbox.setEnabled(true);
|
||||
metadataTypeListbox.setEnabled(true);
|
||||
|
||||
// try to retrieve the licenses
|
||||
setAlertBlock("Retrieving groups, please wait...", AlertType.INFO, true);
|
||||
// try to retrieve the groups
|
||||
LoaderIcon loaderG = new LoaderIcon("Retrieving groups, please wait...");
|
||||
setAlertBlock(null, loaderG, AlertType.INFO, true);
|
||||
|
||||
// request groups
|
||||
ckanServices.getUserGroups(orgName, new AsyncCallback<List<OrganizationBean>>() {
|
||||
|
@ -731,7 +740,8 @@ public class CreateDatasetForm extends Composite {
|
|||
public void onSuccess(List<OrganizationBean> groups) {
|
||||
|
||||
if (groups == null) {
|
||||
setAlertBlock("Error while retrieving groups, try later", AlertType.ERROR, true);
|
||||
setAlertBlock("Error while retrieving groups. Refresh and retry later", null,
|
||||
AlertType.ERROR, true);
|
||||
} else {
|
||||
if (groups.isEmpty()) {
|
||||
groupsControlGroup.setVisible(false);
|
||||
|
@ -744,19 +754,22 @@ public class CreateDatasetForm extends Composite {
|
|||
groupsListbox.setEnabled(true);
|
||||
hideGroupsAlreadyInProfile(profiles);
|
||||
}
|
||||
setAlertBlock("", AlertType.ERROR, false);
|
||||
setAlertBlock("", null, AlertType.ERROR, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
setAlertBlock("Error while retrieving groups, try later", AlertType.ERROR, true);
|
||||
setAlertBlock("Error while retrieving groups. Refresh and retry later", null,
|
||||
AlertType.ERROR, true);
|
||||
}
|
||||
});
|
||||
|
||||
// check also for tags (if for that context there is a vocabulary or not)
|
||||
tagsPanel.setVisible(false);
|
||||
setAlertBlock("Checking for tags vocabulary, please wait...", AlertType.INFO, true);
|
||||
LoaderIcon loaderV = new LoaderIcon("Checking for tags vocabulary, please wait...");
|
||||
setAlertBlock(null, loaderV, AlertType.INFO, true);
|
||||
|
||||
ckanServices.getTagsForOrganization(orgName, new AsyncCallback<List<String>>() {
|
||||
|
||||
@Override
|
||||
|
@ -764,7 +777,7 @@ public class CreateDatasetForm extends Composite {
|
|||
|
||||
tagsPanel.setVocabulary(vocabulary);
|
||||
tagsPanel.setVisible(true);
|
||||
setAlertBlock("", AlertType.ERROR, false);
|
||||
setAlertBlock("", null, AlertType.ERROR, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -772,7 +785,7 @@ public class CreateDatasetForm extends Composite {
|
|||
|
||||
setAlertBlock(
|
||||
"Error while checking if a vocabulary of tags is defined in the selected organization.",
|
||||
AlertType.ERROR, true);
|
||||
null, AlertType.ERROR, true);
|
||||
tagsPanel.setVocabulary(null);
|
||||
tagsPanel.setVisible(true);
|
||||
|
||||
|
@ -780,14 +793,14 @@ public class CreateDatasetForm extends Composite {
|
|||
});
|
||||
|
||||
} else
|
||||
setAlertBlock("Error while retrieving types, sorry", AlertType.ERROR, true);
|
||||
setAlertBlock("Error while retrieving types. Refresh and retry", null, AlertType.ERROR, true);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
||||
setAlertBlock("Error while retrieving types, sorry", AlertType.ERROR, true);
|
||||
setAlertBlock("Error while retrieving types. Refresh and retry", null, AlertType.ERROR, true);
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -1281,16 +1294,14 @@ public class CreateDatasetForm extends Composite {
|
|||
// silent
|
||||
}
|
||||
}
|
||||
|
||||
//firing the event to load the dataset in the Portlet
|
||||
|
||||
// firing the event to load the dataset in the Portlet
|
||||
eventBusPublisherWidget.fireEvent(new ReloadDatasetPageEvent(createdDatasetBean.getId()));
|
||||
|
||||
} else {
|
||||
|
||||
alertOnCreate(ERROR_PRODUCT_CREATION, false, AlertType.ERROR, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -1607,19 +1618,42 @@ public class CreateDatasetForm extends Composite {
|
|||
resourcesSelectByWEMainPanel.freeze();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * change alert block behavior.
|
||||
// *
|
||||
// * @param textToShow
|
||||
// * @param type
|
||||
// * @param visible
|
||||
// */
|
||||
// private void setAlertBlock(String textToShow, AlertType type, boolean visible) {
|
||||
//
|
||||
// infoBlock.setText(textToShow);
|
||||
// infoBlock.setType(type);
|
||||
// infoBlock.setVisible(visible);
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* change alert block behavior.
|
||||
*
|
||||
* @param textToShow
|
||||
* @param type
|
||||
* @param visible
|
||||
*
|
||||
* @param textToShow the text to show
|
||||
* @param type the type
|
||||
* @param visible the visible
|
||||
*/
|
||||
private void setAlertBlock(String textToShow, AlertType type, boolean visible) {
|
||||
private void setAlertBlock(String textToShow, LoaderIcon loader, AlertType type, boolean visible) {
|
||||
|
||||
infoBlock.setText(textToShow);
|
||||
alertPanel.clear();
|
||||
|
||||
if (loader != null) {
|
||||
alertPanel.add(loader);
|
||||
}
|
||||
infoBlock.setType(type);
|
||||
infoBlock.setVisible(visible);
|
||||
|
||||
if (textToShow != null) {
|
||||
alertPanel.add(new HTML(textToShow));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@UiHandler("licenseListbox")
|
||||
|
|
|
@ -1165,7 +1165,7 @@ public class UpdateDatasetForm extends Composite {
|
|||
String errorMessage = areProfileDataValid();
|
||||
|
||||
if (errorMessage != null) {
|
||||
alertOnCreate("Please check the inserted values and the mandatory fields [" + errorMessage + "]", false,
|
||||
alertOnUpdated("Please check the inserted values and the mandatory fields [" + errorMessage + "]", false,
|
||||
AlertType.ERROR, true);
|
||||
} else {
|
||||
|
||||
|
@ -1280,7 +1280,7 @@ public class UpdateDatasetForm extends Composite {
|
|||
theDatasetBean.setCustomFields(customFieldsMap);
|
||||
|
||||
// alert
|
||||
alertOnCreate(TRYING_TO_UPDATE_PRODUCT, true, AlertType.INFO, false);
|
||||
alertOnUpdated(TRYING_TO_UPDATE_PRODUCT, true, AlertType.INFO, false);
|
||||
|
||||
// invoke the create method
|
||||
updateButton.setEnabled(false);
|
||||
|
@ -1300,7 +1300,7 @@ public class UpdateDatasetForm extends Composite {
|
|||
|
||||
final String datasetUrl = createdDatasetBean.getSource();
|
||||
|
||||
alertOnCreate(PRODUCT_UPDATED_OK, false, AlertType.SUCCESS, false);
|
||||
alertOnUpdated(PRODUCT_UPDATED_OK, false, AlertType.SUCCESS, false);
|
||||
|
||||
try {
|
||||
// disable dataset fields
|
||||
|
@ -1343,14 +1343,14 @@ public class UpdateDatasetForm extends Composite {
|
|||
|
||||
} else {
|
||||
|
||||
alertOnCreate(ERROR_PRODUCT_CREATION, false, AlertType.ERROR, true);
|
||||
alertOnUpdated(ERROR_PRODUCT_CREATION, false, AlertType.ERROR, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
alertOnCreate(ERROR_PRODUCT_CREATION + " Error message is : " + caught.getMessage(), false,
|
||||
alertOnUpdated(ERROR_PRODUCT_CREATION + " Error message is : " + caught.getMessage(), false,
|
||||
AlertType.ERROR, true);
|
||||
CKanMetadataPublisher.printJs(caught.toString());
|
||||
}
|
||||
|
@ -1547,7 +1547,7 @@ public class UpdateDatasetForm extends Composite {
|
|||
* @param type the type
|
||||
* @param hideAfterAWhile the hide after A while
|
||||
*/
|
||||
private void alertOnCreate(String text, boolean showSpinner, AlertType type, boolean hideAfterAWhile) {
|
||||
private void alertOnUpdated(String text, boolean showSpinner, AlertType type, boolean hideAfterAWhile) {
|
||||
|
||||
onCreateAlertBlock.clear();
|
||||
|
||||
|
@ -1737,10 +1737,6 @@ public class UpdateDatasetForm extends Composite {
|
|||
*/
|
||||
private void setAlertBlock(String textToShow, LoaderIcon loader, AlertType type, boolean visible) {
|
||||
|
||||
// infoBlock.setText(textToShow);
|
||||
// infoBlock.setType(type);
|
||||
// infoBlock.setVisible(visible);
|
||||
|
||||
alertPanel.clear();
|
||||
|
||||
if (loader != null) {
|
||||
|
|
Loading…
Reference in New Issue