ref 9056:TabMan - Improve resource management in TabMan

https://support.d4science.org/issues/9056

Improve resources management

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-resources-widget@151393 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-07-27 15:23:06 +00:00
parent 0909055093
commit c588bd2d66
1 changed files with 177 additions and 263 deletions

View File

@ -106,13 +106,12 @@ public class ResourcesListViewPanel extends FramedPanel {
@FormatterFactories(@FormatterFactory(factory = ShortenFactory.class, name = "shorten"))
public interface Renderer extends XTemplates {
@XTemplate(source = "ResourcesListView.html")
public SafeHtml renderItem(ResourceTDDescriptor resourceTDDescriptor,
SafeUri thumbnailPath, ResourceListViewCSS style);
public SafeHtml renderItem(ResourceTDDescriptor resourceTDDescriptor, SafeUri thumbnailPath,
ResourceListViewCSS style);
}
public interface ResourcesListViewBundle extends ClientBundle {
public static final ResourcesListViewBundle INSTANCE = GWT
.create(ResourcesListViewBundle.class);
public static final ResourcesListViewBundle INSTANCE = GWT.create(ResourcesListViewBundle.class);
@Source("ResourcesListView.css")
ResourceListViewCSS css();
@ -151,8 +150,7 @@ 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;
@ -254,8 +252,7 @@ public class ResourcesListViewPanel extends FramedPanel {
Log.debug("Create Resource List View");
RpcProxy<Object, List<ResourceTDDescriptor>> proxy = new RpcProxy<Object, List<ResourceTDDescriptor>>() {
@Override
public void load(Object loadConfig,
AsyncCallback<List<ResourceTDDescriptor>> callback) {
public void load(Object loadConfig, AsyncCallback<List<ResourceTDDescriptor>> callback) {
loadData(callback);
}
};
@ -268,38 +265,31 @@ public class ResourcesListViewPanel extends FramedPanel {
};
store = new ListStore<ResourceTDDescriptor>(keyProvider);
store.addSortInfo(new StoreSortInfo<ResourceTDDescriptor>(
new Comparator<ResourceTDDescriptor>() {
@Override
public int compare(ResourceTDDescriptor o1,
ResourceTDDescriptor o2) {
store.addSortInfo(new StoreSortInfo<ResourceTDDescriptor>(new Comparator<ResourceTDDescriptor>() {
@Override
public int compare(ResourceTDDescriptor o1, ResourceTDDescriptor o2) {
String v = comboSort.getCurrentValue();
if (v.equals(ResourcesSortInfo.Name.getIdI18N())) {
return o1.getName().compareToIgnoreCase(
o2.getName());
} else if (v.equals(ResourcesSortInfo.CreationDate
.getIdI18N())) {
return o1.getCreationDate().compareTo(
o2.getCreationDate());
String v = comboSort.getCurrentValue();
if (v.equals(ResourcesSortInfo.Name.getIdI18N())) {
return o1.getName().compareToIgnoreCase(o2.getName());
} else if (v.equals(ResourcesSortInfo.CreationDate.getIdI18N())) {
return o1.getCreationDate().compareTo(o2.getCreationDate());
}
}
return 0;
}
}, SortDir.ASC));
return 0;
}
}, SortDir.ASC));
loader = new Loader<Object, List<ResourceTDDescriptor>>(proxy);
loader.addLoadHandler(new ListStoreBinding<Object, ResourceTDDescriptor, List<ResourceTDDescriptor>>(
store));
loader.addLoadHandler(new ListStoreBinding<Object, ResourceTDDescriptor, List<ResourceTDDescriptor>>(store));
// ToolBar
StoreFilterField<ResourceTDDescriptor> filterField = new StoreFilterField<ResourceTDDescriptor>() {
@Override
protected boolean doSelect(Store<ResourceTDDescriptor> store,
ResourceTDDescriptor parent, ResourceTDDescriptor item,
String filter) {
protected boolean doSelect(Store<ResourceTDDescriptor> store, ResourceTDDescriptor parent,
ResourceTDDescriptor item, String filter) {
String name = item.getName().toLowerCase();
if (name.indexOf(filter.toLowerCase()) != -1) {
return true;
@ -322,8 +312,7 @@ public class ResourcesListViewPanel extends FramedPanel {
toolBar.add(new SeparatorToolItem());
toolBar.add(new LabelToolItem(msgs.toolBarSortBy()));
comboSort = new SimpleComboBox<String>(
new StringLabelProvider<String>());
comboSort = new SimpleComboBox<String>(new StringLabelProvider<String>());
comboSort.setTriggerAction(TriggerAction.ALL);
comboSort.setEditable(false);
comboSort.setForceSelection(true);
@ -354,26 +343,23 @@ public class ResourcesListViewPanel extends FramedPanel {
"." + style.thumbWrap(), style.over(), style.select()) {
@Override
public void renderEnd(SafeHtmlBuilder builder) {
String markup = new StringBuilder("<div class=\"")
.append(CommonStyles.get().clear()).append("\"></div>")
.toString();
String markup = new StringBuilder("<div class=\"").append(CommonStyles.get().clear())
.append("\"></div>").toString();
builder.appendHtmlConstant(markup);
}
@Override
public void renderItem(SafeHtmlBuilder builder, SafeHtml content) {
builder.appendHtmlConstant("<div class='" + style.thumbWrap()
+ "' style='border: 1px solid white'>");
builder.appendHtmlConstant("<div class='" + style.thumbWrap() + "' style='border: 1px solid white'>");
builder.append(content);
builder.appendHtmlConstant("</div>");
}
};
listView = new ListView<ResourceTDDescriptor, ResourceTDDescriptor>(
store, new IdentityValueProvider<ResourceTDDescriptor>() {
listView = new ListView<ResourceTDDescriptor, ResourceTDDescriptor>(store,
new IdentityValueProvider<ResourceTDDescriptor>() {
@Override
public void setValue(ResourceTDDescriptor object,
ResourceTDDescriptor value) {
public void setValue(ResourceTDDescriptor object, ResourceTDDescriptor value) {
}
}, appearance) {
@ -391,8 +377,8 @@ public class ResourcesListViewPanel extends FramedPanel {
};
listView.setLoader(loader);
listView.setCell(new SimpleSafeHtmlCell<ResourceTDDescriptor>(
new AbstractSafeHtmlRenderer<ResourceTDDescriptor>() {
listView.setCell(
new SimpleSafeHtmlCell<ResourceTDDescriptor>(new AbstractSafeHtmlRenderer<ResourceTDDescriptor>() {
@Override
public SafeHtml render(ResourceTDDescriptor descriptor) {
return renderCellResource(descriptor);
@ -400,14 +386,12 @@ public class ResourcesListViewPanel extends FramedPanel {
}));
listView.getSelectionModel().setSelectionMode(SelectionMode.MULTI);
listView.getSelectionModel().addSelectionChangedHandler(
new SelectionChangedHandler<ResourceTDDescriptor>() {
@Override
public void onSelectionChanged(
SelectionChangedEvent<ResourceTDDescriptor> event) {
ResourcesListViewPanel.this.onSelectionChange(event);
}
});
listView.getSelectionModel().addSelectionChangedHandler(new SelectionChangedHandler<ResourceTDDescriptor>() {
@Override
public void onSelectionChanged(SelectionChangedEvent<ResourceTDDescriptor> event) {
ResourcesListViewPanel.this.onSelectionChange(event);
}
});
listView.setBorders(false);
createContextMenu();
@ -450,8 +434,7 @@ public class ResourcesListViewPanel extends FramedPanel {
thumbnailPath = ResourceBundle.INSTANCE.chart80().getSafeUri();
break;
case CODELIST:
thumbnailPath = ResourceBundle.INSTANCE.codelist80()
.getSafeUri();
thumbnailPath = ResourceBundle.INSTANCE.codelist80().getSafeUri();
break;
case CSV:
thumbnailPath = ResourceBundle.INSTANCE.csv80().getSafeUri();
@ -463,8 +446,7 @@ public class ResourcesListViewPanel extends FramedPanel {
thumbnailPath = ResourceBundle.INSTANCE.table80().getSafeUri();
break;
case GUESSER:
thumbnailPath = ResourceBundle.INSTANCE.resources80()
.getSafeUri();
thumbnailPath = ResourceBundle.INSTANCE.resources80().getSafeUri();
break;
case JSON:
thumbnailPath = ResourceBundle.INSTANCE.json80().getSafeUri();
@ -476,8 +458,7 @@ public class ResourcesListViewPanel extends FramedPanel {
thumbnailPath = ResourceBundle.INSTANCE.sdmx80().getSafeUri();
break;
default:
thumbnailPath = ResourceBundle.INSTANCE.resources80()
.getSafeUri();
thumbnailPath = ResourceBundle.INSTANCE.resources80().getSafeUri();
break;
}
}
@ -486,22 +467,15 @@ public class ResourcesListViewPanel extends FramedPanel {
if (resourceTD instanceof InternalURITD) {
InternalURITD internalURITD = (InternalURITD) resourceTD;
if (internalURITD.getThumbnailTD() != null
&& internalURITD.getThumbnailTD().getUrl() != null) {
thumbnailPath = UriUtils.fromTrustedString(internalURITD
.getThumbnailTD().getUrl());
if (internalURITD.getThumbnailTD() != null && internalURITD.getThumbnailTD().getUrl() != null) {
thumbnailPath = UriUtils.fromTrustedString(internalURITD.getThumbnailTD().getUrl());
} else {
if (internalURITD.getMimeType() != null) {
if (internalURITD.getMimeType().compareTo(
MimeTypeSupport._gif.getMimeName()) == 0
|| internalURITD.getMimeType().compareTo(
MimeTypeSupport._jpg.getMimeName()) == 0
|| internalURITD.getMimeType().compareTo(
MimeTypeSupport._png.getMimeName()) == 0
|| internalURITD.getMimeType().compareTo(
MimeTypeSupport._bmp.getMimeName()) == 0) {
thumbnailPath = ResourceBundle.INSTANCE.picture80()
.getSafeUri();
if (internalURITD.getMimeType().compareTo(MimeTypeSupport._gif.getMimeName()) == 0
|| internalURITD.getMimeType().compareTo(MimeTypeSupport._jpg.getMimeName()) == 0
|| internalURITD.getMimeType().compareTo(MimeTypeSupport._png.getMimeName()) == 0
|| internalURITD.getMimeType().compareTo(MimeTypeSupport._bmp.getMimeName()) == 0) {
thumbnailPath = ResourceBundle.INSTANCE.picture80().getSafeUri();
}
}
}
@ -510,8 +484,7 @@ public class ResourcesListViewPanel extends FramedPanel {
return renderer.renderItem(descriptor, thumbnailPath, style);
}
private void onSelectionChange(
SelectionChangedEvent<ResourceTDDescriptor> se) {
private void onSelectionChange(SelectionChangedEvent<ResourceTDDescriptor> se) {
if (se.getSelection().size() > 0) {
ResourceTDDescriptor descriptor = se.getSelection().get(0);
details.setDescriptor(descriptor);
@ -522,57 +495,46 @@ public class ResourcesListViewPanel extends FramedPanel {
}
protected void loadData(
final AsyncCallback<List<ResourceTDDescriptor>> callback) {
protected void loadData(final AsyncCallback<List<ResourceTDDescriptor>> callback) {
Log.debug("Called loadData");
if (trId != null) {
TDGWTServiceAsync.INSTANCE.getResourcesTD(trId,
new AsyncCallback<ArrayList<ResourceTDDescriptor>>() {
TDGWTServiceAsync.INSTANCE.getResourcesTD(trId, new AsyncCallback<ArrayList<ResourceTDDescriptor>>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
if (caught instanceof TDGWTIsLockedException) {
Log.error(caught.getLocalizedMessage());
UtilsGXT3.alert(msgsCommon.errorLocked(),
caught.getLocalizedMessage());
} else {
Log.error("Error Retrieving Resources: "
+ caught.getLocalizedMessage());
UtilsGXT3.alert(
msgs.errorRetrievingResourcesHead(),
caught.getLocalizedMessage());
}
}
callback.onFailure(caught);
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(SessionExpiredType.EXPIREDONSERVER));
} else {
if (caught instanceof TDGWTIsLockedException) {
Log.error(caught.getLocalizedMessage());
UtilsGXT3.alert(msgsCommon.errorLocked(), caught.getLocalizedMessage());
} else {
Log.error("Error Retrieving Resources: " + caught.getLocalizedMessage());
UtilsGXT3.alert(msgs.errorRetrievingResourcesHead(), caught.getLocalizedMessage());
}
}
callback.onFailure(caught);
}
public void onSuccess(
ArrayList<ResourceTDDescriptor> result) {
Log.debug("Resources loaded " + result.size());
if (result != null && result.size() > 0) {
statusBar.clear();
statusBar.add(new LabelToolItem(msgs
.statusBarNumberOfResources(result
.size())));
} else {
statusBar.clear();
statusBar.add(new LabelToolItem(msgs
.statusBarNoResource()));
public void onSuccess(ArrayList<ResourceTDDescriptor> result) {
Log.debug("Resources loaded " + result.size());
if (result != null && result.size() > 0) {
statusBar.clear();
statusBar.add(new LabelToolItem(msgs.statusBarNumberOfResources(result.size())));
} else {
statusBar.clear();
statusBar.add(new LabelToolItem(msgs.statusBarNoResource()));
}
statusBar.forceLayout();
try {
callback.onSuccess(result);
} catch (Throwable e) {
Log.debug("Error: " + e.getLocalizedMessage());
e.printStackTrace();
}
}
}
statusBar.forceLayout();
try {
callback.onSuccess(result);
} catch (Throwable e) {
Log.debug("Error: " + e.getLocalizedMessage());
e.printStackTrace();
}
}
});
});
}
}
@ -586,8 +548,7 @@ public class ResourcesListViewPanel extends FramedPanel {
@Override
public void onSelection(SelectionEvent<Item> event) {
List<ResourceTDDescriptor> resources = listView
.getSelectionModel().getSelectedItems();
List<ResourceTDDescriptor> resources = listView.getSelectionModel().getSelectedItems();
ResourceTDDescriptor selected = null;
if (resources != null && resources.size() > 0) {
selected = resources.get(0);
@ -605,8 +566,7 @@ public class ResourcesListViewPanel extends FramedPanel {
@Override
public void onSelection(SelectionEvent<Item> event) {
List<ResourceTDDescriptor> resources = listView
.getSelectionModel().getSelectedItems();
List<ResourceTDDescriptor> resources = listView.getSelectionModel().getSelectedItems();
ResourceTDDescriptor selected = null;
if (resources != null && resources.size() > 0) {
selected = resources.get(0);
@ -624,11 +584,9 @@ 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);
}
@ -642,8 +600,7 @@ public class ResourcesListViewPanel extends FramedPanel {
public void onBeforeShowContextMenu(BeforeShowContextMenuEvent event) {
Menu contextMenu = event.getMenu();
ResourceTDDescriptor selected = listView.getSelectionModel()
.getSelectedItem();
ResourceTDDescriptor selected = listView.getSelectionModel().getSelectedItem();
ResourceTDType resourceTDType = selected.getResourceType();
switch (resourceTDType) {
case CHART:
@ -747,28 +704,24 @@ public class ResourcesListViewPanel extends FramedPanel {
}
protected void requestSaveResource(
ResourceTDDescriptor resourceTDDescriptor, MimeTypeSupport mime) {
protected void requestSaveResource(ResourceTDDescriptor resourceTDDescriptor, MimeTypeSupport mime) {
saveResourceSession = new SaveResourceSession();
saveResourceSession.setResourceTDDescriptor(resourceTDDescriptor);
saveResourceSession.setMime(mime);
saveResourceSession.setFileName(resourceTDDescriptor.getName());
saveResourceSession.setFileDescription(resourceTDDescriptor
.getDescription());
saveResourceSession.setFileDescription(resourceTDDescriptor.getDescription());
GWT.runAsync(new RunAsyncCallback() {
public void onSuccess() {
SaveResourceWizard saveResourceWizard = new SaveResourceWizard(
saveResourceSession, msgs.saveResourceWizardHead(),
eventBus);
SaveResourceWizard saveResourceWizard = new SaveResourceWizard(saveResourceSession,
msgs.saveResourceWizardHead(), eventBus);
saveResourceWizard.addListener(new WizardListener() {
public void failed(String title, String message,
String details, Throwable throwable) {
public void failed(String title, String message, String details, Throwable throwable) {
Log.debug(title + ", " + message + " " + details);
}
@ -792,49 +745,42 @@ public class ResourcesListViewPanel extends FramedPanel {
public void onFailure(Throwable reason) {
Log.error("Async code loading failed", reason);
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
eventBus.fireEvent(new SessionExpiredEvent(SessionExpiredType.EXPIREDONSERVER));
}
});
}
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);
TDGWTServiceAsync.INSTANCE.removeResource(removeResourceSession,
new AsyncCallback<Void>() {
TDGWTServiceAsync.INSTANCE.removeResource(removeResourceSession, new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
if (caught instanceof TDGWTIsLockedException) {
Log.error(caught.getLocalizedMessage());
UtilsGXT3.alert(msgsCommon.errorLocked(),
caught.getLocalizedMessage());
} else {
Log.error("Error removing the resource: "
+ caught.getLocalizedMessage());
UtilsGXT3.alert(msgsCommon.error(),
msgs.errorRemovingTheResource()
+ caught.getLocalizedMessage());
}
}
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(SessionExpiredType.EXPIREDONSERVER));
} else {
if (caught instanceof TDGWTIsLockedException) {
Log.error(caught.getLocalizedMessage());
UtilsGXT3.alert(msgsCommon.errorLocked(), caught.getLocalizedMessage());
} else {
Log.error("Error removing the resource: " + caught.getLocalizedMessage());
UtilsGXT3.alert(msgsCommon.error(),
msgs.errorRemovingTheResource() + caught.getLocalizedMessage());
}
}
}
public void onSuccess(Void v) {
Log.debug("Resource removed");
loader.load();
details.setDescriptor(null);
forceLayout();
// UtilsGXT3.info("Resource", "Resource Removed!");
}
public void onSuccess(Void v) {
Log.debug("Resource removed");
loader.load();
details.setDescriptor(null);
forceLayout();
// UtilsGXT3.info("Resource", "Resource Removed!");
}
});
});
}
@ -870,98 +816,77 @@ public class ResourcesListViewPanel extends FramedPanel {
}
private void requestOpenChart(ResourceTDDescriptor resourceTDDescriptor) {
ChartViewerDialog chartDialog = new ChartViewerDialog(
resourceTDDescriptor, trId, eventBus);
ChartViewerDialog chartDialog = new ChartViewerDialog(resourceTDDescriptor, trId, eventBus);
chartDialog.show();
}
private void requestOpenSDMX(ResourceTDDescriptor resourceTDDescriptor) {
ResourceTD resource = resourceTDDescriptor.getResourceTD();
if (resource instanceof SDMXResourceTD) {
SDMXResourceTD sdmxResourceTD=(SDMXResourceTD) resource;
String link=
sdmxResourceTD.getResourceUrl();
SDMXResourceTD sdmxResourceTD = (SDMXResourceTD) resource;
String link = sdmxResourceTD.getResourceUrl();
Log.debug("Retrieved link: " + link);
Window.open(link,
resourceTDDescriptor.getName(), "");
}
Window.open(link, resourceTDDescriptor.getName(), "");
}
}
protected void requestOpenMap(
final ResourceTDDescriptor resourceTDDescriptor) {
protected void requestOpenMap(final ResourceTDDescriptor resourceTDDescriptor) {
ResourceTD resource = resourceTDDescriptor.getResourceTD();
if (resource instanceof StringResourceTD) {
StringResourceTD stringResourceTD = (StringResourceTD) resource;
UriResolverSession uriResolverSession = new UriResolverSession(
stringResourceTD.getValue(), ApplicationType.GIS);
UriResolverSession uriResolverSession = new UriResolverSession(stringResourceTD.getValue(),
ApplicationType.GIS);
TDGWTServiceAsync.INSTANCE.getUriFromResolver(uriResolverSession,
new AsyncCallback<String>() {
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 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 {
if (resource instanceof InternalURITD) {
InternalURITD internalURITD = (InternalURITD) resource;
UriResolverSession uriResolverSession = new UriResolverSession(
internalURITD.getId(), ApplicationType.GIS);
UriResolverSession uriResolverSession = new UriResolverSession(internalURITD.getId(),
ApplicationType.GIS);
TDGWTServiceAsync.INSTANCE.getUriFromResolver(
uriResolverSession, new AsyncCallback<String>() {
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 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 {
if (resource instanceof TableResourceTD) {
} else {
Log.error("Error with resource: no valid resource");
UtilsGXT3.alert(msgsCommon.error(),
msgs.errorNoValidInternalUri());
UtilsGXT3.alert(msgsCommon.error(), msgs.errorNoValidInternalUri());
}
@ -969,8 +894,7 @@ public class ResourcesListViewPanel extends FramedPanel {
}
}
protected void requestOpenGenericFile(
final ResourceTDDescriptor resourceTDDescriptor) {
protected void requestOpenGenericFile(final ResourceTDDescriptor resourceTDDescriptor) {
ResourceTD resource = resourceTDDescriptor.getResourceTD();
if (resource instanceof InternalURITD) {
@ -992,9 +916,7 @@ public class ResourcesListViewPanel extends FramedPanel {
* } } if(ext==null){
*/
MimeTypeSupport mts = MimeTypeSupport
.getMimeTypeSupportFromMimeName(genericFileResourceTD
.getMimeType());
MimeTypeSupport mts = MimeTypeSupport.getMimeTypeSupportFromMimeName(genericFileResourceTD.getMimeType());
if (mts != null) {
name = name + mts.getExtension();
}
@ -1003,43 +925,35 @@ public class ResourcesListViewPanel extends FramedPanel {
* }
*/
if (genericFileResourceTD.getId() != null
&& !genericFileResourceTD.getId().isEmpty()
&& (genericFileResourceTD.getId().startsWith("http:") || genericFileResourceTD
.getId().startsWith("https:"))) {
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(), "");
Window.open(genericFileResourceTD.getId(), resourceTDDescriptor.getName(), "");
} else {
UriResolverSession uriResolverSession = new UriResolverSession(
genericFileResourceTD.getId(), ApplicationType.SMP_ID,
name, genericFileResourceTD.getMimeType());
UriResolverSession uriResolverSession = new UriResolverSession(genericFileResourceTD.getId(),
ApplicationType.SMP_ID, name, genericFileResourceTD.getMimeType());
TDGWTServiceAsync.INSTANCE.getUriFromResolver(
uriResolverSession, new AsyncCallback<String>() {
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 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");