Search in sources :

Example 36 with Component

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);
    }
}
Also used : JSONObject(org.json.simple.JSONObject) LegendObject(au.org.ala.legend.LegendObject) SpeciesAutoCompleteComponent(au.org.ala.spatial.composer.species.SpeciesAutoCompleteComponent) Component(org.zkoss.zk.ui.Component)

Example 37 with Component

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;
}
Also used : SelectedArea(au.org.emii.portal.menu.SelectedArea) MapLayer(au.org.emii.portal.menu.MapLayer) ArrayList(java.util.ArrayList) JSONArray(org.json.simple.JSONArray) ParseException(org.json.simple.parser.ParseException) JSONObject(org.json.simple.JSONObject) JSONParser(org.json.simple.parser.JSONParser) ParseException(org.json.simple.parser.ParseException) Component(org.zkoss.zk.ui.Component)

Example 38 with Component

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);
        }
    });
}
Also used : Event(org.zkoss.zk.ui.event.Event) ForwardEvent(org.zkoss.zk.ui.event.ForwardEvent) UploadEvent(org.zkoss.zk.ui.event.UploadEvent) JSONObject(org.json.simple.JSONObject) UserDataDTO(au.org.ala.spatial.dto.UserDataDTO) EventListener(org.zkoss.zk.ui.event.EventListener) Component(org.zkoss.zk.ui.Component) Map(java.util.Map) WrongValueException(org.zkoss.zk.ui.WrongValueException) WrongValueException(org.zkoss.zk.ui.WrongValueException)

Example 39 with Component

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;
    }
}
Also used : AddFacetController(au.org.ala.spatial.composer.add.AddFacetController) Component(org.zkoss.zk.ui.Component)

Example 40 with Component

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);
    }
}
Also used : Component(org.zkoss.zk.ui.Component) Image(org.zkoss.zul.Image) ParseException(org.json.simple.parser.ParseException)

Aggregations

Component (org.zkoss.zk.ui.Component)70 IOException (java.io.IOException)8 HtmlBasedComponent (org.zkoss.zk.ui.HtmlBasedComponent)8 Checkbox (org.adempiere.webui.component.Checkbox)7 ToolBarButton (org.adempiere.webui.component.ToolBarButton)7 Div (org.zkoss.zul.Div)7 Listitem (org.zkoss.zul.Listitem)7 MapLayer (au.org.emii.portal.menu.MapLayer)6 Button (org.adempiere.webui.component.Button)6 Tabpanel (org.adempiere.webui.component.Tabpanel)6 WEditor (org.adempiere.webui.editor.WEditor)6 ParseException (org.json.simple.parser.ParseException)6 Event (org.zkoss.zk.ui.event.Event)6 MapComposer (au.org.emii.portal.composer.MapComposer)5 PreparedStatement (java.sql.PreparedStatement)5 ResultSet (java.sql.ResultSet)5 DashboardPanel (org.adempiere.webui.dashboard.DashboardPanel)5 HeaderPanel (org.adempiere.webui.panel.HeaderPanel)5 SidePanel (org.adempiere.webui.panel.SidePanel)5 UiException (org.zkoss.zk.ui.UiException)5