Manage enum case as Task Parameter
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/ws-task-executor-widget@169329 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
66d763a6a4
commit
ff9935200a
|
@ -40,6 +40,7 @@ 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.regexp.shared.RegExp;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
|
@ -289,12 +290,11 @@ public class WsTaskExecutorWidget {
|
|||
return;
|
||||
|
||||
List<String> listMessages = result.getOutputMessages();
|
||||
|
||||
String outMsg = "";
|
||||
String outMsg = "<ul style=\"margin:5px;\">";
|
||||
for (String msg : listMessages) {
|
||||
outMsg+="<br>"+msg;
|
||||
outMsg+="<li>"+msg+"</li><br/>";
|
||||
}
|
||||
|
||||
outMsg += "</ul>";
|
||||
|
||||
final DialogResult dResult = new DialogResult(null, "Computation results are:", outMsg);
|
||||
dResult.center();
|
||||
|
@ -309,6 +309,36 @@ public class WsTaskExecutorWidget {
|
|||
|
||||
}
|
||||
|
||||
// private String addHtmlLink(String text){
|
||||
//
|
||||
// if(text==null || text.isEmpty())
|
||||
// return text;
|
||||
//
|
||||
// MatchResult matcher = urlPattern.exec(text);
|
||||
// boolean matchFound = matcher != null; // equivalent to regExp.test(inputStr);
|
||||
//
|
||||
// String msgWithHref = text;
|
||||
// if (matchFound) {
|
||||
// // Get all groups for this match
|
||||
// for (int i = 0; i < matcher.getGroupCount(); i++) {
|
||||
// String groupStr = matcher.getGroup(i);
|
||||
// System.out.println(groupStr);
|
||||
// msgWithHref= msgWithHref.replace(groupStr, "<a href='"+groupStr+"'>");
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// GWT.log("Replace html: "+msgWithHref);
|
||||
//
|
||||
// return msgWithHref;
|
||||
// }
|
||||
|
||||
// Pattern for recognizing a URL, based off RFC 3986
|
||||
private static final RegExp urlPattern = RegExp.compile(
|
||||
"(?:^|[\\W])((ht|f)tp(s?):\\/\\/|www\\.)"
|
||||
+ "(([\\w\\-]+\\.){1,}?([\\w\\-.~]+\\/?)*"
|
||||
+ "[\\p{Alnum}.,%_=?&#\\-+()\\[\\]\\*$~@!:/{};']*)");
|
||||
|
||||
|
||||
/**
|
||||
* Perform run task.
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.portlets.widgets.wstaskexecutor.client.view.binder;
|
|||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -193,7 +194,7 @@ public abstract class CreateTaskConfigurationView extends Composite {
|
|||
|
||||
List<TaskParameter> params = editConfiguration.getListParameters();
|
||||
for (TaskParameter taskParameter : params) {
|
||||
appendCustomField(taskParameter.getKey(), taskParameter.getValue(), taskParameter.getType().getType(), false);
|
||||
appendCustomField(taskParameter.getKey(), Arrays.asList(taskParameter.getValue()), taskParameter.getType().getType(), false);
|
||||
}
|
||||
|
||||
pager.getRight().setText("Update Configuration");
|
||||
|
@ -255,13 +256,13 @@ public abstract class CreateTaskConfigurationView extends Composite {
|
|||
* Append custom field.
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
* @param values the values
|
||||
* @param parameterType the parameter type
|
||||
* @param removable the removable
|
||||
*/
|
||||
private void appendCustomField(String key, String value, String parameterType, boolean removable){
|
||||
private void appendCustomField(String key, List<String> values, String parameterType, boolean removable){
|
||||
|
||||
CustomFieldEntry toAdd = new CustomFieldEntry(eventBus, key, value, parameterType, removable);
|
||||
CustomFieldEntry toAdd = new CustomFieldEntry(eventBus, key, values, parameterType, removable);
|
||||
customFieldEntriesList.add(toAdd);
|
||||
cg_parameters_control.add(toAdd);
|
||||
}
|
||||
|
@ -284,19 +285,23 @@ public abstract class CreateTaskConfigurationView extends Composite {
|
|||
if(operator.getType().getType().equals("FILE")){
|
||||
countFileParameter++;
|
||||
if(countFileParameter==1){
|
||||
appendCustomField("publicLink", wsItem.getPublicLink(), operator.getType().getType(), false);
|
||||
List<String> pLink = new ArrayList<String>(1);
|
||||
pLink.add(wsItem.getPublicLink());
|
||||
appendCustomField("publicLink", pLink, operator.getType().getType(), false);
|
||||
addedPublicLink = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!addedPublicLink)
|
||||
appendCustomField(operator.getKey(), operator.getDefaultValue(), operator.getType().getType(), false);
|
||||
appendCustomField(operator.getKey(), operator.getDefaultValues(), operator.getType().getType(), false);
|
||||
}
|
||||
|
||||
|
||||
if(wsItem.isFolder()){
|
||||
appendCustomField("folderId", wsItem.getItemId(), "OBJECT", true);
|
||||
List<String> pItemId = new ArrayList<String>(1);
|
||||
pItemId.add(wsItem.getItemId());
|
||||
appendCustomField("folderId", pItemId, "OBJECT", true);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.gcube.portlets.widgets.wstaskexecutor.client.event.DeleteCustomFieldE
|
|||
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
||||
import com.github.gwtbootstrap.client.ui.Controls;
|
||||
import com.github.gwtbootstrap.client.ui.InputAddOn;
|
||||
import com.github.gwtbootstrap.client.ui.ListBox;
|
||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||
|
@ -48,14 +49,18 @@ public class CustomFieldEntry extends Composite {
|
|||
|
||||
@UiField InputAddOn keyFieldPrepend;
|
||||
@UiField InputAddOn valueFieldPrepend;
|
||||
@UiField InputAddOn valuesSelectPrepend;
|
||||
@UiField Button removeCustomField;
|
||||
@UiField ListBox field_select_parameter;
|
||||
@UiField ControlGroup cg_parameter;
|
||||
@UiField TextBox field_input_value;
|
||||
//@UiField ListBox field_select_value;
|
||||
@UiField Controls control_select_value;
|
||||
@UiField Controls control_input_value;
|
||||
|
||||
private List<TaskParameterType> parameterTypes;
|
||||
|
||||
//inserted values
|
||||
private String value;
|
||||
private List<String> values;
|
||||
private String key;
|
||||
//private boolean isCustomCreatedByUser;
|
||||
|
||||
|
@ -72,7 +77,7 @@ public class CustomFieldEntry extends Composite {
|
|||
* @param value the value
|
||||
* @param parameterType the parameter type
|
||||
*/
|
||||
public CustomFieldEntry(HandlerManager eventBus, String key, String value, final String parameterType, boolean removable) {
|
||||
public CustomFieldEntry(HandlerManager eventBus, String key, List<String> values, final String parameterType, boolean removable) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.getElement().getStyle().setMarginTop(10, Unit.PX);
|
||||
this.getElement().getStyle().setMarginBottom(20, Unit.PX);
|
||||
|
@ -81,10 +86,12 @@ public class CustomFieldEntry extends Composite {
|
|||
keyFieldPrepend.setTitle("This is the key of the parameter");
|
||||
valueFieldPrepend.setTitle("This is the value of the parameter");
|
||||
|
||||
control_select_value.setVisible(false);
|
||||
|
||||
// save information
|
||||
this.eventBus = eventBus;
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
this.values = values;
|
||||
this.parameterType = parameterType;
|
||||
|
||||
|
||||
|
@ -92,8 +99,22 @@ public class CustomFieldEntry extends Composite {
|
|||
((TextBox)this.keyFieldPrepend.getWidget(1)).setText(key);
|
||||
}
|
||||
|
||||
if(value!=null && !value.isEmpty()){
|
||||
((TextBox)this.valueFieldPrepend.getWidget(1)).setText(value);
|
||||
if(values!=null && !values.isEmpty()){
|
||||
//one default value is added
|
||||
if(values.size()==1){
|
||||
control_input_value.setVisible(true);
|
||||
((TextBox)this.valueFieldPrepend.getWidget(1)).setText(values.get(0));
|
||||
}
|
||||
else{
|
||||
//Many default value existing.. creating combo box to them
|
||||
control_input_value.setVisible(false);
|
||||
control_select_value.setVisible(true);
|
||||
ListBox selectValues = (ListBox) this.valuesSelectPrepend.getWidget(1);
|
||||
for (String value : values) {
|
||||
selectValues.addItem(value, value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
WsTaskExecutorWidget.wsTaskService.getAvailableParameterTypes(new AsyncCallback<List<TaskParameterType>>() {
|
||||
|
@ -167,6 +188,9 @@ public class CustomFieldEntry extends Composite {
|
|||
*/
|
||||
public String getValue(){
|
||||
|
||||
if(values!=null && values.size()>1)
|
||||
return ((ListBox) this.valuesSelectPrepend.getWidget(1)).getSelectedValue();
|
||||
|
||||
return ((TextBox)this.valueFieldPrepend.getWidget(1)).getText();
|
||||
|
||||
}
|
||||
|
|
|
@ -17,10 +17,18 @@
|
|||
<b:TextBox addStyleNames="my-input-width" />
|
||||
</b:InputAddOn>
|
||||
</b:Controls>
|
||||
<b:Controls>
|
||||
<b:Controls ui:field="control_input_value">
|
||||
<b:InputAddOn addStyleNames="my-prepend-width"
|
||||
prependText="Value:" ui:field="valueFieldPrepend">
|
||||
<b:TextBox addStyleNames="my-input-width" />
|
||||
<b:TextBox ui:field="field_input_value" addStyleNames="my-input-width" />
|
||||
</b:InputAddOn>
|
||||
</b:Controls>
|
||||
<b:Controls ui:field="control_select_value">
|
||||
<b:InputAddOn addStyleNames="my-prepend-width"
|
||||
prependText="Values:" ui:field="valuesSelectPrepend">
|
||||
<b:ListBox name="Select the value of Parameter..." b:id="field_select_value"
|
||||
ui:field="field_select_value" addStyleNames="my-input-width">
|
||||
</b:ListBox>
|
||||
</b:InputAddOn>
|
||||
</b:Controls>
|
||||
<b:Controls>
|
||||
|
|
Loading…
Reference in New Issue