|
|
|
@ -1,21 +1,31 @@
|
|
|
|
|
package org.gcube.portlets.widgets.wsthreddssync.client.view.binder;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import org.gcube.portal.wssynclibrary.shared.thredds.ThCatalogueBean;
|
|
|
|
|
import org.gcube.portlets.widgets.wsthreddssync.client.WsThreddsWidget;
|
|
|
|
|
import org.gcube.portlets.widgets.wsthreddssync.shared.GcubeVRE;
|
|
|
|
|
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.Fieldset;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.ListBox;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.Pager;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.TextBox;
|
|
|
|
|
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
|
|
|
|
|
import com.google.gwt.core.client.GWT;
|
|
|
|
|
import com.google.gwt.dom.client.Document;
|
|
|
|
|
import com.google.gwt.dom.client.Style.Float;
|
|
|
|
|
import com.google.gwt.dom.client.Style.Unit;
|
|
|
|
|
import com.google.gwt.event.dom.client.ChangeEvent;
|
|
|
|
|
import com.google.gwt.event.dom.client.ChangeHandler;
|
|
|
|
|
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
|
|
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
|
|
import com.google.gwt.event.dom.client.DomEvent;
|
|
|
|
|
import com.google.gwt.uibinder.client.UiBinder;
|
|
|
|
|
import com.google.gwt.uibinder.client.UiField;
|
|
|
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
|
|
@ -50,43 +60,67 @@ public abstract class CreateThreddsConfigurationView extends Composite {
|
|
|
|
|
/** The pager. */
|
|
|
|
|
@UiField
|
|
|
|
|
Pager pager;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** The field course desciption. */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
ListBox field_select_vre;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
Button butt_create_new_catalogue;
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
Button butt_add_catalogue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
ListBox field_select_catalogue_name;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** The field catalogue name. */
|
|
|
|
|
@UiField
|
|
|
|
|
TextBox field_catalogue_name;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** The field folder name. */
|
|
|
|
|
@UiField
|
|
|
|
|
TextBox field_remote_path;
|
|
|
|
|
|
|
|
|
|
TextBox field_folder_name;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** The cg catalogue name. */
|
|
|
|
|
@UiField
|
|
|
|
|
ControlGroup cg_catalogue_name;
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
ControlGroup cg_folder_name;
|
|
|
|
|
|
|
|
|
|
/** The cg folder name. */
|
|
|
|
|
//@UiField
|
|
|
|
|
//ControlGroup cg_remote_path;
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
ControlGroup cg_select_catalogue_name;
|
|
|
|
|
|
|
|
|
|
@UiField
|
|
|
|
|
ControlGroup cg_remote_path;
|
|
|
|
|
Fieldset fieldset_add_catalogue_bean;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** The folder id. */
|
|
|
|
|
private String folderId;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** The map VR es. */
|
|
|
|
|
private Map<String, GcubeVRE> mapVREs = new HashMap<String, GcubeVRE>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Map<String, List<ThCatalogueBean>> mapCatalogueNames = new HashMap<String, List<ThCatalogueBean>>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String currentScope;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Submit handler.
|
|
|
|
|
*/
|
|
|
|
|
public abstract void submitHandler();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the error.
|
|
|
|
|
*
|
|
|
|
@ -94,7 +128,7 @@ public abstract class CreateThreddsConfigurationView extends Composite {
|
|
|
|
|
* @param error the error
|
|
|
|
|
*/
|
|
|
|
|
public abstract void setError(boolean visible, String error);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Because this class has a default constructor, it can
|
|
|
|
@ -113,44 +147,196 @@ public abstract class CreateThreddsConfigurationView extends Composite {
|
|
|
|
|
this.folderId = folderId;
|
|
|
|
|
|
|
|
|
|
initWidget(uiBinder.createAndBindUi(this));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pager.getLeft().setVisible(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pager.getRight().addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
|
setError(false, "");
|
|
|
|
|
boolean isValid = validateSubmit();
|
|
|
|
|
if(isValid)
|
|
|
|
|
submitHandler();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cg_catalogue_name.getElement().getStyle().setMarginTop(20, Unit.PX);
|
|
|
|
|
|
|
|
|
|
field_select_vre.addChangeHandler(new ChangeHandler() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onChange(ChangeEvent event) {
|
|
|
|
|
String scope = field_select_vre.getSelectedItemText();
|
|
|
|
|
GWT.log("Selected VRE: "+scope);
|
|
|
|
|
loadCatalogueNamesForScope(scope);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WsThreddsWidget.wsThreddsSyncService.getListOfVREsForLoggedUser(new AsyncCallback<List<GcubeVRE>>() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(List<GcubeVRE> result) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (GcubeVRE gcubeVRE : result) {
|
|
|
|
|
mapVREs.put(gcubeVRE.getVreScope(), gcubeVRE);
|
|
|
|
|
field_select_vre.addItem(gcubeVRE.getVreScope(), gcubeVRE.getVreName());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(result.size()>0){
|
|
|
|
|
field_select_vre.setSelectedValue(result.get(0).getVreName());
|
|
|
|
|
//field_select_vre.setSelectedIndex(0);
|
|
|
|
|
//field_select_vre.fireEvent(DomEvent.fireNativeEvent(nativeEvent, handlerSource););
|
|
|
|
|
DomEvent.fireNativeEvent(Document.get().createChangeEvent(), field_select_vre);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
butt_create_new_catalogue.addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
|
|
|
|
|
|
fieldset_add_catalogue_bean.setVisible(true);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
butt_add_catalogue.addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
|
|
|
|
|
|
if (field_catalogue_name.getValue() == null || field_catalogue_name.getValue().isEmpty()) {
|
|
|
|
|
cg_catalogue_name.setType(ControlGroupType.ERROR);
|
|
|
|
|
setError(true, "Catalogue Name is required");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(field_folder_name.getValue() == null || field_folder_name.getValue().isEmpty()){
|
|
|
|
|
cg_folder_name.setType(ControlGroupType.ERROR);
|
|
|
|
|
setError(true, "The Folder Name is required");
|
|
|
|
|
return;
|
|
|
|
|
}else if(field_folder_name.getValue().startsWith("/")){
|
|
|
|
|
cg_folder_name.setType(ControlGroupType.ERROR);
|
|
|
|
|
setError(true, "Folder Name must be a relative URL. It does not start with '/'");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addCatalogueNameForCurrentScope(field_catalogue_name.getValue(), field_folder_name.getValue());
|
|
|
|
|
fieldset_add_catalogue_bean.setVisible(false);
|
|
|
|
|
initFieldCatalogueName();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
butt_add_catalogue.getElement().getStyle().setFloat(Float.RIGHT);
|
|
|
|
|
butt_add_catalogue.getElement().getStyle().setMarginRight(90, Unit.PX);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Fill selectable catalogue names.
|
|
|
|
|
*
|
|
|
|
|
* @param scope the scope
|
|
|
|
|
* @param result the result
|
|
|
|
|
*/
|
|
|
|
|
private void fillSelectableCatalogueNames(String scope, List<ThCatalogueBean> result){
|
|
|
|
|
|
|
|
|
|
field_select_catalogue_name.clear();
|
|
|
|
|
field_select_catalogue_name.setEnabled(true);
|
|
|
|
|
|
|
|
|
|
if(result!=null && result.size()>0){
|
|
|
|
|
|
|
|
|
|
mapCatalogueNames.put(scope, result);
|
|
|
|
|
for (ThCatalogueBean thCatalogueBean : result) {
|
|
|
|
|
field_select_catalogue_name.addItem(thCatalogueBean.getName(), thCatalogueBean.getName());
|
|
|
|
|
|
|
|
|
|
if(thCatalogueBean.isDefault()){
|
|
|
|
|
field_select_catalogue_name.setSelectedValue(thCatalogueBean.getName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds the catalogue name for current scope.
|
|
|
|
|
*
|
|
|
|
|
* @param catalogueName the catalogue name
|
|
|
|
|
* @param folderName the folder name. Can be a relative Path
|
|
|
|
|
*/
|
|
|
|
|
private void addCatalogueNameForCurrentScope(String catalogueName, String folderName) {
|
|
|
|
|
|
|
|
|
|
List<ThCatalogueBean> listCtlgs = mapCatalogueNames.get(currentScope);
|
|
|
|
|
|
|
|
|
|
if(listCtlgs==null){
|
|
|
|
|
listCtlgs = new ArrayList<ThCatalogueBean>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
listCtlgs.add(new ThCatalogueBean(catalogueName, folderName, true));
|
|
|
|
|
fillSelectableCatalogueNames(currentScope, listCtlgs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Load catalogue names for scope.
|
|
|
|
|
*
|
|
|
|
|
* @param scope the scope
|
|
|
|
|
*/
|
|
|
|
|
private void loadCatalogueNamesForScope(String scope){
|
|
|
|
|
this.currentScope = scope;
|
|
|
|
|
field_select_catalogue_name.setEnabled(false);
|
|
|
|
|
initFieldCatalogueName();
|
|
|
|
|
|
|
|
|
|
List<ThCatalogueBean> listCtlgs = mapCatalogueNames.get(scope);
|
|
|
|
|
|
|
|
|
|
if(listCtlgs==null){
|
|
|
|
|
|
|
|
|
|
WsThreddsWidget.wsThreddsSyncService.getAvailableCataloguesForScope(scope, new AsyncCallback<List<ThCatalogueBean>>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
GWT.log("Error: "+caught.getMessage());
|
|
|
|
|
field_select_catalogue_name.setEnabled(true);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(List<ThCatalogueBean> result) {
|
|
|
|
|
GWT.log("Fill Catalogue Names: "+result);
|
|
|
|
|
fillSelectableCatalogueNames(currentScope, result);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
fillSelectableCatalogueNames(scope, listCtlgs);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Inits the field catalogue name.
|
|
|
|
|
*/
|
|
|
|
|
private void initFieldCatalogueName() {
|
|
|
|
|
|
|
|
|
|
field_catalogue_name.setText("");
|
|
|
|
|
field_folder_name.setText("");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Validate submit.
|
|
|
|
|
*
|
|
|
|
@ -158,47 +344,63 @@ public abstract class CreateThreddsConfigurationView extends Composite {
|
|
|
|
|
*/
|
|
|
|
|
protected boolean validateSubmit() {
|
|
|
|
|
cg_catalogue_name.setType(ControlGroupType.NONE);
|
|
|
|
|
cg_remote_path.setType(ControlGroupType.NONE);
|
|
|
|
|
|
|
|
|
|
if(field_catalogue_name.getValue()==null || field_catalogue_name.getValue().isEmpty()){
|
|
|
|
|
//cg_remote_path.setType(ControlGroupType.NONE);
|
|
|
|
|
|
|
|
|
|
// if(field_catalogue_name.getValue()==null || field_catalogue_name.getValue().isEmpty()){
|
|
|
|
|
// cg_catalogue_name.setType(ControlGroupType.ERROR);
|
|
|
|
|
// setError(true, "Catalogue Name is required");
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
if(field_select_catalogue_name.getSelectedItemText()==null){
|
|
|
|
|
cg_catalogue_name.setType(ControlGroupType.ERROR);
|
|
|
|
|
setError(true, "Catalogue Name is required");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(field_remote_path.getValue()==null || field_remote_path.getValue().isEmpty()){
|
|
|
|
|
cg_remote_path.setType(ControlGroupType.ERROR);
|
|
|
|
|
setError(true, "Remote Path field is required");
|
|
|
|
|
return false;
|
|
|
|
|
}else if(field_remote_path.getValue().startsWith("/")){
|
|
|
|
|
cg_remote_path.setType(ControlGroupType.ERROR);
|
|
|
|
|
setError(true, "Remote Path must be a relative URL. It does not start with '/'");
|
|
|
|
|
setError(true, "Select a Catalogue Name!!!");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if(field_remote_path.getValue()==null || field_remote_path.getValue().isEmpty()){
|
|
|
|
|
// cg_remote_path.setType(ControlGroupType.ERROR);
|
|
|
|
|
// setError(true, "Remote Path field is required");
|
|
|
|
|
// return false;
|
|
|
|
|
// }else if(field_remote_path.getValue().startsWith("/")){
|
|
|
|
|
// cg_remote_path.setType(ControlGroupType.ERROR);
|
|
|
|
|
// setError(true, "Remote Path must be a relative URL. It does not start with '/'");
|
|
|
|
|
// return false;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the remote path.
|
|
|
|
|
* Gets the selected catalogue.
|
|
|
|
|
*
|
|
|
|
|
* @return the remote path
|
|
|
|
|
* @return the selected catalogue
|
|
|
|
|
*/
|
|
|
|
|
public String getRemotePath() {
|
|
|
|
|
return field_remote_path.getValue();
|
|
|
|
|
public ThCatalogueBean getSelectedCatalogue(){
|
|
|
|
|
|
|
|
|
|
List<ThCatalogueBean> listCatalogues = mapCatalogueNames.get(currentScope);
|
|
|
|
|
|
|
|
|
|
String selectedCatalogueName = getCatalogueName();
|
|
|
|
|
for (ThCatalogueBean thCatalogueBean : listCatalogues) {
|
|
|
|
|
if(thCatalogueBean.getName().compareTo(selectedCatalogueName)==0)
|
|
|
|
|
return thCatalogueBean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the catalogue name.
|
|
|
|
|
*
|
|
|
|
|
* @return the catalogue name
|
|
|
|
|
*/
|
|
|
|
|
public String getCatalogueName(){
|
|
|
|
|
return field_catalogue_name.getValue();
|
|
|
|
|
return field_select_catalogue_name.getSelectedItemText();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the unit description.
|
|
|
|
|
*
|
|
|
|
|