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