209: TDM - Show the resources through a ListView widget

Task-Url: https://support.d4science.org/issues/209

Added Thumbnail icons


git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-resources-widget@115250 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-06-08 11:21:35 +00:00
parent aba485a64d
commit 5d54ed41c7
41 changed files with 184 additions and 71 deletions

View File

@ -6,7 +6,7 @@
} }
.thumb img { .thumb img {
height: 60px; height: 80px;
width: 80px; width: 80px;
} }

View File

@ -4,8 +4,6 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.InternalURITD;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTD; import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTD;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDDescriptor; import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDDescriptor;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDType; import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDType;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.StringResourceTD;
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.TableResourceTD;
import org.gcube.portlets.user.td.resourceswidget.client.resources.ResourceBundle; import org.gcube.portlets.user.td.resourceswidget.client.resources.ResourceBundle;
import com.google.gwt.safehtml.shared.SafeUri; import com.google.gwt.safehtml.shared.SafeUri;
@ -81,8 +79,52 @@ public class ResourcesListViewDetailPanel extends SimpleContainer {
forceLayout(); forceLayout();
return; return;
} }
SafeUri thumbnailPath = ResourceBundle.INSTANCE.resources32()
SafeUri thumbnailPath;
ResourceTDType resourceTDType = descriptor.getResourceType();
if (resourceTDType == null) {
thumbnailPath = ResourceBundle.INSTANCE.resources160().getSafeUri();
} else {
switch (resourceTDType) {
case CHART:
thumbnailPath = ResourceBundle.INSTANCE.chart160().getSafeUri();
break;
case CODELIST:
thumbnailPath = ResourceBundle.INSTANCE.codelist160()
.getSafeUri(); .getSafeUri();
break;
case CSV:
thumbnailPath = ResourceBundle.INSTANCE.csv160().getSafeUri();
break;
case GENERIC_FILE:
thumbnailPath = ResourceBundle.INSTANCE.file160().getSafeUri();
break;
case GENERIC_TABLE:
thumbnailPath = ResourceBundle.INSTANCE.table160().getSafeUri();
break;
case GUESSER:
thumbnailPath = ResourceBundle.INSTANCE.resources160()
.getSafeUri();
break;
case JSON:
thumbnailPath = ResourceBundle.INSTANCE.json160().getSafeUri();
break;
case MAP:
thumbnailPath = ResourceBundle.INSTANCE.gis160().getSafeUri();
break;
case SDMX:
thumbnailPath = ResourceBundle.INSTANCE.sdmx160().getSafeUri();
break;
default:
thumbnailPath = ResourceBundle.INSTANCE.resources160()
.getSafeUri();
break;
}
}
ResourceTD resourceTD = descriptor.getResourceTD(); ResourceTD resourceTD = descriptor.getResourceTD();
if (resourceTD instanceof InternalURITD) { if (resourceTD instanceof InternalURITD) {
@ -92,16 +134,6 @@ public class ResourcesListViewDetailPanel extends SimpleContainer {
thumbnailPath = UriUtils.fromTrustedString(internalURITD thumbnailPath = UriUtils.fromTrustedString(internalURITD
.getThumbnailTD().getUrl()); .getThumbnailTD().getUrl());
} }
} else {
if (resourceTD instanceof StringResourceTD) {
thumbnailPath = ResourceBundle.INSTANCE.resources32()
.getSafeUri();
} else {
if (resourceTD instanceof TableResourceTD) {
thumbnailPath = ResourceBundle.INSTANCE.resources32()
.getSafeUri();
}
}
} }
thumbnail = new Image(); thumbnail = new Image();

View File

@ -101,8 +101,6 @@ public class ResourcesListViewPanel extends FramedPanel {
private static final String HEIGHT = "470px"; private static final String HEIGHT = "470px";
private static final String WIDTH = "630px"; private static final String WIDTH = "630px";
@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")
@ -118,8 +116,6 @@ public class ResourcesListViewPanel extends FramedPanel {
ResourceListViewCSS css(); ResourceListViewCSS css();
} }
public interface ResourceListViewCSS extends CssResource { public interface ResourceListViewCSS extends CssResource {
String over(); String over();
@ -188,14 +184,15 @@ public class ResourcesListViewPanel extends FramedPanel {
} }
private ResourcesListViewDetailPanel details; private ResourcesListViewDetailPanel details;
private ResourceListViewCSS style;
private Renderer renderer;
private TRId trId; private TRId trId;
private EventBus eventBus; private EventBus eventBus;
private ListStore<ResourceTDDescriptor> store; private ListStore<ResourceTDDescriptor> store;
//private ListLoader<Object, ListLoadResult<ResourceTDDescriptor>> loader; // private ListLoader<Object, ListLoadResult<ResourceTDDescriptor>> loader;
private Loader<Object, List<ResourceTDDescriptor>> loader; private Loader<Object, List<ResourceTDDescriptor>> loader;
private ListView<ResourceTDDescriptor, ResourceTDDescriptor> listView; private ListView<ResourceTDDescriptor, ResourceTDDescriptor> listView;
@ -274,8 +271,7 @@ public class ResourcesListViewPanel extends FramedPanel {
} }
}, SortDir.ASC)); }, SortDir.ASC));
loader = new Loader<Object, List<ResourceTDDescriptor>>( loader = new Loader<Object, List<ResourceTDDescriptor>>(proxy);
proxy);
loader.addLoadHandler(new ListStoreBinding<Object, ResourceTDDescriptor, List<ResourceTDDescriptor>>( loader.addLoadHandler(new ListStoreBinding<Object, ResourceTDDescriptor, List<ResourceTDDescriptor>>(
store)); store));
@ -329,10 +325,9 @@ public class ResourcesListViewPanel extends FramedPanel {
// //
ResourcesListViewBundle.INSTANCE.css().ensureInjected(); ResourcesListViewBundle.INSTANCE.css().ensureInjected();
final ResourceListViewCSS style = ResourcesListViewBundle.INSTANCE style = ResourcesListViewBundle.INSTANCE.css();
.css();
final Renderer renderer = GWT.create(Renderer.class); renderer = GWT.create(Renderer.class);
ListViewCustomAppearance<ResourceTDDescriptor> appearance = new ListViewCustomAppearance<ResourceTDDescriptor>( ListViewCustomAppearance<ResourceTDDescriptor> appearance = new ListViewCustomAppearance<ResourceTDDescriptor>(
"." + style.thumbWrap(), style.over(), style.select()) { "." + style.thumbWrap(), style.over(), style.select()) {
@ -353,8 +348,8 @@ public class ResourcesListViewPanel extends FramedPanel {
} }
}; };
listView = new ListView<ResourceTDDescriptor, ResourceTDDescriptor>(store, listView = new ListView<ResourceTDDescriptor, ResourceTDDescriptor>(
new IdentityValueProvider<ResourceTDDescriptor>() { store, new IdentityValueProvider<ResourceTDDescriptor>() {
@Override @Override
public void setValue(ResourceTDDescriptor object, public void setValue(ResourceTDDescriptor object,
ResourceTDDescriptor value) { ResourceTDDescriptor value) {
@ -379,33 +374,9 @@ public class ResourcesListViewPanel extends FramedPanel {
new AbstractSafeHtmlRenderer<ResourceTDDescriptor>() { new AbstractSafeHtmlRenderer<ResourceTDDescriptor>() {
@Override @Override
public SafeHtml render(ResourceTDDescriptor descriptor) { public SafeHtml render(ResourceTDDescriptor descriptor) {
SafeUri thumbnailPath = ResourceBundle.INSTANCE return renderCellResource(descriptor);
.resources32().getSafeUri();
ResourceTD resourceTD = descriptor.getResourceTD();
if (resourceTD instanceof InternalURITD) {
InternalURITD internalURITD = (InternalURITD) resourceTD;
if (internalURITD.getThumbnailTD() != null
&& internalURITD.getThumbnailTD().getUrl() != null) {
thumbnailPath = UriUtils
.fromTrustedString(internalURITD
.getThumbnailTD().getUrl());
}
} else {
if (resourceTD instanceof StringResourceTD) {
thumbnailPath = ResourceBundle.INSTANCE
.resources32().getSafeUri();
} else {
if (resourceTD instanceof TableResourceTD) {
thumbnailPath = ResourceBundle.INSTANCE
.resources32().getSafeUri();
}
}
} }
return renderer.renderItem(descriptor, thumbnailPath,
style);
}
})); }));
listView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); listView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
listView.getSelectionModel().addSelectionChangedHandler( listView.getSelectionModel().addSelectionChangedHandler(
@ -443,6 +414,65 @@ public class ResourcesListViewPanel extends FramedPanel {
add(con, new MarginData(0)); add(con, new MarginData(0));
} }
protected SafeHtml renderCellResource(ResourceTDDescriptor descriptor) {
SafeUri thumbnailPath;
ResourceTDType resourceTDType = descriptor.getResourceType();
if (resourceTDType == null) {
thumbnailPath = ResourceBundle.INSTANCE.resources80().getSafeUri();
} else {
switch (resourceTDType) {
case CHART:
thumbnailPath = ResourceBundle.INSTANCE.chart80().getSafeUri();
break;
case CODELIST:
thumbnailPath = ResourceBundle.INSTANCE.codelist80()
.getSafeUri();
break;
case CSV:
thumbnailPath = ResourceBundle.INSTANCE.csv80().getSafeUri();
break;
case GENERIC_FILE:
thumbnailPath = ResourceBundle.INSTANCE.file80().getSafeUri();
break;
case GENERIC_TABLE:
thumbnailPath = ResourceBundle.INSTANCE.table80().getSafeUri();
break;
case GUESSER:
thumbnailPath = ResourceBundle.INSTANCE.resources80()
.getSafeUri();
break;
case JSON:
thumbnailPath = ResourceBundle.INSTANCE.json80().getSafeUri();
break;
case MAP:
thumbnailPath = ResourceBundle.INSTANCE.gis80().getSafeUri();
break;
case SDMX:
thumbnailPath = ResourceBundle.INSTANCE.sdmx80().getSafeUri();
break;
default:
thumbnailPath = ResourceBundle.INSTANCE.resources80()
.getSafeUri();
break;
}
}
ResourceTD resourceTD = descriptor.getResourceTD();
if (resourceTD instanceof InternalURITD) {
InternalURITD internalURITD = (InternalURITD) resourceTD;
if (internalURITD.getThumbnailTD() != null
&& internalURITD.getThumbnailTD().getUrl() != null) {
thumbnailPath = UriUtils.fromTrustedString(internalURITD
.getThumbnailTD().getUrl());
}
}
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) {
@ -497,7 +527,6 @@ public class ResourcesListViewPanel extends FramedPanel {
} }
} }
protected void createContextMenu() { protected void createContextMenu() {
contextMenu = new Menu(); contextMenu = new Menu();
@ -627,7 +656,6 @@ public class ResourcesListViewPanel extends FramedPanel {
} }
protected void requestSave(ResourceTDDescriptor resourceTDDescriptor) { protected void requestSave(ResourceTDDescriptor resourceTDDescriptor) {
switch (resourceTDDescriptor.getResourceType()) { switch (resourceTDDescriptor.getResourceType()) {
case CHART: case CHART:
@ -910,5 +938,4 @@ public class ResourcesListViewPanel extends FramedPanel {
} }
} }
} }

View File

@ -65,48 +65,108 @@ public interface ResourceBundle extends ClientBundle {
@Source("chart-bar_32.png") @Source("chart-bar_32.png")
ImageResource chart32(); ImageResource chart32();
@Source("chart-bar_80.png")
ImageResource chart80();
@Source("chart-bar_160.png")
ImageResource chart160();
@Source("codelist.png") @Source("codelist.png")
ImageResource codelist(); ImageResource codelist();
@Source("codelist_32.png") @Source("codelist_32.png")
ImageResource codelist32(); ImageResource codelist32();
@Source("codelist_80.png")
ImageResource codelist80();
@Source("codelist_160.png")
ImageResource codelist160();
@Source("csv.png") @Source("csv.png")
ImageResource csv(); ImageResource csv();
@Source("csv_32.png") @Source("csv_32.png")
ImageResource csv32(); ImageResource csv32();
@Source("csv_80.png")
ImageResource csv80();
@Source("csv_160.png")
ImageResource csv160();
@Source("gis.png") @Source("gis.png")
ImageResource gis(); ImageResource gis();
@Source("gis_32.png") @Source("gis_32.png")
ImageResource gis32(); ImageResource gis32();
@Source("gis_80.png")
ImageResource gis80();
@Source("gis_160.png")
ImageResource gis160();
@Source("json.png") @Source("json.png")
ImageResource json(); ImageResource json();
@Source("json_32.png") @Source("json_32.png")
ImageResource json32(); ImageResource json32();
@Source("json_80.png")
ImageResource json80();
@Source("json_160.png")
ImageResource json160();
@Source("sdmx.png") @Source("sdmx.png")
ImageResource sdmx(); ImageResource sdmx();
@Source("sdmx_32.png") @Source("sdmx_32.png")
ImageResource sdmx32(); ImageResource sdmx32();
@Source("sdmx_80.png")
ImageResource sdmx80();
@Source("sdmx_160.png")
ImageResource sdmx160();
@Source("table.png") @Source("table.png")
ImageResource table(); ImageResource table();
@Source("table_32.png") @Source("table_32.png")
ImageResource table32(); ImageResource table32();
@Source("table_80.png")
ImageResource table80();
@Source("table_160.png")
ImageResource table160();
@Source("resources.png") @Source("resources.png")
ImageResource resources(); ImageResource resources();
@Source("resources_32.png") @Source("resources_32.png")
ImageResource resources32(); ImageResource resources32();
@Source("resources_80.png")
ImageResource resources80();
@Source("resources_160.png")
ImageResource resources160();
@Source("file.png")
ImageResource file();
@Source("file_32.png")
ImageResource file32();
@Source("file_80.png")
ImageResource file80();
@Source("file_160.png")
ImageResource file160();
@Source("magnifier-zoom-in_32.png") @Source("magnifier-zoom-in_32.png")
ImageResource magnifierZoomIn32(); ImageResource magnifierZoomIn32();
@ -131,12 +191,6 @@ public interface ResourceBundle extends ClientBundle {
@Source("application.png") @Source("application.png")
ImageResource application(); ImageResource application();
@Source("file_32.png")
ImageResource file32();
@Source("file.png")
ImageResource file();
@Source("Resources.css") @Source("Resources.css")
ResourceCSS resourceCSS(); ResourceCSS resourceCSS();
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -6,7 +6,7 @@
} }
.thumb img { .thumb img {
height: 60px; height: 80px;
width: 80px; width: 80px;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB