Added support to default value for ListParameter [#24026]
Before Width: | Height: | Size: 496 B After Width: | Height: | Size: 496 B |
Before Width: | Height: | Size: 99 B After Width: | Height: | Size: 99 B |
Before Width: | Height: | Size: 462 B After Width: | Height: | Size: 462 B |
Before Width: | Height: | Size: 99 B After Width: | Height: | Size: 99 B |
Before Width: | Height: | Size: 492 B After Width: | Height: | Size: 492 B |
Before Width: | Height: | Size: 120 B After Width: | Height: | Size: 120 B |
@ -0,0 +1,100 @@
|
||||
package org.gcube.portlets.user.dataminerexecutor.client.parametersfield;
|
||||
|
||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ObjectParameter;
|
||||
import org.gcube.portlets.user.dataminerexecutor.client.DataMinerExecutor;
|
||||
|
||||
import com.sencha.gxt.core.client.util.Margins;
|
||||
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
||||
import com.sencha.gxt.widget.core.client.form.TextField;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class StringItem extends HBoxLayoutContainer {
|
||||
private ListStringFld parent;
|
||||
private TextField field;
|
||||
private TextButton addBtn;
|
||||
private TextButton removeBtn;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param parent parend
|
||||
* @param objectParameter object parameter
|
||||
* @param first true if is first
|
||||
*/
|
||||
public StringItem(ListStringFld parent, ObjectParameter objectParameter, boolean first) {
|
||||
super();
|
||||
this.parent=parent;
|
||||
create(objectParameter,first);
|
||||
}
|
||||
|
||||
private void create( ObjectParameter objectParameter, boolean first){
|
||||
field = new TextField();
|
||||
field.setAllowBlank(false);
|
||||
|
||||
if(objectParameter!=null && objectParameter.getDefaultValue()!=null &&
|
||||
!objectParameter.getDefaultValue().isEmpty()) {
|
||||
field.setValue(objectParameter.getDefaultValue());
|
||||
}
|
||||
|
||||
addBtn = new TextButton("");
|
||||
|
||||
addBtn.setIcon(DataMinerExecutor.resources.add());
|
||||
|
||||
addBtn.addSelectHandler(new SelectEvent.SelectHandler() {
|
||||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
parent.addField(StringItem.this);
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
removeBtn = new TextButton("");
|
||||
|
||||
removeBtn.setIcon(DataMinerExecutor.resources.cancel());
|
||||
|
||||
removeBtn.addSelectHandler(new SelectEvent.SelectHandler() {
|
||||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
parent.removeField(StringItem.this);
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
removeBtn.setVisible(!first);
|
||||
|
||||
setPack(BoxLayoutPack.START);
|
||||
setEnableOverflow(false);
|
||||
add(field, new BoxLayoutData(new Margins()));
|
||||
add(addBtn, new BoxLayoutData(new Margins()));
|
||||
add(removeBtn, new BoxLayoutData(new Margins()));
|
||||
|
||||
forceLayout();
|
||||
}
|
||||
|
||||
public void showCancelButton() {
|
||||
removeBtn.setVisible(true);
|
||||
}
|
||||
|
||||
public void hideCancelButton() {
|
||||
removeBtn.setVisible(false);
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return field.getCurrentValue();
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return field.isValid();
|
||||
}
|
||||
|
||||
}
|
Before Width: | Height: | Size: 733 B After Width: | Height: | Size: 733 B |
Before Width: | Height: | Size: 137 B After Width: | Height: | Size: 137 B |
Before Width: | Height: | Size: 293 B After Width: | Height: | Size: 293 B |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 723 B After Width: | Height: | Size: 723 B |
Before Width: | Height: | Size: 271 B After Width: | Height: | Size: 271 B |
Before Width: | Height: | Size: 349 B After Width: | Height: | Size: 349 B |
Before Width: | Height: | Size: 587 B After Width: | Height: | Size: 587 B |