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@146281 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-03-22 17:12:34 +00:00
parent 14d38a5010
commit 930909e538
2 changed files with 171 additions and 72 deletions

View File

@ -9,7 +9,10 @@ import org.gcube.data.analysis.dataminermanagercl.shared.parameters.TabularParam
import org.gcube.portlets.widgets.dataminermanagerwidget.client.DataMinerManagerPanel; import org.gcube.portlets.widgets.dataminermanagerwidget.client.DataMinerManagerPanel;
import org.gcube.portlets.widgets.dataminermanagerwidget.client.common.EventBusProvider; 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.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.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.client.util.UtilsGXT3;
import org.gcube.portlets.widgets.dataminermanagerwidget.shared.exception.SessionExpiredServiceException; import org.gcube.portlets.widgets.dataminermanagerwidget.shared.exception.SessionExpiredServiceException;
import org.gcube.portlets.widgets.dataminermanagerwidget.shared.workspace.ItemDescription; import org.gcube.portlets.widgets.dataminermanagerwidget.shared.workspace.ItemDescription;
@ -37,16 +40,24 @@ import com.sencha.gxt.widget.core.client.form.TextField;
public class TabItem extends HBoxLayoutContainer { public class TabItem extends HBoxLayoutContainer {
private TabularListFld parent; private TabularListFld parent;
private TextButton selectButton;
private TextButton selectButton2;
private TableItemSimple selectedTableItem; private TableItemSimple selectedTableItem;
private TextButton addBtn; private TextButton addBtn;
private TextButton removeBtn; private TextButton removeBtn;
private TextField tableDescription; private TextButton selectButton;
private WorkspaceExplorerSelectDialog wselectDialog; private TextButton selectButton2;
private TextButton selectTRButton;
private TextButton selectTRButton2;
private TextButton downloadButton; private TextButton downloadButton;
private TextField tableDescription;
private WorkspaceExplorerSelectDialog wselectDialog;
private ItemDescription itemDescriptionSelected; private ItemDescription itemDescriptionSelected;
private TabularResourceData tabularResourceData;
private boolean created = false;
private boolean first = true;
/** /**
* *
* @param tabularListFld * @param tabularListFld
@ -57,16 +68,72 @@ public class TabItem extends HBoxLayoutContainer {
boolean first) { boolean first) {
super(); super();
this.parent = parent; this.parent = parent;
initDialog(); this.first = first;
create(tabularParameter, first); Log.debug("TabItem");
retrieveInfo();
} }
private void create(TabularParameter tabularParameter, boolean first) { 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;
initDialog();
create();
}
}
});
}
private void retrieveTabularResourceInfo() {
TabularResourceInfoRequestEvent event = new TabularResourceInfoRequestEvent();
EventBusProvider.INSTANCE.fireEvent(event);
}
private void create() {
tableDescription = new TextField(); tableDescription = new TextField();
tableDescription.setReadOnly(true); tableDescription.setReadOnly(true);
tableDescription.setVisible(false); tableDescription.setVisible(false);
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 Data Set"); selectButton = new TextButton("Select Data Set");
selectButton.addSelectHandler(new SelectEvent.SelectHandler() { selectButton.addSelectHandler(new SelectEvent.SelectHandler() {
@ -90,8 +157,7 @@ public class TabItem extends HBoxLayoutContainer {
} }
}); });
selectButton2.setVisible(false); selectButton2.setVisible(false);
downloadButton = new TextButton(""); downloadButton = new TextButton("");
downloadButton.setIcon(DataMinerManagerPanel.resources.download()); downloadButton.setIcon(DataMinerManagerPanel.resources.download());
downloadButton.addSelectHandler(new SelectEvent.SelectHandler() { downloadButton.addSelectHandler(new SelectEvent.SelectHandler() {
@ -102,8 +168,7 @@ public class TabItem extends HBoxLayoutContainer {
} }
}); });
downloadButton.setVisible(false); downloadButton.setVisible(false);
addBtn = new TextButton(""); addBtn = new TextButton("");
addBtn.setIcon(DataMinerManagerPanel.resources.add()); addBtn.setIcon(DataMinerManagerPanel.resources.add());
addBtn.addSelectHandler(new SelectEvent.SelectHandler() { addBtn.addSelectHandler(new SelectEvent.SelectHandler() {
@ -128,20 +193,20 @@ public class TabItem extends HBoxLayoutContainer {
}); });
removeBtn.setVisible(!first); removeBtn.setVisible(!first);
setPack(BoxLayoutPack.START); setPack(BoxLayoutPack.START);
setEnableOverflow(false); setEnableOverflow(false);
add(tableDescription, new BoxLayoutData(new Margins())); add(tableDescription, new BoxLayoutData(new Margins()));
add(selectTRButton, new BoxLayoutData(new Margins()));
add(selectTRButton2, new BoxLayoutData(new Margins()));
add(selectButton, new BoxLayoutData(new Margins())); add(selectButton, new BoxLayoutData(new Margins()));
add(selectButton2, new BoxLayoutData(new Margins())); add(selectButton2, new BoxLayoutData(new Margins()));
add(downloadButton, new BoxLayoutData(new Margins())); add(downloadButton, new BoxLayoutData(new Margins()));
add(addBtn, new BoxLayoutData(new Margins())); add(addBtn, new BoxLayoutData(new Margins()));
add(removeBtn, new BoxLayoutData(new Margins())); add(removeBtn, new BoxLayoutData(new Margins()));
forceLayout(); forceLayout();
} }
private void initDialog() { private void initDialog() {
@ -214,9 +279,9 @@ public class TabItem extends HBoxLayoutContainer {
private void retrieveTableInformation(Item item) { private void retrieveTableInformation(Item item) {
Log.debug("Retrieved: " + item); Log.debug("Retrieved: " + item);
itemDescriptionSelected = new ItemDescription( itemDescriptionSelected = new ItemDescription(item.getId(),
item.getId(), item.getName(), item.getOwner(), item.getPath(), item.getName(), item.getOwner(), item.getPath(), item.getType()
item.getType().name()); .name());
DataMinerPortletServiceAsync.INSTANCE.retrieveTableInformation(item, DataMinerPortletServiceAsync.INSTANCE.retrieveTableInformation(item,
new AsyncCallback<TableItemSimple>() { new AsyncCallback<TableItemSimple>() {
@ -240,13 +305,12 @@ public class TabItem extends HBoxLayoutContainer {
public void onSuccess(TableItemSimple result) { public void onSuccess(TableItemSimple result) {
Log.debug("Retrieved: " + result); Log.debug("Retrieved: " + result);
selectedTableItem = result; selectedTableItem = result;
showFieldWithSelection(); showFieldWithFileSelection();
} }
}); });
} }
private void downloadFile() { private void downloadFile() {
if (itemDescriptionSelected != null) { if (itemDescriptionSelected != null) {
DataMinerPortletServiceAsync.INSTANCE.getPublicLink( DataMinerPortletServiceAsync.INSTANCE.getPublicLink(
@ -270,7 +334,8 @@ public class TabItem extends HBoxLayoutContainer {
@Override @Override
public void onSuccess(String link) { public void onSuccess(String link) {
Log.debug("Retrieved link: " + link); Log.debug("Retrieved link: " + link);
Window.open(link, itemDescriptionSelected.getName(), ""); Window.open(link,
itemDescriptionSelected.getName(), "");
} }
}); });
@ -280,11 +345,22 @@ public class TabItem extends HBoxLayoutContainer {
} }
} }
private void useTabularResource() {
Log.debug("TabularResourceData: " + tabularResourceData);
selectedTableItem = new TableItemSimple(
tabularResourceData.getTabularResourceId(),
tabularResourceData.getName(),
tabularResourceData.getDescription(),
tabularResourceData.getType());
selectedTableItem.setColumns(tabularResourceData.getColumns());
showFieldWithTRSelection();
}
/** /**
* *
*/ */
private void showFieldWithSelection() { private void showFieldWithTRSelection() {
try { try {
String tableName = selectedTableItem.getName(); String tableName = selectedTableItem.getName();
@ -295,6 +371,32 @@ public class TabItem extends HBoxLayoutContainer {
tableDescription.setValue(tableName); tableDescription.setValue(tableName);
tableDescription.setVisible(true); tableDescription.setVisible(true);
selectTRButton.setVisible(false);
selectTRButton2.setVisible(false);
selectButton.setVisible(false);
selectButton2.setVisible(true);
downloadButton.setVisible(false);
parent.forceLayout();
} catch (Throwable e) {
Log.error(e.getLocalizedMessage());
e.printStackTrace();
}
}
private void showFieldWithFileSelection() {
try {
String tableName = selectedTableItem.getName();
if (tableName == null || tableName.isEmpty()) {
tableName = "NoName";
}
tableDescription.setValue(tableName);
tableDescription.setVisible(true);
selectTRButton.setVisible(false);
selectTRButton2.setVisible(true);
selectButton.setVisible(false); selectButton.setVisible(false);
selectButton2.setVisible(true); selectButton2.setVisible(true);
downloadButton.setVisible(true); downloadButton.setVisible(true);

View File

@ -62,15 +62,19 @@ public class TabularFld extends AbstractFld implements
private VerticalLayoutContainer vp; private VerticalLayoutContainer vp;
private WorkspaceExplorerSelectDialog wselectDialog; private WorkspaceExplorerSelectDialog wselectDialog;
private TextButton selectButton, selectButton2, selectTRButton, selectTRButton2, cancelButton, private TextButton selectButton;
downloadButton; private TextButton selectButton2;
private TextButton selectTRButton;
private TextButton selectTRButton2;
private TextButton cancelButton;
private TextButton downloadButton;
private HtmlLayoutContainer templatesList; private HtmlLayoutContainer templatesList;
private TabularResourceData tabularResourceData; private TabularResourceData tabularResourceData;
private TableItemSimple selectedTableItem = null; private TableItemSimple selectedTableItem = null;
private ItemDescription itemDescriptionSelected; private ItemDescription itemDescriptionSelected;
private TabularParameter tabularParameter; private TabularParameter tabularParameter;
private boolean created=false; private boolean created = false;
/** /**
* @param parameter * @param parameter
@ -80,19 +84,17 @@ public class TabularFld extends AbstractFld implements
Log.debug("TabularField"); Log.debug("TabularField");
retrieveInfo(); retrieveInfo();
} }
private void bind() { private void bind() {
EventBusProvider.INSTANCE.addHandler(TabularResourceInfoEvent.TYPE, EventBusProvider.INSTANCE.addHandler(TabularResourceInfoEvent.TYPE,
new TabularResourceInfoEvent.TabularResourceInfoEventHandler() { new TabularResourceInfoEvent.TabularResourceInfoEventHandler() {
@Override @Override
public void onInfoReceived(TabularResourceInfoEvent event) { public void onInfoReceived(TabularResourceInfoEvent event) {
Log.debug("Catch TabularResourceInfoEvent"); Log.debug("Catch TabularResourceInfoEvent");
tabularResourceData=event.getTabularResourceData(); tabularResourceData = event.getTabularResourceData();
if(!created){ if (!created) {
created=true; created = true;
create(); create();
} }
@ -100,15 +102,13 @@ public class TabularFld extends AbstractFld implements
}); });
} }
private void retrieveTabularResourceInfo(){ private void retrieveTabularResourceInfo() {
TabularResourceInfoRequestEvent event=new TabularResourceInfoRequestEvent(); TabularResourceInfoRequestEvent event = new TabularResourceInfoRequestEvent();
EventBusProvider.INSTANCE.fireEvent(event); EventBusProvider.INSTANCE.fireEvent(event);
} }
private void create() {
private void create(){
try { try {
tabularParameter = (TabularParameter) parameter; tabularParameter = (TabularParameter) parameter;
@ -130,7 +130,7 @@ public class TabularFld extends AbstractFld implements
private void retrieveInfo() { private void retrieveInfo() {
bind(); bind();
retrieveTabularResourceInfo(); retrieveTabularResourceInfo();
} }
private void createField(SimpleContainer tabContainer) { private void createField(SimpleContainer tabContainer) {
@ -161,12 +161,14 @@ public class TabularFld extends AbstractFld implements
HtmlLayoutContainer descr; HtmlLayoutContainer descr;
if (tabularParameter.getDescription() == null) { if (tabularParameter.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 { } else {
descr = new HtmlLayoutContainer("<p style='margin-left:5px !important;'>" descr = new HtmlLayoutContainer(
+ tabularParameter.getDescription() + "</p>"); "<p style='margin-left:5px !important;'>"
+ tabularParameter.getDescription() + "</p>");
descr.addStyleName("workflow-fieldDescription"); descr.addStyleName("workflow-fieldDescription");
} }
@ -264,7 +266,8 @@ public class TabularFld extends AbstractFld implements
useTabularResource(); useTabularResource();
} }
}); });
selectTRButton.setIcon(DataMinerManagerPanel.resources.tabularResource()); selectTRButton.setIcon(DataMinerManagerPanel.resources
.tabularResource());
selectTRButton.setToolTip("Use Tabular Resource"); selectTRButton.setToolTip("Use Tabular Resource");
selectTRButton2 = new TextButton(""); selectTRButton2 = new TextButton("");
@ -276,12 +279,10 @@ public class TabularFld extends AbstractFld implements
} }
}); });
selectTRButton2.setIcon(DataMinerManagerPanel.resources.tabularResource()); selectTRButton2.setIcon(DataMinerManagerPanel.resources
selectTRButton2.setToolTip("Select Tabular Resource"); .tabularResource());
selectTRButton2.setToolTip("Use Tabular Resource");
selectButton = new TextButton("Select Data Set"); selectButton = new TextButton("Select Data Set");
selectButton.addSelectHandler(new SelectEvent.SelectHandler() { selectButton.addSelectHandler(new SelectEvent.SelectHandler() {
@ -290,10 +291,10 @@ public class TabularFld extends AbstractFld implements
wselectDialog.show(); wselectDialog.show();
} }
}); });
selectButton.setIcon(DataMinerManagerPanel.resources.folderExplore()); selectButton.setIcon(DataMinerManagerPanel.resources
.folderExplore());
selectButton.setToolTip("Select Data Set"); selectButton.setToolTip("Select Data Set");
selectButton2 = new TextButton(""); selectButton2 = new TextButton("");
selectButton2.addSelectHandler(new SelectEvent.SelectHandler() { selectButton2.addSelectHandler(new SelectEvent.SelectHandler() {
@ -303,12 +304,10 @@ public class TabularFld extends AbstractFld implements
} }
}); });
selectButton2.setIcon(DataMinerManagerPanel.resources.folderExplore()); selectButton2.setIcon(DataMinerManagerPanel.resources
.folderExplore());
selectButton2.setToolTip("Select Another Data Set"); selectButton2.setToolTip("Select Another Data Set");
cancelButton = new TextButton(""); cancelButton = new TextButton("");
cancelButton.setIcon(DataMinerManagerPanel.resources.cancel()); cancelButton.setIcon(DataMinerManagerPanel.resources.cancel());
cancelButton.addSelectHandler(new SelectEvent.SelectHandler() { cancelButton.addSelectHandler(new SelectEvent.SelectHandler() {
@ -336,26 +335,26 @@ public class TabularFld extends AbstractFld implements
throw e; throw e;
} }
} }
private void useTabularResource() { private void useTabularResource() {
Log.debug("TabularResourceData: " + tabularResourceData); Log.debug("TabularResourceData: " + tabularResourceData);
selectedTableItem=new TableItemSimple(tabularResourceData.getTabularResourceId(), selectedTableItem = new TableItemSimple(
tabularResourceData.getName(),tabularResourceData.getDescription(), tabularResourceData.getType()); tabularResourceData.getTabularResourceId(),
tabularResourceData.getName(),
tabularResourceData.getDescription(),
tabularResourceData.getType());
selectedTableItem.setColumns(tabularResourceData.getColumns()); selectedTableItem.setColumns(tabularResourceData.getColumns());
showFieldWithTRSelection(); showFieldWithTRSelection();
updateListeners(selectedTableItem); updateListeners(selectedTableItem);
} }
private void retrieveTableInformation(Item item) { private void retrieveTableInformation(Item item) {
Log.debug("Retrieved: " + item); Log.debug("Retrieved: " + item);
itemDescriptionSelected = new ItemDescription( itemDescriptionSelected = new ItemDescription(item.getId(),
item.getId(), item.getName(), item.getOwner(), item.getPath(), item.getName(), item.getOwner(), item.getPath(), item.getType()
item.getType().name()); .name());
DataMinerPortletServiceAsync.INSTANCE.retrieveTableInformation(item, DataMinerPortletServiceAsync.INSTANCE.retrieveTableInformation(item,
new AsyncCallback<TableItemSimple>() { new AsyncCallback<TableItemSimple>() {
@ -383,7 +382,7 @@ public class TabularFld extends AbstractFld implements
} }
}); });
} }
private void downloadFile() { private void downloadFile() {
if (itemDescriptionSelected != null) { if (itemDescriptionSelected != null) {
DataMinerPortletServiceAsync.INSTANCE.getPublicLink( DataMinerPortletServiceAsync.INSTANCE.getPublicLink(
@ -407,7 +406,8 @@ public class TabularFld extends AbstractFld implements
@Override @Override
public void onSuccess(String link) { public void onSuccess(String link) {
Log.debug("Retrieved link: " + link); Log.debug("Retrieved link: " + link);
Window.open(link, itemDescriptionSelected.getName(), ""); Window.open(link,
itemDescriptionSelected.getName(), "");
} }
}); });
@ -430,7 +430,6 @@ public class TabularFld extends AbstractFld implements
fieldContainer.forceLayout(); fieldContainer.forceLayout();
} }
private void showFieldWithFileSelection() { private void showFieldWithFileSelection() {
String tableName = selectedTableItem.getName(); String tableName = selectedTableItem.getName();
@ -455,7 +454,6 @@ public class TabularFld extends AbstractFld implements
fieldContainer.forceLayout(); fieldContainer.forceLayout();
} }
private void showFieldWithTRSelection() { private void showFieldWithTRSelection() {
String tableName = selectedTableItem.getName(); String tableName = selectedTableItem.getName();
@ -478,7 +476,6 @@ public class TabularFld extends AbstractFld implements
fieldContainer.forceLayout(); fieldContainer.forceLayout();
} }
/** /**
* *
*/ */