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 {
|
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;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -163,7 +164,7 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResourcesSortInfo(String id) {
|
private ResourcesSortInfo(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
@ -173,12 +174,11 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIdI18N(){
|
public String getIdI18N() {
|
||||||
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;
|
||||||
|
@ -188,7 +188,7 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
return resourcesSortInfoI18NList;
|
return resourcesSortInfoI18NList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResourcesListViewDetailPanel details;
|
private ResourcesListViewDetailPanel details;
|
||||||
|
@ -221,8 +221,8 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
init();
|
init();
|
||||||
create();
|
create();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initMessages(){
|
protected void initMessages() {
|
||||||
msgs = GWT.create(ResourcesMessages.class);
|
msgs = GWT.create(ResourcesMessages.class);
|
||||||
msgsCommon = GWT.create(CommonMessages.class);
|
msgsCommon = GWT.create(CommonMessages.class);
|
||||||
}
|
}
|
||||||
|
@ -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,12 +553,14 @@ 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();
|
||||||
try {
|
try {
|
||||||
|
@ -581,11 +585,11 @@ 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);
|
||||||
}
|
}
|
||||||
Log.debug("selected: " + selected);
|
Log.debug("selected: " + selected);
|
||||||
requestOpen(selected);
|
requestOpen(selected);
|
||||||
|
@ -600,11 +604,11 @@ 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);
|
||||||
}
|
}
|
||||||
Log.debug("selected: " + selected);
|
Log.debug("selected: " + selected);
|
||||||
requestSave(selected);
|
requestSave(selected);
|
||||||
|
@ -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,
|
|
||||||
resources);
|
removeResourceSession = new RemoveResourceSession(trId, 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());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -950,69 +955,74 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
|
|
||||||
InternalURITD genericFileResourceTD = (InternalURITD) resource;
|
InternalURITD genericFileResourceTD = (InternalURITD) resource;
|
||||||
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
|
||||||
.getMimeTypeSupportFromMimeName(genericFileResourceTD
|
.getMimeTypeSupportFromMimeName(genericFileResourceTD
|
||||||
.getMimeType());
|
.getMimeType());
|
||||||
if (mts != null) {
|
if (mts != null) {
|
||||||
name = name + mts.getExtension();
|
name = name + mts.getExtension();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
}
|
* }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
UriResolverSession uriResolverSession = new UriResolverSession(
|
if (genericFileResourceTD.getId() != null
|
||||||
genericFileResourceTD.getId(), ApplicationType.SMP_ID,
|
&& !genericFileResourceTD.getId().isEmpty()
|
||||||
name, genericFileResourceTD.getMimeType());
|
&& (genericFileResourceTD.getId().startsWith("http:") || genericFileResourceTD
|
||||||
|
.getId().startsWith("https:"))) {
|
||||||
|
|
||||||
|
Log.debug("Use direct http link");
|
||||||
|
Window.open(genericFileResourceTD.getId(),
|
||||||
|
resourceTDDescriptor.getName(), "");
|
||||||
|
|
||||||
TDGWTServiceAsync.INSTANCE.getUriFromResolver(uriResolverSession,
|
} else {
|
||||||
new AsyncCallback<String>() {
|
|
||||||
|
|
||||||
public void onFailure(Throwable caught) {
|
UriResolverSession uriResolverSession = new UriResolverSession(
|
||||||
if (caught instanceof TDGWTSessionExpiredException) {
|
genericFileResourceTD.getId(), ApplicationType.SMP_ID,
|
||||||
eventBus.fireEvent(new SessionExpiredEvent(
|
name, genericFileResourceTD.getMimeType());
|
||||||
SessionExpiredType.EXPIREDONSERVER));
|
|
||||||
} else {
|
TDGWTServiceAsync.INSTANCE.getUriFromResolver(
|
||||||
Log.error("Error with uri resolver: "
|
uriResolverSession, new AsyncCallback<String>() {
|
||||||
+ caught.getLocalizedMessage());
|
|
||||||
UtilsGXT3.alert(msgsCommon.error(),
|
public void onFailure(Throwable caught) {
|
||||||
msgs.errorRetrievingURIFromResolver());
|
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) {
|
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