Search in sources :

Example 6 with EventListener

use of org.zkoss.zk.ui.event.EventListener in project spatial-portal by AtlasOfLivingAustralia.

the class AreaUploadShapefile method afterCompose.

@Override
public void afterCompose() {
    super.afterCompose();
    txtLayerName.setValue(getMapComposer().getNextAreaLayerName(CommonData.lang(StringConstants.DEFAULT_AREA_LAYER_NAME)));
    fileUpload.addEventListener("onUpload", new EventListener() {

        public void onEvent(Event event) throws Exception {
            onClick$btnOk(event);
        }
    });
}
Also used : Event(org.zkoss.zk.ui.event.Event) ForwardEvent(org.zkoss.zk.ui.event.ForwardEvent) UploadEvent(org.zkoss.zk.ui.event.UploadEvent) EventListener(org.zkoss.zk.ui.event.EventListener) ParseException(com.vividsolutions.jts.io.ParseException) SuspendNotAllowedException(org.zkoss.zk.ui.SuspendNotAllowedException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException)

Example 7 with EventListener

use of org.zkoss.zk.ui.event.EventListener in project spatial-portal by AtlasOfLivingAustralia.

the class ToolComposer method onClick$bSpeciesListUpload.

public void onClick$bSpeciesListUpload(Event event) {
    UploadLayerListController window = (UploadLayerListController) Executions.createComponents("WEB-INF/zul/input/UploadSpeciesList.zul", this, null);
    window.setCallback(new EventListener() {

        @Override
        public void onEvent(Event event) throws Exception {
            importList((String) event.getData());
            //enable btnOk
            btnOk.setAutodisable("");
            btnOk.setDisabled(false);
        }
    });
    try {
        window.setParent(this);
        window.doModal();
    } catch (Exception e) {
        LOGGER.error("error opening UploadSpeciesList.zul", e);
    }
}
Also used : UploadLayerListController(au.org.ala.spatial.composer.input.UploadLayerListController) EventListener(org.zkoss.zk.ui.event.EventListener) IOException(java.io.IOException)

Example 8 with EventListener

use of org.zkoss.zk.ui.event.EventListener in project spatial-portal by AtlasOfLivingAustralia.

the class TabulationComposer method afterCompose.

@Override
public void afterCompose() {
    super.afterCompose();
    this.selectedMethod = StringConstants.TABULATION;
    this.totalSteps = 1;
    this.updateWindowTitle();
    cbTabLayers1.setFocus(true);
    tabLayers = new HashMap<FieldDTO, List<FieldDTO>>();
    tabLayerDisplayNames = new HashMap<String, List<String>>();
    try {
        int i;
        HttpClient client = new HttpClient();
        GetMethod get = new GetMethod(CommonData.getLayersServer() + "/tabulations.json");
        get.addRequestHeader(StringConstants.ACCEPT, StringConstants.APPLICATION_JSON);
        client.executeMethod(get);
        String tlayers = get.getResponseBodyAsString();
        JSONParser jp = new JSONParser();
        JSONObject joTop = (JSONObject) jp.parse(tlayers);
        JSONArray joarr = (JSONArray) joTop.get("tabulations");
        for (i = 0; i < joarr.size(); i++) {
            JSONObject jo = (JSONObject) joarr.get(i);
            FieldDTO f1 = new FieldDTO(jo.get("fid1").toString(), jo.get("name1").toString(), "");
            FieldDTO f2 = new FieldDTO(jo.get("fid2").toString(), jo.get("name2").toString(), "");
            load(f1, f2);
            load(f2, f1);
        }
        Set keySet = (Set) tabLayerDisplayNames.keySet();
        List keyList = new ArrayList(keySet);
        Collections.sort(keyList);
        LOGGER.debug("keyList1=" + keyList);
        for (int j = 0; j < keyList.size(); j++) {
            String temp = (String) keyList.get(j);
            LOGGER.debug("temp=" + temp);
            Comboitem ci = new Comboitem(temp);
            ci.setValue(temp);
            ci.setParent(cbTabLayers1);
        }
        cbTabLayers1.addEventListener("onChange", new EventListener() {

            public void onEvent(Event event) throws Exception {
                onChange$cbTabLayer1(event);
            }
        });
        cbTabLayers1.setSelectedIndex(0);
        onChange$cbTabLayer1(null);
        cbTabLayers2.setSelectedIndex(0);
        cbTabType.setSelectedIndex(0);
    } catch (Exception e) {
        LOGGER.debug("Unable to call tabulation service for a list of layers", e);
    }
}
Also used : JSONArray(org.json.simple.JSONArray) JSONObject(org.json.simple.JSONObject) HttpClient(org.apache.commons.httpclient.HttpClient) GetMethod(org.apache.commons.httpclient.methods.GetMethod) Event(org.zkoss.zk.ui.event.Event) JSONParser(org.json.simple.parser.JSONParser) Comboitem(org.zkoss.zul.Comboitem) EventListener(org.zkoss.zk.ui.event.EventListener) FieldDTO(au.org.ala.spatial.dto.FieldDTO)

Example 9 with EventListener

use of org.zkoss.zk.ui.event.EventListener in project spatial-portal by AtlasOfLivingAustralia.

the class ToolComposer method addTolMultipleBk.

private void addTolMultipleBk(String lsid, String sciname, String family, String kingdom, boolean insertAtBeginning) {
    for (Listitem li : lMultipleBk.getItems()) {
        Listcell lsidCell = (Listcell) li.getLastChild();
        Listcell scinameCell = (Listcell) li.getFirstChild().getNextSibling();
        if ((lsidCell.getLabel().equals(lsid)) || (scinameCell.getLabel().replace("(not found)", "").trim().equals(sciname))) {
            return;
        }
    }
    Listitem li = new Listitem();
    // remove button
    Listcell lc = new Listcell("x");
    lc.setSclass("xRemove");
    lc.addEventListener(StringConstants.ONCLICK, new EventListener() {

        @Override
        public void onEvent(Event event) throws Exception {
            Listitem li = (Listitem) event.getTarget().getParent();
            li.detach();
            toggles();
        }
    });
    lc.setParent(li);
    // sci name
    if (lsid == null) {
        lc = new Listcell(sciname + " (not found)");
        lc.setSclass("notFoundSciname");
    } else {
        lc = new Listcell(sciname);
    }
    lc.setParent(li);
    // family
    if (lsid == null) {
        lc = new Listcell("click to search");
        lc.setSclass("notFoundFamily");
        lc.addEventListener(StringConstants.ONCLICK, new EventListener() {

            @Override
            public void onEvent(Event event) throws Exception {
                Listitem li = (Listitem) event.getTarget().getParent();
                Listcell scinameCell = (Listcell) li.getFirstChild().getNextSibling();
                String sciname = scinameCell.getLabel().replace("(not found)", "").trim();
                mSearchSpeciesACCompBk.getAutoComplete().refresh(sciname);
                mSearchSpeciesACCompBk.getAutoComplete().open();
                mSearchSpeciesACCompBk.getAutoComplete().setText(sciname + " ");
                li.detach();
                toggles();
            }
        });
    } else {
        lc = new Listcell(family);
    }
    lc.setParent(li);
    // kingdom
    lc = new Listcell(kingdom);
    lc.setParent(li);
    // count
    if (lsid != null) {
        int count = new BiocacheQuery(lsid, null, null, null, false, getGeospatialKosherBk()).getOccurrenceCount();
        if (count > 0) {
            lc = new Listcell(String.valueOf(count));
        } else {
            lc = new Listcell(kingdom);
        }
    } else {
        lc = new Listcell(kingdom);
    }
    lc.setParent(li);
    // lsid
    lc = new Listcell(lsid);
    lc.setParent(li);
    if (insertAtBeginning && !lMultipleBk.getChildren().isEmpty()) {
        lMultipleBk.insertBefore(li, lMultipleBk.getFirstChild());
    } else {
        li.setParent(lMultipleBk);
    }
}
Also used : EventListener(org.zkoss.zk.ui.event.EventListener) IOException(java.io.IOException)

Example 10 with EventListener

use of org.zkoss.zk.ui.event.EventListener in project spatial-portal by AtlasOfLivingAustralia.

the class ToolComposer method addToMpLayers.

void addToMpLayers(MapLayer ml, boolean analysis) {
    // get layer name
    String name = null;
    String url = ml.getUri();
    if (analysis) {
        name = ml.getName();
    } else {
        int p1 = url.indexOf("&style=") + 7;
        int p2 = url.indexOf("_style", p1);
        if (p1 > 4) {
            if (p2 < 0) {
                p2 = url.length();
            }
            name = url.substring(p1, p2);
        }
    }
    // cbLayer1
    Menuitem mi = new Menuitem(ml.getDisplayName());
    mi.setValue(name);
    mi.addEventListener(StringConstants.ONCLICK, new EventListener() {

        public void onEvent(Event event) {
            Menuitem mi = (Menuitem) event.getTarget();
            String displayname = ((JSONObject) CommonData.getLayer(mi.getValue()).get("layer")).get("displayname").toString();
            cbLayer1.setValue(displayname + " ");
            cbLayer1.refresh(displayname);
            for (Object o : cbLayer1.getItems()) {
                Comboitem ci = (Comboitem) o;
                JSONObject jo = ci.getValue();
                if (jo.get(StringConstants.NAME).toString().equals(displayname)) {
                    cbLayer1.setSelectedItem(ci);
                    cbLayer1.setText(ci.getLabel());
                    toggles();
                    return;
                }
            }
        }
    });
    mi.setParent(mpLayer1);
    // cbLayer2
    mi = new Menuitem(ml.getDisplayName());
    mi.setValue(name);
    mi.addEventListener(StringConstants.ONCLICK, new EventListener() {

        public void onEvent(Event event) throws Exception {
            Menuitem mi = (Menuitem) event.getTarget();
            String displayname = ((JSONObject) CommonData.getLayer(mi.getValue()).get("layer")).get("displayname").toString();
            cbLayer2.setValue(displayname + " ");
            cbLayer2.refresh(displayname);
            for (Object o : cbLayer2.getItems()) {
                Comboitem ci = (Comboitem) o;
                JSONObject jo = ci.getValue();
                if (jo.get(StringConstants.NAME).equals(displayname)) {
                    cbLayer2.setSelectedItem(ci);
                    cbLayer2.setText(ci.getLabel());
                    toggles();
                    return;
                }
            }
        }
    });
    mi.setParent(mpLayer2);
}
Also used : JSONObject(org.json.simple.JSONObject) JSONObject(org.json.simple.JSONObject) EventListener(org.zkoss.zk.ui.event.EventListener) IOException(java.io.IOException)

Aggregations

EventListener (org.zkoss.zk.ui.event.EventListener)50 Event (org.zkoss.zk.ui.event.Event)42 IOException (java.io.IOException)13 JSONObject (org.json.simple.JSONObject)11 CheckEvent (org.zkoss.zk.ui.event.CheckEvent)7 ForwardEvent (org.zkoss.zk.ui.event.ForwardEvent)7 LegendObject (au.org.ala.legend.LegendObject)5 Component (org.zkoss.zk.ui.Component)5 MapLayer (au.org.emii.portal.menu.MapLayer)4 SQLException (java.sql.SQLException)4 ValueChangeEvent (org.adempiere.exceptions.ValueChangeEvent)4 JSONArray (org.json.simple.JSONArray)4 Div (org.zkoss.zul.Div)4 DashboardPanel (org.adempiere.webui.dashboard.DashboardPanel)3 HeaderPanel (org.adempiere.webui.panel.HeaderPanel)3 SidePanel (org.adempiere.webui.panel.SidePanel)3 JSONParser (org.json.simple.parser.JSONParser)3 ParseException (org.json.simple.parser.ParseException)3 OpenEvent (org.zkoss.zk.ui.event.OpenEvent)3 Center (org.zkoss.zul.Center)3