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.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;
@ -37,16 +40,24 @@ import com.sencha.gxt.widget.core.client.form.TextField;
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 selectButton;
private TextButton selectButton2;
private TextButton selectTRButton;
private TextButton selectTRButton2;
private TextButton downloadButton;
private TextField tableDescription;
private WorkspaceExplorerSelectDialog wselectDialog;
private ItemDescription itemDescriptionSelected;
private TabularResourceData tabularResourceData;
private boolean created = false;
private boolean first = true;
/**
*
* @param tabularListFld
@ -57,16 +68,72 @@ public class TabItem extends HBoxLayoutContainer {
boolean first) {
super();
this.parent = parent;
initDialog();
create(tabularParameter, first);
this.first = 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.setReadOnly(true);
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.addSelectHandler(new SelectEvent.SelectHandler() {
@ -90,8 +157,7 @@ public class TabItem extends HBoxLayoutContainer {
}
});
selectButton2.setVisible(false);
downloadButton = new TextButton("");
downloadButton.setIcon(DataMinerManagerPanel.resources.download());
downloadButton.addSelectHandler(new SelectEvent.SelectHandler() {
@ -102,8 +168,7 @@ public class TabItem extends HBoxLayoutContainer {
}
});
downloadButton.setVisible(false);
addBtn = new TextButton("");
addBtn.setIcon(DataMinerManagerPanel.resources.add());
addBtn.addSelectHandler(new SelectEvent.SelectHandler() {
@ -128,20 +193,20 @@ public class TabItem extends HBoxLayoutContainer {
});
removeBtn.setVisible(!first);
setPack(BoxLayoutPack.START);
setEnableOverflow(false);
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(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() {
@ -214,9 +279,9 @@ public class TabItem extends HBoxLayoutContainer {
private void retrieveTableInformation(Item item) {
Log.debug("Retrieved: " + item);
itemDescriptionSelected = new ItemDescription(
item.getId(), item.getName(), item.getOwner(), item.getPath(),
item.getType().name());
itemDescriptionSelected = new ItemDescription(item.getId(),
item.getName(), item.getOwner(), item.getPath(), item.getType()
.name());
DataMinerPortletServiceAsync.INSTANCE.retrieveTableInformation(item,
new AsyncCallback<TableItemSimple>() {
@ -240,13 +305,12 @@ public class TabItem extends HBoxLayoutContainer {
public void onSuccess(TableItemSimple result) {
Log.debug("Retrieved: " + result);
selectedTableItem = result;
showFieldWithSelection();
showFieldWithFileSelection();
}
});
}
private void downloadFile() {
if (itemDescriptionSelected != null) {
DataMinerPortletServiceAsync.INSTANCE.getPublicLink(
@ -270,7 +334,8 @@ public class TabItem extends HBoxLayoutContainer {
@Override
public void onSuccess(String 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 {
String tableName = selectedTableItem.getName();
@ -295,6 +371,32 @@ public class TabItem extends HBoxLayoutContainer {
tableDescription.setValue(tableName);
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);
selectButton2.setVisible(true);
downloadButton.setVisible(true);

View File

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