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;
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.widgets.NetCDFPreviewDialog;
@ -17,6 +16,11 @@ import com.google.gwt.core.shared.GWT;
*
*/
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}
@ -31,7 +35,6 @@ public class NetCDFBasicWidgets implements EntryPoint {
}
private void loadMainPanel() {
GWT.log("NetcdfBasicWidgetsManager");
@ -45,7 +48,7 @@ public class NetCDFBasicWidgets implements EntryPoint {
}
};
NetCDFPreviewDialog dialog=new NetCDFPreviewDialog();
NetCDFPreviewDialog dialog = new NetCDFPreviewDialog(example2);
dialog.addSelectVariableEventHandler(handler);
}

View File

@ -27,14 +27,15 @@ import com.google.gwt.view.client.ListDataProvider;
*/
public class NetCDFDataModel {
private String url;
private NetCDFData netCDFData;
private ArrayList<NetCDFDataEventHandler> handlers = new ArrayList<>();
private ListDataProvider<VariableData> variableDataProvider = new ListDataProvider<>();
private ListDataProvider<AttributeData> globalAttributeDataProvider = new ListDataProvider<>();
public NetCDFDataModel() {
public NetCDFDataModel(String url) {
this.url=url;
retrieveData();
}
@ -74,7 +75,7 @@ public class NetCDFDataModel {
public void retrieveData() {
NetCDFBasicWidgetServiceAsync.INSTANCE.getNetCDFFromPublicLink("", new AsyncCallback<NetCDFData>() {
NetCDFBasicWidgetServiceAsync.INSTANCE.getNetCDFFromPublicLink(url, new AsyncCallback<NetCDFData>() {
@Override
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 getNetCDFFromItem(String itemId) throws ServiceException;
public void closeNetCDF(NetCDFId netCDFId) 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 getNetCDFFromItem(String itemId, AsyncCallback<NetCDFData> callback);
void closeNetCDF(NetCDFId netCDFId, AsyncCallback<Void> callback);
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 {
private static final String TABPANEL_HEIGHT = "400px";
private static final String TABPANEL_WIDTH = "700px";
@ -53,25 +54,15 @@ public class NetCDFPreviewDialog extends DialogBox implements SelectVariableEven
private DetailPanel detailPanel;
private SamplePanel samplePanel;
private InfoPanel infoPanel;
private String url;
// 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 {
GWT.log("FileId: " + fileId);
GWT.log("PublicLink: " + url);
this.url = url;
initWindow();
initHandler();
addToolIcon();
@ -107,7 +98,7 @@ public class NetCDFPreviewDialog extends DialogBox implements SelectVariableEven
private void create() {
netCDFDataModel = new NetCDFDataModel();
netCDFDataModel = new NetCDFDataModel(url);
// Create a tab panel
TabLayoutPanel tabPanel = new TabLayoutPanel(2.5, Unit.EM);
tabPanel.setAnimationDuration(1000);
@ -124,7 +115,6 @@ public class NetCDFPreviewDialog extends DialogBox implements SelectVariableEven
detailPanel = new DetailPanel(netCDFDataModel);
tabPanel.add(detailPanel, messages.detailTab());
// Sample TabPanel
samplePanel = new SamplePanel(netCDFDataModel);
tabPanel.add(samplePanel, messages.sampleTab());
@ -133,19 +123,15 @@ public class NetCDFPreviewDialog extends DialogBox implements SelectVariableEven
infoPanel = new InfoPanel(netCDFDataModel);
tabPanel.add(infoPanel, messages.infoTab());
// Return the content
tabPanel.selectTab(0);
tabPanel.ensureDebugId("netcdfTabPanel");
tabPanel.addSelectionHandler(new SelectionHandler<Integer>()
{
public void onSelection(SelectionEvent<Integer> event)
{
tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
public void onSelection(SelectionEvent<Integer> event) {
int tabId = event.getSelectedItem();
Widget tabWidget = tabPanel.getWidget(tabId);
if (tabWidget != null)
{
if (tabWidget != null) {
if (tabWidget instanceof VariablesPanel) {
VariablesPanel variablesPanel = (VariablesPanel) tabWidget;
variablesPanel.refresh();
@ -166,8 +152,6 @@ public class NetCDFPreviewDialog extends DialogBox implements SelectVariableEven
}
});
// Create a table to layout the content
// VerticalPanel dialogContents = new VerticalPanel();
// dialogContents.setSpacing(4);
@ -205,9 +189,10 @@ public class NetCDFPreviewDialog extends DialogBox implements SelectVariableEven
// buttonPack.add(btnSave);
buttonPack.add(btnClose);
/*HorizontalPanel hp=new HorizontalPanel();
hp.add(buttonPack);
hp.setCellHorizontalAlignment(buttonPack, HasHorizontalAlignment.ALIGN_CENTER);
/*
* HorizontalPanel hp=new HorizontalPanel(); hp.add(buttonPack);
* hp.setCellHorizontalAlignment(buttonPack,
* HasHorizontalAlignment.ALIGN_CENTER);
*/
DockPanel dockPanel = new DockPanel();
@ -217,13 +202,10 @@ public class NetCDFPreviewDialog extends DialogBox implements SelectVariableEven
dockPanel.add(buttonPack, DockPanel.SOUTH);
dockPanel.setCellHorizontalAlignment(buttonPack, DockPanel.ALIGN_CENTER);
dockPanel.setWidth("100%");
setWidget(dockPanel);
center();
}
@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
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.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
@ -52,9 +51,6 @@ import ucar.nc2.Variable;
*
*/
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);
@ -67,17 +63,6 @@ public class NetCDFResource {
* { 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 {
this.publicLink = publicLink;