211 lines
4.8 KiB
Java
211 lines
4.8 KiB
Java
|
package org.gcube.portlets.widgets.wstaskexecutor.client.view.binder;
|
||
|
|
||
|
|
||
|
import java.util.HashMap;
|
||
|
import java.util.Map;
|
||
|
|
||
|
import org.gcube.portlets.widgets.wstaskexecutor.shared.GcubeScope;
|
||
|
|
||
|
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
||
|
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.event.dom.client.ClickEvent;
|
||
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||
|
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 ShowTaskConfigurationView extends Composite {
|
||
|
|
||
|
/** The ui binder. */
|
||
|
private static ShowTaskConfigurationViewUiBinder uiBinder =
|
||
|
GWT.create(ShowTaskConfigurationViewUiBinder.class);
|
||
|
|
||
|
/**
|
||
|
* The Interface CreateTaskConfigurationViewUiBinder.
|
||
|
*
|
||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||
|
* May 4, 2018
|
||
|
*/
|
||
|
interface ShowTaskConfigurationViewUiBinder
|
||
|
extends UiBinder<Widget, ShowTaskConfigurationView> {
|
||
|
}
|
||
|
|
||
|
/** The pager. */
|
||
|
@UiField
|
||
|
Pager pager;
|
||
|
|
||
|
|
||
|
@UiField
|
||
|
ListBox field_select_scope;
|
||
|
|
||
|
@UiField
|
||
|
TextBox field_key_param;
|
||
|
|
||
|
@UiField
|
||
|
TextBox field_value_param;
|
||
|
|
||
|
@UiField
|
||
|
ControlGroup cg_input_task_id;
|
||
|
|
||
|
@UiField
|
||
|
ControlGroup cg_select_vre;
|
||
|
|
||
|
@UiField
|
||
|
ControlGroup cg_input_key_param;
|
||
|
|
||
|
@UiField
|
||
|
ControlGroup cg_input_value_param;
|
||
|
|
||
|
|
||
|
|
||
|
@UiField
|
||
|
TextBox field_task_id;
|
||
|
|
||
|
|
||
|
/** The folder id. */
|
||
|
private String folderId;
|
||
|
|
||
|
/** The map VR es. */
|
||
|
private Map<String, GcubeScope> mapScopes = new HashMap<String, GcubeScope>();
|
||
|
|
||
|
|
||
|
|
||
|
private String currentScope;
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 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 folderId the folder id
|
||
|
*/
|
||
|
public ShowTaskConfigurationView(String folderId) {
|
||
|
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();
|
||
|
|
||
|
}
|
||
|
});
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Inits the field catalogue name.
|
||
|
*/
|
||
|
private void initFields() {
|
||
|
|
||
|
field_task_id.setText("");
|
||
|
field_key_param.setText("");
|
||
|
field_value_param.setText("");
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Validate submit.
|
||
|
*
|
||
|
* @return true, if successful
|
||
|
*/
|
||
|
protected boolean validateSubmit() {
|
||
|
cg_input_task_id.setType(ControlGroupType.NONE);
|
||
|
cg_input_key_param.setType(ControlGroupType.NONE);
|
||
|
cg_input_value_param.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_task_id.getValue() == null || field_task_id.getValue().isEmpty()){
|
||
|
cg_input_task_id.setType(ControlGroupType.ERROR);
|
||
|
setError(true, "You must type an Algorithm Identifier!");
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
if(field_key_param.getValue() == null || field_key_param.getValue().isEmpty()){
|
||
|
cg_input_key_param.setType(ControlGroupType.WARNING);
|
||
|
setConfirm(true, "The key of input parameter is empty. Do you want continue anyway?");
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
if(field_value_param.getValue() == null || field_value_param.getValue().isEmpty()){
|
||
|
cg_input_key_param.setType(ControlGroupType.WARNING);
|
||
|
setConfirm(true, "The value of input parameter is empty. Do you want continue anyway?");
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Gets the selected scope.
|
||
|
*
|
||
|
* @return the selected scope
|
||
|
*/
|
||
|
public GcubeScope getSelectedScope(){
|
||
|
//String item = field_select_scope.getSelectedItemText();
|
||
|
String text = field_select_scope.getSelectedValue();
|
||
|
return mapScopes.get(text);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|