Initial import.
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-executor@176691 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1630f645c1
commit
6fd062f35f
|
@ -1,184 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.gcube.portlets.user.dataminerexecutor.client.parametersfield;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.ColumnItem;
|
|
||||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.TableItemSimple;
|
|
||||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ColumnParameter;
|
|
||||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
|
||||||
import org.gcube.portlets.user.dataminerexecutor.client.events.TabularFldChangeEvent;
|
|
||||||
import org.gcube.portlets.user.dataminerexecutor.client.events.TabularFldChangeEvent.TabularFldChangeEventHandler;
|
|
||||||
import org.gcube.portlets.user.dataminerexecutor.client.properties.ColumnItemPropertiesCombo;
|
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
|
||||||
import com.google.gwt.core.client.GWT;
|
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
|
||||||
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
|
|
||||||
import com.sencha.gxt.core.client.util.Format;
|
|
||||||
import com.sencha.gxt.core.client.util.Margins;
|
|
||||||
import com.sencha.gxt.data.shared.ListStore;
|
|
||||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
|
||||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
|
|
||||||
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.VerticalLayoutContainer;
|
|
||||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
|
||||||
import com.sencha.gxt.widget.core.client.form.ComboBox;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Giancarlo Panichi
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ColumnFld extends AbstractFld implements
|
|
||||||
TabularFldChangeEventHandler {
|
|
||||||
|
|
||||||
private String defaultColumn;
|
|
||||||
private ComboBox<ColumnItem> comboBox;
|
|
||||||
private ListStore<ColumnItem> store;
|
|
||||||
private String referredTabularParameterName;
|
|
||||||
|
|
||||||
private SimpleContainer fieldContainer;
|
|
||||||
private SimpleContainer vContainer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param parameter parameter
|
|
||||||
*/
|
|
||||||
public ColumnFld(Parameter parameter) {
|
|
||||||
super(parameter);
|
|
||||||
|
|
||||||
ColumnParameter columnParameter = (ColumnParameter) parameter;
|
|
||||||
|
|
||||||
referredTabularParameterName = columnParameter
|
|
||||||
.getReferredTabularParameterName();
|
|
||||||
defaultColumn = columnParameter.getDefaultColumn();
|
|
||||||
|
|
||||||
fieldContainer = new SimpleContainer();
|
|
||||||
HBoxLayoutContainer horiz = new HBoxLayoutContainer();
|
|
||||||
horiz.setPack(BoxLayoutPack.START);
|
|
||||||
horiz.setEnableOverflow(false);
|
|
||||||
|
|
||||||
ColumnItemPropertiesCombo props = GWT
|
|
||||||
.create(ColumnItemPropertiesCombo.class);
|
|
||||||
|
|
||||||
store = new ListStore<ColumnItem>(props.id());
|
|
||||||
|
|
||||||
comboBox = new ComboBox<ColumnItem>(store, props.label());
|
|
||||||
comboBox.setAllowBlank(false);
|
|
||||||
comboBox.setForceSelection(true);
|
|
||||||
comboBox.setEditable(false);
|
|
||||||
comboBox.setTriggerAction(TriggerAction.ALL);
|
|
||||||
comboBox.setEnabled(false);
|
|
||||||
HtmlLayoutContainer descr;
|
|
||||||
|
|
||||||
if (columnParameter.getDescription() == null) {
|
|
||||||
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'></p>");
|
|
||||||
descr.addStyleName("workflow-fieldDescription");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
//comboBox.setToolTip(columnParameter.getDescription());
|
|
||||||
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'>"
|
|
||||||
+ columnParameter.getDescription() + "</p>");
|
|
||||||
descr.addStyleName("workflow-fieldDescription");
|
|
||||||
}
|
|
||||||
|
|
||||||
vContainer = new SimpleContainer();
|
|
||||||
showNoSelectionField();
|
|
||||||
horiz.add(vContainer, new BoxLayoutData(new Margins()));
|
|
||||||
horiz.add(descr, new BoxLayoutData(new Margins()));
|
|
||||||
|
|
||||||
fieldContainer.add(horiz);
|
|
||||||
fieldContainer.forceLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showNoSelectionField() {
|
|
||||||
vContainer.clear();
|
|
||||||
VerticalLayoutContainer vField = new VerticalLayoutContainer();
|
|
||||||
HtmlLayoutContainer typeDescription = new HtmlLayoutContainer(
|
|
||||||
"<div class='workflow-parameters-description'><p>Select table from parameter "
|
|
||||||
+ Format.ellipse(referredTabularParameterName, 30)
|
|
||||||
+ "</p></div>");
|
|
||||||
typeDescription.setStylePrimaryName("workflow-parameters-description");
|
|
||||||
vField.add(comboBox, new VerticalLayoutData(1, -1, new Margins(0)));
|
|
||||||
vField.add(typeDescription, new VerticalLayoutData(-1, -1, new Margins(
|
|
||||||
0)));
|
|
||||||
vContainer.add(vField);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showFieldWithSelection(TableItemSimple tableItem) {
|
|
||||||
vContainer.clear();
|
|
||||||
VerticalLayoutContainer vField = new VerticalLayoutContainer();
|
|
||||||
HtmlLayoutContainer typeDescription = new HtmlLayoutContainer(
|
|
||||||
"<div class='workflow-parameters-description'><p>Columns of Table "
|
|
||||||
+ Format.ellipse(tableItem.getName(), 30)
|
|
||||||
+ "</p></div>");
|
|
||||||
typeDescription.setStylePrimaryName("workflow-parameters-description");
|
|
||||||
vField.add(comboBox, new VerticalLayoutData(1, -1, new Margins(0)));
|
|
||||||
vField.add(typeDescription, new VerticalLayoutData(-1, -1, new Margins(
|
|
||||||
0)));
|
|
||||||
vContainer.add(vField);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String getValue() {
|
|
||||||
ColumnItem columnItem = comboBox.getCurrentValue();
|
|
||||||
return columnItem != null ? columnItem.getName() : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Widget getWidget() {
|
|
||||||
return fieldContainer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValid() {
|
|
||||||
return comboBox.isValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onChange(TabularFldChangeEvent event) {
|
|
||||||
TableItemSimple tableItemSimple = event.getTableItemSimple();
|
|
||||||
if (tableItemSimple == null) {
|
|
||||||
store.clear();
|
|
||||||
store.commitChanges();
|
|
||||||
comboBox.clear();
|
|
||||||
comboBox.setEnabled(false);
|
|
||||||
showNoSelectionField();
|
|
||||||
} else {
|
|
||||||
store.clear();
|
|
||||||
store.commitChanges();
|
|
||||||
comboBox.clear();
|
|
||||||
ArrayList<ColumnItem> columns = tableItemSimple.getColumns();
|
|
||||||
if (columns != null) {
|
|
||||||
store.addAll(columns);
|
|
||||||
store.commitChanges();
|
|
||||||
Log.debug("DefaultColumn: "+defaultColumn);
|
|
||||||
for (ColumnItem columnItem : columns) {
|
|
||||||
Log.debug("ColumnItem: "+ columnItem);
|
|
||||||
if (columnItem.getName().compareToIgnoreCase(defaultColumn) == 0) {
|
|
||||||
comboBox.setValue(columnItem);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
comboBox.setEnabled(true);
|
|
||||||
showFieldWithSelection(tableItemSimple);
|
|
||||||
}
|
|
||||||
fieldContainer.forceLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,94 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.gcube.portlets.user.dataminerexecutor.client.parametersfield;
|
|
||||||
|
|
||||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.EnumParameter;
|
|
||||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
|
||||||
|
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
|
||||||
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
|
|
||||||
import com.sencha.gxt.core.client.util.Margins;
|
|
||||||
import com.sencha.gxt.data.shared.StringLabelProvider;
|
|
||||||
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;
|
|
||||||
import com.sencha.gxt.widget.core.client.form.SimpleComboBox;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Giancarlo Panichi
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class EnumFld extends AbstractFld {
|
|
||||||
|
|
||||||
private SimpleContainer fieldContainer;
|
|
||||||
private SimpleComboBox<String> listBox;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param parameter
|
|
||||||
* parameter
|
|
||||||
*/
|
|
||||||
public EnumFld(Parameter parameter) {
|
|
||||||
super(parameter);
|
|
||||||
fieldContainer = new SimpleContainer();
|
|
||||||
HBoxLayoutContainer horiz = new HBoxLayoutContainer();
|
|
||||||
horiz.setPack(BoxLayoutPack.START);
|
|
||||||
horiz.setEnableOverflow(false);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
if (p.getDefaultValue() != null)
|
|
||||||
listBox.setValue(p.getDefaultValue());
|
|
||||||
|
|
||||||
HtmlLayoutContainer descr;
|
|
||||||
|
|
||||||
if (p.getDescription() == null) {
|
|
||||||
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'></p>");
|
|
||||||
descr.addStyleName("workflow-fieldDescription");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// listBox.setToolTip(p.getDescription());
|
|
||||||
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'>" + p.getDescription() + "</p>");
|
|
||||||
descr.addStyleName("workflow-fieldDescription");
|
|
||||||
}
|
|
||||||
horiz.add(listBox, new BoxLayoutData(new Margins()));
|
|
||||||
horiz.add(descr, new BoxLayoutData(new Margins()));
|
|
||||||
|
|
||||||
fieldContainer.add(horiz);
|
|
||||||
fieldContainer.forceLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String getValue() {
|
|
||||||
return listBox.getCurrentValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Widget getWidget() {
|
|
||||||
return fieldContainer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValid() {
|
|
||||||
return listBox.isValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -4,10 +4,14 @@
|
||||||
package org.gcube.portlets.user.dataminerexecutor.client.parametersfield;
|
package org.gcube.portlets.user.dataminerexecutor.client.parametersfield;
|
||||||
|
|
||||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
||||||
|
import org.gcube.portlets.user.dataminerexecutor.client.DataMinerExecutor;
|
||||||
|
import org.gcube.portlets.user.dataminerexecutor.client.util.UtilsGXT3;
|
||||||
|
import org.gcube.portlets.user.dataminerexecutor.client.workspace.DownloadWidget;
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
import com.sencha.gxt.core.client.util.Margins;
|
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.BoxLayoutContainer.BoxLayoutData;
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
||||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
|
||||||
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
|
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
|
||||||
|
@ -15,6 +19,7 @@ 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.SimpleContainer;
|
||||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -25,10 +30,8 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.Verti
|
||||||
public class FileFld extends AbstractFld {
|
public class FileFld extends AbstractFld {
|
||||||
|
|
||||||
private SimpleContainer fieldContainer;
|
private SimpleContainer fieldContainer;
|
||||||
//private TextField textField;
|
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param parameter
|
* @param parameter
|
||||||
* parameter
|
* parameter
|
||||||
|
@ -36,33 +39,43 @@ public class FileFld extends AbstractFld {
|
||||||
public FileFld(Parameter parameter) {
|
public FileFld(Parameter parameter) {
|
||||||
super(parameter);
|
super(parameter);
|
||||||
|
|
||||||
//ObjectParameter p = (ObjectParameter) parameter;
|
Log.debug("Create File field: " + parameter.getName());
|
||||||
Log.debug("Create File field: "+parameter.getName());
|
value = parameter.getValue();
|
||||||
value=parameter.getValue();
|
|
||||||
|
// Description
|
||||||
HtmlLayoutContainer descr;
|
HtmlLayoutContainer descr;
|
||||||
|
|
||||||
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'></p>");
|
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'></p>");
|
||||||
descr.addStyleName("workflow-fieldDescription");
|
descr.addStyleName("workflow-fieldDescription");
|
||||||
|
|
||||||
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'>" + parameter.getDescription() + "</p>");
|
descr = new HtmlLayoutContainer(
|
||||||
|
"<p style='margin-left:5px !important;'>" + parameter.getDescription() + "</p>");
|
||||||
descr.addStyleName("workflow-fieldDescription");
|
descr.addStyleName("workflow-fieldDescription");
|
||||||
|
|
||||||
|
// Value
|
||||||
|
TextButton downloadButton = new TextButton("");
|
||||||
|
downloadButton.setIcon(DataMinerExecutor.resources.download());
|
||||||
|
downloadButton.setTitle(value);
|
||||||
|
downloadButton.addSelectHandler(new SelectEvent.SelectHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
downloadUrl();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
SimpleContainer dataContainer = new SimpleContainer();
|
||||||
|
dataContainer.addStyleName("workflow-fieldValue");
|
||||||
|
dataContainer.add(downloadButton);
|
||||||
|
|
||||||
|
//
|
||||||
SimpleContainer vContainer = new SimpleContainer();
|
SimpleContainer vContainer = new SimpleContainer();
|
||||||
VerticalLayoutContainer vField = new VerticalLayoutContainer();
|
VerticalLayoutContainer vField = new VerticalLayoutContainer();
|
||||||
|
|
||||||
HtmlLayoutContainer typeDescription = new HtmlLayoutContainer("File Value");
|
HtmlLayoutContainer typeDescription = new HtmlLayoutContainer("File Value");
|
||||||
typeDescription.setStylePrimaryName("workflow-parameters-description");
|
typeDescription.setStylePrimaryName("workflow-parameters-description");
|
||||||
|
|
||||||
//textField = new TextField();
|
vField.add(dataContainer, new VerticalLayoutData(-1, -1, new Margins(0)));
|
||||||
//textField.setValue(p.getValue());
|
|
||||||
//textField.isReadOnly();
|
|
||||||
|
|
||||||
HtmlLayoutContainer val = new HtmlLayoutContainer("<span style='overflow-wrap: break-word;'><a href='" + parameter.getValue() + "'>File</a></span>");
|
|
||||||
val.addStyleName("workflow-fieldValue");
|
|
||||||
|
|
||||||
|
|
||||||
vField.add(val, new VerticalLayoutData(-1, -1, new Margins(0)));
|
|
||||||
|
|
||||||
vField.add(typeDescription, new VerticalLayoutData(-1, -1, new Margins(0)));
|
vField.add(typeDescription, new VerticalLayoutData(-1, -1, new Margins(0)));
|
||||||
vContainer.add(vField);
|
vContainer.add(vField);
|
||||||
|
|
||||||
|
@ -79,6 +92,15 @@ public class FileFld extends AbstractFld {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void downloadUrl() {
|
||||||
|
if (value != null) {
|
||||||
|
DownloadWidget downloadWidget = new DownloadWidget();
|
||||||
|
downloadWidget.downloadUrl(value);
|
||||||
|
} else {
|
||||||
|
UtilsGXT3.info("Attention", "The url is invalid: " + value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -100,7 +122,7 @@ public class FileFld extends AbstractFld {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
if(value!=null&&!value.isEmpty()){
|
if (value != null && !value.isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,238 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.gcube.portlets.user.dataminerexecutor.client.parametersfield;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ListParameter;
|
|
||||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ObjectParameter;
|
|
||||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
|
||||||
import org.gcube.portlets.user.dataminerexecutor.client.DataMinerExecutor;
|
|
||||||
|
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
|
||||||
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.BoxLayoutContainer.BoxLayoutData;
|
|
||||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
|
|
||||||
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.MarginData;
|
|
||||||
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
|
||||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
|
||||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
|
||||||
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
|
||||||
import com.sencha.gxt.widget.core.client.form.IntegerField;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Giancarlo Panichi
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ListIntFld extends AbstractFld {
|
|
||||||
|
|
||||||
private List<Item> items;
|
|
||||||
private SimpleContainer simpleContainer;
|
|
||||||
private VerticalLayoutContainer vp;
|
|
||||||
private ListParameter listParameter;
|
|
||||||
private SimpleContainer listContainer;
|
|
||||||
private SimpleContainer fieldContainer;
|
|
||||||
private HBoxLayoutContainer horiz;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param parameter
|
|
||||||
* parameter
|
|
||||||
*/
|
|
||||||
public ListIntFld(Parameter parameter) {
|
|
||||||
super(parameter);
|
|
||||||
this.listParameter = (ListParameter) parameter;
|
|
||||||
|
|
||||||
listContainer = new SimpleContainer();
|
|
||||||
vp = new VerticalLayoutContainer();
|
|
||||||
items = new ArrayList<Item>();
|
|
||||||
addField(null);
|
|
||||||
listContainer.add(vp, new MarginData(new Margins()));
|
|
||||||
|
|
||||||
fieldContainer = new SimpleContainer();
|
|
||||||
horiz = new HBoxLayoutContainer();
|
|
||||||
horiz.setPack(BoxLayoutPack.START);
|
|
||||||
horiz.setEnableOverflow(false);
|
|
||||||
|
|
||||||
HtmlLayoutContainer descr;
|
|
||||||
|
|
||||||
if (listParameter.getDescription() == null) {
|
|
||||||
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'></p>");
|
|
||||||
descr.addStyleName("workflow-fieldDescription");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// listContainer.setToolTip(listParameter.getDescription());
|
|
||||||
descr = new HtmlLayoutContainer(
|
|
||||||
"<p style='margin-left:5px !important;'>" + listParameter.getDescription() + "</p>");
|
|
||||||
descr.addStyleName("workflow-fieldDescription");
|
|
||||||
}
|
|
||||||
|
|
||||||
horiz.add(listContainer, new BoxLayoutData(new Margins(0)));
|
|
||||||
horiz.add(descr, new BoxLayoutData(new Margins(0)));
|
|
||||||
|
|
||||||
fieldContainer.add(horiz);
|
|
||||||
fieldContainer.forceLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addField(Item upperItem) {
|
|
||||||
|
|
||||||
ObjectParameter objPar = new ObjectParameter(listParameter.getName(), listParameter.getDescription(),
|
|
||||||
listParameter.getType(), null);
|
|
||||||
|
|
||||||
if (upperItem == null) {
|
|
||||||
Item item = new Item(objPar, true);
|
|
||||||
items.add(item);
|
|
||||||
vp.add(item, new VerticalLayoutData(1, -1, new Margins()));
|
|
||||||
} else {
|
|
||||||
// search the position of the upper item
|
|
||||||
int pos = 0;
|
|
||||||
for (int i = 0; i < items.size(); i++)
|
|
||||||
if (items.get(i) == upperItem) {
|
|
||||||
pos = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
upperItem.showCancelButton();
|
|
||||||
Item item = new Item(objPar, false);
|
|
||||||
items.add(pos + 1, item);
|
|
||||||
vp.insert(item, pos + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param item
|
|
||||||
*/
|
|
||||||
private void removeField(Item item) {
|
|
||||||
items.remove(item);
|
|
||||||
|
|
||||||
vp.remove(item);
|
|
||||||
|
|
||||||
if (items.size() == 1) {
|
|
||||||
items.get(0).hideCancelButton();
|
|
||||||
}
|
|
||||||
|
|
||||||
simpleContainer.forceLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String getValue() {
|
|
||||||
String separator = listParameter.getSeparator();
|
|
||||||
String value = "";
|
|
||||||
boolean first = true;
|
|
||||||
for (Item item : items) {
|
|
||||||
Integer itemValue = item.getValue();
|
|
||||||
if (itemValue != null) {
|
|
||||||
value += (first ? "" : separator) + itemValue;
|
|
||||||
first = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Widget getWidget() {
|
|
||||||
return fieldContainer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isValid() {
|
|
||||||
for (Item item : items)
|
|
||||||
if (!item.isValid()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class Item extends HBoxLayoutContainer {
|
|
||||||
|
|
||||||
private IntegerField field;
|
|
||||||
private TextButton addBtn;
|
|
||||||
private TextButton removeBtn;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param objPar
|
|
||||||
*/
|
|
||||||
public Item(ObjectParameter objectParameter, boolean first) {
|
|
||||||
super();
|
|
||||||
|
|
||||||
field = new IntegerField();
|
|
||||||
field.setAllowBlank(false);
|
|
||||||
|
|
||||||
addBtn = new TextButton("");
|
|
||||||
|
|
||||||
addBtn.setIcon(DataMinerExecutor.resources.add());
|
|
||||||
|
|
||||||
addBtn.addSelectHandler(new SelectEvent.SelectHandler() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSelect(SelectEvent event) {
|
|
||||||
addField(Item.this);
|
|
||||||
forceLayout();
|
|
||||||
vp.forceLayout();
|
|
||||||
fieldContainer.forceLayout();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
removeBtn = new TextButton("");
|
|
||||||
|
|
||||||
removeBtn.setIcon(DataMinerExecutor.resources.cancel());
|
|
||||||
|
|
||||||
removeBtn.addSelectHandler(new SelectEvent.SelectHandler() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSelect(SelectEvent event) {
|
|
||||||
removeField(Item.this);
|
|
||||||
forceLayout();
|
|
||||||
vp.forceLayout();
|
|
||||||
fieldContainer.forceLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
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 Integer getValue() {
|
|
||||||
return field.getCurrentValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isValid() {
|
|
||||||
return field.isValid();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -3,22 +3,20 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.user.dataminerexecutor.client.parametersfield;
|
package org.gcube.portlets.user.dataminerexecutor.client.parametersfield;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ListParameter;
|
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ListParameter;
|
||||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.ObjectParameter;
|
|
||||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
import com.sencha.gxt.core.client.util.Margins;
|
import com.sencha.gxt.core.client.util.Margins;
|
||||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
||||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
|
||||||
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
|
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.HtmlLayoutContainer;
|
||||||
import com.sencha.gxt.widget.core.client.container.MarginData;
|
|
||||||
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
||||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -29,101 +27,75 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||||
public class ListStringFld extends AbstractFld {
|
public class ListStringFld extends AbstractFld {
|
||||||
|
|
||||||
private SimpleContainer fieldContainer;
|
private SimpleContainer fieldContainer;
|
||||||
private HBoxLayoutContainer horiz;
|
// private TextField textField;
|
||||||
private SimpleContainer listContainer;
|
private String value;
|
||||||
private VerticalLayoutContainer vp;
|
|
||||||
private List<StringItem> items;
|
|
||||||
private ListParameter listParameter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param parameter
|
* @param parameter
|
||||||
* parameter
|
* parameter
|
||||||
*/
|
*/
|
||||||
public ListStringFld(Parameter parameter) {
|
public ListStringFld(Parameter parameter) {
|
||||||
super(parameter);
|
super(parameter);
|
||||||
|
|
||||||
listParameter = (ListParameter) parameter;
|
// ObjectParameter p = (ObjectParameter) parameter;
|
||||||
|
Log.debug("Create String List field: " + parameter.getName());
|
||||||
|
value = parameter.getValue();
|
||||||
|
|
||||||
listContainer = new SimpleContainer();
|
ListParameter listParameter = (ListParameter) parameter;
|
||||||
vp = new VerticalLayoutContainer();
|
|
||||||
items = new ArrayList<StringItem>();
|
|
||||||
listContainer.add(vp, new MarginData(new Margins()));
|
|
||||||
|
|
||||||
fieldContainer = new SimpleContainer();
|
StringBuilder columnListHtml = new StringBuilder();
|
||||||
horiz = new HBoxLayoutContainer();
|
String tempValue = new String(value);
|
||||||
horiz.setPack(BoxLayoutPack.START);
|
int pos = tempValue.indexOf(listParameter.getSeparator());
|
||||||
horiz.setEnableOverflow(false);
|
while (pos > -1) {
|
||||||
|
SafeHtmlBuilder safeValue = new SafeHtmlBuilder();
|
||||||
|
safeValue.appendEscaped(tempValue.substring(0, pos));
|
||||||
|
columnListHtml.append("<span style='display:block;overflow-wrap: break-word;'>"
|
||||||
|
+ safeValue.toSafeHtml().asString() + "</span>");
|
||||||
|
tempValue = tempValue.substring(pos + 1, tempValue.length());
|
||||||
|
pos = tempValue.indexOf(listParameter.getSeparator());
|
||||||
|
}
|
||||||
|
if (tempValue != null && !tempValue.isEmpty()) {
|
||||||
|
SafeHtmlBuilder safeValue = new SafeHtmlBuilder();
|
||||||
|
safeValue.appendEscaped(tempValue);
|
||||||
|
columnListHtml.append("<span style='display:block;overflow-wrap: break-word;'>"
|
||||||
|
+ safeValue.toSafeHtml().asString() + "</span>");
|
||||||
|
} else {
|
||||||
|
columnListHtml.append("<span style='display:block;overflow-wrap: break-word;'></span>");
|
||||||
|
}
|
||||||
|
|
||||||
HtmlLayoutContainer descr;
|
HtmlLayoutContainer descr;
|
||||||
|
|
||||||
if (listParameter.getDescription() == null) {
|
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'></p>");
|
||||||
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'></p>");
|
descr.addStyleName("workflow-fieldDescription");
|
||||||
descr.addStyleName("workflow-fieldDescription");
|
|
||||||
|
|
||||||
} else {
|
descr = new HtmlLayoutContainer(
|
||||||
/* listContainer.setToolTip(listParameter.getDescription()); */
|
"<p style='margin-left:5px !important;'>" + parameter.getDescription() + "</p>");
|
||||||
descr = new HtmlLayoutContainer(
|
descr.addStyleName("workflow-fieldDescription");
|
||||||
"<p style='margin-left:5px !important;'>" + listParameter.getDescription() + "</p>");
|
|
||||||
descr.addStyleName("workflow-fieldDescription");
|
|
||||||
}
|
|
||||||
|
|
||||||
horiz.add(listContainer, new BoxLayoutData(new Margins(0)));
|
SimpleContainer vContainer = new SimpleContainer();
|
||||||
horiz.add(descr, new BoxLayoutData(new Margins(0)));
|
VerticalLayoutContainer vField = new VerticalLayoutContainer();
|
||||||
|
HtmlLayoutContainer typeDescription = new HtmlLayoutContainer("");
|
||||||
|
typeDescription.setStylePrimaryName("workflow-parameters-description");
|
||||||
|
|
||||||
|
HtmlLayoutContainer val = new HtmlLayoutContainer(columnListHtml.toString());
|
||||||
|
val.addStyleName("workflow-fieldValue");
|
||||||
|
|
||||||
|
vField.add(val, new VerticalLayoutData(-1, -1, new Margins(0)));
|
||||||
|
|
||||||
|
vField.add(typeDescription, new VerticalLayoutData(-1, -1, new Margins(0)));
|
||||||
|
vContainer.add(vField);
|
||||||
|
|
||||||
|
fieldContainer = new SimpleContainer();
|
||||||
|
HBoxLayoutContainer horiz = new HBoxLayoutContainer();
|
||||||
|
horiz.setPack(BoxLayoutPack.START);
|
||||||
|
horiz.setEnableOverflow(false);
|
||||||
|
|
||||||
|
horiz.add(vContainer, new BoxLayoutData(new Margins()));
|
||||||
|
horiz.add(descr, new BoxLayoutData(new Margins()));
|
||||||
|
|
||||||
fieldContainer.add(horiz);
|
fieldContainer.add(horiz);
|
||||||
addField(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void addField(StringItem upperItem) {
|
|
||||||
|
|
||||||
ObjectParameter objPar = new ObjectParameter(listParameter.getName(), listParameter.getDescription(),
|
|
||||||
listParameter.getType(), null);
|
|
||||||
|
|
||||||
if (upperItem == null) {
|
|
||||||
StringItem item = new StringItem(this, objPar, true);
|
|
||||||
items.add(item);
|
|
||||||
vp.add(item);
|
|
||||||
} else {
|
|
||||||
// search the position of the upper item
|
|
||||||
int pos = items.indexOf(upperItem);
|
|
||||||
if (pos > -1) {
|
|
||||||
upperItem.showCancelButton();
|
|
||||||
upperItem.forceLayout();
|
|
||||||
StringItem item = new StringItem(this, objPar, false);
|
|
||||||
items.add(pos + 1, item);
|
|
||||||
vp.insert(item, pos + 1);// don't use new VerticalLayoutData(1,
|
|
||||||
// -1,new Margins(0))
|
|
||||||
} else {
|
|
||||||
upperItem.forceLayout();
|
|
||||||
StringItem item = new StringItem(this, objPar, true);
|
|
||||||
items.add(item);
|
|
||||||
vp.add(item);// don't use new VerticalLayoutData(-1, -1, new
|
|
||||||
// Margins(0))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
forceLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void forceLayout() {
|
|
||||||
vp.forceLayout();
|
|
||||||
horiz.forceLayout();
|
|
||||||
fieldContainer.forceLayout();
|
fieldContainer.forceLayout();
|
||||||
}
|
|
||||||
|
|
||||||
protected void removeField(StringItem item) {
|
|
||||||
items.remove(item);
|
|
||||||
|
|
||||||
vp.remove(item);
|
|
||||||
|
|
||||||
if (items.size() == 1) {
|
|
||||||
items.get(0).hideCancelButton();
|
|
||||||
items.get(0).forceLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
forceLayout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,16 +103,6 @@ public class ListStringFld extends AbstractFld {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
String separator = listParameter.getSeparator();
|
|
||||||
String value = "";
|
|
||||||
boolean first = true;
|
|
||||||
for (StringItem item : items) {
|
|
||||||
String itemValue = item.getValue();
|
|
||||||
if (itemValue != null && !itemValue.contentEquals("")) {
|
|
||||||
value += (first ? "" : separator) + itemValue;
|
|
||||||
first = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,18 +114,13 @@ public class ListStringFld extends AbstractFld {
|
||||||
return fieldContainer;
|
return fieldContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
boolean valid = false;
|
if (value != null && !value.isEmpty()) {
|
||||||
for (StringItem item : items)
|
return true;
|
||||||
if (item.isValid()) {
|
} else {
|
||||||
valid = true;
|
return false;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
return valid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,95 +0,0 @@
|
||||||
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);
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,264 +0,0 @@
|
||||||
package org.gcube.portlets.user.dataminerexecutor.client.parametersfield;
|
|
||||||
|
|
||||||
import org.gcube.data.analysis.dataminermanagercl.shared.data.TableItemSimple;
|
|
||||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.TabularParameter;
|
|
||||||
import org.gcube.data.analysis.dataminermanagercl.shared.workspace.ItemDescription;
|
|
||||||
import org.gcube.portlets.user.dataminerexecutor.client.DataMinerExecutor;
|
|
||||||
import org.gcube.portlets.user.dataminerexecutor.client.rpc.DataMinerExecutorServiceAsync;
|
|
||||||
import org.gcube.portlets.user.dataminerexecutor.client.util.UtilsGXT3;
|
|
||||||
import org.gcube.portlets.user.dataminerexecutor.client.workspace.DownloadWidget;
|
|
||||||
import org.gcube.portlets.user.dataminerexecutor.shared.exception.SessionExpiredServiceException;
|
|
||||||
import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSelectNotification.WorskpaceExplorerSelectNotificationListener;
|
|
||||||
import org.gcube.portlets.widgets.wsexplorer.client.select.WorkspaceExplorerSelectDialog;
|
|
||||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
|
||||||
import org.gcube.portlets.widgets.wsexplorer.shared.ItemType;
|
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
||||||
import com.sencha.gxt.core.client.dom.XDOM;
|
|
||||||
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 TabItem extends HBoxLayoutContainer {
|
|
||||||
|
|
||||||
private TabularListFld parent;
|
|
||||||
private TextButton selectButton;
|
|
||||||
private TextButton selectButton2;
|
|
||||||
private TableItemSimple selectedTableItem;
|
|
||||||
private TextButton addBtn;
|
|
||||||
private TextButton removeBtn;
|
|
||||||
private TextField tableDescription;
|
|
||||||
private WorkspaceExplorerSelectDialog wselectDialog;
|
|
||||||
private TextButton downloadButton;
|
|
||||||
private ItemDescription itemDescriptionSelected;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param parent
|
|
||||||
* parent
|
|
||||||
* @param tabularParameter
|
|
||||||
* tabular parameter
|
|
||||||
* @param first
|
|
||||||
* true if is first
|
|
||||||
*/
|
|
||||||
public TabItem(TabularListFld parent, TabularParameter tabularParameter, boolean first) {
|
|
||||||
super();
|
|
||||||
this.parent = parent;
|
|
||||||
initDialog();
|
|
||||||
create(tabularParameter, first);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void create(TabularParameter tabularParameter, boolean first) {
|
|
||||||
|
|
||||||
tableDescription = new TextField();
|
|
||||||
tableDescription.setReadOnly(true);
|
|
||||||
tableDescription.setVisible(false);
|
|
||||||
|
|
||||||
selectButton = new TextButton("Select Data Set");
|
|
||||||
selectButton.addSelectHandler(new SelectEvent.SelectHandler() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSelect(SelectEvent event) {
|
|
||||||
wselectDialog.show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
selectButton.setIcon(DataMinerExecutor.resources.folderExplore());
|
|
||||||
selectButton.setToolTip("Select Data Set");
|
|
||||||
|
|
||||||
selectButton2 = new TextButton("");
|
|
||||||
selectButton2.setIcon(DataMinerExecutor.resources.folderExplore());
|
|
||||||
selectButton2.setToolTip("Select Another Data Set");
|
|
||||||
selectButton2.addSelectHandler(new SelectEvent.SelectHandler() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSelect(SelectEvent event) {
|
|
||||||
wselectDialog.show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
selectButton2.setVisible(false);
|
|
||||||
|
|
||||||
downloadButton = new TextButton("");
|
|
||||||
downloadButton.setIcon(DataMinerExecutor.resources.download());
|
|
||||||
downloadButton.addSelectHandler(new SelectEvent.SelectHandler() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSelect(SelectEvent event) {
|
|
||||||
downloadFile();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
downloadButton.setVisible(false);
|
|
||||||
|
|
||||||
addBtn = new TextButton("");
|
|
||||||
addBtn.setIcon(DataMinerExecutor.resources.add());
|
|
||||||
addBtn.addSelectHandler(new SelectEvent.SelectHandler() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSelect(SelectEvent event) {
|
|
||||||
parent.addField(TabItem.this);
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
removeBtn = new TextButton("");
|
|
||||||
removeBtn.setIcon(DataMinerExecutor.resources.cancel());
|
|
||||||
removeBtn.addSelectHandler(new SelectEvent.SelectHandler() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSelect(SelectEvent event) {
|
|
||||||
selectedTableItem = null;
|
|
||||||
parent.removeField(TabItem.this);
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
removeBtn.setVisible(!first);
|
|
||||||
|
|
||||||
setPack(BoxLayoutPack.START);
|
|
||||||
setEnableOverflow(false);
|
|
||||||
|
|
||||||
add(tableDescription, new BoxLayoutData(new Margins()));
|
|
||||||
add(selectButton, new BoxLayoutData(new Margins()));
|
|
||||||
add(selectButton2, new BoxLayoutData(new Margins()));
|
|
||||||
add(downloadButton, new BoxLayoutData(new Margins()));
|
|
||||||
add(addBtn, new BoxLayoutData(new Margins()));
|
|
||||||
add(removeBtn, new BoxLayoutData(new Margins()));
|
|
||||||
|
|
||||||
forceLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initDialog() {
|
|
||||||
|
|
||||||
|
|
||||||
wselectDialog = new WorkspaceExplorerSelectDialog("Select CSV", false);
|
|
||||||
|
|
||||||
WorskpaceExplorerSelectNotificationListener handler = new WorskpaceExplorerSelectNotificationListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSelectedItem(Item item) {
|
|
||||||
|
|
||||||
if (item == null || item.getType() == ItemType.FOLDER
|
|
||||||
|| item.getType() == ItemType.PRIVATE_FOLDER
|
|
||||||
|| item.getType() == ItemType.SHARED_FOLDER
|
|
||||||
|| item.getType() == ItemType.VRE_FOLDER) {
|
|
||||||
UtilsGXT3.info("Attention", "Select a valid csv!");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
TabItem.this.retrieveTableInformation(item);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailed(Throwable throwable) {
|
|
||||||
Log.error("Error in create project: " + throwable.getLocalizedMessage());
|
|
||||||
UtilsGXT3.alert("Error", throwable.getLocalizedMessage());
|
|
||||||
throwable.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAborted() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNotValidSelection() {
|
|
||||||
UtilsGXT3.info("Attention", "Select a valid csv!");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
wselectDialog.addWorkspaceExplorerSelectNotificationListener(handler);
|
|
||||||
wselectDialog.setZIndex(XDOM.getTopZIndex());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void retrieveTableInformation(Item item) {
|
|
||||||
Log.debug("Retrieved: " + item);
|
|
||||||
itemDescriptionSelected = new ItemDescription(item.getId(), item.getName(), item.getOwner(), item.getPath(),
|
|
||||||
item.getType().name());
|
|
||||||
|
|
||||||
DataMinerExecutorServiceAsync.INSTANCE.retrieveTableInformation(itemDescriptionSelected, new AsyncCallback<TableItemSimple>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
Log.error("Error in retrieveTableInformation " + caught.getMessage());
|
|
||||||
if (caught instanceof SessionExpiredServiceException) {
|
|
||||||
UtilsGXT3.alert("Error", "Expired Session");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
UtilsGXT3.alert("Error", "Error retrieving table information: " + caught.getLocalizedMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSuccess(TableItemSimple result) {
|
|
||||||
Log.debug("Retrieved: " + result);
|
|
||||||
selectedTableItem = result;
|
|
||||||
showFieldWithSelection();
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void downloadFile() {
|
|
||||||
if (itemDescriptionSelected != null) {
|
|
||||||
DownloadWidget downloadWidget = new DownloadWidget();
|
|
||||||
downloadWidget.download(itemDescriptionSelected.getId());
|
|
||||||
} else {
|
|
||||||
UtilsGXT3.info("Attention", "Select a table!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private void showFieldWithSelection() {
|
|
||||||
try {
|
|
||||||
|
|
||||||
String tableName = selectedTableItem.getName();
|
|
||||||
|
|
||||||
if (tableName == null || tableName.isEmpty()) {
|
|
||||||
tableName = "NoName";
|
|
||||||
}
|
|
||||||
|
|
||||||
tableDescription.setValue(tableName);
|
|
||||||
tableDescription.setVisible(true);
|
|
||||||
selectButton.setVisible(false);
|
|
||||||
selectButton2.setVisible(true);
|
|
||||||
downloadButton.setVisible(true);
|
|
||||||
parent.forceLayout();
|
|
||||||
|
|
||||||
} catch (Throwable e) {
|
|
||||||
Log.error(e.getLocalizedMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showCancelButton() {
|
|
||||||
removeBtn.setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hideCancelButton() {
|
|
||||||
removeBtn.setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue() {
|
|
||||||
return (selectedTableItem == null) ? null : selectedTableItem.getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isValid() {
|
|
||||||
return (selectedTableItem != null);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -4,17 +4,23 @@
|
||||||
package org.gcube.portlets.user.dataminerexecutor.client.parametersfield;
|
package org.gcube.portlets.user.dataminerexecutor.client.parametersfield;
|
||||||
|
|
||||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
||||||
|
import org.gcube.portlets.user.dataminerexecutor.client.DataMinerExecutor;
|
||||||
|
import org.gcube.portlets.user.dataminerexecutor.client.util.UtilsGXT3;
|
||||||
|
import org.gcube.portlets.user.dataminerexecutor.client.workspace.DownloadWidget;
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
import com.sencha.gxt.core.client.util.Margins;
|
import com.sencha.gxt.core.client.util.Margins;
|
||||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
||||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
|
||||||
|
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.container.HBoxLayoutContainer;
|
||||||
import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer;
|
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.SimpleContainer;
|
||||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -25,10 +31,8 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.Verti
|
||||||
public class TabularFld extends AbstractFld {
|
public class TabularFld extends AbstractFld {
|
||||||
|
|
||||||
private SimpleContainer fieldContainer;
|
private SimpleContainer fieldContainer;
|
||||||
//private TextField textField;
|
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param parameter
|
* @param parameter
|
||||||
* parameter
|
* parameter
|
||||||
|
@ -36,33 +40,43 @@ public class TabularFld extends AbstractFld {
|
||||||
public TabularFld(Parameter parameter) {
|
public TabularFld(Parameter parameter) {
|
||||||
super(parameter);
|
super(parameter);
|
||||||
|
|
||||||
//ObjectParameter p = (ObjectParameter) parameter;
|
Log.debug("Create Tabular field: " + parameter.getName());
|
||||||
Log.debug("Create File field: "+parameter.getName());
|
value = parameter.getValue();
|
||||||
value=parameter.getValue();
|
|
||||||
|
// Description
|
||||||
HtmlLayoutContainer descr;
|
HtmlLayoutContainer descr;
|
||||||
|
|
||||||
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'></p>");
|
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'></p>");
|
||||||
descr.addStyleName("workflow-fieldDescription");
|
descr.addStyleName("workflow-fieldDescription");
|
||||||
|
|
||||||
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'>" + parameter.getDescription() + "</p>");
|
descr = new HtmlLayoutContainer(
|
||||||
|
"<p style='margin-left:5px !important;'>" + parameter.getDescription() + "</p>");
|
||||||
descr.addStyleName("workflow-fieldDescription");
|
descr.addStyleName("workflow-fieldDescription");
|
||||||
|
|
||||||
|
// Value
|
||||||
|
TextButton downloadButton = new TextButton("");
|
||||||
|
downloadButton.setIcon(DataMinerExecutor.resources.download());
|
||||||
|
downloadButton.setTitle(value);
|
||||||
|
downloadButton.addSelectHandler(new SelectEvent.SelectHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
downloadUrl();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
SimpleContainer dataContainer = new SimpleContainer();
|
||||||
|
dataContainer.addStyleName("workflow-fieldValue");
|
||||||
|
dataContainer.add(downloadButton);
|
||||||
|
|
||||||
|
//
|
||||||
SimpleContainer vContainer = new SimpleContainer();
|
SimpleContainer vContainer = new SimpleContainer();
|
||||||
VerticalLayoutContainer vField = new VerticalLayoutContainer();
|
VerticalLayoutContainer vField = new VerticalLayoutContainer();
|
||||||
|
|
||||||
HtmlLayoutContainer typeDescription = new HtmlLayoutContainer("Table Value");
|
HtmlLayoutContainer typeDescription = new HtmlLayoutContainer("Table Value");
|
||||||
typeDescription.setStylePrimaryName("workflow-parameters-description");
|
typeDescription.setStylePrimaryName("workflow-parameters-description");
|
||||||
|
|
||||||
//textField = new TextField();
|
vField.add(dataContainer, new VerticalLayoutData(-1, -1, new Margins(0)));
|
||||||
//textField.setValue(p.getValue());
|
|
||||||
//textField.isReadOnly();
|
|
||||||
|
|
||||||
HtmlLayoutContainer val = new HtmlLayoutContainer("<span style='overflow-wrap: break-word;'><a href='" + parameter.getValue() + "'>Table</a></span>");
|
|
||||||
val.addStyleName("workflow-fieldValue");
|
|
||||||
|
|
||||||
|
|
||||||
vField.add(val, new VerticalLayoutData(-1, -1, new Margins(0)));
|
|
||||||
|
|
||||||
vField.add(typeDescription, new VerticalLayoutData(-1, -1, new Margins(0)));
|
vField.add(typeDescription, new VerticalLayoutData(-1, -1, new Margins(0)));
|
||||||
vContainer.add(vField);
|
vContainer.add(vField);
|
||||||
|
|
||||||
|
@ -79,6 +93,15 @@ public class TabularFld extends AbstractFld {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void downloadUrl() {
|
||||||
|
if (value != null) {
|
||||||
|
DownloadWidget downloadWidget = new DownloadWidget();
|
||||||
|
downloadWidget.downloadUrl(value);
|
||||||
|
} else {
|
||||||
|
UtilsGXT3.info("Attention", "The url is invalid: " + value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -100,7 +123,7 @@ public class TabularFld extends AbstractFld {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
if(value!=null&&!value.isEmpty()){
|
if (value != null && !value.isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -4,21 +4,26 @@
|
||||||
package org.gcube.portlets.user.dataminerexecutor.client.parametersfield;
|
package org.gcube.portlets.user.dataminerexecutor.client.parametersfield;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
||||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.TabularListParameter;
|
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.TabularListParameter;
|
||||||
import org.gcube.data.analysis.dataminermanagercl.shared.parameters.TabularParameter;
|
import org.gcube.portlets.user.dataminerexecutor.client.DataMinerExecutor;
|
||||||
|
import org.gcube.portlets.user.dataminerexecutor.client.util.UtilsGXT3;
|
||||||
|
import org.gcube.portlets.user.dataminerexecutor.client.workspace.DownloadWidget;
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
import com.sencha.gxt.core.client.util.Margins;
|
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.BoxLayoutContainer.BoxLayoutData;
|
||||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
|
||||||
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
|
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.HtmlLayoutContainer;
|
||||||
import com.sencha.gxt.widget.core.client.container.MarginData;
|
|
||||||
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
||||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -29,11 +34,9 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||||
public class TabularListFld extends AbstractFld {
|
public class TabularListFld extends AbstractFld {
|
||||||
|
|
||||||
private SimpleContainer fieldContainer;
|
private SimpleContainer fieldContainer;
|
||||||
private HBoxLayoutContainer horiz;
|
private VerticalLayoutContainer vl;
|
||||||
private SimpleContainer listContainer;
|
private ArrayList<String> list;
|
||||||
private List<TabItem> items;
|
private String value;
|
||||||
private VerticalLayoutContainer vp;
|
|
||||||
private TabularListParameter tabularListParameter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param parameter
|
* @param parameter
|
||||||
|
@ -41,131 +44,117 @@ public class TabularListFld extends AbstractFld {
|
||||||
*/
|
*/
|
||||||
public TabularListFld(Parameter parameter) {
|
public TabularListFld(Parameter parameter) {
|
||||||
super(parameter);
|
super(parameter);
|
||||||
Log.debug("TabularListField");
|
|
||||||
try {
|
|
||||||
tabularListParameter = (TabularListParameter) parameter;
|
|
||||||
createField();
|
|
||||||
} catch (Throwable e) {
|
|
||||||
Log.error("TabularListField: " + e.getLocalizedMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createField() {
|
Log.debug("Create Tabular List field: " + parameter.getName());
|
||||||
vp = new VerticalLayoutContainer();
|
value = parameter.getValue();
|
||||||
items = new ArrayList<>();
|
|
||||||
|
|
||||||
listContainer = new SimpleContainer();
|
TabularListParameter tabularListParameter = (TabularListParameter) parameter;
|
||||||
listContainer.add(vp, new MarginData(new Margins(0)));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* List<String> templates = tabularListParameter.getTemplates(); String
|
|
||||||
* list = ""; boolean firstTemplate = true; for (String template :
|
|
||||||
* templates) { list += (firstTemplate ? "" : ", ") +
|
|
||||||
* Format.ellipse(template,50); firstTemplate = false; }
|
|
||||||
* HtmlLayoutContainer templatesList = new
|
|
||||||
* HtmlLayoutContainer("<p>Suitable Data Set Templates: <br>" +
|
|
||||||
* list+"</p>");
|
|
||||||
* templatesList.addStyleName("workflow-parameters-description");
|
|
||||||
*/
|
|
||||||
|
|
||||||
fieldContainer = new SimpleContainer();
|
|
||||||
// fieldContainer.setResize(true);
|
|
||||||
horiz = new HBoxLayoutContainer();
|
|
||||||
horiz.setPack(BoxLayoutPack.START);
|
|
||||||
horiz.setEnableOverflow(false);
|
|
||||||
|
|
||||||
HtmlLayoutContainer descr;
|
HtmlLayoutContainer descr;
|
||||||
|
|
||||||
if (tabularListParameter.getDescription() == null) {
|
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'></p>");
|
||||||
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'></p>");
|
descr.addStyleName("workflow-fieldDescription");
|
||||||
descr.addStyleName("workflow-fieldDescription");
|
|
||||||
} else {
|
|
||||||
/* listContainer.setToolTip(listParameter.getDescription()); */
|
|
||||||
descr = new HtmlLayoutContainer(
|
|
||||||
"<p style='margin-left:5px !important;'>" + tabularListParameter.getDescription() + "</p>");
|
|
||||||
descr.addStyleName("workflow-fieldDescription");
|
|
||||||
}
|
|
||||||
|
|
||||||
horiz.add(listContainer);
|
descr = new HtmlLayoutContainer(
|
||||||
horiz.add(descr);
|
"<p style='margin-left:5px !important;'>" + parameter.getDescription() + "</p>");
|
||||||
|
descr.addStyleName("workflow-fieldDescription");
|
||||||
|
|
||||||
fieldContainer.add(horiz, new MarginData(new Margins(0)));
|
vl = new VerticalLayoutContainer();
|
||||||
|
createListField(tabularListParameter);
|
||||||
|
|
||||||
|
SimpleContainer dataContainer = new SimpleContainer();
|
||||||
|
dataContainer.addStyleName("workflow-fieldValue");
|
||||||
|
dataContainer.add(vl);
|
||||||
|
|
||||||
|
//
|
||||||
|
SimpleContainer vContainer = new SimpleContainer();
|
||||||
|
VerticalLayoutContainer vField = new VerticalLayoutContainer();
|
||||||
|
HtmlLayoutContainer typeDescription = new HtmlLayoutContainer("");
|
||||||
|
typeDescription.setStylePrimaryName("workflow-parameters-description");
|
||||||
|
|
||||||
|
vField.add(dataContainer, new VerticalLayoutData(-1, -1, new Margins(0)));
|
||||||
|
vField.add(typeDescription, new VerticalLayoutData(-1, -1, new Margins(0)));
|
||||||
|
vContainer.add(vField);
|
||||||
|
|
||||||
|
fieldContainer = new SimpleContainer();
|
||||||
|
HBoxLayoutContainer horiz = new HBoxLayoutContainer();
|
||||||
|
horiz.setPack(BoxLayoutPack.START);
|
||||||
|
horiz.setEnableOverflow(false);
|
||||||
|
|
||||||
|
horiz.add(vContainer, new BoxLayoutData(new Margins()));
|
||||||
|
horiz.add(descr, new BoxLayoutData(new Margins()));
|
||||||
|
|
||||||
|
fieldContainer.add(horiz);
|
||||||
fieldContainer.forceLayout();
|
fieldContainer.forceLayout();
|
||||||
addField(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addField(TabItem upperItem) {
|
private void createListField(TabularListParameter tabularListParameter) {
|
||||||
try {
|
String tempValue = new String(value);
|
||||||
|
list = new ArrayList<>();
|
||||||
|
|
||||||
TabularParameter tabPar = new TabularParameter(tabularListParameter.getName(),
|
int pos = tempValue.indexOf(tabularListParameter.getSeparator());
|
||||||
tabularListParameter.getDescription(), null, tabularListParameter.getTemplates(),
|
while (pos > -1) {
|
||||||
tabularListParameter.getDefaultMimeType(), tabularListParameter.getSupportedMimeTypes());
|
SafeHtmlBuilder safeValue = new SafeHtmlBuilder();
|
||||||
|
safeValue.appendEscaped(tempValue.substring(0, pos));
|
||||||
|
list.add(safeValue.toSafeHtml().asString());
|
||||||
|
tempValue = tempValue.substring(pos + 1, tempValue.length());
|
||||||
|
pos = tempValue.indexOf(tabularListParameter.getSeparator());
|
||||||
|
}
|
||||||
|
if (tempValue != null && !tempValue.isEmpty()) {
|
||||||
|
SafeHtmlBuilder safeValue = new SafeHtmlBuilder();
|
||||||
|
safeValue.appendEscaped(tempValue);
|
||||||
|
list.add(safeValue.toSafeHtml().asString());
|
||||||
|
}
|
||||||
|
|
||||||
if (upperItem == null) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
TabItem item = new TabItem(this, tabPar, true);
|
String url = list.get(i);
|
||||||
items.add(item);
|
TextButton downloadButton = new TextButton("");
|
||||||
vp.add(item);// don't use new VerticalLayoutData(1, -1, new
|
downloadButton.setIcon(DataMinerExecutor.resources.download());
|
||||||
// Margins(0))
|
downloadButton.setTitle(url);
|
||||||
} else {
|
downloadButton.setItemId(String.valueOf(i));
|
||||||
// search the position of the upper item
|
downloadButton.addSelectHandler(new SelectEvent.SelectHandler() {
|
||||||
int pos = items.indexOf(upperItem);
|
|
||||||
if (pos > -1) {
|
@Override
|
||||||
upperItem.showCancelButton();
|
public void onSelect(SelectEvent event) {
|
||||||
upperItem.forceLayout();
|
downloadRequest(event);
|
||||||
TabItem item = new TabItem(this, tabPar, false);
|
|
||||||
items.add(pos + 1, item);
|
|
||||||
vp.insert(item, pos + 1);// don't use new
|
|
||||||
// VerticalLayoutData(-1, -1,new
|
|
||||||
// Margins(0))
|
|
||||||
} else {
|
|
||||||
upperItem.forceLayout();
|
|
||||||
TabItem item = new TabItem(this, tabPar, true);
|
|
||||||
items.add(item);
|
|
||||||
vp.add(item);// don't use new VerticalLayoutData(-1, -1, new
|
|
||||||
// Margins(0))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
vl.add(downloadButton, new VerticalLayoutData(-1, -1, new Margins(0)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void downloadRequest(SelectEvent event) {
|
||||||
|
TextButton button = (TextButton) event.getSource();
|
||||||
|
String id = button.getItemId();
|
||||||
|
try {
|
||||||
|
int i = Integer.valueOf(id);
|
||||||
|
if (i > -1 && i < list.size() && !list.isEmpty()) {
|
||||||
|
downloadUrl(list.get(i));
|
||||||
}
|
}
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
forceLayout();
|
Log.error("Invalid id: " + e.getLocalizedMessage(), e);
|
||||||
|
|
||||||
} catch (Throwable e) {
|
|
||||||
Log.error(e.getLocalizedMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void removeField(TabItem item) {
|
private void downloadUrl(String url) {
|
||||||
items.remove(item);
|
if (value != null) {
|
||||||
|
DownloadWidget downloadWidget = new DownloadWidget();
|
||||||
if (items.size() == 1) {
|
downloadWidget.downloadUrl(value);
|
||||||
items.get(0).hideCancelButton();
|
} else {
|
||||||
items.get(0).forceLayout();
|
UtilsGXT3.info("Attention", "The url is invalid: " + value);
|
||||||
}
|
}
|
||||||
vp.remove(item);
|
|
||||||
forceLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void forceLayout() {
|
|
||||||
vp.forceLayout();
|
|
||||||
listContainer.forceLayout();
|
|
||||||
horiz.forceLayout();
|
|
||||||
fieldContainer.forceLayout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
String separator = tabularListParameter.getSeparator();
|
|
||||||
// String separator="";
|
|
||||||
String value = "";
|
|
||||||
boolean first = true;
|
|
||||||
for (TabItem item : items) {
|
|
||||||
String itemValue = item.getValue();
|
|
||||||
if (itemValue != null && !itemValue.contentEquals("")) {
|
|
||||||
value += (first ? "" : separator) + itemValue;
|
|
||||||
first = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,13 +168,11 @@ public class TabularListFld extends AbstractFld {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid() {
|
public boolean isValid() {
|
||||||
boolean valid = false;
|
if (value != null && !value.isEmpty()) {
|
||||||
for (TabItem item : items)
|
return true;
|
||||||
if (item.isValid()) {
|
} else {
|
||||||
valid = true;
|
return false;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
return valid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,11 @@ public class DownloadWidget {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void downloadUrl(String url) {
|
||||||
|
Log.debug("Download from url: "+url);
|
||||||
|
Window.open(URL.encode(url.toString()), "_blank", "");
|
||||||
|
}
|
||||||
|
|
||||||
private void requestDownload(ItemDescription itemDescription) {
|
private void requestDownload(ItemDescription itemDescription) {
|
||||||
switch (itemDescription.getType()) {
|
switch (itemDescription.getType()) {
|
||||||
case "AbstractFileItem":
|
case "AbstractFileItem":
|
||||||
|
|
|
@ -398,6 +398,7 @@
|
||||||
|
|
||||||
.menuItemImage {
|
.menuItemImage {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menuItemImage:HOVER {
|
.menuItemImage:HOVER {
|
||||||
|
|
Loading…
Reference in New Issue