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:
Giancarlo Panichi 2019-01-18 16:13:43 +00:00
parent 1630f645c1
commit 6fd062f35f
11 changed files with 252 additions and 1132 deletions

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -4,10 +4,14 @@
package org.gcube.portlets.user.dataminerexecutor.client.parametersfield;
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.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;
@ -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.VerticalLayoutContainer;
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 {
private SimpleContainer fieldContainer;
//private TextField textField;
private String value;
/**
* @param parameter
* parameter
@ -36,33 +39,43 @@ public class FileFld extends AbstractFld {
public FileFld(Parameter parameter) {
super(parameter);
//ObjectParameter p = (ObjectParameter) parameter;
Log.debug("Create File field: "+parameter.getName());
value=parameter.getValue();
Log.debug("Create File field: " + parameter.getName());
value = parameter.getValue();
// Description
HtmlLayoutContainer descr;
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'></p>");
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");
// 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();
VerticalLayoutContainer vField = new VerticalLayoutContainer();
HtmlLayoutContainer typeDescription = new HtmlLayoutContainer("File Value");
typeDescription.setStylePrimaryName("workflow-parameters-description");
//textField = new TextField();
//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(dataContainer, new VerticalLayoutData(-1, -1, new Margins(0)));
vField.add(typeDescription, new VerticalLayoutData(-1, -1, new Margins(0)));
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
public boolean isValid() {
if(value!=null&&!value.isEmpty()){
if (value != null && !value.isEmpty()) {
return true;
} else {
return false;

View File

@ -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();
}
}
}

View File

@ -3,22 +3,20 @@
*/
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 com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.ui.Widget;
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.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;
/**
*
@ -29,101 +27,75 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
public class ListStringFld extends AbstractFld {
private SimpleContainer fieldContainer;
private HBoxLayoutContainer horiz;
private SimpleContainer listContainer;
private VerticalLayoutContainer vp;
private List<StringItem> items;
private ListParameter listParameter;
// private TextField textField;
private String value;
/**
*
* @param parameter
* parameter
*/
public ListStringFld(Parameter parameter) {
super(parameter);
listParameter = (ListParameter) parameter;
// ObjectParameter p = (ObjectParameter) parameter;
Log.debug("Create String List field: " + parameter.getName());
value = parameter.getValue();
listContainer = new SimpleContainer();
vp = new VerticalLayoutContainer();
items = new ArrayList<StringItem>();
listContainer.add(vp, new MarginData(new Margins()));
ListParameter listParameter = (ListParameter) parameter;
fieldContainer = new SimpleContainer();
horiz = new HBoxLayoutContainer();
horiz.setPack(BoxLayoutPack.START);
horiz.setEnableOverflow(false);
StringBuilder columnListHtml = new StringBuilder();
String tempValue = new String(value);
int pos = tempValue.indexOf(listParameter.getSeparator());
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;
if (listParameter.getDescription() == null) {
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'></p>");
descr.addStyleName("workflow-fieldDescription");
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");
}
descr = new HtmlLayoutContainer(
"<p style='margin-left:5px !important;'>" + parameter.getDescription() + "</p>");
descr.addStyleName("workflow-fieldDescription");
horiz.add(listContainer, new BoxLayoutData(new Margins(0)));
horiz.add(descr, new BoxLayoutData(new Margins(0)));
SimpleContainer vContainer = new SimpleContainer();
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);
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();
}
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
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;
}
@ -152,18 +114,13 @@ public class ListStringFld extends AbstractFld {
return fieldContainer;
}
/**
*
*/
@Override
public boolean isValid() {
boolean valid = false;
for (StringItem item : items)
if (item.isValid()) {
valid = true;
break;
}
return valid;
if (value != null && !value.isEmpty()) {
return true;
} else {
return false;
}
}
}

View File

@ -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();
}
}

View File

@ -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);
}
}

View File

@ -4,17 +4,23 @@
package org.gcube.portlets.user.dataminerexecutor.client.parametersfield;
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.google.gwt.user.client.ui.Widget;
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.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.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.event.SelectEvent;
/**
*
@ -25,10 +31,8 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.Verti
public class TabularFld extends AbstractFld {
private SimpleContainer fieldContainer;
//private TextField textField;
private String value;
/**
* @param parameter
* parameter
@ -36,33 +40,43 @@ public class TabularFld extends AbstractFld {
public TabularFld(Parameter parameter) {
super(parameter);
//ObjectParameter p = (ObjectParameter) parameter;
Log.debug("Create File field: "+parameter.getName());
value=parameter.getValue();
Log.debug("Create Tabular field: " + parameter.getName());
value = parameter.getValue();
// Description
HtmlLayoutContainer descr;
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'></p>");
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");
// 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();
VerticalLayoutContainer vField = new VerticalLayoutContainer();
HtmlLayoutContainer typeDescription = new HtmlLayoutContainer("Table Value");
typeDescription.setStylePrimaryName("workflow-parameters-description");
//textField = new TextField();
//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(dataContainer, new VerticalLayoutData(-1, -1, new Margins(0)));
vField.add(typeDescription, new VerticalLayoutData(-1, -1, new Margins(0)));
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
public boolean isValid() {
if(value!=null&&!value.isEmpty()){
if (value != null && !value.isEmpty()) {
return true;
} else {
return false;

View File

@ -4,21 +4,26 @@
package org.gcube.portlets.user.dataminerexecutor.client.parametersfield;
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.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.google.gwt.safehtml.shared.SafeHtmlBuilder;
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;
/**
*
@ -29,11 +34,9 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
public class TabularListFld extends AbstractFld {
private SimpleContainer fieldContainer;
private HBoxLayoutContainer horiz;
private SimpleContainer listContainer;
private List<TabItem> items;
private VerticalLayoutContainer vp;
private TabularListParameter tabularListParameter;
private VerticalLayoutContainer vl;
private ArrayList<String> list;
private String value;
/**
* @param parameter
@ -41,131 +44,117 @@ public class TabularListFld extends AbstractFld {
*/
public TabularListFld(Parameter parameter) {
super(parameter);
Log.debug("TabularListField");
try {
tabularListParameter = (TabularListParameter) parameter;
createField();
} catch (Throwable e) {
Log.error("TabularListField: " + e.getLocalizedMessage());
e.printStackTrace();
}
}
private void createField() {
vp = new VerticalLayoutContainer();
items = new ArrayList<>();
Log.debug("Create Tabular List field: " + parameter.getName());
value = parameter.getValue();
listContainer = new SimpleContainer();
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);
TabularListParameter tabularListParameter = (TabularListParameter) parameter;
HtmlLayoutContainer descr;
if (tabularListParameter.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;'>" + tabularListParameter.getDescription() + "</p>");
descr.addStyleName("workflow-fieldDescription");
}
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'></p>");
descr.addStyleName("workflow-fieldDescription");
horiz.add(listContainer);
horiz.add(descr);
descr = new HtmlLayoutContainer(
"<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();
addField(null);
}
protected void addField(TabItem upperItem) {
try {
private void createListField(TabularListParameter tabularListParameter) {
String tempValue = new String(value);
list = new ArrayList<>();
TabularParameter tabPar = new TabularParameter(tabularListParameter.getName(),
tabularListParameter.getDescription(), null, tabularListParameter.getTemplates(),
tabularListParameter.getDefaultMimeType(), tabularListParameter.getSupportedMimeTypes());
int pos = tempValue.indexOf(tabularListParameter.getSeparator());
while (pos > -1) {
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) {
TabItem item = new TabItem(this, tabPar, true);
items.add(item);
vp.add(item);// don't use new VerticalLayoutData(1, -1, new
// Margins(0))
} else {
// search the position of the upper item
int pos = items.indexOf(upperItem);
if (pos > -1) {
upperItem.showCancelButton();
upperItem.forceLayout();
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))
for (int i = 0; i < list.size(); i++) {
String url = list.get(i);
TextButton downloadButton = new TextButton("");
downloadButton.setIcon(DataMinerExecutor.resources.download());
downloadButton.setTitle(url);
downloadButton.setItemId(String.valueOf(i));
downloadButton.addSelectHandler(new SelectEvent.SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
downloadRequest(event);
}
});
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));
}
forceLayout();
} catch (Throwable e) {
Log.error(e.getLocalizedMessage());
e.printStackTrace();
} catch (NumberFormatException e) {
Log.error("Invalid id: " + e.getLocalizedMessage(), e);
}
}
protected void removeField(TabItem item) {
items.remove(item);
if (items.size() == 1) {
items.get(0).hideCancelButton();
items.get(0).forceLayout();
private void downloadUrl(String url) {
if (value != null) {
DownloadWidget downloadWidget = new DownloadWidget();
downloadWidget.downloadUrl(value);
} else {
UtilsGXT3.info("Attention", "The url is invalid: " + value);
}
vp.remove(item);
forceLayout();
}
protected void forceLayout() {
vp.forceLayout();
listContainer.forceLayout();
horiz.forceLayout();
fieldContainer.forceLayout();
}
/**
*
*/
@Override
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;
}
@ -179,13 +168,11 @@ public class TabularListFld extends AbstractFld {
@Override
public boolean isValid() {
boolean valid = false;
for (TabItem item : items)
if (item.isValid()) {
valid = true;
break;
}
return valid;
if (value != null && !value.isEmpty()) {
return true;
} else {
return false;
}
}
}

View File

@ -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) {
switch (itemDescription.getType()) {
case "AbstractFileItem":

View File

@ -398,6 +398,7 @@
.menuItemImage {
opacity: 0.5;
float: right;
}
.menuItemImage:HOVER {