Updated Resource Panel

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-resources-widget@100810 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-10-21 09:45:44 +00:00
parent 907e9c51eb
commit c79c57aa6a
46 changed files with 177 additions and 105 deletions

View File

@ -89,8 +89,7 @@ public class ResourcesPanel extends FramedPanel {
private Menu contextMenu;
private MenuItem openItem;
public ResourcesPanel(ResourcesDialog parent, TRId trId,
EventBus eventBus) {
public ResourcesPanel(ResourcesDialog parent, TRId trId, EventBus eventBus) {
super();
this.parent = parent;
this.trId = trId;
@ -106,31 +105,29 @@ public class ResourcesPanel extends FramedPanel {
forceLayoutOnResize = true;
retrieveUserInfo();
}
protected void retrieveUserInfo(){
TDGWTServiceAsync.INSTANCE.hello(
new AsyncCallback<UserInfo>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("Error Retrieving User Info: "
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error",
"Error retrieving User Info");
}
}
protected void retrieveUserInfo() {
TDGWTServiceAsync.INSTANCE.hello(new AsyncCallback<UserInfo>() {
public void onSuccess(UserInfo userInfo) {
Log.debug("User Info: " + userInfo);
draw();
}
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
});
Log.error("Error Retrieving User Info: "
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error", "Error retrieving User Info");
}
}
public void onSuccess(UserInfo userInfo) {
Log.debug("User Info: " + userInfo);
draw();
}
});
}
protected void draw() {
@ -153,10 +150,10 @@ public class ResourcesPanel extends FramedPanel {
.create(ResourceTDDescriptorProperties.class);
IdentityValueProvider<ResourceTDDescriptor> identityProvider = new IdentityValueProvider<ResourceTDDescriptor>();
final GridSelectionModel<ResourceTDDescriptor> sm = new GridSelectionModel<ResourceTDDescriptor>();
sm.setSelectionMode(SelectionMode.SINGLE);
final GridSelectionModel<ResourceTDDescriptor> sm = new GridSelectionModel<ResourceTDDescriptor>();
sm.setSelectionMode(SelectionMode.SINGLE);
RowExpander<ResourceTDDescriptor> expander = new RowExpander<ResourceTDDescriptor>(
identityProvider, new AbstractCell<ResourceTDDescriptor>() {
@ -212,20 +209,19 @@ public class ResourcesPanel extends FramedPanel {
+ "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'>")
.appendEscaped(internalURITD.getFileId())
.appendHtmlConstant("</td>" + "</tr>");
/*
sb.appendHtmlConstant(
"<tr>"
+ "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'><b>URI: </b></td>"
+ "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'>"
+ "<a href='")
.appendEscaped(internalURITD.getUri())
.appendHtmlConstant("' title='")
.appendEscaped(internalURITD.getUri())
.appendHtmlConstant(
"'>link</a>" + "</td>" + "</tr>");*/
* sb.appendHtmlConstant( "<tr>" +
* "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'><b>URI: </b></td>"
* +
* "<td style='font-size: 12px; padding: 2px 1px 1px 1px;'>"
* + "<a href='")
* .appendEscaped(internalURITD.getUri())
* .appendHtmlConstant("' title='")
* .appendEscaped(internalURITD.getUri())
* .appendHtmlConstant( "'>link</a>" + "</td>" +
* "</tr>");
*/
} else {
if (resource instanceof StringResourceTD) {
@ -263,7 +259,7 @@ public class ResourcesPanel extends FramedPanel {
});
ColumnConfig<ResourceTDDescriptor, String> nameCol = new ColumnConfig<ResourceTDDescriptor, String>(
props.name(), 132, "Name");
props.name(), 142, "Name");
nameCol.setCell(new AbstractCell<String>() {
@ -278,8 +274,55 @@ public class ResourcesPanel extends FramedPanel {
});
ColumnConfig<ResourceTDDescriptor, ResourceTDType> typeColumn = new ColumnConfig<ResourceTDDescriptor, ResourceTDType>(
props.resourceType(), 40, "Type");
props.resourceType(), 30, "Type");
typeColumn.setCell(new AbstractCell<ResourceTDType>() {
@Override
public void render(Context context, ResourceTDType value,
SafeHtmlBuilder sb) {
sb.appendHtmlConstant("<img title='")
.appendEscaped(value.toString())
.appendHtmlConstant("' src='");
switch (value) {
case CHART:
sb.appendEscaped(ResourceBundle.INSTANCE.chart()
.getSafeUri().asString());
break;
case CODELIST:
sb.appendEscaped(ResourceBundle.INSTANCE.codelist()
.getSafeUri().asString());
break;
case CSV:
sb.appendEscaped(ResourceBundle.INSTANCE.csv().getSafeUri()
.asString());
break;
case GUESSER:
sb.appendEscaped(ResourceBundle.INSTANCE.resources()
.getSafeUri().asString());
break;
case JSON:
sb.appendEscaped(ResourceBundle.INSTANCE.json()
.getSafeUri().asString());
break;
case MAP:
sb.appendEscaped(ResourceBundle.INSTANCE.gis().getSafeUri()
.asString());
break;
case SDMX:
sb.appendEscaped(ResourceBundle.INSTANCE.sdmx()
.getSafeUri().asString());
break;
default:
sb.appendEscaped(ResourceBundle.INSTANCE.resources()
.getSafeUri().asString());
break;
}
sb.appendHtmlConstant("' >");
}
});
List<ColumnConfig<ResourceTDDescriptor, ?>> l = new ArrayList<ColumnConfig<ResourceTDDescriptor, ?>>();
l.add(expander);
l.add(nameCol);
@ -333,12 +376,11 @@ public class ResourcesPanel extends FramedPanel {
grid.setColumnResize(true);
grid.getView().setAutoExpandColumn(nameCol);
grid.getView().setEmptyText("Empty");
expander.initPlugin(grid);
createContextMenu();
add(grid, new MarginData(0));
onResize();
@ -349,24 +391,24 @@ public class ResourcesPanel extends FramedPanel {
openItem = new MenuItem();
openItem.setText("Open");
openItem.setIcon(ResourceBundle.INSTANCE.codelistLink());
openItem.setIcon(ResourceBundle.INSTANCE.resources());
openItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override
public void onSelection(SelectionEvent<Item> event) {
ResourceTDDescriptor selected = grid.getSelectionModel().getSelectedItem();
Log.debug("selected: "+selected);
ResourceTDDescriptor selected = grid.getSelectionModel()
.getSelectedItem();
Log.debug("selected: " + selected);
requestOpen(selected);
}
});
contextMenu.add(openItem);
grid.setContextMenu(contextMenu);
}
protected void requestOpen(ResourceTDDescriptor resourceTDDescriptor) {
switch (resourceTDDescriptor.getResourceType()){
switch (resourceTDDescriptor.getResourceType()) {
case CHART:
break;
case CODELIST:
@ -384,48 +426,48 @@ public class ResourcesPanel extends FramedPanel {
break;
default:
break;
}
}
protected void requestOpenMap(final ResourceTDDescriptor resourceTDDescriptor){
ResourceTD resource=resourceTDDescriptor.getResourceTD();
protected void requestOpenMap(
final ResourceTDDescriptor resourceTDDescriptor) {
ResourceTD resource = resourceTDDescriptor.getResourceTD();
if (resource instanceof InternalURITD) {
InternalURITD internalURITD = (InternalURITD) resource;
UriResolverSession uriResolverSession=new UriResolverSession(internalURITD.getUri(), ApplicationType.GIS);
TDGWTServiceAsync.INSTANCE.getUriFromResolver(uriResolverSession, new AsyncCallback<String>() {
UriResolverSession uriResolverSession = new UriResolverSession(
internalURITD.getUri(), ApplicationType.GIS);
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("Error",
"Error retrieving uri from resolver");
}
}
TDGWTServiceAsync.INSTANCE.getUriFromResolver(uriResolverSession,
new AsyncCallback<String>() {
public void onSuccess(String link) {
Log.debug("Retrieved link: " + link);
Window.open(link, resourceTDDescriptor.getName(), "");
}
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("Error",
"Error retrieving uri from resolver");
}
}
public void onSuccess(String link) {
Log.debug("Retrieved link: " + link);
Window.open(link, resourceTDDescriptor.getName(),
"");
}
});
});
} else {
Log.error("Error with resource: no valid InternalUri");
UtilsGXT3.alert("Error with resource",
"Error no valid InternalUri");
UtilsGXT3
.alert("Error with resource", "Error no valid InternalUri");
}
}
protected void loadData(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<ResourceTDDescriptor>> callback) {
@ -501,8 +543,6 @@ public class ResourcesPanel extends FramedPanel {
});
}
protected void close() {
if (parent != null) {

View File

@ -45,25 +45,7 @@ public interface ResourceBundle extends ClientBundle {
@Source("disk_32.png")
ImageResource save32();
@Source("codelist-link.png")
ImageResource codelistLink();
@Source("codelist-link_24.png")
ImageResource codelistLink24();
@Source("codelist-link_32.png")
ImageResource codelistLink32();
@Source("codelist-link-break.png")
ImageResource codelistLinkBreak();
@Source("codelist-link-break_24.png")
ImageResource codelistLinkBreak24();
@Source("codelist-link-break_32.png")
ImageResource codelistLinkBreak32();
@Source("add.png")
ImageResource add();
@ -75,6 +57,56 @@ public interface ResourceBundle extends ClientBundle {
@Source("delete_32.png")
ImageResource delete32();
@Source("chart-bar.png")
ImageResource chart();
@Source("chart-bar_32.png")
ImageResource chart32();
@Source("codelist.png")
ImageResource codelist();
@Source("codelist_32.png")
ImageResource codelist32();
@Source("csv.png")
ImageResource csv();
@Source("csv_32.png")
ImageResource csv32();
@Source("gis.png")
ImageResource gis();
@Source("gis_32.png")
ImageResource gis32();
@Source("json.png")
ImageResource json();
@Source("json_32.png")
ImageResource json32();
@Source("sdmx.png")
ImageResource sdmx();
@Source("sdmx_32.png")
ImageResource sdmx32();
@Source("table.png")
ImageResource table();
@Source("table_32.png")
ImageResource table32();
@Source("resources.png")
ImageResource resources();
@Source("resources_32.png")
ImageResource resources32();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 937 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 856 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1014 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1011 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 933 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 792 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 769 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 805 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 937 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1014 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1011 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 933 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 792 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 769 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 805 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 B