ref 6078:TDM - Create a new widget to support operations's invocation on DataMiner
https://support.d4science.org/issues/6078 Updated to support DataMiner git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/data-miner-manager-widget@146465 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
99602386b2
commit
da00f0e4e3
|
@ -9,7 +9,7 @@ import com.google.gwt.event.shared.HandlerRegistration;
|
|||
import com.google.gwt.event.shared.HasHandlers;
|
||||
|
||||
/**
|
||||
* Start Computation Event
|
||||
* TabularFldChangeEvent
|
||||
*
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
|
|
|
@ -45,6 +45,7 @@ public class ColumnFld extends AbstractFld implements
|
|||
|
||||
private SimpleContainer fieldContainer;
|
||||
private SimpleContainer vContainer;
|
||||
private TableItemSimple tableItemSimple;
|
||||
|
||||
/**
|
||||
* @param parameter
|
||||
|
@ -77,13 +78,15 @@ public class ColumnFld extends AbstractFld implements
|
|||
HtmlLayoutContainer descr;
|
||||
|
||||
if (columnParameter.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");
|
||||
|
||||
} else {
|
||||
//comboBox.setToolTip(columnParameter.getDescription());
|
||||
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'>"
|
||||
+ columnParameter.getDescription() + "</p>");
|
||||
// comboBox.setToolTip(columnParameter.getDescription());
|
||||
descr = new HtmlLayoutContainer(
|
||||
"<p style='margin-left:5px !important;'>"
|
||||
+ columnParameter.getDescription() + "</p>");
|
||||
descr.addStyleName("workflow-fieldDescription");
|
||||
}
|
||||
|
||||
|
@ -130,8 +133,20 @@ public class ColumnFld extends AbstractFld implements
|
|||
*/
|
||||
@Override
|
||||
public String getValue() {
|
||||
ColumnItem columnItem = comboBox.getCurrentValue();
|
||||
return columnItem != null ? columnItem.getName() : null;
|
||||
if (tableItemSimple == null) {
|
||||
return null;
|
||||
} else {
|
||||
ColumnItem columnItem = comboBox.getCurrentValue();
|
||||
if (columnItem == null) {
|
||||
return null;
|
||||
} else {
|
||||
if (tableItemSimple.isTabularResource()) {
|
||||
return columnItem.getId();
|
||||
} else {
|
||||
return columnItem.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,7 +164,7 @@ public class ColumnFld extends AbstractFld implements
|
|||
|
||||
@Override
|
||||
public void onChange(TabularFldChangeEvent event) {
|
||||
TableItemSimple tableItemSimple = event.getTableItemSimple();
|
||||
tableItemSimple = event.getTableItemSimple();
|
||||
if (tableItemSimple == null) {
|
||||
store.clear();
|
||||
store.commitChanges();
|
||||
|
@ -164,16 +179,15 @@ public class ColumnFld extends AbstractFld implements
|
|||
if (columns != null) {
|
||||
store.addAll(columns);
|
||||
store.commitChanges();
|
||||
Log.debug("DefaultColumn: "+defaultColumn);
|
||||
Log.debug("DefaultColumn: " + defaultColumn);
|
||||
for (ColumnItem columnItem : columns) {
|
||||
Log.debug("ColumnItem: "+ columnItem);
|
||||
Log.debug("ColumnItem: " + columnItem);
|
||||
if (columnItem.getName().compareToIgnoreCase(defaultColumn) == 0) {
|
||||
comboBox.setValue(columnItem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
comboBox.setEnabled(true);
|
||||
showFieldWithSelection(tableItemSimple);
|
||||
|
|
|
@ -58,6 +58,7 @@ public class ColumnListFld extends AbstractFld implements
|
|||
private CheckBoxSelectionModel<ColumnItem> sm;
|
||||
private SimpleContainer fieldContainer;
|
||||
private SimpleContainer vContainer;
|
||||
private TableItemSimple tableItemSimple;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -79,13 +80,15 @@ public class ColumnListFld extends AbstractFld implements
|
|||
HtmlLayoutContainer descr;
|
||||
|
||||
if (columnListParameter.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");
|
||||
|
||||
} else {
|
||||
//grid.setToolTip(columnListParameter.getDescription());
|
||||
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'>"
|
||||
+ columnListParameter.getDescription() + "</p>");
|
||||
// grid.setToolTip(columnListParameter.getDescription());
|
||||
descr = new HtmlLayoutContainer(
|
||||
"<p style='margin-left:5px !important;'>"
|
||||
+ columnListParameter.getDescription() + "</p>");
|
||||
descr.addStyleName("workflow-fieldDescription");
|
||||
}
|
||||
|
||||
|
@ -115,7 +118,6 @@ public class ColumnListFld extends AbstractFld implements
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
IdentityValueProvider<ColumnItem> identity = new IdentityValueProvider<ColumnItem>();
|
||||
sm = new CheckBoxSelectionModel<ColumnItem>(identity);
|
||||
|
||||
|
@ -181,12 +183,22 @@ public class ColumnListFld extends AbstractFld implements
|
|||
String value = "";
|
||||
boolean first = true;
|
||||
|
||||
for (ColumnItem columnItem : sm.getSelection()) {
|
||||
String columnName = columnItem.getName();
|
||||
value += (first ? "" : separator) + columnName;
|
||||
first = false;
|
||||
if (tableItemSimple == null) {
|
||||
return value;
|
||||
} else {
|
||||
for (ColumnItem columnItem : sm.getSelection()) {
|
||||
String columnName;
|
||||
if (tableItemSimple.isTabularResource()) {
|
||||
columnName = columnItem.getId();
|
||||
} else {
|
||||
columnName = columnItem.getName();
|
||||
}
|
||||
value += (first ? "" : separator) + columnName;
|
||||
first = false;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -207,7 +219,7 @@ public class ColumnListFld extends AbstractFld implements
|
|||
|
||||
@Override
|
||||
public void onChange(TabularFldChangeEvent event) {
|
||||
TableItemSimple tableItemSimple = event.getTableItemSimple();
|
||||
tableItemSimple = event.getTableItemSimple();
|
||||
if (tableItemSimple == null) {
|
||||
store.clear();
|
||||
store.commitChanges();
|
||||
|
|
|
@ -12,7 +12,10 @@ import org.gcube.data.analysis.dataminermanagercl.shared.parameters.Parameter;
|
|||
import org.gcube.portlets.widgets.dataminermanagerwidget.client.DataMinerManagerPanel;
|
||||
import org.gcube.portlets.widgets.dataminermanagerwidget.client.common.EventBusProvider;
|
||||
import org.gcube.portlets.widgets.dataminermanagerwidget.client.events.SessionExpiredEvent;
|
||||
import org.gcube.portlets.widgets.dataminermanagerwidget.client.events.TabularResourceInfoEvent;
|
||||
import org.gcube.portlets.widgets.dataminermanagerwidget.client.events.TabularResourceInfoRequestEvent;
|
||||
import org.gcube.portlets.widgets.dataminermanagerwidget.client.rpc.DataMinerPortletServiceAsync;
|
||||
import org.gcube.portlets.widgets.dataminermanagerwidget.client.tr.TabularResourceData;
|
||||
import org.gcube.portlets.widgets.dataminermanagerwidget.client.util.UtilsGXT3;
|
||||
import org.gcube.portlets.widgets.dataminermanagerwidget.shared.exception.SessionExpiredServiceException;
|
||||
import org.gcube.portlets.widgets.dataminermanagerwidget.shared.workspace.ItemDescription;
|
||||
|
@ -47,27 +50,65 @@ import com.sencha.gxt.widget.core.client.form.TextField;
|
|||
public class FileFld extends AbstractFld {
|
||||
|
||||
private VerticalLayoutContainer vp;
|
||||
private SimpleContainer fieldContainer;
|
||||
private HBoxLayoutContainer horiz;
|
||||
|
||||
// FileSelector fileSelector;
|
||||
private WorkspaceExplorerSelectDialog wselectDialog;
|
||||
private TextButton selectButton, selectButton2, cancelButton;
|
||||
private ItemDescription selectedFileItem = null;
|
||||
|
||||
private FileParameter fileParameter;
|
||||
|
||||
private SimpleContainer fieldContainer;
|
||||
|
||||
private HBoxLayoutContainer horiz;
|
||||
|
||||
private TextButton selectButton;
|
||||
private TextButton selectButton2;
|
||||
private TextButton selectTRButton;
|
||||
private TextButton selectTRButton2;
|
||||
private TextButton cancelButton;
|
||||
private TextButton downloadButton;
|
||||
|
||||
private ItemDescription selectedFileItem = null;
|
||||
private TabularResourceData tabularResourceData;
|
||||
private FileParameter fileParameter;
|
||||
private boolean created = false;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param parameter
|
||||
*/
|
||||
public FileFld(Parameter parameter) {
|
||||
super(parameter);
|
||||
fileParameter = (FileParameter) parameter;
|
||||
Log.debug("FileField");
|
||||
retrieveInfo();
|
||||
}
|
||||
|
||||
private void retrieveInfo() {
|
||||
bind();
|
||||
retrieveTabularResourceInfo();
|
||||
|
||||
}
|
||||
|
||||
private void bind() {
|
||||
EventBusProvider.INSTANCE.addHandler(TabularResourceInfoEvent.TYPE,
|
||||
new TabularResourceInfoEvent.TabularResourceInfoEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onInfoReceived(TabularResourceInfoEvent event) {
|
||||
Log.debug("Catch TabularResourceInfoEvent");
|
||||
tabularResourceData = event.getTabularResourceData();
|
||||
if (!created) {
|
||||
created = true;
|
||||
create();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void retrieveTabularResourceInfo() {
|
||||
TabularResourceInfoRequestEvent event = new TabularResourceInfoRequestEvent();
|
||||
EventBusProvider.INSTANCE.fireEvent(event);
|
||||
}
|
||||
|
||||
private void create(){
|
||||
SimpleContainer tabContainer = new SimpleContainer();
|
||||
vp = new VerticalLayoutContainer();
|
||||
init();
|
||||
|
@ -144,6 +185,34 @@ public class FileFld extends AbstractFld {
|
|||
wselectDialog.addWorkspaceExplorerSelectNotificationListener(handler);
|
||||
wselectDialog.setZIndex(XDOM.getTopZIndex());
|
||||
|
||||
|
||||
selectTRButton = new TextButton("Use Tabular Resource");
|
||||
selectTRButton.addSelectHandler(new SelectEvent.SelectHandler() {
|
||||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
useTabularResource();
|
||||
}
|
||||
});
|
||||
selectTRButton.setIcon(DataMinerManagerPanel.resources
|
||||
.tabularResource());
|
||||
selectTRButton.setToolTip("Use Tabular Resource");
|
||||
|
||||
selectTRButton2 = new TextButton("");
|
||||
selectTRButton2.addSelectHandler(new SelectEvent.SelectHandler() {
|
||||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
useTabularResource();
|
||||
}
|
||||
});
|
||||
|
||||
selectTRButton2.setIcon(DataMinerManagerPanel.resources
|
||||
.tabularResource());
|
||||
selectTRButton2.setToolTip("Use Tabular Resource");
|
||||
|
||||
|
||||
|
||||
selectButton = new TextButton("Select File");
|
||||
selectButton.setIcon(DataMinerManagerPanel.resources.folderExplore());
|
||||
selectButton.addSelectHandler(new SelectEvent.SelectHandler() {
|
||||
|
@ -177,6 +246,7 @@ public class FileFld extends AbstractFld {
|
|||
showNoSelectionField();
|
||||
}
|
||||
});
|
||||
cancelButton.setToolTip("Cancel");
|
||||
|
||||
downloadButton = new TextButton("");
|
||||
downloadButton.setIcon(DataMinerManagerPanel.resources.download());
|
||||
|
@ -187,9 +257,22 @@ public class FileFld extends AbstractFld {
|
|||
downloadFile();
|
||||
}
|
||||
});
|
||||
downloadButton.setToolTip("Download File");
|
||||
|
||||
}
|
||||
|
||||
private void useTabularResource() {
|
||||
Log.debug("TabularResourceData: " + tabularResourceData);
|
||||
selectedFileItem = new ItemDescription(
|
||||
tabularResourceData.getTabularResourceId(),
|
||||
tabularResourceData.getName(),
|
||||
"","",
|
||||
tabularResourceData.getType());
|
||||
selectedFileItem.setPublicLink(tabularResourceData.getTabularResourceId());
|
||||
showFieldWithTRSelection();
|
||||
}
|
||||
|
||||
|
||||
private void retrieveFileInformation(final Item item) {
|
||||
Log.debug("Retrieved: " + item);
|
||||
final ItemDescription itemDescription = new ItemDescription(
|
||||
|
@ -219,7 +302,7 @@ public class FileFld extends AbstractFld {
|
|||
itemDescription.setPublicLink(result);
|
||||
selectedFileItem = itemDescription;
|
||||
Log.debug("SelectedFileItem: " + selectedFileItem);
|
||||
showFieldWithSelection();
|
||||
showFieldWithFileSelection();
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -260,14 +343,17 @@ public class FileFld extends AbstractFld {
|
|||
|
||||
}
|
||||
|
||||
|
||||
private void showNoSelectionField() {
|
||||
vp.clear();
|
||||
vp.add(selectTRButton);
|
||||
vp.add(selectButton);
|
||||
vp.forceLayout();
|
||||
fieldContainer.forceLayout();
|
||||
}
|
||||
|
||||
private void showFieldWithSelection() {
|
||||
|
||||
private void showFieldWithFileSelection() {
|
||||
String fileName = selectedFileItem.getName();
|
||||
|
||||
if (fileName == null || fileName.isEmpty()) {
|
||||
|
@ -280,6 +366,7 @@ public class FileFld extends AbstractFld {
|
|||
|
||||
HBoxLayoutContainer h = new HBoxLayoutContainer();
|
||||
h.add(tableDescription, new BoxLayoutData(new Margins()));
|
||||
h.add(selectTRButton2, new BoxLayoutData(new Margins()));
|
||||
h.add(selectButton2, new BoxLayoutData(new Margins()));
|
||||
h.add(downloadButton, new BoxLayoutData(new Margins()));
|
||||
h.add(cancelButton, new BoxLayoutData(new Margins()));
|
||||
|
@ -290,6 +377,31 @@ public class FileFld extends AbstractFld {
|
|||
|
||||
}
|
||||
|
||||
private void showFieldWithTRSelection() {
|
||||
String fileName = selectedFileItem.getName();
|
||||
|
||||
if (fileName == null || fileName.isEmpty()) {
|
||||
fileName = "NoName";
|
||||
}
|
||||
|
||||
TextField tableDescription = new TextField();
|
||||
tableDescription.setValue(fileName);
|
||||
tableDescription.setReadOnly(true);
|
||||
|
||||
HBoxLayoutContainer h = new HBoxLayoutContainer();
|
||||
h.add(tableDescription, new BoxLayoutData(new Margins()));
|
||||
h.add(selectTRButton2, new BoxLayoutData(new Margins()));
|
||||
h.add(selectButton2, new BoxLayoutData(new Margins()));
|
||||
h.add(downloadButton, new BoxLayoutData(new Margins()));
|
||||
h.add(cancelButton, new BoxLayoutData(new Margins()));
|
||||
vp.clear();
|
||||
vp.add(h);
|
||||
vp.forceLayout();
|
||||
fieldContainer.forceLayout();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -85,6 +85,12 @@ public class TabularFld extends AbstractFld implements
|
|||
retrieveInfo();
|
||||
}
|
||||
|
||||
private void retrieveInfo() {
|
||||
bind();
|
||||
retrieveTabularResourceInfo();
|
||||
|
||||
}
|
||||
|
||||
private void bind() {
|
||||
EventBusProvider.INSTANCE.addHandler(TabularResourceInfoEvent.TYPE,
|
||||
new TabularResourceInfoEvent.TabularResourceInfoEventHandler() {
|
||||
|
@ -114,7 +120,7 @@ public class TabularFld extends AbstractFld implements
|
|||
|
||||
SimpleContainer tabContainer = new SimpleContainer();
|
||||
vp = new VerticalLayoutContainer();
|
||||
retrieveInfo();
|
||||
//retrieveInfo();
|
||||
init();
|
||||
|
||||
createField(tabContainer);
|
||||
|
@ -127,11 +133,7 @@ public class TabularFld extends AbstractFld implements
|
|||
}
|
||||
}
|
||||
|
||||
private void retrieveInfo() {
|
||||
bind();
|
||||
retrieveTabularResourceInfo();
|
||||
|
||||
}
|
||||
|
||||
private void createField(SimpleContainer tabContainer) {
|
||||
List<String> templates = tabularParameter.getTemplates();
|
||||
|
@ -349,6 +351,7 @@ public class TabularFld extends AbstractFld implements
|
|||
tabularResourceData.getDescription(),
|
||||
tabularResourceData.getType());
|
||||
selectedTableItem.setColumns(tabularResourceData.getColumns());
|
||||
selectedTableItem.setTabularResource(true);
|
||||
showFieldWithTRSelection();
|
||||
updateListeners(selectedTableItem);
|
||||
|
||||
|
|
Loading…
Reference in New Issue