use of org.zkoss.zk.ui.Component in project spatial-portal by AtlasOfLivingAustralia.
the class ActiveLayersRemoveEventListener method onEvent.
@Override
public void onEvent(Event event) throws Exception {
MapComposer mapComposer = getMapComposer(event);
if (mapComposer != null && mapComposer.safeToPerformMapAction()) {
// get reference to the label/image the user clicked on
Component target = event.getTarget();
Listitem listItem = (Listitem) target.getParent().getParent();
MapLayer activeLayer = listItem.getValue();
if (activeLayer != null) {
mapComposer.deactiveLayer(activeLayer, true, false);
}
} else {
LOGGER.debug("MapController reports unsafe to perform action");
}
}
use of org.zkoss.zk.ui.Component in project spatial-portal by AtlasOfLivingAustralia.
the class ActiveLayersZoomExtentEventListener method onEvent.
@Override
public void onEvent(Event event) throws Exception {
MapComposer mapComposer = getMapComposer(event);
if (mapComposer != null && mapComposer.safeToPerformMapAction()) {
// get reference to the label/image the user clicked on
Component target = event.getTarget();
Listitem listItem = (Listitem) target.getParent().getParent();
MapLayer activeLayer = listItem.getValue();
if (activeLayer != null) {
mapComposer.zoomToExtent(activeLayer);
}
} else {
LOGGER.debug("MapController reports unsafe to perform action");
}
}
use of org.zkoss.zk.ui.Component in project spatial-portal by AtlasOfLivingAustralia.
the class InOutComposer method getSelectedAreas.
public List<SelectedArea> getSelectedAreas() {
List<SelectedArea> selectedAreas = new ArrayList<SelectedArea>();
Vbox vboxArea = (Vbox) getFellowIfAny("vboxArea");
for (Component c : vboxArea.getChildren()) {
if ((c instanceof Checkbox) && ((Checkbox) c).isChecked()) {
SelectedArea sa = null;
String area = ((Checkbox) c).getValue();
try {
if (StringConstants.CURRENT.equals(area)) {
sa = new SelectedArea(null, getMapComposer().getViewArea());
} else if (StringConstants.AUSTRALIA.equals(area)) {
sa = new SelectedArea(null, CommonData.getSettings().getProperty(CommonData.AUSTRALIA_WKT));
} else if (StringConstants.WORLD.equals(area)) {
sa = new SelectedArea(null, CommonData.WORLD_WKT);
} else {
List<MapLayer> layers = getMapComposer().getPolygonLayers();
for (MapLayer ml : layers) {
if (area.equals(ml.getName())) {
sa = new SelectedArea(ml, null);
break;
}
}
}
} catch (Exception e) {
LOGGER.warn("Unable to retrieve selected area", e);
}
if (sa != null) {
selectedAreas.add(sa);
}
}
}
return selectedAreas;
}
use of org.zkoss.zk.ui.Component in project spatial-portal by AtlasOfLivingAustralia.
the class PhylogeneticDiversityComposer method fillPDTreeList.
private void fillPDTreeList() {
JSONArray ja = null;
String url = CommonData.getSettings().getProperty(CommonData.PHYLOLIST_URL) + "/phylo/getExpertTrees";
JSONParser jp = new JSONParser();
try {
ja = (JSONArray) jp.parse(Util.readUrl(url));
} catch (ParseException e) {
LOGGER.error("failed to parse getExpertTrees");
}
if (ja == null || ja.size() == 0) {
Events.echoEvent("onClose", this, null);
getMapComposer().showMessage("Phylogenetic diversity tool is currently unavailable.");
return;
}
trees = new Object[ja.size()];
header = new ArrayList<String>();
//restrict header to what is in the zul
for (Component c : getFellow(StringConstants.TREES_HEADER).getChildren()) {
header.add(c.getId().substring(3));
}
int row = 0;
for (int i = 0; i < ja.size(); i++) {
JSONObject j = (JSONObject) ja.get(i);
Map<String, String> pdrow = new HashMap<String, String>();
for (Object o : j.keySet()) {
String key = (String) o;
if (j.containsKey(key) && j.get(key) != null) {
pdrow.put(key, j.get(key).toString());
} else {
pdrow.put(key, null);
}
}
trees[row] = pdrow;
row++;
}
treesList.setModel(new ListModelArray(trees, false));
treesList.setItemRenderer(new ListitemRenderer() {
public void render(Listitem li, Object data, int itemIdx) {
Map<String, String> map = (Map<String, String>) data;
for (int i = 0; i < header.size(); i++) {
String value = map.get(header.get(i));
if (value == null) {
value = "";
}
if ("treeViewUrl".equalsIgnoreCase(header.get(i))) {
Html img = new Html("<i class='icon-info-sign'></i>");
img.setAttribute("link", value.isEmpty() ? CommonData.getSettings().getProperty(CommonData.PHYLOLIST_URL) : value);
Listcell lc = new Listcell();
lc.setParent(li);
img.setParent(lc);
img.addEventListener(StringConstants.ONCLICK, new EventListener() {
@Override
public void onEvent(Event event) throws Exception {
//re-toggle the checked flag
Listitem li = (Listitem) event.getTarget().getParent().getParent();
li.getListbox().toggleItemSelection(li);
String metadata = (String) event.getTarget().getAttribute("link");
getMapComposer().activateLink(metadata, "Metadata", false);
}
});
} else {
Listcell lc = new Listcell(value);
lc.setParent(li);
}
}
}
});
treesList.setMultiple(true);
}
use of org.zkoss.zk.ui.Component in project spatial-portal by AtlasOfLivingAustralia.
the class MapComposer method closeExternalContentWindow.
void closeExternalContentWindow() {
//close any prevously opened externalcontentwindow
try {
Component c = getFellowIfAny("externalContentWindow");
if (c != null) {
LOGGER.debug("found externalContentWindow, closing");
c.detach();
}
} catch (Exception e) {
LOGGER.error("error closing externalContentWindow window", e);
}
}
Aggregations