Initial import.

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/netcdf-basic-widgets@157580 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-10-25 17:49:38 +00:00
parent bc7291c931
commit 3f008a55a7
6 changed files with 66 additions and 75 deletions

View File

@ -70,6 +70,9 @@
height: 318px; height: 318px;
width: 616px !important; width: 616px !important;
resize: none; resize: none;
} }
.cell-word-wrap {
/* width:100%; */
word-wrap: break-word;
}

View File

@ -39,8 +39,10 @@ public interface NetCDFBasicCSS extends CssResource {
@ClassName("combo-geometry-type") @ClassName("combo-geometry-type")
public String getComboGeometryType(); public String getComboGeometryType();
@ClassName("sample-data-text-area") @ClassName("sample-data-text-area")
public String getSampleDataTextArea(); public String getSampleDataTextArea();
@ClassName("cell-word-wrap")
public String getCellWordWrap();
} }

View File

@ -8,6 +8,7 @@ import java.util.Set;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.NetCDFDataEvent; import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.NetCDFDataEvent;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.NetCDFDataEvent.NetCDFDataEventHandler; import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.NetCDFDataEvent.NetCDFDataEventHandler;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.model.NetCDFDataModel; import org.gcube.portlets.widgets.netcdfbasicwidgets.client.model.NetCDFDataModel;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.resource.NetCDFBasicResources;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.AttributeData; import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.AttributeData;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.RangeData; import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.RangeData;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.VariableData; import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.VariableData;
@ -35,7 +36,7 @@ import com.google.gwt.view.client.SelectionModel;
/** /**
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi
* *
* *
*/ */
@ -47,23 +48,20 @@ public class DetailPanel extends SimplePanel implements NetCDFDataEventHandler {
private static final String RANGE_DATA_GRID_HEIGHT = "105px"; private static final String RANGE_DATA_GRID_HEIGHT = "105px";
private static final String RANGE_DATA_GRID_WIDTH = "608px"; private static final String RANGE_DATA_GRID_WIDTH = "608px";
private static final NetCDFPreviewMessages messages = GWT.create(NetCDFPreviewMessages.class); private static final NetCDFPreviewMessages messages = GWT.create(NetCDFPreviewMessages.class);
private ListBox variablesBox; private ListBox variablesBox;
private ArrayList<VariableData> variables; private ArrayList<VariableData> variables;
private NetCDFDataModel netCDFDataModel; private NetCDFDataModel netCDFDataModel;
private ListDataProvider<AttributeData> attributesOfVariableProvider; private ListDataProvider<AttributeData> attributesOfVariableProvider;
private DataGrid<AttributeData> attributesOfVariableGrid; private DataGrid<AttributeData> attributesOfVariableGrid;
private SimplePager attributesOfVariablePager; private SimplePager attributesOfVariablePager;
private ListDataProvider<RangeData> rangesOfVariableProvider; private ListDataProvider<RangeData> rangesOfVariableProvider;
private DataGrid<RangeData> rangesOfVariableGrid; private DataGrid<RangeData> rangesOfVariableGrid;
private SimplePager rangesOfVariablePager; private SimplePager rangesOfVariablePager;
public DetailPanel(NetCDFDataModel netCDFDataModel) { public DetailPanel(NetCDFDataModel netCDFDataModel) {
this.netCDFDataModel = netCDFDataModel; this.netCDFDataModel = netCDFDataModel;
@ -84,8 +82,7 @@ public class DetailPanel extends SimplePanel implements NetCDFDataEventHandler {
// Form // Form
FlexTable detailFlexTable = new FlexTable(); FlexTable detailFlexTable = new FlexTable();
detailFlexTable.setCellSpacing(2); detailFlexTable.setCellSpacing(2);
//detailFlexTable.setBorderWidth(1); // detailFlexTable.setBorderWidth(1);
// Add a drop box with the list types // Add a drop box with the list types
variablesBox = new ListBox(); variablesBox = new ListBox();
@ -105,41 +102,38 @@ public class DetailPanel extends SimplePanel implements NetCDFDataEventHandler {
detailFlexTable.setHTML(0, 0, "Variable:"); detailFlexTable.setHTML(0, 0, "Variable:");
detailFlexTable.setWidget(0, 1, variablesBox); detailFlexTable.setWidget(0, 1, variablesBox);
//Attributes // Attributes
detailFlexTable.getFlexCellFormatter().setVerticalAlignment(1, 0,HasVerticalAlignment.ALIGN_TOP); detailFlexTable.getFlexCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_TOP);
detailFlexTable.setHTML(1, 0, "Attributes:"); detailFlexTable.setHTML(1, 0, "Attributes:");
attributesOfVariablePager.getElement().getStyle().setProperty("margin", "auto"); attributesOfVariablePager.getElement().getStyle().setProperty("margin", "auto");
VerticalPanel vpAttributes=new VerticalPanel(); VerticalPanel vpAttributes = new VerticalPanel();
vpAttributes.getElement().getStyle().setBackgroundColor("#f8f8fb"); vpAttributes.getElement().getStyle().setBackgroundColor("#f8f8fb");
vpAttributes.add(attributesOfVariableGrid); vpAttributes.add(attributesOfVariableGrid);
vpAttributes.add(attributesOfVariablePager); vpAttributes.add(attributesOfVariablePager);
detailFlexTable.setWidget(1, 1, vpAttributes);
//Ranges
detailFlexTable.getFlexCellFormatter().setVerticalAlignment(2, 0,HasVerticalAlignment.ALIGN_TOP);
detailFlexTable.setHTML(2, 0, "Ranges:");
//detailFlexTable.getFlexCellFormatter().setColSpan(1, 0, 2);
rangesOfVariablePager.getElement().getStyle().setProperty("margin", "auto");
//detailFlexTable.setWidget(2, 1, attributesOfVariablePager);
detailFlexTable.setWidget(1, 1, vpAttributes);
VerticalPanel vpRanges=new VerticalPanel();
// Ranges
detailFlexTable.getFlexCellFormatter().setVerticalAlignment(2, 0, HasVerticalAlignment.ALIGN_TOP);
detailFlexTable.setHTML(2, 0, "Ranges:");
// detailFlexTable.getFlexCellFormatter().setColSpan(1, 0, 2);
rangesOfVariablePager.getElement().getStyle().setProperty("margin", "auto");
// detailFlexTable.setWidget(2, 1, attributesOfVariablePager);
VerticalPanel vpRanges = new VerticalPanel();
vpRanges.getElement().getStyle().setBackgroundColor("#f8f8fb"); vpRanges.getElement().getStyle().setBackgroundColor("#f8f8fb");
vpRanges.add(rangesOfVariableGrid); vpRanges.add(rangesOfVariableGrid);
vpRanges.add(rangesOfVariablePager); vpRanges.add(rangesOfVariablePager);
detailFlexTable.setWidget(2, 1, vpRanges); detailFlexTable.setWidget(2, 1, vpRanges);
setWidget(detailFlexTable); setWidget(detailFlexTable);
} }
public void refresh() { public void refresh() {
refreshAttributes(); refreshAttributes();
refreshRanges(); refreshRanges();
@ -157,23 +151,21 @@ public class DetailPanel extends SimplePanel implements NetCDFDataEventHandler {
} }
if (variableRequested != null) { if (variableRequested != null) {
GWT.log("Variable retrieved: "+variableRequested); GWT.log("Variable retrieved: " + variableRequested);
List<AttributeData> attributesOfVariable = attributesOfVariableProvider.getList(); List<AttributeData> attributesOfVariable = attributesOfVariableProvider.getList();
attributesOfVariable.clear(); attributesOfVariable.clear();
attributesOfVariable.addAll(variableRequested.getAttributes()); attributesOfVariable.addAll(variableRequested.getAttributes());
attributesOfVariableProvider.refresh(); attributesOfVariableProvider.refresh();
refreshAttributes(); refreshAttributes();
List<RangeData> rangesOfVariable = rangesOfVariableProvider.getList(); List<RangeData> rangesOfVariable = rangesOfVariableProvider.getList();
rangesOfVariable.clear(); rangesOfVariable.clear();
rangesOfVariable.addAll(variableRequested.getRanges()); rangesOfVariable.addAll(variableRequested.getRanges());
rangesOfVariableProvider.refresh(); rangesOfVariableProvider.refresh();
refreshRanges(); refreshRanges();
} else { } else {
GWT.log("Variable not retrieved: "+selectedValue); GWT.log("Variable not retrieved: " + selectedValue);
} }
} }
} }
@ -187,15 +179,14 @@ public class DetailPanel extends SimplePanel implements NetCDFDataEventHandler {
variablesBox.addItem(varData.getFullName(), String.valueOf(varData.getId())); variablesBox.addItem(varData.getFullName(), String.valueOf(varData.getId()));
} }
variablesBox.setEnabled(true); variablesBox.setEnabled(true);
// //
attributesOfVariableProvider.addDataDisplay(attributesOfVariableGrid); attributesOfVariableProvider.addDataDisplay(attributesOfVariableGrid);
attributesOfVariableProvider.refresh(); attributesOfVariableProvider.refresh();
rangesOfVariableProvider.addDataDisplay(rangesOfVariableGrid); rangesOfVariableProvider.addDataDisplay(rangesOfVariableGrid);
rangesOfVariableProvider.refresh(); rangesOfVariableProvider.refresh();
} }
private void createAttributesOfVariableGrid() { private void createAttributesOfVariableGrid() {
@ -209,6 +200,7 @@ public class DetailPanel extends SimplePanel implements NetCDFDataEventHandler {
attributesOfVariableGrid = new DataGrid<AttributeData>(8, AttributeData.KEY_PROVIDER); attributesOfVariableGrid = new DataGrid<AttributeData>(8, AttributeData.KEY_PROVIDER);
attributesOfVariableGrid.setWidth(ATTRIBUTE_DATA_GRID_WIDTH); attributesOfVariableGrid.setWidth(ATTRIBUTE_DATA_GRID_WIDTH);
attributesOfVariableGrid.setHeight(ATTRIBUTE_DATA_GRID_HEIGHT); attributesOfVariableGrid.setHeight(ATTRIBUTE_DATA_GRID_HEIGHT);
attributesOfVariableGrid.addStyleName(NetCDFBasicResources.INSTANCE.netCDFBasicCSS().getCellWordWrap());
/* /*
* Do not refresh the headers every time the data is updated. The footer * Do not refresh the headers every time the data is updated. The footer
@ -241,8 +233,7 @@ public class DetailPanel extends SimplePanel implements NetCDFDataEventHandler {
// Initialize the columns. // Initialize the columns.
initAttributesTableColumns(selectionModel, sortHandler); initAttributesTableColumns(selectionModel, sortHandler);
} }
public void refreshAttributes() { public void refreshAttributes() {
@ -324,7 +315,7 @@ public class DetailPanel extends SimplePanel implements NetCDFDataEventHandler {
// dataGrid.setColumnWidth(valuesColumn, 40, Unit.PX); // dataGrid.setColumnWidth(valuesColumn, 40, Unit.PX);
} }
public Set<AttributeData> selecetedAttributes() { public Set<AttributeData> selecetedAttributes() {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Set<AttributeData> selected = ((MultiSelectionModel<AttributeData>) attributesOfVariableGrid Set<AttributeData> selected = ((MultiSelectionModel<AttributeData>) attributesOfVariableGrid
@ -333,7 +324,6 @@ public class DetailPanel extends SimplePanel implements NetCDFDataEventHandler {
} }
private void createRangesOfVariableGrid() { private void createRangesOfVariableGrid() {
/* /*
@ -345,6 +335,7 @@ public class DetailPanel extends SimplePanel implements NetCDFDataEventHandler {
rangesOfVariableGrid = new DataGrid<RangeData>(8, RangeData.KEY_PROVIDER); rangesOfVariableGrid = new DataGrid<RangeData>(8, RangeData.KEY_PROVIDER);
rangesOfVariableGrid.setWidth(RANGE_DATA_GRID_WIDTH); rangesOfVariableGrid.setWidth(RANGE_DATA_GRID_WIDTH);
rangesOfVariableGrid.setHeight(RANGE_DATA_GRID_HEIGHT); rangesOfVariableGrid.setHeight(RANGE_DATA_GRID_HEIGHT);
rangesOfVariableGrid.addStyleName(NetCDFBasicResources.INSTANCE.netCDFBasicCSS().getCellWordWrap());
/* /*
* Do not refresh the headers every time the data is updated. The footer * Do not refresh the headers every time the data is updated. The footer
@ -377,19 +368,16 @@ public class DetailPanel extends SimplePanel implements NetCDFDataEventHandler {
// Initialize the columns. // Initialize the columns.
initRangesTableColumns(selectionModel, sortHandler); initRangesTableColumns(selectionModel, sortHandler);
} }
public void refreshRanges() { public void refreshRanges() {
rangesOfVariableGrid.redraw(); rangesOfVariableGrid.redraw();
} }
private void initRangesTableColumns(SelectionModel<RangeData> selectionModel, private void initRangesTableColumns(SelectionModel<RangeData> selectionModel, ListHandler<RangeData> sortHandler) {
ListHandler<RangeData> sortHandler) {
// Name
//Name
Column<RangeData, String> nameColum = new Column<RangeData, String>(new TextCell()) { Column<RangeData, String> nameColum = new Column<RangeData, String>(new TextCell()) {
@Override @Override
public String getValue(RangeData object) { public String getValue(RangeData object) {
@ -425,7 +413,6 @@ public class DetailPanel extends SimplePanel implements NetCDFDataEventHandler {
rangesOfVariableGrid.addColumn(nColumn, messages.columnN()); rangesOfVariableGrid.addColumn(nColumn, messages.columnN());
rangesOfVariableGrid.setColumnWidth(nColumn, 80, Unit.PX); rangesOfVariableGrid.setColumnWidth(nColumn, 80, Unit.PX);
// First // First
Column<RangeData, String> firstColumn = new Column<RangeData, String>(new TextCell()) { Column<RangeData, String> firstColumn = new Column<RangeData, String>(new TextCell()) {
@Override @Override
@ -443,7 +430,6 @@ public class DetailPanel extends SimplePanel implements NetCDFDataEventHandler {
rangesOfVariableGrid.addColumn(firstColumn, messages.columnFirst()); rangesOfVariableGrid.addColumn(firstColumn, messages.columnFirst());
rangesOfVariableGrid.setColumnWidth(firstColumn, 80, Unit.PX); rangesOfVariableGrid.setColumnWidth(firstColumn, 80, Unit.PX);
// Stride // Stride
Column<RangeData, String> strideColumn = new Column<RangeData, String>(new TextCell()) { Column<RangeData, String> strideColumn = new Column<RangeData, String>(new TextCell()) {
@Override @Override
@ -456,25 +442,21 @@ public class DetailPanel extends SimplePanel implements NetCDFDataEventHandler {
@Override @Override
public int compare(RangeData o1, RangeData o2) { public int compare(RangeData o1, RangeData o2) {
return (o1.getStride() < o2.getStride()) ? -1 : ((o1.getStride() == o2.getStride()) ? 0 : 1); return (o1.getStride() < o2.getStride()) ? -1 : ((o1.getStride() == o2.getStride()) ? 0 : 1);
} }
}); });
rangesOfVariableGrid.addColumn(strideColumn, messages.columnStride()); rangesOfVariableGrid.addColumn(strideColumn, messages.columnStride());
// dataGrid.setColumnWidth(valuesColumn, 40, Unit.PX); // dataGrid.setColumnWidth(valuesColumn, 40, Unit.PX);
} }
public Set<RangeData> selecetedRanges() { public Set<RangeData> selecetedRanges() {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Set<RangeData> selected = ((MultiSelectionModel<RangeData>) rangesOfVariableGrid Set<RangeData> selected = ((MultiSelectionModel<RangeData>) rangesOfVariableGrid.getSelectionModel())
.getSelectionModel()).getSelectedSet(); .getSelectedSet();
return selected; return selected;
} }
} }

View File

@ -6,6 +6,7 @@ import java.util.Set;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.NetCDFDataEvent; import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.NetCDFDataEvent;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.NetCDFDataEvent.NetCDFDataEventHandler; import org.gcube.portlets.widgets.netcdfbasicwidgets.client.event.NetCDFDataEvent.NetCDFDataEventHandler;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.model.NetCDFDataModel; import org.gcube.portlets.widgets.netcdfbasicwidgets.client.model.NetCDFDataModel;
import org.gcube.portlets.widgets.netcdfbasicwidgets.client.resource.NetCDFBasicResources;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.AttributeData; import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.AttributeData;
import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFDetailData; import org.gcube.portlets.widgets.netcdfbasicwidgets.shared.netcdf.NetCDFDetailData;
@ -29,7 +30,7 @@ import com.google.gwt.view.client.SelectionModel;
/** /**
* *
* @author Giancarlo Panichi * @author Giancarlo Panichi
* *
* *
*/ */
@ -140,6 +141,7 @@ public class InfoPanel extends SimplePanel implements NetCDFDataEventHandler {
globalAttributesDataGrid = new DataGrid<AttributeData>(7, AttributeData.KEY_PROVIDER); globalAttributesDataGrid = new DataGrid<AttributeData>(7, AttributeData.KEY_PROVIDER);
globalAttributesDataGrid.setWidth(DATA_GRID_WIDTH); globalAttributesDataGrid.setWidth(DATA_GRID_WIDTH);
globalAttributesDataGrid.setHeight(DATA_GRID_HEIGHT); globalAttributesDataGrid.setHeight(DATA_GRID_HEIGHT);
globalAttributesDataGrid.addStyleName(NetCDFBasicResources.INSTANCE.netCDFBasicCSS().getCellWordWrap());
/* /*
* Do not refresh the headers every time the data is updated. The footer * Do not refresh the headers every time the data is updated. The footer

View File

@ -72,12 +72,12 @@ public class VariablesPanel extends SimplePanel implements NetCDFDataEventHandle
setWidget(netCDFPreviewFlexTable); setWidget(netCDFPreviewFlexTable);
} }
@Override @Override
public void onNetCDFDataReady(NetCDFDataEvent event) { public void onNetCDFDataReady(NetCDFDataEvent event) {
// Add the CellList to the adapter in the database. // Add the CellList to the adapter in the database.
netCDFDataModel.addVariableDataDisplay(variablesDataGrid); netCDFDataModel.addVariableDataDisplay(variablesDataGrid);
netCDFDataModel.refreshVariableDisplays(); netCDFDataModel.refreshVariableDisplays();
} }
@ -88,10 +88,11 @@ public class VariablesPanel extends SimplePanel implements NetCDFDataEventHandle
* key is used to identify contacts when fields (such as the name and * key is used to identify contacts when fields (such as the name and
* address) change. * address) change.
*/ */
variablesDataGrid = new DataGrid<VariableData>(10, VariableData.KEY_PROVIDER); variablesDataGrid = new DataGrid<VariableData>(10, VariableData.KEY_PROVIDER);
variablesDataGrid.setWidth(DATA_GRID_WIDTH); variablesDataGrid.setWidth(DATA_GRID_WIDTH);
variablesDataGrid.setHeight(DATA_GRID_HEIGHT); variablesDataGrid.setHeight(DATA_GRID_HEIGHT);
variablesDataGrid.addStyleName(NetCDFBasicResources.INSTANCE.netCDFBasicCSS().getCellWordWrap());
/* /*
* Do not refresh the headers every time the data is updated. The footer * Do not refresh the headers every time the data is updated. The footer
@ -117,20 +118,18 @@ public class VariablesPanel extends SimplePanel implements NetCDFDataEventHandle
// Add a selection model so we can select cells. // Add a selection model so we can select cells.
final MultiSelectionModel<VariableData> selectionModel = new MultiSelectionModel<VariableData>( final MultiSelectionModel<VariableData> selectionModel = new MultiSelectionModel<VariableData>(
VariableData.KEY_PROVIDER); VariableData.KEY_PROVIDER);
variablesDataGrid.setSelectionModel(selectionModel, DefaultSelectionEventManager.<VariableData>createCheckboxManager()); variablesDataGrid.setSelectionModel(selectionModel,
DefaultSelectionEventManager.<VariableData>createCheckboxManager());
// Initialize the columns. // Initialize the columns.
initTableColumns(selectionModel, sortHandler); initTableColumns(selectionModel, sortHandler);
} }
public void refresh(){ public void refresh() {
variablesDataGrid.redraw(); variablesDataGrid.redraw();
} }
private void initTableColumns(SelectionModel<VariableData> selectionModel, ListHandler<VariableData> sortHandler) { private void initTableColumns(SelectionModel<VariableData> selectionModel, ListHandler<VariableData> sortHandler) {
// Checkbox column. This table will uses a checkbox column for // Checkbox column. This table will uses a checkbox column for
// selection. // selection.

View File

@ -70,6 +70,9 @@
height: 318px; height: 318px;
width: 616px !important; width: 616px !important;
resize: none; resize: none;
} }
.cell-word-wrap {
/* width:100%; */
word-wrap: break-word;
}