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/user/tabular-data-resources-widget@146532 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
5d7fd26fa5
commit
94cc8323cc
|
@ -150,7 +150,8 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
public enum ResourcesSortInfo {
|
public enum ResourcesSortInfo {
|
||||||
Name("Name"), CreationDate("Creation Date");
|
Name("Name"), CreationDate("Creation Date");
|
||||||
|
|
||||||
private static ResourcesMessages msgs=GWT.create(ResourcesMessages.class);
|
private static ResourcesMessages msgs = GWT
|
||||||
|
.create(ResourcesMessages.class);
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
private static List<String> resourcesSortInfoI18NList;
|
private static List<String> resourcesSortInfoI18NList;
|
||||||
|
@ -178,7 +179,6 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
return msgs.resourceSortInfo(this);
|
return msgs.resourceSortInfo(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static List<ResourcesSortInfo> asList() {
|
public static List<ResourcesSortInfo> asList() {
|
||||||
List<ResourcesSortInfo> list = Arrays.asList(values());
|
List<ResourcesSortInfo> list = Arrays.asList(values());
|
||||||
return list;
|
return list;
|
||||||
|
@ -277,7 +277,8 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
if (v.equals(ResourcesSortInfo.Name.getIdI18N())) {
|
if (v.equals(ResourcesSortInfo.Name.getIdI18N())) {
|
||||||
return o1.getName().compareToIgnoreCase(
|
return o1.getName().compareToIgnoreCase(
|
||||||
o2.getName());
|
o2.getName());
|
||||||
} else if (v.equals(ResourcesSortInfo.CreationDate.getIdI18N())) {
|
} else if (v.equals(ResourcesSortInfo.CreationDate
|
||||||
|
.getIdI18N())) {
|
||||||
return o1.getCreationDate().compareTo(
|
return o1.getCreationDate().compareTo(
|
||||||
o2.getCreationDate());
|
o2.getCreationDate());
|
||||||
|
|
||||||
|
@ -539,7 +540,8 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
} else {
|
} else {
|
||||||
Log.error("Error Retrieving Resources: "
|
Log.error("Error Retrieving Resources: "
|
||||||
+ caught.getLocalizedMessage());
|
+ caught.getLocalizedMessage());
|
||||||
UtilsGXT3.alert(msgs.errorRetrievingResourcesHead(),
|
UtilsGXT3.alert(
|
||||||
|
msgs.errorRetrievingResourcesHead(),
|
||||||
caught.getLocalizedMessage());
|
caught.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -551,11 +553,13 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
Log.debug("Resources loaded " + result.size());
|
Log.debug("Resources loaded " + result.size());
|
||||||
if (result != null && result.size() > 0) {
|
if (result != null && result.size() > 0) {
|
||||||
statusBar.clear();
|
statusBar.clear();
|
||||||
statusBar
|
statusBar.add(new LabelToolItem(msgs
|
||||||
.add(new LabelToolItem(msgs.statusBarNumberOfResources(result.size())));
|
.statusBarNumberOfResources(result
|
||||||
|
.size())));
|
||||||
} else {
|
} else {
|
||||||
statusBar.clear();
|
statusBar.clear();
|
||||||
statusBar.add(new LabelToolItem(msgs.statusBarNoResource()));
|
statusBar.add(new LabelToolItem(msgs
|
||||||
|
.statusBarNoResource()));
|
||||||
|
|
||||||
}
|
}
|
||||||
statusBar.forceLayout();
|
statusBar.forceLayout();
|
||||||
|
@ -581,8 +585,8 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSelection(SelectionEvent<Item> event) {
|
public void onSelection(SelectionEvent<Item> event) {
|
||||||
List<ResourceTDDescriptor> resources= listView.getSelectionModel()
|
List<ResourceTDDescriptor> resources = listView
|
||||||
.getSelectedItems();
|
.getSelectionModel().getSelectedItems();
|
||||||
ResourceTDDescriptor selected = null;
|
ResourceTDDescriptor selected = null;
|
||||||
if (resources != null && resources.size() > 0) {
|
if (resources != null && resources.size() > 0) {
|
||||||
selected = resources.get(0);
|
selected = resources.get(0);
|
||||||
|
@ -600,8 +604,8 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSelection(SelectionEvent<Item> event) {
|
public void onSelection(SelectionEvent<Item> event) {
|
||||||
List<ResourceTDDescriptor> resources= listView.getSelectionModel()
|
List<ResourceTDDescriptor> resources = listView
|
||||||
.getSelectedItems();
|
.getSelectionModel().getSelectedItems();
|
||||||
ResourceTDDescriptor selected = null;
|
ResourceTDDescriptor selected = null;
|
||||||
if (resources != null && resources.size() > 0) {
|
if (resources != null && resources.size() > 0) {
|
||||||
selected = resources.get(0);
|
selected = resources.get(0);
|
||||||
|
@ -619,10 +623,11 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSelection(SelectionEvent<Item> event) {
|
public void onSelection(SelectionEvent<Item> event) {
|
||||||
List<ResourceTDDescriptor> selected= listView.getSelectionModel()
|
List<ResourceTDDescriptor> selected = listView
|
||||||
.getSelectedItems();
|
.getSelectionModel().getSelectedItems();
|
||||||
Log.debug("selected: " + selected);
|
Log.debug("selected: " + selected);
|
||||||
ArrayList<ResourceTDDescriptor> resources=new ArrayList<ResourceTDDescriptor>(selected);
|
ArrayList<ResourceTDDescriptor> resources = new ArrayList<ResourceTDDescriptor>(
|
||||||
|
selected);
|
||||||
requestRemove(resources);
|
requestRemove(resources);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -756,7 +761,8 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
|
|
||||||
SaveResourceWizard saveResourceWizard = new SaveResourceWizard(
|
SaveResourceWizard saveResourceWizard = new SaveResourceWizard(
|
||||||
saveResourceSession, msgs.saveResourceWizardHead(), eventBus);
|
saveResourceSession, msgs.saveResourceWizardHead(),
|
||||||
|
eventBus);
|
||||||
|
|
||||||
saveResourceWizard.addListener(new WizardListener() {
|
saveResourceWizard.addListener(new WizardListener() {
|
||||||
|
|
||||||
|
@ -792,10 +798,10 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void requestRemove(ArrayList<ResourceTDDescriptor> resourcesList) {
|
protected void requestRemove(ArrayList<ResourceTDDescriptor> resourcesList) {
|
||||||
ArrayList<ResourceTDDescriptor> resources=new ArrayList<ResourceTDDescriptor>(resourcesList);
|
ArrayList<ResourceTDDescriptor> resources = new ArrayList<ResourceTDDescriptor>(
|
||||||
|
resourcesList);
|
||||||
|
|
||||||
removeResourceSession = new RemoveResourceSession(trId,
|
removeResourceSession = new RemoveResourceSession(trId, resources);
|
||||||
resources);
|
|
||||||
|
|
||||||
TDGWTServiceAsync.INSTANCE.removeResource(removeResourceSession,
|
TDGWTServiceAsync.INSTANCE.removeResource(removeResourceSession,
|
||||||
new AsyncCallback<Void>() {
|
new AsyncCallback<Void>() {
|
||||||
|
@ -915,9 +921,8 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
} else {
|
} else {
|
||||||
Log.error("Error with uri resolver: "
|
Log.error("Error with uri resolver: "
|
||||||
+ caught.getLocalizedMessage());
|
+ caught.getLocalizedMessage());
|
||||||
UtilsGXT3
|
UtilsGXT3.alert(msgsCommon.error(), msgs
|
||||||
.alert(msgsCommon.error(),
|
.errorRetrievingURIFromResolver());
|
||||||
msgs.errorRetrievingURIFromResolver());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -952,24 +957,18 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
String name = resourceTDDescriptor.getName();
|
String name = resourceTDDescriptor.getName();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
MimeTypeSupport ext=null;
|
* MimeTypeSupport ext=null; String extentionInName=null;
|
||||||
String extentionInName=null;
|
* if(name!=null){ List<String> nameS=null; try{
|
||||||
if(name!=null){
|
* nameS=Arrays.asList(name.split("\\.(?=[^\\.]+$)")); }
|
||||||
List<String> nameS=null;
|
* catch(Throwable e) {
|
||||||
try{
|
* Log.error("No valid name for resource: "+name); }
|
||||||
nameS=Arrays.asList(name.split("\\.(?=[^\\.]+$)"));
|
*
|
||||||
} catch(Throwable e) {
|
* if(nameS!=null&&nameS.size()>1){
|
||||||
Log.error("No valid name for resource: "+name);
|
* extentionInName=nameS.get(nameS.size()-1);
|
||||||
}
|
* ext=MimeTypeSupport.getMimeTypeSupportFromExtension
|
||||||
|
* ("."+extentionInName);
|
||||||
if(nameS!=null&&nameS.size()>1){
|
*
|
||||||
extentionInName=nameS.get(nameS.size()-1);
|
* } } if(ext==null){
|
||||||
ext=MimeTypeSupport.getMimeTypeSupportFromExtension("."+extentionInName);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(ext==null){
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MimeTypeSupport mts = MimeTypeSupport
|
MimeTypeSupport mts = MimeTypeSupport
|
||||||
|
@ -980,15 +979,26 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
}
|
* }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (genericFileResourceTD.getId() != null
|
||||||
|
&& !genericFileResourceTD.getId().isEmpty()
|
||||||
|
&& (genericFileResourceTD.getId().startsWith("http:") || genericFileResourceTD
|
||||||
|
.getId().startsWith("https:"))) {
|
||||||
|
|
||||||
|
Log.debug("Use direct http link");
|
||||||
|
Window.open(genericFileResourceTD.getId(),
|
||||||
|
resourceTDDescriptor.getName(), "");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
UriResolverSession uriResolverSession = new UriResolverSession(
|
UriResolverSession uriResolverSession = new UriResolverSession(
|
||||||
genericFileResourceTD.getId(), ApplicationType.SMP_ID,
|
genericFileResourceTD.getId(), ApplicationType.SMP_ID,
|
||||||
name, genericFileResourceTD.getMimeType());
|
name, genericFileResourceTD.getMimeType());
|
||||||
|
|
||||||
TDGWTServiceAsync.INSTANCE.getUriFromResolver(uriResolverSession,
|
TDGWTServiceAsync.INSTANCE.getUriFromResolver(
|
||||||
new AsyncCallback<String>() {
|
uriResolverSession, new AsyncCallback<String>() {
|
||||||
|
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
if (caught instanceof TDGWTSessionExpiredException) {
|
if (caught instanceof TDGWTSessionExpiredException) {
|
||||||
|
@ -997,22 +1007,22 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
} else {
|
} else {
|
||||||
Log.error("Error with uri resolver: "
|
Log.error("Error with uri resolver: "
|
||||||
+ caught.getLocalizedMessage());
|
+ caught.getLocalizedMessage());
|
||||||
UtilsGXT3.alert(msgsCommon.error(),
|
UtilsGXT3.alert(msgsCommon.error(), msgs
|
||||||
msgs.errorRetrievingURIFromResolver());
|
.errorRetrievingURIFromResolver());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSuccess(String link) {
|
public void onSuccess(String link) {
|
||||||
Log.debug("Retrieved link: " + link);
|
Log.debug("Retrieved link: " + link);
|
||||||
Window.open(link, resourceTDDescriptor.getName(),
|
Window.open(link,
|
||||||
"");
|
resourceTDDescriptor.getName(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.error("Error with resource: no valid resource");
|
Log.error("Error with resource: no valid resource");
|
||||||
UtilsGXT3
|
UtilsGXT3.alert(msgsCommon.error(), msgs.errorNoValidInternalUri());
|
||||||
.alert(msgsCommon.error(), msgs.errorNoValidInternalUri());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue