added README and test classes
This commit is contained in:
parent
ed38085eb5
commit
502d9ef1f2
|
@ -6,6 +6,7 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" path="src/main/test"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||||
<wb-module deploy-name="gis-viewer">
|
<wb-module deploy-name="gis-viewer">
|
||||||
<wb-resource deploy-path="/" source-path="/src/main/java"/>
|
<wb-resource deploy-path="/" source-path="/src/main/java"/>
|
||||||
|
<wb-resource deploy-path="/" source-path="/src/main/test"/>
|
||||||
</wb-module>
|
</wb-module>
|
||||||
</project-modules>
|
</project-modules>
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
# Gis Viewer Widget
|
||||||
|
|
||||||
|
The Gis Viewer Widget is an application to access GIS Data via interactive Map. It is OGC standards compliant (by using the WMS and WFS standards)
|
||||||
|
|
||||||
|
## Built With
|
||||||
|
|
||||||
|
* [OpenJDK](https://openjdk.java.net/) - The JDK used
|
||||||
|
* [Maven](https://maven.apache.org/) - Dependency Management
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
You can find the documentation at [Wiki Gis Viewer](https://wiki.gcube-system.org/gcube/GIS_Viewer)
|
||||||
|
|
||||||
|
## Change log
|
||||||
|
|
||||||
|
See the [Releases](https://code-repo.d4science.org/gCubeSystem/gis-viewer/releases)
|
||||||
|
|
||||||
|
## Authors
|
||||||
|
|
||||||
|
* **Francesco Mangiacrapa** ([ORCID](https://orcid.org/0000-0002-6528-664X)) Computer Scientist at [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This project is licensed under the EUPL V.1.1 License - see the [LICENSE.md](LICENSE.md) file for details.
|
||||||
|
|
||||||
|
|
||||||
|
## About the gCube Framework
|
||||||
|
This software is part of the [gCubeFramework](https://www.gcube-system.org/ "gCubeFramework"): an
|
||||||
|
open-source software toolkit used for building and operating Hybrid Data
|
||||||
|
Infrastructures enabling the dynamic deployment of Virtual Research Environments
|
||||||
|
by favouring the realisation of reuse oriented policies.
|
||||||
|
|
||||||
|
The projects leading to this software have received funding from a series of European Union programmes including:
|
||||||
|
|
||||||
|
- the Sixth Framework Programme for Research and Technological Development
|
||||||
|
- DILIGENT (grant no. 004260).
|
||||||
|
- the Seventh Framework Programme for research, technological development and demonstration
|
||||||
|
- D4Science (grant no. 212488);
|
||||||
|
- D4Science-II (grant no.239019);
|
||||||
|
- ENVRI (grant no. 283465);
|
||||||
|
- EUBrazilOpenBio (grant no. 288754);
|
||||||
|
- iMarine(grant no. 283644).
|
||||||
|
- the H2020 research and innovation programme
|
||||||
|
- BlueBRIDGE (grant no. 675680);
|
||||||
|
- EGIEngage (grant no. 654142);
|
||||||
|
- ENVRIplus (grant no. 654182);
|
||||||
|
- PARTHENOS (grant no. 654119);
|
||||||
|
- SoBigData (grant no. 654024);
|
||||||
|
- DESIRA (grant no. 818194);
|
||||||
|
- ARIADNEplus (grant no. 823914);
|
||||||
|
- RISIS2 (grant no. 824091);
|
||||||
|
- PerformFish (grant no. 727610);
|
||||||
|
- AGINFRAplus (grant no. 731001).
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,253 @@
|
||||||
|
package org.gcube.portlets.user.gisviewer.test.client;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
||||||
|
import com.extjs.gxt.ui.client.data.BaseModel;
|
||||||
|
import com.extjs.gxt.ui.client.store.ListStore;
|
||||||
|
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.Grid;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
|
||||||
|
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
||||||
|
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||||
|
import com.google.gwt.i18n.client.NumberFormat;
|
||||||
|
import com.google.gwt.user.client.Element;
|
||||||
|
|
||||||
|
public class GridExample extends ContentPanel {
|
||||||
|
|
||||||
|
public GridExample() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onRender(Element parent, int pos) {
|
||||||
|
super.onRender(parent, pos);
|
||||||
|
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
|
||||||
|
|
||||||
|
ColumnConfig column = new ColumnConfig();
|
||||||
|
column.setId("name");
|
||||||
|
column.setHeader("Employee Name");
|
||||||
|
column.setWidth(200);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
column = new ColumnConfig("department", "Department", 150);
|
||||||
|
column.setAlignment(HorizontalAlignment.LEFT);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
column = new ColumnConfig("designation", "Designation", 150);
|
||||||
|
column.setAlignment(HorizontalAlignment.LEFT);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
column = new ColumnConfig("salary", "Slary", 100);
|
||||||
|
column.setAlignment(HorizontalAlignment.RIGHT);
|
||||||
|
final NumberFormat number = NumberFormat.getFormat("0.00");
|
||||||
|
GridCellRenderer<Employee> checkSalary = new GridCellRenderer<Employee>() {
|
||||||
|
public String render(Employee model, String property,
|
||||||
|
ColumnData config, int rowIndex, int colIndex,
|
||||||
|
ListStore<Employee> employeeList, Grid<Employee> grid) {
|
||||||
|
double val = (Double) model.get(property);
|
||||||
|
String style = val < 70000 ? "red" : "green";
|
||||||
|
return "<span style='color:" + style + "'>"
|
||||||
|
+ number.format(val) + "</span>";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
column.setRenderer(checkSalary);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
column = new ColumnConfig("joiningdate", "Joining Date", 100);
|
||||||
|
column.setAlignment(HorizontalAlignment.RIGHT);
|
||||||
|
column.setDateTimeFormat(DateTimeFormat.getShortDateFormat());
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
ListStore<Employee> employeeList = new ListStore<Employee>();
|
||||||
|
employeeList.add(new TestData().getEmployees());
|
||||||
|
|
||||||
|
ColumnModel cm = new ColumnModel(configs);
|
||||||
|
Grid<Employee> grid = new Grid<Employee>(employeeList, cm);
|
||||||
|
grid.setStyleAttribute("borderTop", "none");
|
||||||
|
grid.setAutoExpandColumn("name");
|
||||||
|
grid.setBorders(true);
|
||||||
|
grid.setStripeRows(true);
|
||||||
|
grid.setColumnLines(true);
|
||||||
|
|
||||||
|
setBodyBorder(true);
|
||||||
|
setHeading("Employee List");
|
||||||
|
setButtonAlign(HorizontalAlignment.CENTER);
|
||||||
|
setLayout(new FitLayout());
|
||||||
|
setSize(700, 500);
|
||||||
|
add(grid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Grid<Employee> getGrid() {
|
||||||
|
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
|
||||||
|
|
||||||
|
ColumnConfig column = new ColumnConfig();
|
||||||
|
column.setId("name");
|
||||||
|
column.setHeader("Employee Name");
|
||||||
|
column.setWidth(200);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
column = new ColumnConfig("department", "Department", 150);
|
||||||
|
column.setAlignment(HorizontalAlignment.LEFT);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
column = new ColumnConfig("designation", "Designation", 150);
|
||||||
|
column.setAlignment(HorizontalAlignment.LEFT);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
column = new ColumnConfig("salary", "Slary", 100);
|
||||||
|
column.setAlignment(HorizontalAlignment.RIGHT);
|
||||||
|
final NumberFormat number = NumberFormat.getFormat("0.00");
|
||||||
|
GridCellRenderer<Employee> checkSalary = new GridCellRenderer<Employee>() {
|
||||||
|
public String render(Employee model, String property,
|
||||||
|
ColumnData config, int rowIndex, int colIndex,
|
||||||
|
ListStore<Employee> employeeList, Grid<Employee> grid) {
|
||||||
|
double val = (Double) model.get(property);
|
||||||
|
String style = val < 70000 ? "red" : "green";
|
||||||
|
return "<span style='color:" + style + "'>"
|
||||||
|
+ number.format(val) + "</span>";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
column.setRenderer(checkSalary);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
column = new ColumnConfig("joiningdate", "Joining Date", 100);
|
||||||
|
column.setAlignment(HorizontalAlignment.RIGHT);
|
||||||
|
column.setDateTimeFormat(DateTimeFormat.getShortDateFormat());
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
ListStore<Employee> employeeList = new ListStore<Employee>();
|
||||||
|
employeeList.add(getEmployees());
|
||||||
|
|
||||||
|
ColumnModel cm = new ColumnModel(configs);
|
||||||
|
Grid<Employee> grid = new Grid<Employee>(employeeList, cm);
|
||||||
|
grid.setStyleAttribute("borderTop", "none");
|
||||||
|
grid.setAutoExpandColumn("name");
|
||||||
|
grid.setBorders(true);
|
||||||
|
grid.setStripeRows(true);
|
||||||
|
grid.setColumnLines(true);
|
||||||
|
|
||||||
|
return grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Employee> getEmployees() {
|
||||||
|
List<Employee> employees = new ArrayList<Employee>();
|
||||||
|
DateTimeFormat f = DateTimeFormat.getFormat("yyyy-mm-dd");
|
||||||
|
employees.add(new Employee("Hollie Voss", "General Administration",
|
||||||
|
"Executive Director", 150000, f.parse("2006-05-01")));
|
||||||
|
employees.add(new Employee("Emerson Milton",
|
||||||
|
"Information Technology", "CTO", 120000, f
|
||||||
|
.parse("2007-03-01")));
|
||||||
|
employees.add(new Employee("Christina Blake",
|
||||||
|
"Information Technology", "Project Manager", 90000, f
|
||||||
|
.parse("2008-08-01")));
|
||||||
|
employees.add(new Employee("Heriberto Rush",
|
||||||
|
"Information Technology", "Senior S/WEngineer", 70000, f
|
||||||
|
.parse("2009-02-07")));
|
||||||
|
employees.add(new Employee("Candice Carson",
|
||||||
|
"Information Technology", "S/W Engineer", 60000, f
|
||||||
|
.parse("2007-11-01")));
|
||||||
|
employees.add(new Employee("Chad Andrews",
|
||||||
|
"Information Technology", "Senior S/W Engineer", 70000, f
|
||||||
|
.parse("2008-02-01")));
|
||||||
|
employees.add(new Employee("Dirk Newman", "Information Technology",
|
||||||
|
"S/W Engineer", 62000, f.parse("2009-03-01")));
|
||||||
|
employees.add(new Employee("Bell Snedden",
|
||||||
|
"Information Technology", "S/W Engineer", 73000, f
|
||||||
|
.parse("2007-07-07")));
|
||||||
|
employees.add(new Employee("Benito Meeks", "Marketing",
|
||||||
|
"General Manager", 105000, f.parse("2008-02-01")));
|
||||||
|
employees.add(new Employee("Gail Horton", "Marketing", "Executive",
|
||||||
|
55000, f.parse("2009-05-01")));
|
||||||
|
employees.add(new Employee("Claudio Engle", "Marketing",
|
||||||
|
"Executive", 58000, f.parse("2008-09-03")));
|
||||||
|
employees.add(new Employee("Buster misjenou", "Accounts",
|
||||||
|
"Executive", 52000, f.parse("2008-02-07")));
|
||||||
|
return employees;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ////////////////////////////////
|
||||||
|
public class Employee extends BaseModel {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public Employee() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Employee(String name, String department, String designation,
|
||||||
|
double salary, Date joiningdate) {
|
||||||
|
set("name", name);
|
||||||
|
set("department", department);
|
||||||
|
set("designation", designation);
|
||||||
|
set("salary", salary);
|
||||||
|
set("joiningdate", joiningdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getJoiningdate() {
|
||||||
|
return (Date) get("joiningdate");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return (String) get("name");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDepartment() {
|
||||||
|
return (String) get("department");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDesignation() {
|
||||||
|
return (String) get("designation");
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getSalary() {
|
||||||
|
Double salary = (Double) get("salary");
|
||||||
|
return salary.doubleValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TestData {
|
||||||
|
public List<Employee> getEmployees() {
|
||||||
|
List<Employee> employees = new ArrayList<Employee>();
|
||||||
|
DateTimeFormat f = DateTimeFormat.getFormat("yyyy-mm-dd");
|
||||||
|
employees.add(new Employee("Hollie Voss", "General Administration",
|
||||||
|
"Executive Director", 150000, f.parse("2006-05-01")));
|
||||||
|
employees.add(new Employee("Emerson Milton",
|
||||||
|
"Information Technology", "CTO", 120000, f
|
||||||
|
.parse("2007-03-01")));
|
||||||
|
employees.add(new Employee("Christina Blake",
|
||||||
|
"Information Technology", "Project Manager", 90000, f
|
||||||
|
.parse("2008-08-01")));
|
||||||
|
employees.add(new Employee("Heriberto Rush",
|
||||||
|
"Information Technology", "Senior S/WEngineer", 70000, f
|
||||||
|
.parse("2009-02-07")));
|
||||||
|
employees.add(new Employee("Candice Carson",
|
||||||
|
"Information Technology", "S/W Engineer", 60000, f
|
||||||
|
.parse("2007-11-01")));
|
||||||
|
employees.add(new Employee("Chad Andrews",
|
||||||
|
"Information Technology", "Senior S/W Engineer", 70000, f
|
||||||
|
.parse("2008-02-01")));
|
||||||
|
employees.add(new Employee("Dirk Newman", "Information Technology",
|
||||||
|
"S/W Engineer", 62000, f.parse("2009-03-01")));
|
||||||
|
employees.add(new Employee("Bell Snedden",
|
||||||
|
"Information Technology", "S/W Engineer", 73000, f
|
||||||
|
.parse("2007-07-07")));
|
||||||
|
employees.add(new Employee("Benito Meeks", "Marketing",
|
||||||
|
"General Manager", 105000, f.parse("2008-02-01")));
|
||||||
|
employees.add(new Employee("Gail Horton", "Marketing", "Executive",
|
||||||
|
55000, f.parse("2009-05-01")));
|
||||||
|
employees.add(new Employee("Claudio Engle", "Marketing",
|
||||||
|
"Executive", 58000, f.parse("2008-09-03")));
|
||||||
|
employees.add(new Employee("Buster misjenou", "Accounts",
|
||||||
|
"Executive", 52000, f.parse("2008-02-07")));
|
||||||
|
return employees;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,496 @@
|
||||||
|
package org.gcube.portlets.user.gisviewer.test.client;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ext GWT 2.2.5 - Ext for GWT
|
||||||
|
* Copyright(c) 2007-2010, Ext JS, LLC.
|
||||||
|
* licensing@extjs.com
|
||||||
|
*
|
||||||
|
* http://extjs.com/license
|
||||||
|
*/
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
||||||
|
import com.extjs.gxt.ui.client.Style.SelectionMode;
|
||||||
|
import com.extjs.gxt.ui.client.core.XTemplate;
|
||||||
|
import com.extjs.gxt.ui.client.data.BaseModel;
|
||||||
|
import com.extjs.gxt.ui.client.dnd.DND.Feedback;
|
||||||
|
import com.extjs.gxt.ui.client.dnd.GridDragSource;
|
||||||
|
import com.extjs.gxt.ui.client.dnd.GridDropTarget;
|
||||||
|
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
||||||
|
import com.extjs.gxt.ui.client.event.Events;
|
||||||
|
import com.extjs.gxt.ui.client.event.FieldEvent;
|
||||||
|
import com.extjs.gxt.ui.client.event.Listener;
|
||||||
|
import com.extjs.gxt.ui.client.event.SelectionListener;
|
||||||
|
import com.extjs.gxt.ui.client.store.ListStore;
|
||||||
|
import com.extjs.gxt.ui.client.util.DateWrapper;
|
||||||
|
import com.extjs.gxt.ui.client.widget.Component;
|
||||||
|
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
||||||
|
import com.extjs.gxt.ui.client.widget.VerticalPanel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.button.Button;
|
||||||
|
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
|
||||||
|
import com.extjs.gxt.ui.client.widget.form.SimpleComboBox;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.CheckBoxSelectionModel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.Grid;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.RowExpander;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
|
||||||
|
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
||||||
|
import com.extjs.gxt.ui.client.widget.table.NumberCellRenderer;
|
||||||
|
import com.extjs.gxt.ui.client.widget.toolbar.LabelToolItem;
|
||||||
|
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
|
||||||
|
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
|
||||||
|
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||||
|
import com.google.gwt.i18n.client.NumberFormat;
|
||||||
|
import com.google.gwt.user.client.Element;
|
||||||
|
public class GridPluginsExample extends LayoutContainer {
|
||||||
|
|
||||||
|
private VerticalPanel panel;
|
||||||
|
private GridCellRenderer<Stock> gridNumber;
|
||||||
|
private GridCellRenderer<Stock> change;
|
||||||
|
|
||||||
|
public GridPluginsExample() {
|
||||||
|
final NumberFormat currency = NumberFormat.getCurrencyFormat();
|
||||||
|
final NumberFormat number = NumberFormat.getFormat("0.00");
|
||||||
|
final NumberCellRenderer<Grid<Stock>> numberRenderer = new NumberCellRenderer<Grid<Stock>>(currency);
|
||||||
|
|
||||||
|
change = new GridCellRenderer<Stock>() {
|
||||||
|
public String render(Stock model, String property, ColumnData config, int rowIndex, int colIndex,
|
||||||
|
ListStore<Stock> store, Grid<Stock> grid) {
|
||||||
|
double val = (Double) model.get(property);
|
||||||
|
String style = val < 0 ? "red" : "green";
|
||||||
|
return "<span style='color:" + style + "'>" + number.format(val) + "</span>";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
gridNumber = new GridCellRenderer<Stock>() {
|
||||||
|
public String render(Stock model, String property, ColumnData config, int rowIndex, int colIndex,
|
||||||
|
ListStore<Stock> store, Grid<Stock> grid) {
|
||||||
|
return numberRenderer.render(null, property, model.get(property));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
panel = new VerticalPanel();
|
||||||
|
panel.setSpacing(20);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onRender(Element parent, int index) {
|
||||||
|
super.onRender(parent, index);
|
||||||
|
|
||||||
|
createExpander();
|
||||||
|
//createCheckBox();
|
||||||
|
//createNumberer();
|
||||||
|
//createFramed();
|
||||||
|
add(panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createCheckBox() {
|
||||||
|
List<Stock> stocks = getStocks();
|
||||||
|
|
||||||
|
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
|
||||||
|
|
||||||
|
final CheckBoxSelectionModel<Stock> sm = new CheckBoxSelectionModel<Stock>();
|
||||||
|
// selection model supports the SIMPLE selection mode
|
||||||
|
// sm.setSelectionMode(SelectionMode.SIMPLE);
|
||||||
|
|
||||||
|
configs.add(sm.getColumn());
|
||||||
|
|
||||||
|
ColumnConfig column = new ColumnConfig();
|
||||||
|
column.setId("name");
|
||||||
|
column.setHeader("Company");
|
||||||
|
column.setWidth(300);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
column = new ColumnConfig();
|
||||||
|
column.setId("symbol");
|
||||||
|
column.setHeader("Symbol");
|
||||||
|
column.setWidth(100);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
column = new ColumnConfig();
|
||||||
|
column.setId("last");
|
||||||
|
column.setHeader("Last");
|
||||||
|
column.setAlignment(HorizontalAlignment.RIGHT);
|
||||||
|
column.setWidth(75);
|
||||||
|
column.setRenderer(gridNumber);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
column = new ColumnConfig("change", "Change", 100);
|
||||||
|
column.setAlignment(HorizontalAlignment.RIGHT);
|
||||||
|
column.setRenderer(change);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
ListStore<Stock> store = new ListStore<Stock>();
|
||||||
|
store.add(stocks);
|
||||||
|
|
||||||
|
ColumnModel cm = new ColumnModel(configs);
|
||||||
|
|
||||||
|
ContentPanel cp = new ContentPanel();
|
||||||
|
cp.setHeading("Framed with Checkbox Selection and Horizontal Scrolling");
|
||||||
|
cp.setFrame(true);
|
||||||
|
//cp.setIcon(Resources.ICONS.table());
|
||||||
|
cp.setLayout(new FitLayout());
|
||||||
|
cp.setSize(600, 300);
|
||||||
|
|
||||||
|
Grid<Stock> grid = new Grid<Stock>(store, cm);
|
||||||
|
grid.setSelectionModel(sm);
|
||||||
|
grid.setBorders(true);
|
||||||
|
grid.setColumnReordering(true);
|
||||||
|
grid.getAriaSupport().setLabelledBy(cp.getHeader().getId() + "-label");
|
||||||
|
grid.addPlugin(sm);
|
||||||
|
|
||||||
|
ToolBar toolBar = new ToolBar();
|
||||||
|
toolBar.getAriaSupport().setLabel("Grid Options");
|
||||||
|
toolBar.add(new LabelToolItem("Selection Mode: "));
|
||||||
|
final SimpleComboBox<String> type = new SimpleComboBox<String>();
|
||||||
|
type.setTriggerAction(TriggerAction.ALL);
|
||||||
|
type.setEditable(false);
|
||||||
|
type.setFireChangeEventOnSetValue(true);
|
||||||
|
type.setWidth(100);
|
||||||
|
type.add("Multi");
|
||||||
|
type.add("Simple");
|
||||||
|
type.setSimpleValue("Multi");
|
||||||
|
type.addListener(Events.Change, new Listener<FieldEvent>() {
|
||||||
|
public void handleEvent(FieldEvent be) {
|
||||||
|
boolean simple = type.getSimpleValue().equals("Simple");
|
||||||
|
sm.deselectAll();
|
||||||
|
sm.setSelectionMode(simple ? SelectionMode.SIMPLE : SelectionMode.MULTI);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
toolBar.add(type);
|
||||||
|
toolBar.add(new SeparatorToolItem());
|
||||||
|
cp.setTopComponent(toolBar);
|
||||||
|
|
||||||
|
cp.add(grid);
|
||||||
|
panel.add(cp);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createExpander() {
|
||||||
|
List<Stock> stocks = getStocks();
|
||||||
|
for (Stock s : stocks) {
|
||||||
|
s.set(
|
||||||
|
"desc",
|
||||||
|
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed metus nibh, sodales a, porta at, vulputate eget, dui. Pellentesque ut nisl. Maecenas tortor turpis, interdum non, sodales non, iaculis ac, lacus. Vestibulum auctor, tortor quis iaculis malesuada, libero lectus bibendum purus, sit amet tincidunt quam turpis vel lacus. In pellentesque nisl non sem. Suspendisse nunc sem, pretium eget, cursus a, fringilla vel, urna.<br/><br/>Aliquam commodo ullamcorper erat. Nullam vel justo in neque porttitor laoreet. Aenean lacus dui, consequat eu, adipiscing eget, nonummy non, nisi. Morbi nunc est, dignissim non, ornare sed, luctus eu, massa. Vivamus eget quam. Vivamus tincidunt diam nec urna. Curabitur velit.");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
|
||||||
|
|
||||||
|
XTemplate tpl = XTemplate.create("<p><b>Company:</b> {name}</p><br><p><b>Summary:</b> {desc}</p>");
|
||||||
|
|
||||||
|
RowExpander expander = new RowExpander();
|
||||||
|
expander.setTemplate(tpl);
|
||||||
|
|
||||||
|
configs.add(expander);
|
||||||
|
|
||||||
|
ColumnConfig column = new ColumnConfig();
|
||||||
|
column.setId("name");
|
||||||
|
column.setHeader("Company");
|
||||||
|
column.setWidth(200);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
column = new ColumnConfig();
|
||||||
|
column.setId("symbol");
|
||||||
|
column.setHeader("Symbol");
|
||||||
|
column.setWidth(100);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
column = new ColumnConfig();
|
||||||
|
column.setId("last");
|
||||||
|
column.setHeader("Last");
|
||||||
|
column.setAlignment(HorizontalAlignment.RIGHT);
|
||||||
|
column.setWidth(75);
|
||||||
|
column.setRenderer(gridNumber);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
column = new ColumnConfig("change", "Change", 100);
|
||||||
|
column.setAlignment(HorizontalAlignment.RIGHT);
|
||||||
|
column.setRenderer(change);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
column = new ColumnConfig("date", "Last Updated", 100);
|
||||||
|
column.setAlignment(HorizontalAlignment.RIGHT);
|
||||||
|
column.setDateTimeFormat(DateTimeFormat.getFormat("MM/dd/yyyy"));
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
ListStore<Stock> store = new ListStore<Stock>();
|
||||||
|
store.add(stocks);
|
||||||
|
|
||||||
|
ColumnModel cm = new ColumnModel(configs);
|
||||||
|
|
||||||
|
ContentPanel cp = new ContentPanel();
|
||||||
|
cp.setHeading("Expander Rows, Collapse and Auto Fill");
|
||||||
|
//cp.setIcon(Resources.ICONS.table());
|
||||||
|
cp.setAnimCollapse(false);
|
||||||
|
cp.setCollapsible(true);
|
||||||
|
cp.setLayout(new FitLayout());
|
||||||
|
cp.setSize(600, 300);
|
||||||
|
|
||||||
|
Grid<Stock> grid = new Grid<Stock>(store, cm);
|
||||||
|
//grid.addPlugin(expander);
|
||||||
|
grid.setColumnReordering(true);
|
||||||
|
grid.getView().setAutoFill(true);
|
||||||
|
grid.getAriaSupport().setLabelledBy(cp.getHeader().getId() + "-label");
|
||||||
|
cp.add(grid);
|
||||||
|
|
||||||
|
new GridDragSource(grid);
|
||||||
|
|
||||||
|
GridDropTarget target = new GridDropTarget(grid);
|
||||||
|
target.setAllowSelfAsSource(true);
|
||||||
|
target.setFeedback(Feedback.INSERT);
|
||||||
|
|
||||||
|
panel.add(cp);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createFramed() {
|
||||||
|
List<Stock> stocks = getStocks();
|
||||||
|
|
||||||
|
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
|
||||||
|
|
||||||
|
CheckBoxSelectionModel<Stock> sm = new CheckBoxSelectionModel<Stock>();
|
||||||
|
|
||||||
|
configs.add(sm.getColumn());
|
||||||
|
|
||||||
|
ColumnConfig column = new ColumnConfig();
|
||||||
|
column.setId("name");
|
||||||
|
column.setHeader("Company");
|
||||||
|
column.setWidth(200);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
column = new ColumnConfig();
|
||||||
|
column.setId("symbol");
|
||||||
|
column.setHeader("Symbol");
|
||||||
|
column.setWidth(100);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
column = new ColumnConfig();
|
||||||
|
column.setId("last");
|
||||||
|
column.setHeader("Last");
|
||||||
|
column.setAlignment(HorizontalAlignment.RIGHT);
|
||||||
|
column.setWidth(75);
|
||||||
|
column.setRenderer(gridNumber);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
column = new ColumnConfig("change", "Change", 100);
|
||||||
|
column.setAlignment(HorizontalAlignment.RIGHT);
|
||||||
|
column.setRenderer(change);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
column = new ColumnConfig("date", "Last Updated", 100);
|
||||||
|
column.setAlignment(HorizontalAlignment.RIGHT);
|
||||||
|
column.setDateTimeFormat(DateTimeFormat.getFormat("MM/dd/yyyy"));
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
ListStore<Stock> store = new ListStore<Stock>();
|
||||||
|
store.add(stocks);
|
||||||
|
|
||||||
|
ColumnModel cm = new ColumnModel(configs);
|
||||||
|
|
||||||
|
ContentPanel cp = new ContentPanel();
|
||||||
|
cp.setHeading("Support for standard Panel features such as framing, buttons and toolbars");
|
||||||
|
cp.setFrame(true);
|
||||||
|
//cp.setIcon(Resources.ICONS.table());
|
||||||
|
cp.addButton(new Button("Save"));
|
||||||
|
cp.addButton(new Button("Cancel"));
|
||||||
|
cp.setButtonAlign(HorizontalAlignment.CENTER);
|
||||||
|
cp.setLayout(new FitLayout());
|
||||||
|
cp.setSize(600, 300);
|
||||||
|
|
||||||
|
ToolBar toolBar = new ToolBar();
|
||||||
|
toolBar.getAriaSupport().setLabel("Grid Options");
|
||||||
|
toolBar.add(new Button("Add"));//, Resources.ICONS.add()));
|
||||||
|
toolBar.add(new SeparatorToolItem());
|
||||||
|
toolBar.add(new Button("Remove"));//, Resources.ICONS.delete()));
|
||||||
|
toolBar.add(new SeparatorToolItem());
|
||||||
|
toolBar.add(new Button("Configure"));//, Resources.ICONS.plugin()));
|
||||||
|
cp.setTopComponent(toolBar);
|
||||||
|
|
||||||
|
Grid<Stock> grid = new Grid<Stock>(store, cm);
|
||||||
|
grid.setSelectionModel(sm);
|
||||||
|
grid.setAutoExpandColumn("name");
|
||||||
|
grid.setColumnReordering(true);
|
||||||
|
grid.setBorders(true);
|
||||||
|
grid.addPlugin(sm);
|
||||||
|
grid.getAriaSupport().setLabelledBy(cp.getHeader().getId() + "-label");
|
||||||
|
cp.add(grid);
|
||||||
|
panel.add(cp);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createNumberer() {
|
||||||
|
List<Stock> stocks = getStocks();
|
||||||
|
|
||||||
|
RowNumberer r = new RowNumberer();
|
||||||
|
|
||||||
|
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
|
||||||
|
configs.add(r);
|
||||||
|
|
||||||
|
ColumnConfig column = new ColumnConfig();
|
||||||
|
column.setId("name");
|
||||||
|
column.setHeader("Company");
|
||||||
|
column.setWidth(200);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
column = new ColumnConfig();
|
||||||
|
column.setId("symbol");
|
||||||
|
column.setHeader("Symbol");
|
||||||
|
column.setWidth(100);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
column = new ColumnConfig();
|
||||||
|
column.setId("last");
|
||||||
|
column.setHeader("Last");
|
||||||
|
column.setAlignment(HorizontalAlignment.RIGHT);
|
||||||
|
column.setWidth(75);
|
||||||
|
column.setRenderer(gridNumber);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
column = new ColumnConfig("change", "Change", 100);
|
||||||
|
column.setAlignment(HorizontalAlignment.RIGHT);
|
||||||
|
column.setRenderer(change);
|
||||||
|
configs.add(column);
|
||||||
|
|
||||||
|
ListStore<Stock> store = new ListStore<Stock>();
|
||||||
|
store.add(stocks);
|
||||||
|
|
||||||
|
ColumnModel cm = new ColumnModel(configs);
|
||||||
|
|
||||||
|
final Grid<Stock> grid = new Grid<Stock>(store, cm);
|
||||||
|
grid.addPlugin(r);
|
||||||
|
grid.getView().setForceFit(true);
|
||||||
|
|
||||||
|
|
||||||
|
Button btn = new Button("Remove a Row", new SelectionListener<ButtonEvent>() {
|
||||||
|
@Override
|
||||||
|
public void componentSelected(ButtonEvent ce) {
|
||||||
|
grid.getStore().remove(grid.getStore().getAt(0));
|
||||||
|
if (grid.getStore().getCount() == 0) {
|
||||||
|
ce.<Component> getComponent().disable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
//btn.setIcon(Resources.ICONS.delete());
|
||||||
|
|
||||||
|
ContentPanel cp = new ContentPanel();
|
||||||
|
cp.setHeading("Grid with Numbered Rows and Force Fit");
|
||||||
|
//cp.setIcon(Resources.ICONS.table());
|
||||||
|
cp.setLayout(new FitLayout());
|
||||||
|
cp.setSize(600, 300);
|
||||||
|
cp.add(grid);
|
||||||
|
cp.addButton(btn);
|
||||||
|
grid.getAriaSupport().setLabelledBy(cp.getHeader().getId() + "-label");
|
||||||
|
panel.add(cp);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Stock> getStocks() {
|
||||||
|
List<Stock> stocks = new ArrayList<Stock>();
|
||||||
|
|
||||||
|
stocks.add(new Stock("Apple Inc.", "AAPL", 125.64, 123.43));
|
||||||
|
stocks.add(new Stock("Cisco Systems, Inc.", "CSCO", 25.84, 26.3));
|
||||||
|
stocks.add(new Stock("Google Inc.", "GOOG", 516.2, 512.6));
|
||||||
|
stocks.add(new Stock("Intel Corporation", "INTC", 21.36, 21.53));
|
||||||
|
stocks.add(new Stock("Level 3 Communications, Inc.", "LVLT", 5.55, 5.54));
|
||||||
|
stocks.add(new Stock("Microsoft Corporation", "MSFT", 29.56, 29.72));
|
||||||
|
stocks.add(new Stock("Nokia Corporation (ADR)", "NOK", 27.83, 27.93));
|
||||||
|
stocks.add(new Stock("Oracle Corporation", "ORCL", 18.73, 18.98));
|
||||||
|
stocks.add(new Stock("Starbucks Corporation", "SBUX", 27.33, 27.36));
|
||||||
|
stocks.add(new Stock("Yahoo! Inc.", "YHOO", 26.97, 27.29));
|
||||||
|
stocks.add(new Stock("Applied Materials, Inc.", "AMAT", 18.4, 18.66));
|
||||||
|
stocks.add(new Stock("Comcast Corporation", "CMCSA", 25.9, 26.4));
|
||||||
|
stocks.add(new Stock("Sirius Satellite", "SIRI", 2.77, 2.74));
|
||||||
|
stocks.add(new Stock("First Data Corporation", "FDC", 32.7, 32.65));
|
||||||
|
|
||||||
|
return stocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private class Stock extends BaseModel {
|
||||||
|
|
||||||
|
public Stock() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Stock(String name, double open, double change, double pctChange, Date date, String industry) {
|
||||||
|
set("name", name);
|
||||||
|
set("open", open);
|
||||||
|
set("change", change);
|
||||||
|
set("percentChange", pctChange);
|
||||||
|
set("date", date);
|
||||||
|
set("industry", industry);
|
||||||
|
set("split", new Boolean(Math.random() > .5));
|
||||||
|
set("type", getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Stock(String name, String symbol, double open, double last) {
|
||||||
|
set("name", name);
|
||||||
|
set("symbol", symbol);
|
||||||
|
set("open", open);
|
||||||
|
set("last", last);
|
||||||
|
set("date", new DateWrapper().addDays(-(int)(Math.random() * 100)).asDate());
|
||||||
|
set("change", last - open);
|
||||||
|
set("split", new Boolean(Math.random() > .5));
|
||||||
|
set("type", getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getChange() {
|
||||||
|
return getLast() - getOpen();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIndustry() {
|
||||||
|
return get("industry");
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getLast() {
|
||||||
|
Double open = (Double) get("last");
|
||||||
|
return open.doubleValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getLastTrans() {
|
||||||
|
return (Date) get("date");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return (String) get("name");
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getOpen() {
|
||||||
|
Double open = (Double) get("open");
|
||||||
|
return open.doubleValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getPercentChange() {
|
||||||
|
return getChange() / getOpen();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSymbol() {
|
||||||
|
return (String) get("symbol");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIndustry(String industry) {
|
||||||
|
set("industry", industry);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getType() {
|
||||||
|
double r = Math.random();
|
||||||
|
if (r <= .25) {
|
||||||
|
return "Auto";
|
||||||
|
} else if (r > .25 && r <= .50) {
|
||||||
|
return "Media";
|
||||||
|
} else if (r > .5 && r <= .75) {
|
||||||
|
return "Medical";
|
||||||
|
} else {
|
||||||
|
return "Tech";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,151 @@
|
||||||
|
package org.gcube.portlets.user.gisviewer.test.client;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.gisviewer.client.Constants;
|
||||||
|
import org.gcube.portlets.user.gisviewer.client.Constants.Mode;
|
||||||
|
import org.gcube.portlets.user.gisviewer.client.GisViewer;
|
||||||
|
import org.gcube.portlets.user.gisviewer.client.GisViewerParameters;
|
||||||
|
import org.gcube.portlets.user.gisviewer.client.GisViewerService;
|
||||||
|
import org.gcube.portlets.user.gisviewer.client.GisViewerServiceAsync;
|
||||||
|
|
||||||
|
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
||||||
|
import com.extjs.gxt.ui.client.event.SelectionListener;
|
||||||
|
import com.extjs.gxt.ui.client.widget.Window;
|
||||||
|
import com.extjs.gxt.ui.client.widget.button.Button;
|
||||||
|
import com.google.gwt.core.client.EntryPoint;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
|
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
|
||||||
|
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||||
|
import com.google.gwt.user.client.ui.RootPanel;
|
||||||
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entry point classes define <code>onModuleLoad()</code>.
|
||||||
|
*/
|
||||||
|
public class GxtGisViewer implements EntryPoint {
|
||||||
|
|
||||||
|
private GisViewerServiceAsync service;
|
||||||
|
private GisViewer gisViewer;
|
||||||
|
|
||||||
|
public void onModuleLoad() {
|
||||||
|
//disableDefaultContextMenu();
|
||||||
|
service = (GisViewerServiceAsync) GWT.create(GisViewerService.class);
|
||||||
|
|
||||||
|
Button openButton = new Button(".: click :.", new SelectionListener<ButtonEvent>() {
|
||||||
|
public void componentSelected(ButtonEvent ce) {
|
||||||
|
initGeoWindow();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//openButton.setIcon(IconHelper.createPath("images/engine_start.jpg", 330, 290));
|
||||||
|
//openButton.setSize(336, 300);
|
||||||
|
|
||||||
|
RootPanel.get("entryDiv").add(new HTML("<br/>"));
|
||||||
|
RootPanel.get("entryDiv").add(openButton);
|
||||||
|
|
||||||
|
if (Constants.MODE==Mode.TEST) {
|
||||||
|
RootPanel.get("entryDiv").add(new GridPluginsExample());
|
||||||
|
//initGeoWindow();
|
||||||
|
//RootPanel.get("entryDiv").add(new TreeExample());
|
||||||
|
}
|
||||||
|
|
||||||
|
RootPanel.get().add(new Button("Add layer \"salinity\"", new SelectionListener<ButtonEvent>(){
|
||||||
|
@Override
|
||||||
|
public void componentSelected(ButtonEvent ce) {
|
||||||
|
// if (gisViewer!=null)
|
||||||
|
// gisViewer.addLayerByName("salinity");
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initGeoWindow() {
|
||||||
|
GisViewerParameters gisViewerParameters = new GisViewerParameters();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ADDING AN ARRAYLIST OF LAYER TITLES
|
||||||
|
*/
|
||||||
|
// List<String> layers = new ArrayList<String>();
|
||||||
|
// layers.add("TrueMarble.16km.2700x1350");
|
||||||
|
// layers.add("depthmean");
|
||||||
|
// layers.add("eezall");
|
||||||
|
// gisViewerParameters.setOpeningLayers(layers);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ADDING AN ARRAY OF LAYERS TITLES
|
||||||
|
*/
|
||||||
|
// String[] layers = {"TrueMarble.16km.2700x1350", "depthmean", "eezall", "v_point_geometries_example"};
|
||||||
|
// gisViewerParameters.setOpeningLayers(layers);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ADDING A GROUP NAME
|
||||||
|
*/
|
||||||
|
// gisViewerParameters.setOpeningGroup(Constants.defaultGroup);
|
||||||
|
// gisViewerParameters.setGisViewerSaveHandler(new GisViewerSaveHandler() {
|
||||||
|
// @Override
|
||||||
|
// public void saveLayerImage(String name, String contentType, String url) {
|
||||||
|
// // TODO Auto-generated method stub
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void saveMapImage(String name, String outputFormat,
|
||||||
|
// String bbox, String width, String height,
|
||||||
|
// String[] geoservers, String[] layers, String[] styles,
|
||||||
|
// String[] opacities, String[] cqlfilters, String[] gsrefs) {
|
||||||
|
// // TODO Auto-generated method stub
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// });
|
||||||
|
|
||||||
|
gisViewer = new GisViewer(gisViewerParameters);
|
||||||
|
gisViewer.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showSaveDialogLayer(final String format, String content_type, String link) {
|
||||||
|
|
||||||
|
final Window dialogBox = new Window();
|
||||||
|
// dialogBox.addStyleName("z_index_1200");
|
||||||
|
|
||||||
|
VerticalPanel hcafLegend = new VerticalPanel();
|
||||||
|
|
||||||
|
// link = Constants.geoServerURL + link;
|
||||||
|
|
||||||
|
// hcafLegend.add(new Label("Link to save: " + link));
|
||||||
|
// Add a close button at the bottom of the dialog
|
||||||
|
Button closeButton = new Button("close",
|
||||||
|
new SelectionListener<ButtonEvent>() {
|
||||||
|
public void componentSelected(ButtonEvent ce) {
|
||||||
|
dialogBox.hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
closeButton.addStyleName("border_left border_right border_top");
|
||||||
|
|
||||||
|
closeButton.setWidth("50px");
|
||||||
|
|
||||||
|
Button saveButton = new Button("save",
|
||||||
|
new SelectionListener<ButtonEvent>() {
|
||||||
|
public void componentSelected(ButtonEvent ce) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
saveButton.addStyleName("border_left border_right border_top");
|
||||||
|
saveButton.setWidth("100px");
|
||||||
|
|
||||||
|
HorizontalPanel hp = new HorizontalPanel();
|
||||||
|
hp.add(saveButton);
|
||||||
|
hp.add(closeButton);
|
||||||
|
hcafLegend.add(hp);
|
||||||
|
hcafLegend.setCellHorizontalAlignment(hp,
|
||||||
|
HasHorizontalAlignment.ALIGN_RIGHT);
|
||||||
|
|
||||||
|
// legendPanel.insert(hcafLegend, 1);
|
||||||
|
dialogBox.setTitle("Save Layer as " + format);
|
||||||
|
// dialogBox.setAnimationEnabled(true);
|
||||||
|
// dialogBox.setWidth("350px");
|
||||||
|
hcafLegend.setWidth("400px");
|
||||||
|
dialogBox.add(hcafLegend);
|
||||||
|
|
||||||
|
dialogBox.center();
|
||||||
|
|
||||||
|
// Show the popup
|
||||||
|
dialogBox.show();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.gisviewer.test.client;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ceras
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class JsonParser {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param args
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
//InputStream is = JsonParser.class.getResourceAsStream( "test.json");
|
||||||
|
// try {
|
||||||
|
// InputStream is = new URL(url).openStream();
|
||||||
|
// String jsonTxt = IOUtils.toString(is);
|
||||||
|
// String jsonText = readAll(rd);
|
||||||
|
// JSONObject json = new JSONObject(jsonText);
|
||||||
|
// return json;
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
|
||||||
|
try {
|
||||||
|
String url = "http://geoserver.d4science-ii.research-infrastructures.eu/geoserver/wfs?service=wfs&version=1.1.0&REQUEST=GetFeature&TYPENAME=aquamaps:lamarsipuscarlsbergi20120619071303812&BBOX=-14.765625,117.7734375,-2.4609375,132.890625&MAXFEATURES=200&OUTPUTFORMAT=json";
|
||||||
|
InputStream is = new URL(url).openStream();
|
||||||
|
String jsonTxt = IOUtils.toString(is);
|
||||||
|
|
||||||
|
JSONObject json = new JSONObject(jsonTxt);
|
||||||
|
|
||||||
|
String type = json.getString("type");
|
||||||
|
System.out.println("type="+type);
|
||||||
|
|
||||||
|
JSONArray features = json.getJSONArray("features");
|
||||||
|
|
||||||
|
System.out.println(features.length()+" features.");
|
||||||
|
for (int i=0; i<features.length(); i++) {
|
||||||
|
JSONObject properties = ((JSONObject)features.get(i)).getJSONObject("properties");
|
||||||
|
|
||||||
|
|
||||||
|
Iterator<String> ii = properties.keys();
|
||||||
|
|
||||||
|
while (ii.hasNext()) {
|
||||||
|
String key = ii.next();
|
||||||
|
String value = properties.getString(key);
|
||||||
|
System.out.println(key+" = "+value);
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
|
//System.out.println("gid=" + properties.getString("gid") + "; csquarecode=" + properties.getString("csquarecode") + "; probability=" + properties.getString("probability") + ".");
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// double coolness = json.getDouble( "coolness" );
|
||||||
|
// int altitude = json.getInt( "altitude" );
|
||||||
|
// JSONObject pilot = json.getJSONObject("pilot");
|
||||||
|
// String firstName = pilot.getString("firstName");
|
||||||
|
// String lastName = pilot.getString("lastName");
|
||||||
|
//
|
||||||
|
// System.out.println( "Coolness: " + coolness );
|
||||||
|
// System.out.println( "Altitude: " + altitude );
|
||||||
|
// System.out.println( "Pilot: " + lastName );
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (JSONException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package org.gcube.portlets.user.gisviewer.test.client;
|
||||||
|
|
||||||
|
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
||||||
|
import com.extjs.gxt.ui.client.widget.TabItem;
|
||||||
|
import com.extjs.gxt.ui.client.widget.TabPanel;
|
||||||
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
|
|
||||||
|
public class TabExample extends LayoutContainer {
|
||||||
|
|
||||||
|
public TabExample() {
|
||||||
|
TabPanel advanced = new TabPanel();
|
||||||
|
advanced.setSize(600, 250);
|
||||||
|
advanced.setMinTabWidth(115);
|
||||||
|
advanced.setResizeTabs(true);
|
||||||
|
advanced.setAnimScroll(true);
|
||||||
|
advanced.setTabScroll(true);
|
||||||
|
advanced.setCloseContextMenu(true);
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
while (index < 7) {
|
||||||
|
TabItem item = new TabItem();
|
||||||
|
item.setText("New Tab " + ++index);
|
||||||
|
item.setClosable(index != 1);
|
||||||
|
item.add(new HTML("<b>Tab Body " + index+"</b>"));
|
||||||
|
item.addStyleName("pad-text");
|
||||||
|
advanced.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
advanced.setSelection(advanced.getItem(6));
|
||||||
|
add(advanced);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,135 @@
|
||||||
|
package org.gcube.portlets.user.gisviewer.test.client;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.extjs.gxt.ui.client.data.BaseModel;
|
||||||
|
|
||||||
|
public class TestData extends BaseModel {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
String nome, cognome, a, b, c, d, e, f, g, h, i;
|
||||||
|
int eta;
|
||||||
|
|
||||||
|
public TestData() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public TestData(String nome, String cognome, int eta) {
|
||||||
|
set("nome", nome);
|
||||||
|
set("cognome", cognome);
|
||||||
|
set("eta", eta);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public TestData(String nome, String cognome, int eta, String a, String b,
|
||||||
|
String c, String d, String e, String f, String g, String h,
|
||||||
|
String i) {
|
||||||
|
super();
|
||||||
|
set("nome", nome);
|
||||||
|
set("cognome", cognome);
|
||||||
|
set("a", a);
|
||||||
|
set("b", b);
|
||||||
|
set("c", c);
|
||||||
|
set("d", d);
|
||||||
|
set("e", e);
|
||||||
|
set("f", f);
|
||||||
|
set("g", g);
|
||||||
|
set("h", h);
|
||||||
|
set("i", i);
|
||||||
|
set("eta", eta);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCognome() {
|
||||||
|
return cognome;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getEta() {
|
||||||
|
return eta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNome() {
|
||||||
|
return nome;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCognome(String cognome) {
|
||||||
|
this.cognome = cognome;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEta(int eta) {
|
||||||
|
this.eta = eta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNome(String nome) {
|
||||||
|
this.nome = nome;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<TestData> getTestData() {
|
||||||
|
List<TestData> persone = new ArrayList<TestData>();
|
||||||
|
persone.add(new TestData("ciccio", "ceras", 31, "asd", "asd", "asd", "asd", "asd", "asd", "asd", "asd", "asd"));
|
||||||
|
persone.add(new TestData("pinco", "pallino", 25, "dsa", "asd", "dsa", "asd", "dsa", "asd", "dsa", "asd", "dsa"));
|
||||||
|
persone.add(new TestData("moira", "orfei", 22, "dsa", "asd", "dsa", "asd", "dsa", "asd", "dsa", "asd", "dsa"));
|
||||||
|
persone.add(new TestData("silvio", "berlusconi", 89, "dsa", "asd", "dsa", "asd", "dsa", "asd", "dsa", "asd", "dsa"));
|
||||||
|
persone.add(new TestData("pippo", "pluto", 13, "dsa", "asd", "dsa", "asd", "dsa", "asd", "dsa", "asd", "dsa"));
|
||||||
|
persone.add(new TestData("pippo", "pippo", 37, "dsa", "asd", "dsa", "asd", "dsa", "asd", "dsa", "asd", "dsa"));
|
||||||
|
return persone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String str = "ALGORITHM CITATION : Kaschner, K., J. S. Ready, E. Agbayani, J. Rius, K. Kesner-Reyes, P. D. Eastwood, A. B. South, S. O. Kullander, T. Rees, C. H. Close, R. Watson, D. Pauly, and R. Froese. 2008 AquaMaps: Predicted range maps for aquatic species. World wide web electronic publication, www.aquamaps.org, Version 10/2008. | HCAF GENERATION TIME : 1970_01_01_01_00_00_000_CET | HCAF TITLE : Default | HSPEC TITLE : Test Venus_SuitableRange | HSPEN GENERATION TIME : 1970_01_01_01_00_00_000_CET | ALGORITHM : SuitableRange | HSPEN TITLE : Default | HSPEC GENERATION TIME : 2012_03_13_11_25_55_188_CET |";
|
||||||
|
|
||||||
|
// try split by pipe
|
||||||
|
String[] splitPipe = str.split("\\|");
|
||||||
|
System.out.println("split lenght: "+splitPipe.length);
|
||||||
|
|
||||||
|
if (splitPipe.length==1)
|
||||||
|
// no map case
|
||||||
|
System.out.println("Description: "+str);
|
||||||
|
else {
|
||||||
|
// map case
|
||||||
|
System.out.println("Metadata list");
|
||||||
|
for (String metadata: splitPipe) {
|
||||||
|
// try split by ":"
|
||||||
|
String[] splitPoints = metadata.split(":");
|
||||||
|
if (splitPoints.length==0)
|
||||||
|
System.out.println(" - "+metadata);
|
||||||
|
else
|
||||||
|
System.out.println(" - "+getCapitalWords(splitPoints[0]) + "-"+metadata.substring(splitPoints[0].length()+1).trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getCapitalWords(String string) {
|
||||||
|
String ris = "";
|
||||||
|
|
||||||
|
boolean precUnderscore = true;
|
||||||
|
for (int i=0; i<string.length(); i++) {
|
||||||
|
char c = string.charAt(i);
|
||||||
|
|
||||||
|
if (c == '_') {
|
||||||
|
precUnderscore = true;
|
||||||
|
ris += " ";
|
||||||
|
} else {
|
||||||
|
ris += (precUnderscore ? Character.toUpperCase(c) : Character.toLowerCase(c));
|
||||||
|
if (precUnderscore == true)
|
||||||
|
precUnderscore = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ris.trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
package org.gcube.portlets.user.gisviewer.test.client;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ext GWT 2.2.5 - Ext for GWT
|
||||||
|
* Copyright(c) 2007-2010, Ext JS, LLC.
|
||||||
|
* licensing@extjs.com
|
||||||
|
*
|
||||||
|
* http://extjs.com/license
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.extjs.gxt.ui.client.data.BaseModelData;
|
||||||
|
import com.extjs.gxt.ui.client.data.ModelData;
|
||||||
|
import com.extjs.gxt.ui.client.event.Events;
|
||||||
|
import com.extjs.gxt.ui.client.event.Listener;
|
||||||
|
import com.extjs.gxt.ui.client.event.TreePanelEvent;
|
||||||
|
import com.extjs.gxt.ui.client.store.TreeStore;
|
||||||
|
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
||||||
|
import com.extjs.gxt.ui.client.widget.treepanel.TreePanel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.treepanel.TreePanel.CheckCascade;
|
||||||
|
import com.extjs.gxt.ui.client.widget.treepanel.TreePanel.CheckNodes;
|
||||||
|
import com.google.gwt.user.client.Element;
|
||||||
|
import com.google.gwt.user.client.Window;
|
||||||
|
|
||||||
|
public class TreeExample extends LayoutContainer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onRender(Element parent, int index) {
|
||||||
|
super.onRender(parent, index);
|
||||||
|
//setLayout(new FitLayout());
|
||||||
|
setSize("100%", "100%");
|
||||||
|
setBorders(true);
|
||||||
|
|
||||||
|
// creazione dello store
|
||||||
|
TreeStore<ModelData> store = new TreeStore<ModelData>();
|
||||||
|
|
||||||
|
// creazione tree panel
|
||||||
|
TreePanel<ModelData> tree = new TreePanel<ModelData>(store);
|
||||||
|
|
||||||
|
tree.setTrackMouseOver(false);
|
||||||
|
tree.setCheckable(true);
|
||||||
|
tree.setCheckNodes(CheckNodes.LEAF);
|
||||||
|
tree.setCheckStyle(CheckCascade.NONE);
|
||||||
|
tree.setDisplayProperty("nome");
|
||||||
|
|
||||||
|
|
||||||
|
ModelData m = new BaseModelData();
|
||||||
|
m.set("nome", "ciao");
|
||||||
|
|
||||||
|
ModelData mnew = new BaseModelData();
|
||||||
|
mnew.set("nome", "new!");
|
||||||
|
|
||||||
|
ModelData mnew2 = new BaseModelData();
|
||||||
|
mnew2.set("nome", "new!");
|
||||||
|
|
||||||
|
ModelData m2 = new BaseModelData();
|
||||||
|
m2.set("nome", "ciccio");
|
||||||
|
|
||||||
|
ModelData m3 = new BaseModelData();
|
||||||
|
m3.set("nome", "ceras");
|
||||||
|
|
||||||
|
store.add(m, false);
|
||||||
|
store.add(mnew, false);
|
||||||
|
store.add(m, m2, false);
|
||||||
|
store.add(m, m3, false);
|
||||||
|
store.add(mnew, mnew2, false);
|
||||||
|
|
||||||
|
tree.expandAll();
|
||||||
|
|
||||||
|
tree.setChecked(m2, true);
|
||||||
|
|
||||||
|
List<ModelData> a = tree.getCheckedSelection();
|
||||||
|
|
||||||
|
// change in node check state
|
||||||
|
tree.addListener(Events.CheckChange, new Listener<TreePanelEvent<ModelData>>() {
|
||||||
|
public void handleEvent(TreePanelEvent<ModelData> be) {
|
||||||
|
Window.alert("oh "+(be.isChecked()?"yes":"no")+"!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
add(tree);
|
||||||
|
//tree.getSelectionModel().select(store.getRootItems(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,171 @@
|
||||||
|
package org.gcube.portlets.user.gisviewer.test.client;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ext GWT 2.2.5 - Ext for GWT
|
||||||
|
* Copyright(c) 2007-2010, Ext JS, LLC.
|
||||||
|
* licensing@extjs.com
|
||||||
|
*
|
||||||
|
* http://extjs.com/license
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
||||||
|
import com.extjs.gxt.ui.client.data.BaseTreeModel;
|
||||||
|
import com.extjs.gxt.ui.client.data.ModelData;
|
||||||
|
import com.extjs.gxt.ui.client.event.ButtonEvent;
|
||||||
|
import com.extjs.gxt.ui.client.event.SelectionListener;
|
||||||
|
import com.extjs.gxt.ui.client.store.ListStore;
|
||||||
|
import com.extjs.gxt.ui.client.store.TreeStore;
|
||||||
|
import com.extjs.gxt.ui.client.util.IconHelper;
|
||||||
|
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.LayoutContainer;
|
||||||
|
import com.extjs.gxt.ui.client.widget.VerticalPanel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.button.Button;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
|
||||||
|
import com.extjs.gxt.ui.client.widget.grid.Grid;
|
||||||
|
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
||||||
|
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
|
||||||
|
import com.extjs.gxt.ui.client.widget.treegrid.TreeGrid;
|
||||||
|
import com.extjs.gxt.ui.client.widget.treegrid.WidgetTreeGridCellRenderer;
|
||||||
|
import com.google.gwt.dom.client.Style.Unit;
|
||||||
|
import com.google.gwt.user.client.Element;
|
||||||
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
|
public class WidgetTreeGridExample extends LayoutContainer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onRender(Element parent, int index) {
|
||||||
|
super.onRender(parent, index);
|
||||||
|
setLayout(new FlowLayout(10));
|
||||||
|
|
||||||
|
LayerFolder model = getTreeModel();
|
||||||
|
|
||||||
|
TreeStore<ModelData> store = new TreeStore<ModelData>();
|
||||||
|
store.add(model.getChildren(), true);
|
||||||
|
|
||||||
|
ColumnConfig name = new ColumnConfig("name", "Name", 100);
|
||||||
|
name.setRenderer(new WidgetTreeGridCellRenderer<ModelData>(){
|
||||||
|
@Override
|
||||||
|
public Widget getWidget(ModelData model, String property, ColumnData config, int rowIndex, int colIndex,
|
||||||
|
ListStore<ModelData> store, Grid<ModelData> grid) {
|
||||||
|
|
||||||
|
if (model.get("type").equals("music")) {
|
||||||
|
VerticalPanel lc = new VerticalPanel();
|
||||||
|
lc.setSize(200, 100);
|
||||||
|
lc.setBorders(true);
|
||||||
|
lc.add(new Button("ciao"));
|
||||||
|
lc.add(new Button("ciao2"));
|
||||||
|
lc.add(new Button("ciao3"));
|
||||||
|
|
||||||
|
return lc;
|
||||||
|
} else {
|
||||||
|
Button b = new Button((String)model.get(property));
|
||||||
|
b.setToolTip("Click for more information");
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ColumnConfig date = new ColumnConfig("author", "Author", 100);
|
||||||
|
ColumnConfig size = new ColumnConfig("genre", "Genre", 100);
|
||||||
|
ColumnModel cm = new ColumnModel(Arrays.asList(name, date, size));
|
||||||
|
|
||||||
|
ContentPanel cp = new ContentPanel();
|
||||||
|
cp.setBodyBorder(false);
|
||||||
|
cp.setHeading("Widget Renderer TreeGrid");
|
||||||
|
cp.setButtonAlign(HorizontalAlignment.CENTER);
|
||||||
|
cp.setLayout(new FitLayout());
|
||||||
|
cp.setFrame(true);
|
||||||
|
cp.setSize(600, 300);
|
||||||
|
|
||||||
|
final TreeGrid<ModelData> tree = new TreeGrid<ModelData>(store, cm);
|
||||||
|
tree.setBorders(true);
|
||||||
|
tree.setSize(400, 400);
|
||||||
|
tree.setAutoExpandColumn("name");
|
||||||
|
tree.getTreeView().setRowHeight(26);
|
||||||
|
tree.getStyle().setLeafIcon(IconHelper.createStyle("icon-music"));
|
||||||
|
cp.add(tree);
|
||||||
|
|
||||||
|
|
||||||
|
add(cp);
|
||||||
|
add(new Button("dfg", new SelectionListener<ButtonEvent>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void componentSelected(ButtonEvent ce) {
|
||||||
|
tree.getTreeView().getRow(1).getStyle().setHeight(200, Unit.PX);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private LayerFolder getTreeModel() {
|
||||||
|
LayerFolder[] folders = new LayerFolder[] {
|
||||||
|
new LayerFolder("Beethoven", new Music[] {
|
||||||
|
new Music("Six String Quartets", "Beethoven", "Quartets"),
|
||||||
|
}),
|
||||||
|
new LayerFolder("Brahms", new Music[] {
|
||||||
|
new Music("Violin Concerto", "Brahms", "Concertos"),
|
||||||
|
}),
|
||||||
|
new LayerFolder("Mozart", new Music[] {
|
||||||
|
new Music("Piano Concerto No. 12", "Mozart", "Concertos"),
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
LayerFolder root = new LayerFolder("root");
|
||||||
|
for (int i = 0; i < folders.length; i++) {
|
||||||
|
root.add((LayerFolder) folders[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private class LayerFolder extends BaseTreeModel {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public LayerFolder(String name) {
|
||||||
|
set("name", name);
|
||||||
|
set("type", "layer");
|
||||||
|
}
|
||||||
|
|
||||||
|
public LayerFolder(String name, BaseTreeModel[] children) {
|
||||||
|
this(name);
|
||||||
|
for (BaseTreeModel baseTreeModel : children)
|
||||||
|
add(baseTreeModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return get("name");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Music extends BaseTreeModel {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public Music(String name, String author, String genre) {
|
||||||
|
set("name", name);
|
||||||
|
set("author", author);
|
||||||
|
set("genre", genre);
|
||||||
|
set("type", "music");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return (String) get("name");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
{
|
||||||
|
"type": "FeatureCollection",
|
||||||
|
"features": [{
|
||||||
|
"type": "Feature",
|
||||||
|
"id": "lamarsipuscarlsbergi20120619071303812.fid-2a43039e_1386c07be0c_-3894",
|
||||||
|
"geometry": {
|
||||||
|
"type": "MultiPolygon",
|
||||||
|
"coordinates": [
|
||||||
|
[
|
||||||
|
[
|
||||||
|
[-13, 125.5],
|
||||||
|
[-13, 125.00000000000011],
|
||||||
|
[-12.5, 125.00000000000011],
|
||||||
|
[-12.5, 125.5],
|
||||||
|
[-13, 125.5]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"geometry_name": "the_geom",
|
||||||
|
"properties": {
|
||||||
|
"gid": 44883,
|
||||||
|
"csquarecode": "3112:225:3",
|
||||||
|
"probability": 1
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"type": "Feature",
|
||||||
|
"id": "lamarsipuscarlsbergi20120619071303812.fid-2a43039e_1386c07be0c_-3893",
|
||||||
|
"geometry": {
|
||||||
|
"type": "MultiPolygon",
|
||||||
|
"coordinates": [
|
||||||
|
[
|
||||||
|
[
|
||||||
|
[-10.499999999999943, 129.5000000000001],
|
||||||
|
[-10.499999999999943, 129],
|
||||||
|
[-9.999999999999943, 129],
|
||||||
|
[-9.999999999999943, 129.5000000000001],
|
||||||
|
[-10.499999999999943, 129.5000000000001]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"geometry_name": "the_geom",
|
||||||
|
"properties": {
|
||||||
|
"gid": 44857,
|
||||||
|
"csquarecode": "3112:209:1",
|
||||||
|
"probability": 1
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"type": "Feature",
|
||||||
|
"id": "lamarsipuscarlsbergi20120619071303812.fid-2a43039e_1386c07be0c_-3892",
|
||||||
|
"geometry": {
|
||||||
|
"type": "MultiPolygon",
|
||||||
|
"coordinates": [
|
||||||
|
[
|
||||||
|
[
|
||||||
|
[-11, 127.00000000000011],
|
||||||
|
[-11, 126.5],
|
||||||
|
[-10.499999999999943, 126.5],
|
||||||
|
[-10.499999999999943, 127.00000000000011],
|
||||||
|
[-11, 127.00000000000011]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"geometry_name": "the_geom",
|
||||||
|
"properties": {
|
||||||
|
"gid": 44848,
|
||||||
|
"csquarecode": "3112:206:4",
|
||||||
|
"probability": 1
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
Loading…
Reference in New Issue