use of org.zkoss.zk.ui.Component in project spatial-portal by AtlasOfLivingAustralia.
the class MapComposer method onActivateLink.
public void onActivateLink(ForwardEvent event) {
Component component = event.getOrigin().getTarget();
Object oLink = component.getAttribute("link");
if (oLink instanceof String) {
String uri = (String) oLink;
String label = (String) component.getAttribute("label");
this.activateLink(uri, label, false);
}
}
use of org.zkoss.zk.ui.Component in project spatial-portal by AtlasOfLivingAustralia.
the class PhylogeneticDiversityComposer 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);
}
}
}
//add all areas from a selection
if (autoCompleteLayerSelection != null && cAreasFromLayer.isChecked()) {
if (autoCompleteLayerAreas == null) {
String fieldId = CommonData.getLayerFacetNameDefault(autoCompleteLayerSelection);
JSONParser jp = new JSONParser();
JSONObject objJson = null;
try {
objJson = (JSONObject) jp.parse(Util.readUrl(CommonData.getLayersServer() + "/field/" + fieldId));
} catch (ParseException e) {
LOGGER.error("failed to parse for: " + fieldId);
}
JSONArray objects = (JSONArray) objJson.get("objects");
autoCompleteLayerAreas = new ArrayList();
for (int i = 0; i < objects.size(); i++) {
MapLayer ml = createMapLayerForObject((JSONObject) objects.get(i));
SelectedArea sa = new SelectedArea(ml, null);
autoCompleteLayerAreas.add(sa);
}
}
selectedAreas.addAll(autoCompleteLayerAreas);
}
return selectedAreas;
}
use of org.zkoss.zk.ui.Component in project spatial-portal by AtlasOfLivingAustralia.
the class UploadSpeciesController method afterCompose.
@Override
public void afterCompose() {
super.afterCompose();
setTbInstructions("3. Select file (text file, one LSID or name per line)");
Map m = Executions.getCurrent().getArg();
if (m != null) {
for (Object o : m.entrySet()) {
if (((Map.Entry) o).getKey() instanceof String && "setTbInstructions".equals(((Map.Entry) o).getKey())) {
setTbInstructions((String) ((Map.Entry) o).getValue());
}
if (((Map.Entry) o).getKey() instanceof String && "addToMap".equals(((Map.Entry) o).getKey())) {
addToMap = true;
}
}
}
tbName.setConstraint(new Constraint() {
@Override
public void validate(Component comp, Object value) {
String val = (String) value;
Map htUserSpecies = (Map) getMapComposer().getSession().getAttribute(StringConstants.USERPOINTS);
if (htUserSpecies != null && !htUserSpecies.isEmpty()) {
for (Object o : htUserSpecies.values()) {
if (((UserDataDTO) o).getName().equalsIgnoreCase(val.trim())) {
throw new WrongValueException(comp, "User dataset named '" + val + "' already exists. Please enter another name for your dataset.");
}
}
}
}
});
fileUpload.addEventListener("onUpload", new EventListener() {
public void onEvent(Event event) throws Exception {
UserDataDTO ud = new UserDataDTO(tbName.getValue(), tbDesc.getValue(), "points");
addToMap = true;
defineArea = true;
doFileUpload(ud, event);
onClick$btnCancel(null);
}
});
}
use of org.zkoss.zk.ui.Component in project spatial-portal by AtlasOfLivingAustralia.
the class AreaToolComposer method afterCompose.
@Override
public void afterCompose() {
super.afterCompose();
Component parent = this.getParent();
winProps = Executions.getCurrent().getArg();
if (StringConstants.ADDTOOLWINDOW.equals(parent.getId())) {
analysisParent = (ToolComposer) this.getParent();
isAnalysisChild = true;
} else if (StringConstants.ADDFACETWINDOW.equals(parent.getId())) {
facetParent = (AddFacetController) this.getParent();
isFacetChild = true;
} else {
isAnalysisChild = false;
isFacetChild = false;
}
}
use of org.zkoss.zk.ui.Component in project spatial-portal by AtlasOfLivingAustralia.
the class LayerLegendGeneralComposer method onClick$btnPopupLegend.
public void onClick$btnPopupLegend(Event event) {
//return if already open
List<Component> list = getRoot().getChildren();
for (Component c : getRoot().getChildren()) {
if (c instanceof Popup) {
Image img = (Image) ((Popup) c).getFellowIfAny("img", true);
if (img != null && img.getSrc().equalsIgnoreCase(mapLayer.getCurrentLegendUri())) {
return;
}
}
}
Popup layerWindow = (Popup) Executions.createComponents("WEB-INF/zul/legend/Popup.zul", getRoot(), null);
try {
layerWindow.doOverlapped();
layerWindow.setPosition("right,center");
layerWindow.init(mapLayer.getDisplayName(), mapLayer.getCurrentLegendUri());
} catch (Exception e) {
LOGGER.error("failed to open popup layer legend", e);
}
}
Aggregations