Initial import.

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/netcdf-basic-widgets@157537 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-10-24 16:28:12 +00:00
parent 84c012ada2
commit 477c65a150
7 changed files with 97 additions and 148 deletions

View File

@ -1,6 +1,5 @@
package org.gcube.portlets.widgets.netcdfbasicwidgets.client; package org.gcube.portlets.widgets.netcdfbasicwidgets.client;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.SelectVariableEvent; import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.SelectVariableEvent;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.SelectVariableEvent.SelectVariableEventHandler; import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.SelectVariableEvent.SelectVariableEventHandler;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.widgets.NetCDFPreviewDialog; import org.gcube.portlets.widgets.netcdfbasicwidgets.client.widgets.NetCDFPreviewDialog;
@ -17,6 +16,11 @@ import com.google.gwt.core.shared.GWT;
* *
*/ */
public class NetCDFBasicWidgets implements EntryPoint { public class NetCDFBasicWidgets implements EntryPoint {
// private static final String example1 =
// "http://data.d4science.org/Qnc4RXlNQmhlWS83NkFFb2dIU0hQMnhVTER1VEZjbGdHbWJQNStIS0N6Yz0";
private static final String example2 = "http://data.d4science.org/L0FuZGNERGNFL1Y4bDRQdDFHSmdFUkN5V3VvZlF4L2lHbWJQNStIS0N6Yz0";
// private static final String example3 =
// "http://data.d4science.org/WXZFNjRXeE9XWGQ4bDRQdDFHSmdFWVBPd0FEK0VzdlRHbWJQNStIS0N6Yz0";
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -31,7 +35,6 @@ public class NetCDFBasicWidgets implements EntryPoint {
} }
private void loadMainPanel() { private void loadMainPanel() {
GWT.log("NetcdfBasicWidgetsManager"); GWT.log("NetcdfBasicWidgetsManager");
@ -45,7 +48,7 @@ public class NetCDFBasicWidgets implements EntryPoint {
} }
}; };
NetCDFPreviewDialog dialog=new NetCDFPreviewDialog(); NetCDFPreviewDialog dialog = new NetCDFPreviewDialog(example2);
dialog.addSelectVariableEventHandler(handler); dialog.addSelectVariableEventHandler(handler);
} }

View File

@ -27,14 +27,15 @@ import com.google.gwt.view.client.ListDataProvider;
*/ */
public class NetCDFDataModel { public class NetCDFDataModel {
private String url;
private NetCDFData netCDFData; private NetCDFData netCDFData;
private ArrayList<NetCDFDataEventHandler> handlers = new ArrayList<>(); private ArrayList<NetCDFDataEventHandler> handlers = new ArrayList<>();
private ListDataProvider<VariableData> variableDataProvider = new ListDataProvider<>(); private ListDataProvider<VariableData> variableDataProvider = new ListDataProvider<>();
private ListDataProvider<AttributeData> globalAttributeDataProvider = new ListDataProvider<>(); private ListDataProvider<AttributeData> globalAttributeDataProvider = new ListDataProvider<>();
public NetCDFDataModel() { public NetCDFDataModel(String url) {
this.url=url;
retrieveData(); retrieveData();
} }
@ -74,7 +75,7 @@ public class NetCDFDataModel {
public void retrieveData() { public void retrieveData() {
NetCDFBasicWidgetServiceAsync.INSTANCE.getNetCDFFromPublicLink("", new AsyncCallback<NetCDFData>() { NetCDFBasicWidgetServiceAsync.INSTANCE.getNetCDFFromPublicLink(url, new AsyncCallback<NetCDFData>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {

View File

@ -23,8 +23,6 @@ public interface NetCDFBasicWidgetService extends RemoteService {
public NetCDFData getNetCDFFromPublicLink(String publicLink) throws ServiceException; public NetCDFData getNetCDFFromPublicLink(String publicLink) throws ServiceException;
public NetCDFData getNetCDFFromItem(String itemId) throws ServiceException;
public void closeNetCDF(NetCDFId netCDFId) throws ServiceException; public void closeNetCDF(NetCDFId netCDFId) throws ServiceException;
public NetCDFValues readDataVariable(NetCDFId netCDFId, VariableData variableData, boolean sample, int limit) throws ServiceException; public NetCDFValues readDataVariable(NetCDFId netCDFId, VariableData variableData, boolean sample, int limit) throws ServiceException;

View File

@ -24,8 +24,6 @@ public interface NetCDFBasicWidgetServiceAsync {
void getNetCDFFromPublicLink(String publicLink, AsyncCallback<NetCDFData> callback); void getNetCDFFromPublicLink(String publicLink, AsyncCallback<NetCDFData> callback);
void getNetCDFFromItem(String itemId, AsyncCallback<NetCDFData> callback);
void closeNetCDF(NetCDFId netCDFId, AsyncCallback<Void> callback); void closeNetCDF(NetCDFId netCDFId, AsyncCallback<Void> callback);
void readDataVariable(NetCDFId netCDFId, VariableData variableData, boolean sample, int limit, void readDataVariable(NetCDFId netCDFId, VariableData variableData, boolean sample, int limit,

View File

@ -39,6 +39,7 @@ import com.google.gwt.user.client.ui.Widget;
* *
*/ */
public class NetCDFPreviewDialog extends DialogBox implements SelectVariableEvent.HasSelectVariableEventHandler { public class NetCDFPreviewDialog extends DialogBox implements SelectVariableEvent.HasSelectVariableEventHandler {
private static final String TABPANEL_HEIGHT = "400px"; private static final String TABPANEL_HEIGHT = "400px";
private static final String TABPANEL_WIDTH = "700px"; private static final String TABPANEL_WIDTH = "700px";
@ -53,25 +54,15 @@ public class NetCDFPreviewDialog extends DialogBox implements SelectVariableEven
private DetailPanel detailPanel; private DetailPanel detailPanel;
private SamplePanel samplePanel; private SamplePanel samplePanel;
private InfoPanel infoPanel; private InfoPanel infoPanel;
private String url;
// private DataGrid<VariableData> dataGrid; // private DataGrid<VariableData> dataGrid;
public NetCDFPreviewDialog() {
try {
initWindow();
initHandler();
addToolIcon();
create();
} catch (Throwable e) {
GWT.log(e.getLocalizedMessage());
e.printStackTrace();
}
}
public NetCDFPreviewDialog(String fileId) { public NetCDFPreviewDialog(String url) {
try { try {
GWT.log("FileId: " + fileId); GWT.log("PublicLink: " + url);
this.url = url;
initWindow(); initWindow();
initHandler(); initHandler();
addToolIcon(); addToolIcon();
@ -107,7 +98,7 @@ public class NetCDFPreviewDialog extends DialogBox implements SelectVariableEven
private void create() { private void create() {
netCDFDataModel = new NetCDFDataModel(); netCDFDataModel = new NetCDFDataModel(url);
// Create a tab panel // Create a tab panel
TabLayoutPanel tabPanel = new TabLayoutPanel(2.5, Unit.EM); TabLayoutPanel tabPanel = new TabLayoutPanel(2.5, Unit.EM);
tabPanel.setAnimationDuration(1000); tabPanel.setAnimationDuration(1000);
@ -124,7 +115,6 @@ public class NetCDFPreviewDialog extends DialogBox implements SelectVariableEven
detailPanel = new DetailPanel(netCDFDataModel); detailPanel = new DetailPanel(netCDFDataModel);
tabPanel.add(detailPanel, messages.detailTab()); tabPanel.add(detailPanel, messages.detailTab());
// Sample TabPanel // Sample TabPanel
samplePanel = new SamplePanel(netCDFDataModel); samplePanel = new SamplePanel(netCDFDataModel);
tabPanel.add(samplePanel, messages.sampleTab()); tabPanel.add(samplePanel, messages.sampleTab());
@ -133,19 +123,15 @@ public class NetCDFPreviewDialog extends DialogBox implements SelectVariableEven
infoPanel = new InfoPanel(netCDFDataModel); infoPanel = new InfoPanel(netCDFDataModel);
tabPanel.add(infoPanel, messages.infoTab()); tabPanel.add(infoPanel, messages.infoTab());
// Return the content // Return the content
tabPanel.selectTab(0); tabPanel.selectTab(0);
tabPanel.ensureDebugId("netcdfTabPanel"); tabPanel.ensureDebugId("netcdfTabPanel");
tabPanel.addSelectionHandler(new SelectionHandler<Integer>() tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
{ public void onSelection(SelectionEvent<Integer> event) {
public void onSelection(SelectionEvent<Integer> event)
{
int tabId = event.getSelectedItem(); int tabId = event.getSelectedItem();
Widget tabWidget = tabPanel.getWidget(tabId); Widget tabWidget = tabPanel.getWidget(tabId);
if (tabWidget != null) if (tabWidget != null) {
{
if (tabWidget instanceof VariablesPanel) { if (tabWidget instanceof VariablesPanel) {
VariablesPanel variablesPanel = (VariablesPanel) tabWidget; VariablesPanel variablesPanel = (VariablesPanel) tabWidget;
variablesPanel.refresh(); variablesPanel.refresh();
@ -166,8 +152,6 @@ public class NetCDFPreviewDialog extends DialogBox implements SelectVariableEven
} }
}); });
// Create a table to layout the content // Create a table to layout the content
// VerticalPanel dialogContents = new VerticalPanel(); // VerticalPanel dialogContents = new VerticalPanel();
// dialogContents.setSpacing(4); // dialogContents.setSpacing(4);
@ -205,9 +189,10 @@ public class NetCDFPreviewDialog extends DialogBox implements SelectVariableEven
// buttonPack.add(btnSave); // buttonPack.add(btnSave);
buttonPack.add(btnClose); buttonPack.add(btnClose);
/*HorizontalPanel hp=new HorizontalPanel(); /*
hp.add(buttonPack); * HorizontalPanel hp=new HorizontalPanel(); hp.add(buttonPack);
hp.setCellHorizontalAlignment(buttonPack, HasHorizontalAlignment.ALIGN_CENTER); * hp.setCellHorizontalAlignment(buttonPack,
* HasHorizontalAlignment.ALIGN_CENTER);
*/ */
DockPanel dockPanel = new DockPanel(); DockPanel dockPanel = new DockPanel();
@ -217,13 +202,10 @@ public class NetCDFPreviewDialog extends DialogBox implements SelectVariableEven
dockPanel.add(buttonPack, DockPanel.SOUTH); dockPanel.add(buttonPack, DockPanel.SOUTH);
dockPanel.setCellHorizontalAlignment(buttonPack, DockPanel.ALIGN_CENTER); dockPanel.setCellHorizontalAlignment(buttonPack, DockPanel.ALIGN_CENTER);
dockPanel.setWidth("100%"); dockPanel.setWidth("100%");
setWidget(dockPanel); setWidget(dockPanel);
center(); center();
} }
@Override @Override

View File

@ -85,24 +85,6 @@ public class NetCDFBasicWidgetServiceImpl extends RemoteServiceServlet implement
} }
} }
@Override
public NetCDFData getNetCDFFromItem(String itemId) throws ServiceException {
try {
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
NetCDFResource netCDFResource = new NetCDFResource();
NetCDFData netCDFData = netCDFResource.exploreNetCDF();
SessionUtil.setNetCDFData(netCDFData, this.getThreadLocalRequest(), serviceCredentials);
return netCDFData;
} catch (ServiceException e) {
logger.error("Error in getCDFResourceFromItem(): " + e.getLocalizedMessage(), e);
throw e;
} catch (Exception e) {
logger.error("Error in getCDFResourceFromItem(): " + e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e);
}
}
@Override @Override
public NetCDFValues readDataVariable(NetCDFId netCDFId, VariableData variableData, boolean sample, int limit) public NetCDFValues readDataVariable(NetCDFId netCDFId, VariableData variableData, boolean sample, int limit)

View File

@ -5,7 +5,6 @@ import java.io.BufferedOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.nio.file.Files; import java.nio.file.Files;
@ -52,9 +51,6 @@ import ucar.nc2.Variable;
* *
*/ */
public class NetCDFResource { public class NetCDFResource {
//private static final String example1 = "http://data.d4science.org/Qnc4RXlNQmhlWS83NkFFb2dIU0hQMnhVTER1VEZjbGdHbWJQNStIS0N6Yz0";
private static final String example2 = "http://data.d4science.org/L0FuZGNERGNFL1Y4bDRQdDFHSmdFUkN5V3VvZlF4L2lHbWJQNStIS0N6Yz0";
//private static final String example3 = "http://data.d4science.org/WXZFNjRXeE9XWGQ4bDRQdDFHSmdFWVBPd0FEK0VzdlRHbWJQNStIS0N6Yz0";
private static Logger logger = LoggerFactory.getLogger(NetCDFId.class); private static Logger logger = LoggerFactory.getLogger(NetCDFId.class);
@ -67,17 +63,6 @@ public class NetCDFResource {
* { System.loadLibrary("gdaljni"); } * { System.loadLibrary("gdaljni"); }
*/ */
public NetCDFResource() throws ServiceException {
try {
this.publicLink = new URL(example2);
} catch (MalformedURLException e) {
logger.error(e.getLocalizedMessage(), e);
throw new ServiceException(e.getLocalizedMessage(), e);
}
retrievePublicLink();
this.netCDFId = new NetCDFId(ncFile.toAbsolutePath().toString());
}
public NetCDFResource(URL publicLink) throws ServiceException { public NetCDFResource(URL publicLink) throws ServiceException {
this.publicLink = publicLink; this.publicLink = publicLink;