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
|
@ -149,10 +149,11 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
|
||||
public enum ResourcesSortInfo {
|
||||
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 static List<String> resourcesSortInfoI18NList;
|
||||
|
||||
static {
|
||||
|
@ -163,7 +164,7 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
}
|
||||
|
||||
private ResourcesSortInfo(String id) {
|
||||
this.id = id;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@ -173,12 +174,11 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
public String toString() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getIdI18N(){
|
||||
|
||||
public String getIdI18N() {
|
||||
return msgs.resourceSortInfo(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static List<ResourcesSortInfo> asList() {
|
||||
List<ResourcesSortInfo> list = Arrays.asList(values());
|
||||
return list;
|
||||
|
@ -188,7 +188,7 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
return resourcesSortInfoI18NList;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private ResourcesListViewDetailPanel details;
|
||||
|
@ -221,8 +221,8 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
init();
|
||||
create();
|
||||
}
|
||||
|
||||
protected void initMessages(){
|
||||
|
||||
protected void initMessages() {
|
||||
msgs = GWT.create(ResourcesMessages.class);
|
||||
msgsCommon = GWT.create(CommonMessages.class);
|
||||
}
|
||||
|
@ -277,7 +277,8 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
if (v.equals(ResourcesSortInfo.Name.getIdI18N())) {
|
||||
return o1.getName().compareToIgnoreCase(
|
||||
o2.getName());
|
||||
} else if (v.equals(ResourcesSortInfo.CreationDate.getIdI18N())) {
|
||||
} else if (v.equals(ResourcesSortInfo.CreationDate
|
||||
.getIdI18N())) {
|
||||
return o1.getCreationDate().compareTo(
|
||||
o2.getCreationDate());
|
||||
|
||||
|
@ -539,7 +540,8 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
} else {
|
||||
Log.error("Error Retrieving Resources: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert(msgs.errorRetrievingResourcesHead(),
|
||||
UtilsGXT3.alert(
|
||||
msgs.errorRetrievingResourcesHead(),
|
||||
caught.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
@ -551,12 +553,14 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
Log.debug("Resources loaded " + result.size());
|
||||
if (result != null && result.size() > 0) {
|
||||
statusBar.clear();
|
||||
statusBar
|
||||
.add(new LabelToolItem(msgs.statusBarNumberOfResources(result.size())));
|
||||
statusBar.add(new LabelToolItem(msgs
|
||||
.statusBarNumberOfResources(result
|
||||
.size())));
|
||||
} else {
|
||||
statusBar.clear();
|
||||
statusBar.add(new LabelToolItem(msgs.statusBarNoResource()));
|
||||
|
||||
statusBar.add(new LabelToolItem(msgs
|
||||
.statusBarNoResource()));
|
||||
|
||||
}
|
||||
statusBar.forceLayout();
|
||||
try {
|
||||
|
@ -581,11 +585,11 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
|
||||
@Override
|
||||
public void onSelection(SelectionEvent<Item> event) {
|
||||
List<ResourceTDDescriptor> resources= listView.getSelectionModel()
|
||||
.getSelectedItems();
|
||||
ResourceTDDescriptor selected=null;
|
||||
if(resources!=null&&resources.size()>0){
|
||||
selected=resources.get(0);
|
||||
List<ResourceTDDescriptor> resources = listView
|
||||
.getSelectionModel().getSelectedItems();
|
||||
ResourceTDDescriptor selected = null;
|
||||
if (resources != null && resources.size() > 0) {
|
||||
selected = resources.get(0);
|
||||
}
|
||||
Log.debug("selected: " + selected);
|
||||
requestOpen(selected);
|
||||
|
@ -600,11 +604,11 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
|
||||
@Override
|
||||
public void onSelection(SelectionEvent<Item> event) {
|
||||
List<ResourceTDDescriptor> resources= listView.getSelectionModel()
|
||||
.getSelectedItems();
|
||||
ResourceTDDescriptor selected=null;
|
||||
if(resources!=null&&resources.size()>0){
|
||||
selected=resources.get(0);
|
||||
List<ResourceTDDescriptor> resources = listView
|
||||
.getSelectionModel().getSelectedItems();
|
||||
ResourceTDDescriptor selected = null;
|
||||
if (resources != null && resources.size() > 0) {
|
||||
selected = resources.get(0);
|
||||
}
|
||||
Log.debug("selected: " + selected);
|
||||
requestSave(selected);
|
||||
|
@ -619,10 +623,11 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
|
||||
@Override
|
||||
public void onSelection(SelectionEvent<Item> event) {
|
||||
List<ResourceTDDescriptor> selected= listView.getSelectionModel()
|
||||
.getSelectedItems();
|
||||
List<ResourceTDDescriptor> selected = listView
|
||||
.getSelectionModel().getSelectedItems();
|
||||
Log.debug("selected: " + selected);
|
||||
ArrayList<ResourceTDDescriptor> resources=new ArrayList<ResourceTDDescriptor>(selected);
|
||||
ArrayList<ResourceTDDescriptor> resources = new ArrayList<ResourceTDDescriptor>(
|
||||
selected);
|
||||
requestRemove(resources);
|
||||
}
|
||||
|
||||
|
@ -756,7 +761,8 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
public void onSuccess() {
|
||||
|
||||
SaveResourceWizard saveResourceWizard = new SaveResourceWizard(
|
||||
saveResourceSession, msgs.saveResourceWizardHead(), eventBus);
|
||||
saveResourceSession, msgs.saveResourceWizardHead(),
|
||||
eventBus);
|
||||
|
||||
saveResourceWizard.addListener(new WizardListener() {
|
||||
|
||||
|
@ -792,10 +798,10 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
}
|
||||
|
||||
protected void requestRemove(ArrayList<ResourceTDDescriptor> resourcesList) {
|
||||
ArrayList<ResourceTDDescriptor> resources=new ArrayList<ResourceTDDescriptor>(resourcesList);
|
||||
|
||||
removeResourceSession = new RemoveResourceSession(trId,
|
||||
resources);
|
||||
ArrayList<ResourceTDDescriptor> resources = new ArrayList<ResourceTDDescriptor>(
|
||||
resourcesList);
|
||||
|
||||
removeResourceSession = new RemoveResourceSession(trId, resources);
|
||||
|
||||
TDGWTServiceAsync.INSTANCE.removeResource(removeResourceSession,
|
||||
new AsyncCallback<Void>() {
|
||||
|
@ -915,9 +921,8 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
} else {
|
||||
Log.error("Error with uri resolver: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3
|
||||
.alert(msgsCommon.error(),
|
||||
msgs.errorRetrievingURIFromResolver());
|
||||
UtilsGXT3.alert(msgsCommon.error(), msgs
|
||||
.errorRetrievingURIFromResolver());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -950,69 +955,74 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
|
||||
InternalURITD genericFileResourceTD = (InternalURITD) resource;
|
||||
String name = resourceTDDescriptor.getName();
|
||||
|
||||
|
||||
/*
|
||||
MimeTypeSupport ext=null;
|
||||
String extentionInName=null;
|
||||
if(name!=null){
|
||||
List<String> nameS=null;
|
||||
try{
|
||||
nameS=Arrays.asList(name.split("\\.(?=[^\\.]+$)"));
|
||||
} catch(Throwable e) {
|
||||
Log.error("No valid name for resource: "+name);
|
||||
}
|
||||
|
||||
if(nameS!=null&&nameS.size()>1){
|
||||
extentionInName=nameS.get(nameS.size()-1);
|
||||
ext=MimeTypeSupport.getMimeTypeSupportFromExtension("."+extentionInName);
|
||||
|
||||
}
|
||||
}
|
||||
if(ext==null){
|
||||
|
||||
*/
|
||||
|
||||
* MimeTypeSupport ext=null; String extentionInName=null;
|
||||
* if(name!=null){ List<String> nameS=null; try{
|
||||
* nameS=Arrays.asList(name.split("\\.(?=[^\\.]+$)")); }
|
||||
* catch(Throwable e) {
|
||||
* Log.error("No valid name for resource: "+name); }
|
||||
*
|
||||
* if(nameS!=null&&nameS.size()>1){
|
||||
* extentionInName=nameS.get(nameS.size()-1);
|
||||
* ext=MimeTypeSupport.getMimeTypeSupportFromExtension
|
||||
* ("."+extentionInName);
|
||||
*
|
||||
* } } if(ext==null){
|
||||
*/
|
||||
|
||||
MimeTypeSupport mts = MimeTypeSupport
|
||||
.getMimeTypeSupportFromMimeName(genericFileResourceTD
|
||||
.getMimeType());
|
||||
if (mts != null) {
|
||||
name = name + mts.getExtension();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
}
|
||||
* }
|
||||
*/
|
||||
|
||||
UriResolverSession uriResolverSession = new UriResolverSession(
|
||||
genericFileResourceTD.getId(), ApplicationType.SMP_ID,
|
||||
name, genericFileResourceTD.getMimeType());
|
||||
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(), "");
|
||||
|
||||
TDGWTServiceAsync.INSTANCE.getUriFromResolver(uriResolverSession,
|
||||
new AsyncCallback<String>() {
|
||||
} else {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
Log.error("Error with uri resolver: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert(msgsCommon.error(),
|
||||
msgs.errorRetrievingURIFromResolver());
|
||||
UriResolverSession uriResolverSession = new UriResolverSession(
|
||||
genericFileResourceTD.getId(), ApplicationType.SMP_ID,
|
||||
name, genericFileResourceTD.getMimeType());
|
||||
|
||||
TDGWTServiceAsync.INSTANCE.getUriFromResolver(
|
||||
uriResolverSession, new AsyncCallback<String>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
Log.error("Error with uri resolver: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert(msgsCommon.error(), msgs
|
||||
.errorRetrievingURIFromResolver());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onSuccess(String link) {
|
||||
Log.debug("Retrieved link: " + link);
|
||||
Window.open(link, resourceTDDescriptor.getName(),
|
||||
"");
|
||||
}
|
||||
public void onSuccess(String link) {
|
||||
Log.debug("Retrieved link: " + link);
|
||||
Window.open(link,
|
||||
resourceTDDescriptor.getName(), "");
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
} else {
|
||||
Log.error("Error with resource: no valid resource");
|
||||
UtilsGXT3
|
||||
.alert(msgsCommon.error(), msgs.errorNoValidInternalUri());
|
||||
UtilsGXT3.alert(msgsCommon.error(), msgs.errorNoValidInternalUri());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue