From c588bd2d663fdbbbf60b86b576474fcecec1ce7b Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Thu, 27 Jul 2017 15:23:06 +0000 Subject: [PATCH] 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 --- .../client/ResourcesListViewPanel.java | 440 +++++++----------- 1 file changed, 177 insertions(+), 263 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewPanel.java b/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewPanel.java index 80e6d27..305fd51 100644 --- a/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/resourceswidget/client/ResourcesListViewPanel.java @@ -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 resourcesSortInfoI18NList; @@ -254,8 +252,7 @@ public class ResourcesListViewPanel extends FramedPanel { Log.debug("Create Resource List View"); RpcProxy> proxy = new RpcProxy>() { @Override - public void load(Object loadConfig, - AsyncCallback> callback) { + public void load(Object loadConfig, AsyncCallback> callback) { loadData(callback); } }; @@ -268,38 +265,31 @@ public class ResourcesListViewPanel extends FramedPanel { }; store = new ListStore(keyProvider); - store.addSortInfo(new StoreSortInfo( - new Comparator() { - @Override - public int compare(ResourceTDDescriptor o1, - ResourceTDDescriptor o2) { + store.addSortInfo(new StoreSortInfo(new Comparator() { + @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>(proxy); - loader.addLoadHandler(new ListStoreBinding>( - store)); + loader.addLoadHandler(new ListStoreBinding>(store)); // ToolBar StoreFilterField filterField = new StoreFilterField() { @Override - protected boolean doSelect(Store store, - ResourceTDDescriptor parent, ResourceTDDescriptor item, - String filter) { + protected boolean doSelect(Store 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( - new StringLabelProvider()); + comboSort = new SimpleComboBox(new StringLabelProvider()); 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("
") - .toString(); + String markup = new StringBuilder("
").toString(); builder.appendHtmlConstant(markup); } @Override public void renderItem(SafeHtmlBuilder builder, SafeHtml content) { - builder.appendHtmlConstant("
"); + builder.appendHtmlConstant("
"); builder.append(content); builder.appendHtmlConstant("
"); } }; - listView = new ListView( - store, new IdentityValueProvider() { + listView = new ListView(store, + new IdentityValueProvider() { @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( - new AbstractSafeHtmlRenderer() { + listView.setCell( + new SimpleSafeHtmlCell(new AbstractSafeHtmlRenderer() { @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() { - @Override - public void onSelectionChanged( - SelectionChangedEvent event) { - ResourcesListViewPanel.this.onSelectionChange(event); - } - }); + listView.getSelectionModel().addSelectionChangedHandler(new SelectionChangedHandler() { + @Override + public void onSelectionChanged(SelectionChangedEvent 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 se) { + private void onSelectionChange(SelectionChangedEvent 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> callback) { + protected void loadData(final AsyncCallback> callback) { Log.debug("Called loadData"); if (trId != null) { - TDGWTServiceAsync.INSTANCE.getResourcesTD(trId, - new AsyncCallback>() { + TDGWTServiceAsync.INSTANCE.getResourcesTD(trId, new AsyncCallback>() { - 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 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 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 event) { - List resources = listView - .getSelectionModel().getSelectedItems(); + List 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 event) { - List resources = listView - .getSelectionModel().getSelectedItems(); + List 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 event) { - List selected = listView - .getSelectionModel().getSelectedItems(); + List selected = listView.getSelectionModel().getSelectedItems(); Log.debug("selected: " + selected); - ArrayList resources = new ArrayList( - selected); + ArrayList resources = new ArrayList(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 resourcesList) { - ArrayList resources = new ArrayList( - resourcesList); + ArrayList resources = new ArrayList(resourcesList); removeResourceSession = new RemoveResourceSession(trId, resources); - TDGWTServiceAsync.INSTANCE.removeResource(removeResourceSession, - new AsyncCallback() { + TDGWTServiceAsync.INSTANCE.removeResource(removeResourceSession, new AsyncCallback() { - 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() { + TDGWTServiceAsync.INSTANCE.getUriFromResolver(uriResolverSession, new AsyncCallback() { - 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() { + TDGWTServiceAsync.INSTANCE.getUriFromResolver(uriResolverSession, new AsyncCallback() { - 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() { + TDGWTServiceAsync.INSTANCE.getUriFromResolver(uriResolverSession, new AsyncCallback() { - 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");