180: TDM - Portlets must support Storage Id in communications with service
Task-Url: https://support.d4science.org/issues/180 Updated resource to support storage id git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-resources-widget@115162 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
56a3a69eab
commit
cc9fb680ff
28
pom.xml
28
pom.xml
|
@ -79,6 +79,34 @@
|
|||
<version>1.0.1</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- service-client-impl -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.data.analysis.tabulardata</groupId>
|
||||
<artifactId>service-client-impl</artifactId>
|
||||
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-scope-maps</artifactId>
|
||||
<version>[1.0.2-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
<artifactId>aslsocial</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>custom-portal-handler</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
<artifactId>aslcore</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
<artifactId>accesslogger</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
@CHARSET "UTF-8";
|
||||
|
||||
.thumb {
|
||||
background: none repeat scroll 0 0 #DDDDDD;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
.thumb img {
|
||||
height: 60px;
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
.thumbWrap {
|
||||
border: 1px solid white;
|
||||
float: left;
|
||||
margin: 4px 0 4px 4px;
|
||||
padding: 5px;
|
||||
font: 11px Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
.thumbWrap span {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.over {
|
||||
background: repeat-x scroll left top #EFEFEF;
|
||||
border: 1px solid #ddd !important;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.select {
|
||||
background: none repeat scroll 0 50% #DFE8F6;
|
||||
border: 1px dotted #A3BAE9 !important;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.select .thumb {
|
||||
background: none repeat scroll 0 0 transparent;
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
<div class="{style.thumb}">
|
||||
<!-- <img src="{resourceTDDescriptor.pathUri}" title="{resourceTDDescriptor.name}">-->
|
||||
</div>
|
||||
<span class="x-editable">{resourceTDDescriptor.name:shorten(18)}</span>
|
|
@ -0,0 +1,8 @@
|
|||
<div class="details">
|
||||
<!--
|
||||
<img src="{pathUri}">-->
|
||||
<div class="details-info">
|
||||
<b>Name:</b> <span>{resourceTDDescriptor.name}</span><b>Description:</b>
|
||||
<span>{resourceTDDescriptor.description}</span><b>Creation Date:</b> <span>{resourceTDDescriptor.creationDate}</span>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,64 @@
|
|||
package org.gcube.portlets.user.td.resourceswidget.client;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.user.UserInfo;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
import com.sencha.gxt.widget.core.client.Window;
|
||||
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
||||
|
||||
/**
|
||||
* Delete Column Dialog
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ResourcesListViewDialog extends Window {
|
||||
protected String WIDTH = "640px";
|
||||
protected String HEIGHT = "480px";
|
||||
protected TRId trId;
|
||||
protected EventBus eventBus;
|
||||
protected UserInfo userInfo;
|
||||
|
||||
public ResourcesListViewDialog(TRId trId, EventBus eventBus) {
|
||||
this.trId = trId;
|
||||
this.eventBus = eventBus;
|
||||
initWindow();
|
||||
ResourcesListViewPanel resourcesPanel = new ResourcesListViewPanel(
|
||||
trId, eventBus);
|
||||
add(resourcesPanel);
|
||||
}
|
||||
|
||||
protected void initWindow() {
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
setBodyBorder(false);
|
||||
setResizable(false);
|
||||
setHeadingText("Resources List View");
|
||||
// getHeader().setIcon(Resources.IMAGES.side_list());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void initTools() {
|
||||
super.initTools();
|
||||
|
||||
closeBtn.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
close();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void close() {
|
||||
hide();
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,438 @@
|
|||
package org.gcube.portlets.user.td.resourceswidget.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDDescriptor;
|
||||
import org.gcube.portlets.user.td.resourceswidget.client.utils.UtilsGXT3;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.core.client.Scheduler;
|
||||
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||
import com.google.gwt.resources.client.ClientBundle;
|
||||
import com.google.gwt.resources.client.CssResource;
|
||||
import com.google.gwt.safehtml.shared.SafeHtml;
|
||||
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||
import com.google.gwt.text.shared.AbstractSafeHtmlRenderer;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
import com.sencha.gxt.cell.core.client.SimpleSafeHtmlCell;
|
||||
import com.sencha.gxt.core.client.IdentityValueProvider;
|
||||
import com.sencha.gxt.core.client.Style.SelectionMode;
|
||||
import com.sencha.gxt.core.client.XTemplates;
|
||||
import com.sencha.gxt.core.client.XTemplates.Formatter;
|
||||
import com.sencha.gxt.core.client.XTemplates.FormatterFactories;
|
||||
import com.sencha.gxt.core.client.XTemplates.FormatterFactory;
|
||||
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
|
||||
import com.sencha.gxt.core.client.resources.CommonStyles;
|
||||
import com.sencha.gxt.core.client.resources.ThemeStyles;
|
||||
import com.sencha.gxt.core.client.util.Format;
|
||||
import com.sencha.gxt.core.client.util.Margins;
|
||||
import com.sencha.gxt.data.client.loader.RpcProxy;
|
||||
import com.sencha.gxt.data.shared.ListStore;
|
||||
import com.sencha.gxt.data.shared.ModelKeyProvider;
|
||||
import com.sencha.gxt.data.shared.SortDir;
|
||||
import com.sencha.gxt.data.shared.Store;
|
||||
import com.sencha.gxt.data.shared.Store.StoreSortInfo;
|
||||
import com.sencha.gxt.data.shared.loader.ListLoadConfig;
|
||||
import com.sencha.gxt.data.shared.loader.ListLoadResult;
|
||||
import com.sencha.gxt.data.shared.loader.ListLoader;
|
||||
import com.sencha.gxt.data.shared.loader.ListStoreBinding;
|
||||
import com.sencha.gxt.data.shared.loader.Loader;
|
||||
import com.sencha.gxt.theme.base.client.listview.ListViewCustomAppearance;
|
||||
import com.sencha.gxt.widget.core.client.Dialog;
|
||||
import com.sencha.gxt.widget.core.client.Dialog.PredefinedButton;
|
||||
import com.sencha.gxt.widget.core.client.FramedPanel;
|
||||
import com.sencha.gxt.widget.core.client.ListView;
|
||||
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.BorderLayoutData;
|
||||
import com.sencha.gxt.widget.core.client.container.MarginData;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||
import com.sencha.gxt.widget.core.client.form.StoreFilterField;
|
||||
import com.sencha.gxt.widget.core.client.selection.SelectionChangedEvent;
|
||||
import com.sencha.gxt.widget.core.client.selection.SelectionChangedEvent.SelectionChangedHandler;
|
||||
import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem;
|
||||
import com.sencha.gxt.widget.core.client.toolbar.SeparatorToolItem;
|
||||
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
||||
|
||||
/**
|
||||
*
|
||||
* ResourcesPanel shows the resources
|
||||
*
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ResourcesListViewPanel extends FramedPanel {
|
||||
|
||||
public interface DetailRenderer extends XTemplates {
|
||||
@XTemplate(source = "ResourcesListViewDetail.html")
|
||||
public SafeHtml render(ResourceTDDescriptor resourceTDDescriptor);
|
||||
}
|
||||
|
||||
@FormatterFactories(@FormatterFactory(factory = ShortenFactory.class, name = "shorten"))
|
||||
public interface Renderer extends XTemplates {
|
||||
@XTemplate(source = "ResourcesListView.html")
|
||||
public SafeHtml renderItem(ResourceTDDescriptor resourceTDDescriptor,
|
||||
ResourceListViewCSS style);
|
||||
}
|
||||
|
||||
public interface ResourcesListViewBundle extends ClientBundle {
|
||||
public static final ResourcesListViewBundle INSTANCE = GWT
|
||||
.create(ResourcesListViewBundle.class);
|
||||
|
||||
@Source("ResourcesListView.css")
|
||||
ResourceListViewCSS css();
|
||||
}
|
||||
|
||||
public interface ResourceListViewCSS extends CssResource {
|
||||
String over();
|
||||
|
||||
String select();
|
||||
|
||||
String thumb();
|
||||
|
||||
String thumbWrap();
|
||||
}
|
||||
|
||||
static class Shorten implements Formatter<String> {
|
||||
private int length;
|
||||
|
||||
public Shorten(int length) {
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(String data) {
|
||||
return Format.ellipse(data, length);
|
||||
}
|
||||
}
|
||||
|
||||
static class ShortenFactory {
|
||||
public static Shorten getFormat(int length) {
|
||||
return new Shorten(length);
|
||||
}
|
||||
}
|
||||
|
||||
private Dialog chooser;
|
||||
private HTML details;
|
||||
private DetailRenderer detailRenderer;
|
||||
|
||||
private TRId trId;
|
||||
private EventBus eventBus;
|
||||
|
||||
private ListStore<ResourceTDDescriptor> store;
|
||||
private ListLoader<ListLoadConfig, ListLoadResult<ResourceTDDescriptor>> loader;
|
||||
|
||||
private boolean drawed = false;
|
||||
|
||||
private ListView<ResourceTDDescriptor, ResourceTDDescriptor> view;
|
||||
|
||||
public ResourcesListViewPanel(TRId trId, EventBus eventBus) {
|
||||
super();
|
||||
this.trId = trId;
|
||||
this.eventBus = eventBus;
|
||||
forceLayoutOnResize = true;
|
||||
retrieveCurrentTR();
|
||||
}
|
||||
|
||||
protected void draw() {
|
||||
try {
|
||||
drawed = true;
|
||||
init();
|
||||
create();
|
||||
} catch (Throwable e) {
|
||||
Log.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
setHeaderVisible(false);
|
||||
setBodyBorder(false);
|
||||
setResize(true);
|
||||
setWidth("630px");
|
||||
setHeight("470px");
|
||||
|
||||
}
|
||||
|
||||
protected void create() {
|
||||
Log.debug("Create Resource List View");
|
||||
|
||||
detailRenderer = GWT.create(DetailRenderer.class);
|
||||
|
||||
RpcProxy<Object, List<ResourceTDDescriptor>> proxy = new RpcProxy<Object, List<ResourceTDDescriptor>>() {
|
||||
@Override
|
||||
public void load(Object loadConfig,
|
||||
AsyncCallback<List<ResourceTDDescriptor>> callback) {
|
||||
loadData(callback);
|
||||
}
|
||||
};
|
||||
|
||||
ModelKeyProvider<ResourceTDDescriptor> keyProvider = new ModelKeyProvider<ResourceTDDescriptor>() {
|
||||
@Override
|
||||
public String getKey(ResourceTDDescriptor item) {
|
||||
return String.valueOf(item.getId());
|
||||
}
|
||||
};
|
||||
|
||||
store = new ListStore<ResourceTDDescriptor>(keyProvider);
|
||||
store.addSortInfo(new StoreSortInfo<ResourceTDDescriptor>(
|
||||
new Comparator<ResourceTDDescriptor>() {
|
||||
@Override
|
||||
public int compare(ResourceTDDescriptor o1,
|
||||
ResourceTDDescriptor o2) {
|
||||
/*
|
||||
* String v = comboSort.getCurrentValue(); if
|
||||
* (v.equals("Name")) { return
|
||||
* o1.getName().compareToIgnoreCase(o2.getName()); }
|
||||
* else if (v.equals("File Size")) { return o1.getSize()
|
||||
* < o2.getSize() ? -1 : 1; } else {
|
||||
* o1.getDate().compareTo(o2.getDate()); }
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
}, SortDir.ASC));
|
||||
|
||||
final Loader<Object, List<ResourceTDDescriptor>> loader = new Loader<Object, List<ResourceTDDescriptor>>(
|
||||
proxy);
|
||||
loader.addLoadHandler(new ListStoreBinding<Object, ResourceTDDescriptor, List<ResourceTDDescriptor>>(
|
||||
store));
|
||||
|
||||
// ToolBar
|
||||
|
||||
StoreFilterField<ResourceTDDescriptor> filterField = new StoreFilterField<ResourceTDDescriptor>() {
|
||||
@Override
|
||||
protected boolean doSelect(Store<ResourceTDDescriptor> store,
|
||||
ResourceTDDescriptor parent, ResourceTDDescriptor item,
|
||||
String filter) {
|
||||
String name = item.getName().toLowerCase();
|
||||
if (name.indexOf(filter.toLowerCase()) != -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFilter() {
|
||||
super.onFilter();
|
||||
view.getSelectionModel().select(0, false);
|
||||
}
|
||||
};
|
||||
filterField.setWidth(100);
|
||||
filterField.bind(store);
|
||||
|
||||
ToolBar toolbar = new ToolBar();
|
||||
toolbar.add(new LabelToolItem("Filter:"));
|
||||
toolbar.add(filterField);
|
||||
toolbar.add(new SeparatorToolItem());
|
||||
toolbar.add(new LabelToolItem("Sort By:"));
|
||||
/*
|
||||
* comboSort = new SimpleComboBox<String>(new
|
||||
* StringLabelProvider<String>());
|
||||
* comboSort.setTriggerAction(TriggerAction.ALL);
|
||||
* comboSort.setEditable(false); comboSort.setForceSelection(true);
|
||||
* comboSort.setWidth(120); comboSort.add("Name");
|
||||
* comboSort.add("File Size"); comboSort.add("Last Modified");
|
||||
* comboSort.setValue("Name"); comboSort.addSelectionHandler(new
|
||||
* SelectionHandler<String>() {
|
||||
*
|
||||
* @Override public void onSelection(SelectionEvent<String> event) {
|
||||
* store.applySort(false); } }); toolbar.add(comboSort);
|
||||
*/
|
||||
|
||||
//
|
||||
ResourcesListViewBundle.INSTANCE.css().ensureInjected();
|
||||
|
||||
final ResourceListViewCSS style = ResourcesListViewBundle.INSTANCE
|
||||
.css();
|
||||
|
||||
final Renderer renderer = GWT.create(Renderer.class);
|
||||
|
||||
ListViewCustomAppearance<ResourceTDDescriptor> appearance = new ListViewCustomAppearance<ResourceTDDescriptor>(
|
||||
"." + style.thumbWrap(), style.over(), style.select()) {
|
||||
@Override
|
||||
public void renderEnd(SafeHtmlBuilder builder) {
|
||||
String markup = new StringBuilder("<div class=\"")
|
||||
.append(CommonStyles.get().clear()).append("\"></div>")
|
||||
.toString();
|
||||
builder.appendHtmlConstant(markup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(SafeHtmlBuilder builder, SafeHtml content) {
|
||||
builder.appendHtmlConstant("<div class='" + style.thumbWrap()
|
||||
+ "' style='border: 1px solid white'>");
|
||||
builder.append(content);
|
||||
builder.appendHtmlConstant("</div>");
|
||||
}
|
||||
};
|
||||
|
||||
view = new ListView<ResourceTDDescriptor, ResourceTDDescriptor>(store,
|
||||
new IdentityValueProvider<ResourceTDDescriptor>() {
|
||||
@Override
|
||||
public void setValue(ResourceTDDescriptor object,
|
||||
ResourceTDDescriptor value) {
|
||||
}
|
||||
}, appearance) {
|
||||
|
||||
@Override
|
||||
protected void onAfterFirstAttach() {
|
||||
super.onAfterFirstAttach();
|
||||
|
||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
|
||||
public void execute() {
|
||||
loader.load();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
view.setLoader(loader);
|
||||
view.setCell(new SimpleSafeHtmlCell<ResourceTDDescriptor>(
|
||||
new AbstractSafeHtmlRenderer<ResourceTDDescriptor>() {
|
||||
@Override
|
||||
public SafeHtml render(ResourceTDDescriptor object) {
|
||||
return renderer.renderItem(object, style);
|
||||
}
|
||||
}));
|
||||
view.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
|
||||
view.getSelectionModel().addSelectionChangedHandler(
|
||||
new SelectionChangedHandler<ResourceTDDescriptor>() {
|
||||
@Override
|
||||
public void onSelectionChanged(
|
||||
SelectionChangedEvent<ResourceTDDescriptor> event) {
|
||||
ResourcesListViewPanel.this.onSelectionChange(event);
|
||||
}
|
||||
});
|
||||
view.setBorders(false);
|
||||
|
||||
VerticalLayoutContainer main = new VerticalLayoutContainer();
|
||||
main.setScrollMode(ScrollMode.AUTO);
|
||||
main.setAdjustForScroll(true);
|
||||
main.setBorders(true);
|
||||
main.add(toolbar, new VerticalLayoutData(1, -1));
|
||||
main.add(view, new VerticalLayoutData(1, 1));
|
||||
|
||||
/*
|
||||
* details = new HTML();
|
||||
* details.addStyleName(ThemeStyles.get().style().border());
|
||||
* details.getElement().getStyle().setBackgroundColor("white");
|
||||
*
|
||||
* BorderLayoutData eastData = new BorderLayoutData(200);
|
||||
* eastData.setSplit(true);
|
||||
*
|
||||
* BorderLayoutData centerData = new BorderLayoutData();
|
||||
* centerData.setMargins(new Margins(0, 5, 0, 0));
|
||||
*
|
||||
* BorderLayoutContainer con = new BorderLayoutContainer();
|
||||
* con.setCenterWidget(main, centerData); con.setEastWidget(details,
|
||||
* eastData);
|
||||
*/
|
||||
|
||||
add(main, new MarginData(0));
|
||||
}
|
||||
|
||||
private void onSelectionChange(
|
||||
SelectionChangedEvent<ResourceTDDescriptor> se) {
|
||||
if (se.getSelection().size() > 0) {
|
||||
details.setHTML(detailRenderer.render(se.getSelection().get(0))
|
||||
.asString());
|
||||
chooser.getButton(PredefinedButton.OK).enable();
|
||||
} else {
|
||||
chooser.getButton(PredefinedButton.OK).disable();
|
||||
details.setHTML("");
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadData(
|
||||
final AsyncCallback<List<ResourceTDDescriptor>> callback) {
|
||||
Log.debug("Called loadData");
|
||||
TDGWTServiceAsync.INSTANCE.getResourcesTD(trId,
|
||||
new AsyncCallback<ArrayList<ResourceTDDescriptor>>() {
|
||||
|
||||
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("Error Locked",
|
||||
caught.getLocalizedMessage());
|
||||
} else {
|
||||
Log.error("Error Retrieving Resources: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error retrieving resources",
|
||||
"Error retrieving resources");
|
||||
}
|
||||
}
|
||||
callback.onFailure(caught);
|
||||
}
|
||||
|
||||
public void onSuccess(ArrayList<ResourceTDDescriptor> result) {
|
||||
Log.debug("Resources loaded " + result.size());
|
||||
try {
|
||||
callback.onSuccess(result);
|
||||
} catch (Throwable e) {
|
||||
Log.debug("Error: " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void update() {
|
||||
retrieveCurrentTR();
|
||||
loader.load();
|
||||
forceLayout();
|
||||
}
|
||||
|
||||
protected void retrieveCurrentTR() {
|
||||
TDGWTServiceAsync.INSTANCE.getCurrentTRId(new AsyncCallback<TRId>() {
|
||||
|
||||
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("Error Locked",
|
||||
caught.getLocalizedMessage());
|
||||
} else {
|
||||
Log.error("Error retrieving current TRId: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error",
|
||||
"Error retrieving current tabular resource id");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onSuccess(TRId result) {
|
||||
Log.debug("retrieved " + result);
|
||||
trId = result;
|
||||
if (!drawed) {
|
||||
draw();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -1,44 +1,147 @@
|
|||
package org.gcube.portlets.user.td.resourceswidget.client;
|
||||
|
||||
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.ResourceTDDescriptor;
|
||||
import org.gcube.portlets.user.td.resourceswidget.client.charts.ChartViewerDialog;
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.user.UserInfo;
|
||||
import org.gcube.portlets.user.td.resourceswidget.client.utils.UtilsGXT3;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.web.bindery.event.shared.SimpleEventBus;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class ResourcesWidgetEntry implements EntryPoint {
|
||||
|
||||
// private ResourceTDDescriptor resourceTDDescriptor;
|
||||
|
||||
private ResourceTDDescriptor resourceTDDescriptor;
|
||||
private SimpleEventBus eventBus;
|
||||
private TRId trId;
|
||||
private TabResource tabResource;
|
||||
|
||||
public void onModuleLoad() {
|
||||
EventBus eventBus= new SimpleEventBus();
|
||||
Log.info("Hello!");
|
||||
eventBus = new SimpleEventBus();
|
||||
trId = new TRId();
|
||||
//TabularResource: [ id=202, type=STANDARD, lastTable=[ id=4901, type=Generic]]
|
||||
//TabularResource: [ id=68, type=STANDARD, lastTable=[ id=4884, type=Dataset]]
|
||||
|
||||
trId.setId("68");
|
||||
trId.setTableType("STANDARD");
|
||||
trId.setTableId("4884");
|
||||
retrieveUserInfo();
|
||||
}
|
||||
|
||||
TRId trId=new TRId();
|
||||
//For example Tabular Resource 7 and table 402
|
||||
trId.setId("7");
|
||||
trId.setTableId("402");
|
||||
|
||||
private void start() {
|
||||
try {
|
||||
// ResourcesDialog dialog=new ResourcesDialog(trId,eventBus);
|
||||
// dialog.show();
|
||||
|
||||
resourceTDDescriptor=new ResourceTDDescriptor();
|
||||
resourceTDDescriptor.setName("Test Chart");
|
||||
ChartViewerDialog chartDialog=new ChartViewerDialog(resourceTDDescriptor, trId, eventBus, true);
|
||||
chartDialog.show();
|
||||
/*
|
||||
* resourceTDDescriptor=new ResourceTDDescriptor();
|
||||
* resourceTDDescriptor.setName("Test Chart"); ChartViewerDialog
|
||||
* chartDialog=new ChartViewerDialog(resourceTDDescriptor, trId,
|
||||
* eventBus, true); chartDialog.show();
|
||||
*/
|
||||
|
||||
Log.info("Hello!");
|
||||
ResourcesListViewDialog resourcesListViewDialog = new ResourcesListViewDialog(
|
||||
trId, eventBus);
|
||||
resourcesListViewDialog.show();
|
||||
} catch (Throwable e) {
|
||||
Log.error(e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void onSuccess(UserInfo userInfo) {
|
||||
Log.debug("User Info: " + userInfo);
|
||||
getTabularResource();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
protected void getTabularResource(){
|
||||
TDGWTServiceAsync.INSTANCE.getTabResourceInformation(trId, new AsyncCallback<TabResource>() {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
|
||||
Log.error("Error get TR information: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error", "Error get TR information");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(TabResource result) {
|
||||
Log.debug("TabResource:"+result);
|
||||
tabResource=result;
|
||||
setCurrentTabularResource();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void setCurrentTabularResource() {
|
||||
TDGWTServiceAsync.INSTANCE.setTabResource(tabResource,
|
||||
new AsyncCallback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
|
||||
Log.error("Error setting Active TR: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error", "Error setting Active TR");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
Log.debug("Tab Resource set");
|
||||
start();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ public interface ResourceBundle extends ClientBundle {
|
|||
|
||||
public static final ResourceBundle INSTANCE=GWT.create(ResourceBundle.class);
|
||||
|
||||
|
||||
@Source("testImage.jpg")
|
||||
ImageResource testImage();
|
||||
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
@CHARSET "UTF-8";
|
||||
|
||||
.thumb {
|
||||
background: none repeat scroll 0 0 #DDDDDD;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
.thumb img {
|
||||
height: 60px;
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
.thumbWrap {
|
||||
border: 1px solid white;
|
||||
float: left;
|
||||
margin: 4px 0 4px 4px;
|
||||
padding: 5px;
|
||||
font: 11px Arial, Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
.thumbWrap span {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.over {
|
||||
background: repeat-x scroll left top #EFEFEF;
|
||||
border: 1px solid #ddd !important;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.select {
|
||||
background: none repeat scroll 0 50% #DFE8F6;
|
||||
border: 1px dotted #A3BAE9 !important;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.select .thumb {
|
||||
background: none repeat scroll 0 0 transparent;
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
<div class="{style.thumb}">
|
||||
<!-- <img src="{resourceTDDescriptor.pathUri}" title="{resourceTDDescriptor.name}">-->
|
||||
</div>
|
||||
<span class="x-editable">{resourceTDDescriptor.name:shorten(18)}</span>
|
|
@ -0,0 +1,8 @@
|
|||
<div class="details">
|
||||
<!--
|
||||
<img src="{pathUri}">-->
|
||||
<div class="details-info">
|
||||
<b>Name:</b> <span>{resourceTDDescriptor.name}</span><b>Description:</b>
|
||||
<span>{resourceTDDescriptor.description}</span><b>Creation Date:</b> <span>{resourceTDDescriptor.creationDate}</span>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue