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
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
|
||||
.thumb img {
|
||||
height: 60px;
|
||||
height: 80px;
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
|
|
|
@ -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.ResourceTDDescriptor;
|
||||
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 com.google.gwt.safehtml.shared.SafeUri;
|
||||
|
@ -81,8 +79,52 @@ public class ResourcesListViewDetailPanel extends SimpleContainer {
|
|||
forceLayout();
|
||||
return;
|
||||
}
|
||||
SafeUri thumbnailPath = ResourceBundle.INSTANCE.resources32()
|
||||
.getSafeUri();
|
||||
|
||||
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();
|
||||
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();
|
||||
|
||||
if (resourceTD instanceof InternalURITD) {
|
||||
|
@ -92,16 +134,6 @@ public class ResourcesListViewDetailPanel extends SimpleContainer {
|
|||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
thumbnail = new Image();
|
||||
|
|
|
@ -101,8 +101,6 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
private static final String HEIGHT = "470px";
|
||||
private static final String WIDTH = "630px";
|
||||
|
||||
|
||||
|
||||
@FormatterFactories(@FormatterFactory(factory = ShortenFactory.class, name = "shorten"))
|
||||
public interface Renderer extends XTemplates {
|
||||
@XTemplate(source = "ResourcesListView.html")
|
||||
|
@ -118,8 +116,6 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
ResourceListViewCSS css();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public interface ResourceListViewCSS extends CssResource {
|
||||
String over();
|
||||
|
||||
|
@ -188,16 +184,17 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
|
||||
}
|
||||
|
||||
|
||||
private ResourcesListViewDetailPanel details;
|
||||
|
||||
private ResourceListViewCSS style;
|
||||
private Renderer renderer;
|
||||
|
||||
private TRId trId;
|
||||
private EventBus eventBus;
|
||||
|
||||
private ListStore<ResourceTDDescriptor> store;
|
||||
//private ListLoader<Object, ListLoadResult<ResourceTDDescriptor>> loader;
|
||||
// private ListLoader<Object, ListLoadResult<ResourceTDDescriptor>> loader;
|
||||
private Loader<Object, List<ResourceTDDescriptor>> loader;
|
||||
|
||||
|
||||
private ListView<ResourceTDDescriptor, ResourceTDDescriptor> listView;
|
||||
private SimpleComboBox<String> comboSort;
|
||||
private Menu contextMenu;
|
||||
|
@ -274,8 +271,7 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
}
|
||||
}, SortDir.ASC));
|
||||
|
||||
loader = new Loader<Object, List<ResourceTDDescriptor>>(
|
||||
proxy);
|
||||
loader = new Loader<Object, List<ResourceTDDescriptor>>(proxy);
|
||||
loader.addLoadHandler(new ListStoreBinding<Object, ResourceTDDescriptor, List<ResourceTDDescriptor>>(
|
||||
store));
|
||||
|
||||
|
@ -329,10 +325,9 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
//
|
||||
ResourcesListViewBundle.INSTANCE.css().ensureInjected();
|
||||
|
||||
final ResourceListViewCSS style = ResourcesListViewBundle.INSTANCE
|
||||
.css();
|
||||
style = ResourcesListViewBundle.INSTANCE.css();
|
||||
|
||||
final Renderer renderer = GWT.create(Renderer.class);
|
||||
renderer = GWT.create(Renderer.class);
|
||||
|
||||
ListViewCustomAppearance<ResourceTDDescriptor> appearance = new ListViewCustomAppearance<ResourceTDDescriptor>(
|
||||
"." + style.thumbWrap(), style.over(), style.select()) {
|
||||
|
@ -353,8 +348,8 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
}
|
||||
};
|
||||
|
||||
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) {
|
||||
|
@ -379,33 +374,9 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
new AbstractSafeHtmlRenderer<ResourceTDDescriptor>() {
|
||||
@Override
|
||||
public SafeHtml render(ResourceTDDescriptor descriptor) {
|
||||
SafeUri thumbnailPath = ResourceBundle.INSTANCE
|
||||
.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);
|
||||
return renderCellResource(descriptor);
|
||||
}
|
||||
|
||||
}));
|
||||
listView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
|
||||
listView.getSelectionModel().addSelectionChangedHandler(
|
||||
|
@ -417,7 +388,7 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
}
|
||||
});
|
||||
listView.setBorders(false);
|
||||
|
||||
|
||||
createContextMenu();
|
||||
|
||||
VerticalLayoutContainer main = new VerticalLayoutContainer();
|
||||
|
@ -443,6 +414,65 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
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(
|
||||
SelectionChangedEvent<ResourceTDDescriptor> se) {
|
||||
if (se.getSelection().size() > 0) {
|
||||
|
@ -496,8 +526,7 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void createContextMenu() {
|
||||
contextMenu = new Menu();
|
||||
|
||||
|
@ -626,8 +655,7 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void requestSave(ResourceTDDescriptor resourceTDDescriptor) {
|
||||
switch (resourceTDDescriptor.getResourceType()) {
|
||||
case CHART:
|
||||
|
@ -909,6 +937,5 @@ public class ResourcesListViewPanel extends FramedPanel {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -65,48 +65,108 @@ public interface ResourceBundle extends ClientBundle {
|
|||
@Source("chart-bar_32.png")
|
||||
ImageResource chart32();
|
||||
|
||||
@Source("chart-bar_80.png")
|
||||
ImageResource chart80();
|
||||
|
||||
@Source("chart-bar_160.png")
|
||||
ImageResource chart160();
|
||||
|
||||
@Source("codelist.png")
|
||||
ImageResource codelist();
|
||||
|
||||
@Source("codelist_32.png")
|
||||
ImageResource codelist32();
|
||||
|
||||
@Source("codelist_80.png")
|
||||
ImageResource codelist80();
|
||||
|
||||
@Source("codelist_160.png")
|
||||
ImageResource codelist160();
|
||||
|
||||
@Source("csv.png")
|
||||
ImageResource csv();
|
||||
|
||||
@Source("csv_32.png")
|
||||
ImageResource csv32();
|
||||
|
||||
@Source("csv_80.png")
|
||||
ImageResource csv80();
|
||||
|
||||
@Source("csv_160.png")
|
||||
ImageResource csv160();
|
||||
|
||||
@Source("gis.png")
|
||||
ImageResource gis();
|
||||
|
||||
@Source("gis_32.png")
|
||||
ImageResource gis32();
|
||||
|
||||
@Source("gis_80.png")
|
||||
ImageResource gis80();
|
||||
|
||||
@Source("gis_160.png")
|
||||
ImageResource gis160();
|
||||
|
||||
@Source("json.png")
|
||||
ImageResource json();
|
||||
|
||||
@Source("json_32.png")
|
||||
ImageResource json32();
|
||||
|
||||
@Source("json_80.png")
|
||||
ImageResource json80();
|
||||
|
||||
@Source("json_160.png")
|
||||
ImageResource json160();
|
||||
|
||||
@Source("sdmx.png")
|
||||
ImageResource sdmx();
|
||||
|
||||
@Source("sdmx_32.png")
|
||||
ImageResource sdmx32();
|
||||
|
||||
@Source("sdmx_80.png")
|
||||
ImageResource sdmx80();
|
||||
|
||||
@Source("sdmx_160.png")
|
||||
ImageResource sdmx160();
|
||||
|
||||
@Source("table.png")
|
||||
ImageResource table();
|
||||
|
||||
@Source("table_32.png")
|
||||
ImageResource table32();
|
||||
|
||||
@Source("table_80.png")
|
||||
ImageResource table80();
|
||||
|
||||
@Source("table_160.png")
|
||||
ImageResource table160();
|
||||
|
||||
@Source("resources.png")
|
||||
ImageResource resources();
|
||||
|
||||
@Source("resources_32.png")
|
||||
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")
|
||||
ImageResource magnifierZoomIn32();
|
||||
|
||||
|
@ -129,13 +189,7 @@ public interface ResourceBundle extends ClientBundle {
|
|||
ImageResource application32();
|
||||
|
||||
@Source("application.png")
|
||||
ImageResource application();
|
||||
|
||||
@Source("file_32.png")
|
||||
ImageResource file32();
|
||||
|
||||
@Source("file.png")
|
||||
ImageResource file();
|
||||
ImageResource application();
|
||||
|
||||
@Source("Resources.css")
|
||||
ResourceCSS resourceCSS();
|
||||
|
|
After Width: | Height: | Size: 8.8 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 7.5 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 6.6 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 7.1 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 8.7 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 6.4 KiB |
After Width: | Height: | Size: 2.6 KiB |
|
@ -6,7 +6,7 @@
|
|||
}
|
||||
|
||||
.thumb img {
|
||||
height: 60px;
|
||||
height: 80px;
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
|
|
After Width: | Height: | Size: 8.8 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 7.5 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 6.6 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 7.1 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 8.7 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 6.4 KiB |
After Width: | Height: | Size: 2.6 KiB |