2016-04-06 18:28:32 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2016-04-08 20:34:05 +02:00
|
|
|
package org.gcube.portlets.user.dataminermanager.client.parametersfield;
|
2016-04-06 18:28:32 +02:00
|
|
|
|
2018-05-03 16:24:26 +02:00
|
|
|
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.EnumParameter;
|
|
|
|
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
2016-04-06 18:28:32 +02:00
|
|
|
|
|
|
|
import com.google.gwt.user.client.ui.Widget;
|
|
|
|
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
|
2016-04-11 20:27:14 +02:00
|
|
|
import com.sencha.gxt.core.client.util.Margins;
|
2016-04-06 18:28:32 +02:00
|
|
|
import com.sencha.gxt.data.shared.StringLabelProvider;
|
2016-04-11 20:27:14 +02:00
|
|
|
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
|
|
|
|
import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer;
|
|
|
|
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
|
|
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
|
|
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
|
2016-04-06 18:28:32 +02:00
|
|
|
import com.sencha.gxt.widget.core.client.form.SimpleComboBox;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2017-05-12 11:58:15 +02:00
|
|
|
* @author Giancarlo Panichi
|
|
|
|
*
|
2016-04-06 18:28:32 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
public class EnumFld extends AbstractFld {
|
|
|
|
|
2016-04-11 20:27:14 +02:00
|
|
|
private SimpleContainer fieldContainer;
|
2016-04-06 18:28:32 +02:00
|
|
|
private SimpleComboBox<String> listBox;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param parameter
|
2017-05-12 11:58:15 +02:00
|
|
|
* parameter
|
2016-04-06 18:28:32 +02:00
|
|
|
*/
|
|
|
|
public EnumFld(Parameter parameter) {
|
|
|
|
super(parameter);
|
2016-04-11 20:27:14 +02:00
|
|
|
fieldContainer = new SimpleContainer();
|
|
|
|
HBoxLayoutContainer horiz = new HBoxLayoutContainer();
|
|
|
|
horiz.setPack(BoxLayoutPack.START);
|
|
|
|
horiz.setEnableOverflow(false);
|
2016-04-06 18:28:32 +02:00
|
|
|
|
|
|
|
EnumParameter p = (EnumParameter) parameter;
|
|
|
|
|
|
|
|
listBox = new SimpleComboBox<String>(new StringLabelProvider<>());
|
|
|
|
listBox.add(p.getValues());
|
|
|
|
listBox.setAllowBlank(false);
|
|
|
|
listBox.setForceSelection(true);
|
|
|
|
listBox.setEditable(false);
|
|
|
|
listBox.setTriggerAction(TriggerAction.ALL);
|
2016-04-11 20:27:14 +02:00
|
|
|
|
2016-04-06 18:28:32 +02:00
|
|
|
if (p.getDefaultValue() != null)
|
|
|
|
listBox.setValue(p.getDefaultValue());
|
2016-04-11 20:27:14 +02:00
|
|
|
|
|
|
|
HtmlLayoutContainer descr;
|
|
|
|
|
|
|
|
if (p.getDescription() == null) {
|
2016-06-27 10:07:43 +02:00
|
|
|
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'></p>");
|
2016-04-11 20:27:14 +02:00
|
|
|
descr.addStyleName("workflow-fieldDescription");
|
|
|
|
|
|
|
|
} else {
|
2017-05-12 11:58:15 +02:00
|
|
|
// listBox.setToolTip(p.getDescription());
|
|
|
|
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'>" + p.getDescription() + "</p>");
|
2016-04-11 20:27:14 +02:00
|
|
|
descr.addStyleName("workflow-fieldDescription");
|
|
|
|
}
|
|
|
|
horiz.add(listBox, new BoxLayoutData(new Margins()));
|
|
|
|
horiz.add(descr, new BoxLayoutData(new Margins()));
|
|
|
|
|
|
|
|
fieldContainer.add(horiz);
|
2016-05-03 18:03:00 +02:00
|
|
|
fieldContainer.forceLayout();
|
2016-04-11 20:27:14 +02:00
|
|
|
|
2016-04-06 18:28:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public String getValue() {
|
|
|
|
return listBox.getCurrentValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public Widget getWidget() {
|
2016-04-12 18:01:14 +02:00
|
|
|
return fieldContainer;
|
2016-04-06 18:28:32 +02:00
|
|
|
}
|
|
|
|
|
2016-04-12 18:01:14 +02:00
|
|
|
@Override
|
|
|
|
public boolean isValid() {
|
|
|
|
return listBox.isValid();
|
|
|
|
}
|
2017-05-12 11:58:15 +02:00
|
|
|
|
2016-04-06 18:28:32 +02:00
|
|
|
}
|