209: TDM - Show the resources through a ListView widget
Task-Url: https://support.d4science.org/issues/209 Updated Resources ListView git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-resources-widget@115248 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
961bb73a7e
commit
aba485a64d
|
@ -1,26 +0,0 @@
|
||||||
@CHARSET "UTF-8";
|
|
||||||
|
|
||||||
.details {
|
|
||||||
padding: 10px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.detailsInfo {
|
|
||||||
border-top: 1px solid #ccc;
|
|
||||||
font: 11px Arial, Helvetica, sans-serif;
|
|
||||||
margin-top: 5px;
|
|
||||||
padding-top: 5px;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.detailsTable {
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.detailsHead {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.detailsData {
|
|
||||||
padding-left: 5px;
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
<div class="{style.details}">
|
|
||||||
<img src="{thumbnailPath}" title="{resourceTDDescriptor.name}">
|
|
||||||
<div class="{style.detailsInfo}">
|
|
||||||
<table class="{style.detailsTable}">
|
|
||||||
<tr><td class="{style.detailsHead}">Name:</td></tr>
|
|
||||||
<tr><td class="{style.detailsData}">{resourceTDDescriptor.name}</td></tr>
|
|
||||||
<tr><td class="{style.detailsHead}">Description:</td></tr>
|
|
||||||
<tr><td class="{style.detailsData}">{resourceTDDescriptor.description}</td></tr>
|
|
||||||
<tr><td class="{style.detailsHead}">Creation Date:</td></tr>
|
|
||||||
<tr><td class="{style.detailsData}">{resourceTDDescriptor.creationDate}</td></tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
|
@ -3,6 +3,7 @@ package org.gcube.portlets.user.td.resourceswidget.client;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.InternalURITD;
|
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.StringResourceTD;
|
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.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;
|
||||||
|
@ -10,14 +11,19 @@ import org.gcube.portlets.user.td.resourceswidget.client.resources.ResourceBundl
|
||||||
import com.google.gwt.safehtml.shared.SafeUri;
|
import com.google.gwt.safehtml.shared.SafeUri;
|
||||||
import com.google.gwt.safehtml.shared.UriUtils;
|
import com.google.gwt.safehtml.shared.UriUtils;
|
||||||
import com.google.gwt.user.client.ui.Image;
|
import com.google.gwt.user.client.ui.Image;
|
||||||
|
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
|
||||||
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
|
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
|
||||||
import com.sencha.gxt.core.client.resources.ThemeStyles;
|
import com.sencha.gxt.core.client.resources.ThemeStyles;
|
||||||
import com.sencha.gxt.core.client.util.Margins;
|
import com.sencha.gxt.core.client.util.Margins;
|
||||||
|
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
||||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
|
||||||
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
|
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
|
||||||
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
|
||||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
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.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
||||||
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
||||||
import com.sencha.gxt.widget.core.client.form.FormPanel.LabelAlign;
|
import com.sencha.gxt.widget.core.client.form.FormPanel.LabelAlign;
|
||||||
import com.sencha.gxt.widget.core.client.form.TextArea;
|
import com.sencha.gxt.widget.core.client.form.TextArea;
|
||||||
|
@ -30,32 +36,48 @@ import com.sencha.gxt.widget.core.client.form.TextField;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ResourcesListViewDetailPanel extends SimpleContainer {
|
public class ResourcesListViewDetailPanel extends SimpleContainer {
|
||||||
|
private static final String THUMBNAIL_WIDTH = "160px";
|
||||||
|
private static final String THUMBNAIL_HEIGHT = "160px";
|
||||||
private static final String DESCRIPTION_HEIGHT = "70px";
|
private static final String DESCRIPTION_HEIGHT = "70px";
|
||||||
|
|
||||||
|
|
||||||
private Image thumbnail;
|
private Image thumbnail;
|
||||||
private TextField name;
|
private TextField name;
|
||||||
private TextArea description;
|
private TextArea description;
|
||||||
private TextField creationDate;
|
private TextField creationDate;
|
||||||
private VerticalLayoutContainer v;
|
private VerticalLayoutContainer v;
|
||||||
|
|
||||||
public ResourcesListViewDetailPanel() {
|
private ResourceTDDescriptor descriptor;
|
||||||
|
|
||||||
|
private TextButton removeButton;
|
||||||
|
|
||||||
|
private TextButton saveButton;
|
||||||
|
|
||||||
|
private TextButton openButton;
|
||||||
|
|
||||||
|
private ResourcesListViewPanel parent;
|
||||||
|
|
||||||
|
private HBoxLayoutContainer buttonMenu;
|
||||||
|
|
||||||
|
public ResourcesListViewDetailPanel(ResourcesListViewPanel parent) {
|
||||||
super();
|
super();
|
||||||
|
this.parent = parent;
|
||||||
init();
|
init();
|
||||||
|
|
||||||
}
|
}
|
||||||
protected void init(){
|
|
||||||
|
protected void init() {
|
||||||
addStyleName(ThemeStyles.get().style().border());
|
addStyleName(ThemeStyles.get().style().border());
|
||||||
getElement().getStyle().setBackgroundColor("white");
|
// getElement().getStyle().setBackgroundColor("white");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescriptor(ResourceTDDescriptor descriptor){
|
public void setDescriptor(ResourceTDDescriptor descriptor) {
|
||||||
if(v!=null){
|
this.descriptor = descriptor;
|
||||||
|
if (v != null) {
|
||||||
remove(v);
|
remove(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(descriptor==null){
|
if (descriptor == null) {
|
||||||
forceLayout();
|
forceLayout();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -82,35 +104,38 @@ public class ResourcesListViewDetailPanel extends SimpleContainer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
thumbnail = new Image();
|
||||||
|
thumbnail.setWidth(THUMBNAIL_WIDTH);
|
||||||
|
thumbnail.setHeight(THUMBNAIL_HEIGHT);
|
||||||
|
|
||||||
thumbnail=new Image();
|
name = new TextField();
|
||||||
|
FieldLabel nameLabel = new FieldLabel(name, "Name");
|
||||||
|
|
||||||
name=new TextField();
|
|
||||||
FieldLabel nameLabel=new FieldLabel(name, "Name");
|
|
||||||
nameLabel.setLabelAlign(LabelAlign.TOP);
|
nameLabel.setLabelAlign(LabelAlign.TOP);
|
||||||
|
|
||||||
description=new TextArea();
|
description = new TextArea();
|
||||||
description.setHeight(DESCRIPTION_HEIGHT);
|
description.setHeight(DESCRIPTION_HEIGHT);
|
||||||
FieldLabel descriptionLabel=new FieldLabel(description, "Description");
|
FieldLabel descriptionLabel = new FieldLabel(description, "Description");
|
||||||
descriptionLabel.setLabelAlign(LabelAlign.TOP);
|
descriptionLabel.setLabelAlign(LabelAlign.TOP);
|
||||||
|
|
||||||
creationDate=new TextField();
|
creationDate = new TextField();
|
||||||
FieldLabel creationDateLabel=new FieldLabel(creationDate, "Creation Date");
|
FieldLabel creationDateLabel = new FieldLabel(creationDate,
|
||||||
|
"Creation Date");
|
||||||
creationDateLabel.setLabelAlign(LabelAlign.TOP);
|
creationDateLabel.setLabelAlign(LabelAlign.TOP);
|
||||||
|
|
||||||
v=new VerticalLayoutContainer();
|
v = new VerticalLayoutContainer();
|
||||||
v.setScrollMode(ScrollMode.AUTO);
|
v.setScrollMode(ScrollMode.AUTO);
|
||||||
|
|
||||||
HBoxLayoutContainer h=new HBoxLayoutContainer();
|
HBoxLayoutContainer h = new HBoxLayoutContainer();
|
||||||
h.setPack(BoxLayoutPack.CENTER);
|
h.setPack(BoxLayoutPack.CENTER);
|
||||||
h.add(thumbnail);
|
h.add(thumbnail);
|
||||||
|
|
||||||
v.add(h, new VerticalLayoutData(1,-1, new Margins(20,0,10,0)));
|
createMenu();
|
||||||
|
|
||||||
|
v.add(h, new VerticalLayoutData(1, -1, new Margins(20, 0, 10, 0)));
|
||||||
v.add(nameLabel, new VerticalLayoutData(1, -1, new Margins(1)));
|
v.add(nameLabel, new VerticalLayoutData(1, -1, new Margins(1)));
|
||||||
v.add(descriptionLabel, new VerticalLayoutData(1, -1, new Margins(1)));
|
v.add(descriptionLabel, new VerticalLayoutData(1, -1, new Margins(1)));
|
||||||
v.add(creationDateLabel, new VerticalLayoutData(1, -1, new Margins(1)));
|
v.add(creationDateLabel, new VerticalLayoutData(1, -1, new Margins(1)));
|
||||||
|
v.add(buttonMenu, new VerticalLayoutData(1, -1, new Margins(0)));
|
||||||
|
|
||||||
thumbnail.setUrl(thumbnailPath);
|
thumbnail.setUrl(thumbnailPath);
|
||||||
name.setValue(descriptor.getName());
|
name.setValue(descriptor.getName());
|
||||||
|
@ -122,7 +147,129 @@ public class ResourcesListViewDetailPanel extends SimpleContainer {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void createMenu() {
|
||||||
|
if (descriptor == null || descriptor.getResourceType() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
openButton = new TextButton("Open");
|
||||||
|
openButton.setIcon(ResourceBundle.INSTANCE.resources());
|
||||||
|
openButton.setIconAlign(IconAlign.RIGHT);
|
||||||
|
openButton.setToolTip("Open");
|
||||||
|
SelectHandler openHandler = new SelectHandler() {
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
requestOpen();
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
openButton.addSelectHandler(openHandler);
|
||||||
|
|
||||||
|
saveButton = new TextButton("Save");
|
||||||
|
saveButton.setIcon(ResourceBundle.INSTANCE.save());
|
||||||
|
saveButton.setIconAlign(IconAlign.RIGHT);
|
||||||
|
saveButton.setToolTip("Save");
|
||||||
|
SelectHandler saveHandler = new SelectHandler() {
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
requestSave();
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
saveButton.addSelectHandler(saveHandler);
|
||||||
|
|
||||||
|
removeButton = new TextButton("Delete");
|
||||||
|
removeButton.setIcon(ResourceBundle.INSTANCE.delete());
|
||||||
|
removeButton.setIconAlign(IconAlign.RIGHT);
|
||||||
|
removeButton.setToolTip("Save");
|
||||||
|
SelectHandler removeHandler = new SelectHandler() {
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
requestRemove();
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
removeButton.addSelectHandler(removeHandler);
|
||||||
|
|
||||||
|
ResourceTDType resourceTDType = descriptor.getResourceType();
|
||||||
|
switch (resourceTDType) {
|
||||||
|
case CHART:
|
||||||
|
openButton.setIcon(ResourceBundle.INSTANCE.chart());
|
||||||
|
openButton.setVisible(true);
|
||||||
|
saveButton.setVisible(true);
|
||||||
|
removeButton.setVisible(true);
|
||||||
|
break;
|
||||||
|
case CODELIST:
|
||||||
|
openButton.setVisible(false);
|
||||||
|
saveButton.setVisible(false);
|
||||||
|
removeButton.setVisible(true);
|
||||||
|
break;
|
||||||
|
case CSV:
|
||||||
|
openButton.setVisible(false);
|
||||||
|
saveButton.setVisible(true);
|
||||||
|
removeButton.setVisible(true);
|
||||||
|
break;
|
||||||
|
case GENERIC_FILE:
|
||||||
|
openButton.setIcon(ResourceBundle.INSTANCE.file());
|
||||||
|
openButton.setVisible(true);
|
||||||
|
saveButton.setVisible(true);
|
||||||
|
removeButton.setVisible(true);
|
||||||
|
break;
|
||||||
|
case GENERIC_TABLE:
|
||||||
|
openButton.setVisible(false);
|
||||||
|
saveButton.setVisible(false);
|
||||||
|
removeButton.setVisible(true);
|
||||||
|
break;
|
||||||
|
case GUESSER:
|
||||||
|
openButton.setVisible(false);
|
||||||
|
saveButton.setVisible(false);
|
||||||
|
removeButton.setVisible(true);
|
||||||
|
break;
|
||||||
|
case JSON:
|
||||||
|
openButton.setVisible(false);
|
||||||
|
saveButton.setVisible(true);
|
||||||
|
removeButton.setVisible(true);
|
||||||
|
break;
|
||||||
|
case MAP:
|
||||||
|
openButton.setIcon(ResourceBundle.INSTANCE.gis());
|
||||||
|
openButton.setVisible(true);
|
||||||
|
saveButton.setVisible(false);
|
||||||
|
removeButton.setVisible(true);
|
||||||
|
break;
|
||||||
|
case SDMX:
|
||||||
|
openButton.setVisible(false);
|
||||||
|
saveButton.setVisible(false);
|
||||||
|
removeButton.setVisible(true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
openButton.setVisible(false);
|
||||||
|
saveButton.setVisible(false);
|
||||||
|
removeButton.setVisible(true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
buttonMenu = new HBoxLayoutContainer();
|
||||||
|
buttonMenu.setPack(BoxLayoutPack.CENTER);
|
||||||
|
buttonMenu.add(openButton, new BoxLayoutData(new Margins(5, 2, 5, 2)));
|
||||||
|
buttonMenu.add(saveButton, new BoxLayoutData(new Margins(5, 2, 5, 2)));
|
||||||
|
buttonMenu
|
||||||
|
.add(removeButton, new BoxLayoutData(new Margins(5, 2, 5, 2)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void requestOpen() {
|
||||||
|
parent.requestOpen(descriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void requestSave() {
|
||||||
|
parent.requestSave(descriptor);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void requestRemove() {
|
||||||
|
parent.requestRemove(descriptor);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,18 +9,28 @@ 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.TDGWTIsLockedException;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.InternalURITD;
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.InternalURITD;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.RemoveResourceSession;
|
||||||
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.SaveResourceSession;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.resources.StringResourceTD;
|
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.gwtservice.shared.tr.resources.TableResourceTD;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.uriresolver.UriResolverSession;
|
||||||
|
import org.gcube.portlets.user.td.resourceswidget.client.charts.ChartViewerDialog;
|
||||||
import org.gcube.portlets.user.td.resourceswidget.client.resources.ResourceBundle;
|
import org.gcube.portlets.user.td.resourceswidget.client.resources.ResourceBundle;
|
||||||
|
import org.gcube.portlets.user.td.resourceswidget.client.save.SaveResourceWizard;
|
||||||
import org.gcube.portlets.user.td.resourceswidget.client.utils.UtilsGXT3;
|
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.event.SessionExpiredEvent;
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.mime.MimeTypeSupport;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.uriresolver.ApplicationType;
|
||||||
|
import org.gcube.portlets.user.td.wizardwidget.client.WizardListener;
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.core.client.RunAsyncCallback;
|
||||||
import com.google.gwt.core.client.Scheduler;
|
import com.google.gwt.core.client.Scheduler;
|
||||||
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||||
|
@ -32,6 +42,7 @@ import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||||
import com.google.gwt.safehtml.shared.SafeUri;
|
import com.google.gwt.safehtml.shared.SafeUri;
|
||||||
import com.google.gwt.safehtml.shared.UriUtils;
|
import com.google.gwt.safehtml.shared.UriUtils;
|
||||||
import com.google.gwt.text.shared.AbstractSafeHtmlRenderer;
|
import com.google.gwt.text.shared.AbstractSafeHtmlRenderer;
|
||||||
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.web.bindery.event.shared.EventBus;
|
import com.google.web.bindery.event.shared.EventBus;
|
||||||
import com.sencha.gxt.cell.core.client.SimpleSafeHtmlCell;
|
import com.sencha.gxt.cell.core.client.SimpleSafeHtmlCell;
|
||||||
|
@ -53,9 +64,6 @@ import com.sencha.gxt.data.shared.SortDir;
|
||||||
import com.sencha.gxt.data.shared.Store;
|
import com.sencha.gxt.data.shared.Store;
|
||||||
import com.sencha.gxt.data.shared.Store.StoreSortInfo;
|
import com.sencha.gxt.data.shared.Store.StoreSortInfo;
|
||||||
import com.sencha.gxt.data.shared.StringLabelProvider;
|
import com.sencha.gxt.data.shared.StringLabelProvider;
|
||||||
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.ListStoreBinding;
|
||||||
import com.sencha.gxt.data.shared.loader.Loader;
|
import com.sencha.gxt.data.shared.loader.Loader;
|
||||||
import com.sencha.gxt.theme.base.client.listview.ListViewCustomAppearance;
|
import com.sencha.gxt.theme.base.client.listview.ListViewCustomAppearance;
|
||||||
|
@ -66,8 +74,13 @@ import com.sencha.gxt.widget.core.client.container.BorderLayoutContainer.BorderL
|
||||||
import com.sencha.gxt.widget.core.client.container.MarginData;
|
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;
|
||||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.BeforeShowContextMenuEvent;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.BeforeShowContextMenuEvent.BeforeShowContextMenuHandler;
|
||||||
import com.sencha.gxt.widget.core.client.form.SimpleComboBox;
|
import com.sencha.gxt.widget.core.client.form.SimpleComboBox;
|
||||||
import com.sencha.gxt.widget.core.client.form.StoreFilterField;
|
import com.sencha.gxt.widget.core.client.form.StoreFilterField;
|
||||||
|
import com.sencha.gxt.widget.core.client.menu.Item;
|
||||||
|
import com.sencha.gxt.widget.core.client.menu.Menu;
|
||||||
|
import com.sencha.gxt.widget.core.client.menu.MenuItem;
|
||||||
import com.sencha.gxt.widget.core.client.selection.SelectionChangedEvent;
|
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.selection.SelectionChangedEvent.SelectionChangedHandler;
|
||||||
import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem;
|
import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem;
|
||||||
|
@ -88,19 +101,7 @@ 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";
|
||||||
|
|
||||||
public interface DetailRenderer extends XTemplates {
|
|
||||||
@XTemplate(source = "ResourcesListViewDetail.html")
|
|
||||||
public SafeHtml render(ResourceTDDescriptor resourceTDDescriptor,
|
|
||||||
SafeUri thumbnailPath, ResourceListViewDetailCSS style);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface DetailRendererBundle extends ClientBundle {
|
|
||||||
public static final DetailRendererBundle INSTANCE = GWT
|
|
||||||
.create(DetailRendererBundle.class);
|
|
||||||
|
|
||||||
@Source("ResourcesListViewDetail.css")
|
|
||||||
ResourceListViewDetailCSS css();
|
|
||||||
}
|
|
||||||
|
|
||||||
@FormatterFactories(@FormatterFactory(factory = ShortenFactory.class, name = "shorten"))
|
@FormatterFactories(@FormatterFactory(factory = ShortenFactory.class, name = "shorten"))
|
||||||
public interface Renderer extends XTemplates {
|
public interface Renderer extends XTemplates {
|
||||||
|
@ -117,18 +118,7 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
ResourceListViewCSS css();
|
ResourceListViewCSS css();
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ResourceListViewDetailCSS extends CssResource {
|
|
||||||
String details();
|
|
||||||
|
|
||||||
String detailsInfo();
|
|
||||||
|
|
||||||
String detailsTable();
|
|
||||||
|
|
||||||
String detailsHead();
|
|
||||||
|
|
||||||
String detailsData();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface ResourceListViewCSS extends CssResource {
|
public interface ResourceListViewCSS extends CssResource {
|
||||||
String over();
|
String over();
|
||||||
|
@ -198,20 +188,24 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private Dialog chooser;
|
|
||||||
// private HTML details;
|
|
||||||
private ResourcesListViewDetailPanel details;
|
private ResourcesListViewDetailPanel details;
|
||||||
// private static DetailRenderer detailRenderer;
|
|
||||||
// private static ResourceListViewDetailCSS detailStyle;
|
|
||||||
|
|
||||||
private TRId trId;
|
private TRId trId;
|
||||||
private EventBus eventBus;
|
private EventBus eventBus;
|
||||||
|
|
||||||
private ListStore<ResourceTDDescriptor> store;
|
private ListStore<ResourceTDDescriptor> store;
|
||||||
private ListLoader<ListLoadConfig, ListLoadResult<ResourceTDDescriptor>> loader;
|
//private ListLoader<Object, ListLoadResult<ResourceTDDescriptor>> loader;
|
||||||
|
private Loader<Object, List<ResourceTDDescriptor>> loader;
|
||||||
|
|
||||||
private ListView<ResourceTDDescriptor, ResourceTDDescriptor> view;
|
private ListView<ResourceTDDescriptor, ResourceTDDescriptor> listView;
|
||||||
private SimpleComboBox<String> comboSort;
|
private SimpleComboBox<String> comboSort;
|
||||||
|
private Menu contextMenu;
|
||||||
|
private MenuItem openItem;
|
||||||
|
private MenuItem saveItem;
|
||||||
|
private MenuItem removeItem;
|
||||||
|
private RemoveResourceSession removeResourceSession;
|
||||||
|
private SaveResourceSession saveResourceSession;
|
||||||
|
|
||||||
public ResourcesListViewPanel(EventBus eventBus) {
|
public ResourcesListViewPanel(EventBus eventBus) {
|
||||||
super();
|
super();
|
||||||
|
@ -228,7 +222,7 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
details.setDescriptor(null);
|
details.setDescriptor(null);
|
||||||
forceLayout();
|
forceLayout();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Log.error("Error open resources: "+e.getLocalizedMessage());
|
Log.error("Error open resources: " + e.getLocalizedMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -244,14 +238,6 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
|
|
||||||
protected void create() {
|
protected void create() {
|
||||||
Log.debug("Create Resource List View");
|
Log.debug("Create Resource List View");
|
||||||
|
|
||||||
/*
|
|
||||||
* DetailRendererBundle.INSTANCE.css().ensureInjected(); detailStyle =
|
|
||||||
* DetailRendererBundle.INSTANCE.css();
|
|
||||||
*
|
|
||||||
* detailRenderer = GWT.create(DetailRenderer.class);
|
|
||||||
*/
|
|
||||||
|
|
||||||
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,
|
||||||
|
@ -288,7 +274,7 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
}
|
}
|
||||||
}, SortDir.ASC));
|
}, SortDir.ASC));
|
||||||
|
|
||||||
final Loader<Object, List<ResourceTDDescriptor>> 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));
|
||||||
|
@ -310,7 +296,7 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
@Override
|
@Override
|
||||||
protected void onFilter() {
|
protected void onFilter() {
|
||||||
super.onFilter();
|
super.onFilter();
|
||||||
view.getSelectionModel().select(0, false);
|
listView.getSelectionModel().select(0, false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
filterField.setWidth(100);
|
filterField.setWidth(100);
|
||||||
|
@ -367,7 +353,7 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
view = new ListView<ResourceTDDescriptor, ResourceTDDescriptor>(store,
|
listView = new ListView<ResourceTDDescriptor, ResourceTDDescriptor>(store,
|
||||||
new IdentityValueProvider<ResourceTDDescriptor>() {
|
new IdentityValueProvider<ResourceTDDescriptor>() {
|
||||||
@Override
|
@Override
|
||||||
public void setValue(ResourceTDDescriptor object,
|
public void setValue(ResourceTDDescriptor object,
|
||||||
|
@ -388,8 +374,8 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
view.setLoader(loader);
|
listView.setLoader(loader);
|
||||||
view.setCell(new SimpleSafeHtmlCell<ResourceTDDescriptor>(
|
listView.setCell(new SimpleSafeHtmlCell<ResourceTDDescriptor>(
|
||||||
new AbstractSafeHtmlRenderer<ResourceTDDescriptor>() {
|
new AbstractSafeHtmlRenderer<ResourceTDDescriptor>() {
|
||||||
@Override
|
@Override
|
||||||
public SafeHtml render(ResourceTDDescriptor descriptor) {
|
public SafeHtml render(ResourceTDDescriptor descriptor) {
|
||||||
|
@ -421,8 +407,8 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
style);
|
style);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
view.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
|
listView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
|
||||||
view.getSelectionModel().addSelectionChangedHandler(
|
listView.getSelectionModel().addSelectionChangedHandler(
|
||||||
new SelectionChangedHandler<ResourceTDDescriptor>() {
|
new SelectionChangedHandler<ResourceTDDescriptor>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSelectionChanged(
|
public void onSelectionChanged(
|
||||||
|
@ -430,16 +416,18 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
ResourcesListViewPanel.this.onSelectionChange(event);
|
ResourcesListViewPanel.this.onSelectionChange(event);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
view.setBorders(false);
|
listView.setBorders(false);
|
||||||
|
|
||||||
|
createContextMenu();
|
||||||
|
|
||||||
VerticalLayoutContainer main = new VerticalLayoutContainer();
|
VerticalLayoutContainer main = new VerticalLayoutContainer();
|
||||||
main.setScrollMode(ScrollMode.AUTO);
|
main.setScrollMode(ScrollMode.AUTO);
|
||||||
// main.setAdjustForScroll(true);
|
// main.setAdjustForScroll(true);
|
||||||
main.setBorders(true);
|
main.setBorders(true);
|
||||||
main.add(toolbar, new VerticalLayoutData(1, -1));
|
main.add(toolbar, new VerticalLayoutData(1, -1));
|
||||||
main.add(view, new VerticalLayoutData(1, 1));
|
main.add(listView, new VerticalLayoutData(1, 1));
|
||||||
|
|
||||||
details = new ResourcesListViewDetailPanel();
|
details = new ResourcesListViewDetailPanel(this);
|
||||||
|
|
||||||
BorderLayoutData centerData = new BorderLayoutData();
|
BorderLayoutData centerData = new BorderLayoutData();
|
||||||
centerData.setMinSize(330);
|
centerData.setMinSize(330);
|
||||||
|
@ -459,33 +447,10 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
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);
|
||||||
/*
|
|
||||||
* @SuppressWarnings("unused") 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(); } } }
|
|
||||||
*/
|
|
||||||
|
|
||||||
details.setDescriptor(descriptor);
|
details.setDescriptor(descriptor);
|
||||||
/*
|
|
||||||
* details.setHTML(detailRenderer.render(descriptor, thumbnailPath,
|
|
||||||
* detailStyle).asString());
|
|
||||||
*/
|
|
||||||
// chooser.getButton(PredefinedButton.OK).enable();
|
|
||||||
} else {
|
} else {
|
||||||
details.setDescriptor(null);
|
details.setDescriptor(null);
|
||||||
// chooser.getButton(PredefinedButton.OK).disable();
|
|
||||||
// setHTML("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -532,4 +497,418 @@ public class ResourcesListViewPanel extends FramedPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void createContextMenu() {
|
||||||
|
contextMenu = new Menu();
|
||||||
|
|
||||||
|
openItem = new MenuItem();
|
||||||
|
openItem.setText("Open");
|
||||||
|
openItem.setIcon(ResourceBundle.INSTANCE.resources());
|
||||||
|
openItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSelection(SelectionEvent<Item> event) {
|
||||||
|
ResourceTDDescriptor selected = listView.getSelectionModel()
|
||||||
|
.getSelectedItem();
|
||||||
|
Log.debug("selected: " + selected);
|
||||||
|
requestOpen(selected);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
saveItem = new MenuItem();
|
||||||
|
saveItem.setText("Save");
|
||||||
|
saveItem.setIcon(ResourceBundle.INSTANCE.save());
|
||||||
|
saveItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSelection(SelectionEvent<Item> event) {
|
||||||
|
ResourceTDDescriptor selected = listView.getSelectionModel()
|
||||||
|
.getSelectedItem();
|
||||||
|
Log.debug("selected: " + selected);
|
||||||
|
requestSave(selected);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
removeItem = new MenuItem();
|
||||||
|
removeItem.setText("Delete");
|
||||||
|
removeItem.setIcon(ResourceBundle.INSTANCE.delete());
|
||||||
|
removeItem.addSelectionHandler(new SelectionHandler<Item>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSelection(SelectionEvent<Item> event) {
|
||||||
|
ResourceTDDescriptor selected = listView.getSelectionModel()
|
||||||
|
.getSelectedItem();
|
||||||
|
Log.debug("selected: " + selected);
|
||||||
|
requestRemove(selected);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
listView.setContextMenu(contextMenu);
|
||||||
|
|
||||||
|
listView.addBeforeShowContextMenuHandler(new BeforeShowContextMenuHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBeforeShowContextMenu(BeforeShowContextMenuEvent event) {
|
||||||
|
Menu contextMenu = event.getMenu();
|
||||||
|
|
||||||
|
ResourceTDDescriptor selected = listView.getSelectionModel()
|
||||||
|
.getSelectedItem();
|
||||||
|
ResourceTDType resourceTDType = selected.getResourceType();
|
||||||
|
switch (resourceTDType) {
|
||||||
|
case CHART:
|
||||||
|
contextMenu.clear();
|
||||||
|
openItem.setIcon(ResourceBundle.INSTANCE.chart());
|
||||||
|
contextMenu.add(openItem);
|
||||||
|
contextMenu.add(saveItem);
|
||||||
|
contextMenu.add(removeItem);
|
||||||
|
listView.setContextMenu(contextMenu);
|
||||||
|
break;
|
||||||
|
case CODELIST:
|
||||||
|
contextMenu.clear();
|
||||||
|
contextMenu.add(removeItem);
|
||||||
|
listView.setContextMenu(contextMenu);
|
||||||
|
break;
|
||||||
|
case CSV:
|
||||||
|
contextMenu.clear();
|
||||||
|
contextMenu.add(saveItem);
|
||||||
|
contextMenu.add(removeItem);
|
||||||
|
listView.setContextMenu(contextMenu);
|
||||||
|
break;
|
||||||
|
case GUESSER:
|
||||||
|
contextMenu.clear();
|
||||||
|
contextMenu.add(removeItem);
|
||||||
|
listView.setContextMenu(contextMenu);
|
||||||
|
break;
|
||||||
|
case JSON:
|
||||||
|
contextMenu.clear();
|
||||||
|
contextMenu.add(saveItem);
|
||||||
|
contextMenu.add(removeItem);
|
||||||
|
listView.setContextMenu(contextMenu);
|
||||||
|
break;
|
||||||
|
case MAP:
|
||||||
|
contextMenu.clear();
|
||||||
|
openItem.setIcon(ResourceBundle.INSTANCE.gis());
|
||||||
|
contextMenu.add(openItem);
|
||||||
|
contextMenu.add(removeItem);
|
||||||
|
listView.setContextMenu(contextMenu);
|
||||||
|
break;
|
||||||
|
case SDMX:
|
||||||
|
contextMenu.clear();
|
||||||
|
contextMenu.add(removeItem);
|
||||||
|
listView.setContextMenu(contextMenu);
|
||||||
|
break;
|
||||||
|
case GENERIC_FILE:
|
||||||
|
contextMenu.clear();
|
||||||
|
openItem.setIcon(ResourceBundle.INSTANCE.file());
|
||||||
|
contextMenu.add(openItem);
|
||||||
|
contextMenu.add(saveItem);
|
||||||
|
contextMenu.add(removeItem);
|
||||||
|
listView.setContextMenu(contextMenu);
|
||||||
|
break;
|
||||||
|
case GENERIC_TABLE:
|
||||||
|
contextMenu.clear();
|
||||||
|
contextMenu.add(removeItem);
|
||||||
|
listView.setContextMenu(contextMenu);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
contextMenu.clear();
|
||||||
|
contextMenu.add(removeItem);
|
||||||
|
listView.setContextMenu(contextMenu);
|
||||||
|
event.setCancelled(true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void requestSave(ResourceTDDescriptor resourceTDDescriptor) {
|
||||||
|
switch (resourceTDDescriptor.getResourceType()) {
|
||||||
|
case CHART:
|
||||||
|
requestSaveResource(resourceTDDescriptor, MimeTypeSupport._jpg);
|
||||||
|
break;
|
||||||
|
case CODELIST:
|
||||||
|
break;
|
||||||
|
case CSV:
|
||||||
|
requestSaveResource(resourceTDDescriptor, MimeTypeSupport._csv);
|
||||||
|
break;
|
||||||
|
case GUESSER:
|
||||||
|
break;
|
||||||
|
case JSON:
|
||||||
|
requestSaveResource(resourceTDDescriptor, MimeTypeSupport._json);
|
||||||
|
break;
|
||||||
|
case MAP:
|
||||||
|
break;
|
||||||
|
case SDMX:
|
||||||
|
break;
|
||||||
|
case GENERIC_FILE:
|
||||||
|
requestSaveResource(resourceTDDescriptor, MimeTypeSupport._unknow);
|
||||||
|
break;
|
||||||
|
case GENERIC_TABLE:
|
||||||
|
// requestSaveResource(resourceTDDescriptor, MimeTypeSupport._csv);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void requestSaveResource(
|
||||||
|
ResourceTDDescriptor resourceTDDescriptor, MimeTypeSupport mime) {
|
||||||
|
|
||||||
|
saveResourceSession = new SaveResourceSession();
|
||||||
|
saveResourceSession.setResourceTDDescriptor(resourceTDDescriptor);
|
||||||
|
saveResourceSession.setMime(mime);
|
||||||
|
saveResourceSession.setFileName(resourceTDDescriptor.getName());
|
||||||
|
saveResourceSession.setFileDescription(resourceTDDescriptor
|
||||||
|
.getDescription());
|
||||||
|
|
||||||
|
GWT.runAsync(new RunAsyncCallback() {
|
||||||
|
|
||||||
|
public void onSuccess() {
|
||||||
|
|
||||||
|
SaveResourceWizard saveResourceWizard = new SaveResourceWizard(
|
||||||
|
saveResourceSession, "Save Resource", eventBus);
|
||||||
|
|
||||||
|
saveResourceWizard.addListener(new WizardListener() {
|
||||||
|
|
||||||
|
public void failed(String title, String message,
|
||||||
|
String details, Throwable throwable) {
|
||||||
|
Log.debug(title + ", " + message + " " + details);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void completed(TRId id) {
|
||||||
|
Log.debug("Save Resource Completed");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void putInBackground() {
|
||||||
|
Log.debug("PutInBakground");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void aborted() {
|
||||||
|
Log.debug("Save Resource Aborted");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
saveResourceWizard.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onFailure(Throwable reason) {
|
||||||
|
Log.error("Async code loading failed", reason);
|
||||||
|
eventBus.fireEvent(new SessionExpiredEvent(
|
||||||
|
SessionExpiredType.EXPIREDONSERVER));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void requestRemove(ResourceTDDescriptor resourceTDDescriptor) {
|
||||||
|
|
||||||
|
removeResourceSession = new RemoveResourceSession(trId,
|
||||||
|
resourceTDDescriptor);
|
||||||
|
|
||||||
|
TDGWTServiceAsync.INSTANCE.removeResource(removeResourceSession,
|
||||||
|
new AsyncCallback<Void>() {
|
||||||
|
|
||||||
|
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 removing the resource: "
|
||||||
|
+ caught.getLocalizedMessage());
|
||||||
|
UtilsGXT3.alert("Error",
|
||||||
|
"Error removing the resource: "
|
||||||
|
+ caught.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSuccess(Void v) {
|
||||||
|
Log.debug("Resource removed");
|
||||||
|
loader.load();
|
||||||
|
details.setDescriptor(null);
|
||||||
|
forceLayout();
|
||||||
|
// UtilsGXT3.info("Resource", "Resource Removed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void requestOpen(ResourceTDDescriptor resourceTDDescriptor) {
|
||||||
|
switch (resourceTDDescriptor.getResourceType()) {
|
||||||
|
case CHART:
|
||||||
|
repquestOpenChart(resourceTDDescriptor);
|
||||||
|
break;
|
||||||
|
case CODELIST:
|
||||||
|
break;
|
||||||
|
case CSV:
|
||||||
|
break;
|
||||||
|
case GUESSER:
|
||||||
|
break;
|
||||||
|
case JSON:
|
||||||
|
break;
|
||||||
|
case MAP:
|
||||||
|
requestOpenMap(resourceTDDescriptor);
|
||||||
|
break;
|
||||||
|
case SDMX:
|
||||||
|
break;
|
||||||
|
case GENERIC_FILE:
|
||||||
|
requestOpenGenericFile(resourceTDDescriptor);
|
||||||
|
break;
|
||||||
|
case GENERIC_TABLE:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void repquestOpenChart(ResourceTDDescriptor resourceTDDescriptor) {
|
||||||
|
ChartViewerDialog chartDialog = new ChartViewerDialog(
|
||||||
|
resourceTDDescriptor, trId, eventBus);
|
||||||
|
chartDialog.show();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void requestOpenMap(
|
||||||
|
final ResourceTDDescriptor resourceTDDescriptor) {
|
||||||
|
ResourceTD resource = resourceTDDescriptor.getResourceTD();
|
||||||
|
if (resource instanceof StringResourceTD) {
|
||||||
|
StringResourceTD stringResourceTD = (StringResourceTD) resource;
|
||||||
|
UriResolverSession uriResolverSession = new UriResolverSession(
|
||||||
|
stringResourceTD.getValue(), ApplicationType.GIS);
|
||||||
|
|
||||||
|
TDGWTServiceAsync.INSTANCE.getUriFromResolver(uriResolverSession,
|
||||||
|
new AsyncCallback<String>() {
|
||||||
|
|
||||||
|
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 {
|
||||||
|
if (resource instanceof InternalURITD) {
|
||||||
|
InternalURITD internalURITD = (InternalURITD) resource;
|
||||||
|
UriResolverSession uriResolverSession = new UriResolverSession(
|
||||||
|
internalURITD.getId(), ApplicationType.GIS);
|
||||||
|
|
||||||
|
TDGWTServiceAsync.INSTANCE.getUriFromResolver(
|
||||||
|
uriResolverSession, new AsyncCallback<String>() {
|
||||||
|
|
||||||
|
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 {
|
||||||
|
if (resource instanceof TableResourceTD) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.error("Error with resource: no valid resource");
|
||||||
|
UtilsGXT3.alert("Error with resource",
|
||||||
|
"Error no valid InternalUri");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void requestOpenGenericFile(
|
||||||
|
final ResourceTDDescriptor resourceTDDescriptor) {
|
||||||
|
ResourceTD resource = resourceTDDescriptor.getResourceTD();
|
||||||
|
if (resource instanceof InternalURITD) {
|
||||||
|
InternalURITD genericFileResourceTD = (InternalURITD) resource;
|
||||||
|
UriResolverSession uriResolverSession = new UriResolverSession(
|
||||||
|
genericFileResourceTD.getId(), ApplicationType.SMP_ID,
|
||||||
|
resourceTDDescriptor.getName(),
|
||||||
|
genericFileResourceTD.getMimeType());
|
||||||
|
|
||||||
|
TDGWTServiceAsync.INSTANCE.getUriFromResolver(uriResolverSession,
|
||||||
|
new AsyncCallback<String>() {
|
||||||
|
|
||||||
|
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 {
|
||||||
|
if (resource instanceof InternalURITD) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (resource instanceof TableResourceTD) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.error("Error with resource: no valid resource");
|
||||||
|
UtilsGXT3.alert("Error with resource",
|
||||||
|
"Error no valid InternalUri");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
@CHARSET "UTF-8";
|
|
||||||
|
|
||||||
.details {
|
|
||||||
padding: 10px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.detailsInfo {
|
|
||||||
border-top: 1px solid #ccc;
|
|
||||||
font: 11px Arial, Helvetica, sans-serif;
|
|
||||||
margin-top: 5px;
|
|
||||||
padding-top: 5px;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.detailsTable {
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.detailsHead {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.detailsData {
|
|
||||||
padding-left: 5px;
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
<div class="{style.details}">
|
|
||||||
<img src="{thumbnailPath}" title="{resourceTDDescriptor.name}">
|
|
||||||
<div class="{style.detailsInfo}">
|
|
||||||
<table class="{style.detailsTable}">
|
|
||||||
<tr><td class="{style.detailsHead}">Name:</td></tr>
|
|
||||||
<tr><td class="{style.detailsData}">{resourceTDDescriptor.name}</td></tr>
|
|
||||||
<tr><td class="{style.detailsHead}">Description:</td></tr>
|
|
||||||
<tr><td class="{style.detailsData}">{resourceTDDescriptor.description}</td></tr>
|
|
||||||
<tr><td class="{style.detailsHead}">Creation Date:</td></tr>
|
|
||||||
<tr><td class="{style.detailsData}">{resourceTDDescriptor.creationDate}</td></tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
Loading…
Reference in New Issue