Search in sources :

Example 26 with EventListener

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

the class ToolComposer method showExportSpeciesListDialog.

/**
     * Shows a "create species list" dialog for the supplied list box
     *
     * @param lb
     */
private void showExportSpeciesListDialog(Listbox lb) {
    String values = getScientificName(lb);
    LOGGER.debug("Creating species list with " + values);
    if (values.length() > 0) {
        UploadToSpeciesListController dialog = (UploadToSpeciesListController) Executions.createComponents("WEB-INF/zul/input/UploadToSpeciesList.zul", this, null);
        dialog.setSpecies(values);
        dialog.setCallback(new EventListener() {

            @Override
            public void onEvent(Event event) throws Exception {
                updateSpeciesListMessage((String) event.getData());
            }
        });
        try {
            dialog.setParent(this);
            dialog.doModal();
        } catch (Exception e) {
            LOGGER.error("Unable to export assemblage", e);
        }
    }
}
Also used : UploadToSpeciesListController(au.org.ala.spatial.composer.input.UploadToSpeciesListController) EventListener(org.zkoss.zk.ui.event.EventListener) IOException(java.io.IOException)

Example 27 with EventListener

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

the class ExternalContentComposer method doModal.

@Override
public void doModal() {
    super.doModal();
    this.getFellow("hide").addEventListener(StringConstants.ONCLICK, new EventListener() {

        public void onEvent(Event event) throws Exception {
            close();
        }
    });
    this.getFellow(StringConstants.RESET).addEventListener(StringConstants.ONCLICK, new EventListener() {

        public void onEvent(Event event) throws Exception {
            Events.echoEvent(StringConstants.SET_SRC, event.getTarget().getParent().getParent(), null);
        }
    });
    this.getFellow(StringConstants.BREAKOUT).addEventListener(StringConstants.ONCLICK, new EventListener() {

        public void onEvent(Event event) throws Exception {
            close();
        }
    });
}
Also used : Event(org.zkoss.zk.ui.event.Event) EventListener(org.zkoss.zk.ui.event.EventListener)

Example 28 with EventListener

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

the class SpeciesListListbox method init.

public void init() {
    setItemRenderer(new ListitemRenderer() {

        @Override
        public void render(Listitem li, Object data, int itemIdx) {
            if (data == null) {
                return;
            }
            final SpeciesListDTO item = (SpeciesListDTO) data;
            li.setValue(item);
            // add a button to select the species list for the assemblage
            Listcell lc = new Listcell();
            Checkbox c = new Checkbox();
            c.setChecked(selectedLists.contains(item.getDataResourceUid()));
            c.addEventListener(StringConstants.ONCLICK, new EventListener() {

                @Override
                public void onEvent(Event event) throws Exception {
                    Checkbox c = (Checkbox) event.getTarget();
                    if (c.isChecked()) {
                        selectedLists.add(item.getDataResourceUid());
                    } else {
                        selectedLists.remove(item.getDataResourceUid());
                    }
                    if (selectedLists.size() <= 1) {
                        //need to fire a refresh to the parent components
                        postCheckBoxStatusChanged();
                    }
                }
            });
            c.setParent(lc);
            lc.setParent(li);
            Listcell name = new Listcell();
            name.setSclass("list-a");
            A a = new A(item.getListName());
            a.setHref(CommonData.getSpeciesListServer() + "/speciesListItem/list/" + item.getDataResourceUid());
            a.setTarget(StringConstants.BLANK);
            a.setParent(name);
            name.setParent(li);
            Listcell date = new Listcell(item.getDateCreated());
            date.setParent(li);
            String sowner = item.getFullName() != null ? item.getFullName() : item.getFirstName() + " " + item.getSurname();
            Listcell owner = new Listcell(sowner);
            owner.setParent(li);
            Listcell count = new Listcell(item.getItemCount().toString());
            count.setParent(li);
        }
    });
    //SpeciesListListModel model = new SpeciesListListModel();
    //this.setModel(model);
    String searchTerm = getParent() != null ? ((Textbox) getParent().getFellowIfAny("txtSearchTerm")) != null ? ((Textbox) getParent().getFellowIfAny("txtSearchTerm")).getValue() : null : null;
    MutableInt listCount = new MutableInt();
    currentLists = new ArrayList<SpeciesListDTO>(SpeciesListUtil.getPublicSpeciesLists(Util.getUserEmail(), 0, 1000000, null, null, searchTerm, listCount));
    setModel(new SimpleListModel<Object>(currentLists));
}
Also used : MutableInt(org.apache.commons.lang.mutable.MutableInt) ListDataEvent(org.zkoss.zul.event.ListDataEvent) Event(org.zkoss.zk.ui.event.Event) EventListener(org.zkoss.zk.ui.event.EventListener) SpeciesListDTO(au.org.ala.spatial.dto.SpeciesListDTO)

Example 29 with EventListener

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

the class ToolComposer method addTolMultiple.

private void addTolMultiple(String lsid, String sciname, String family, String kingdom, boolean insertAtBeginning) {
    for (Listitem li : lMultiple.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();
                mSearchSpeciesACComp.getAutoComplete().refresh(sciname);
                mSearchSpeciesACComp.getAutoComplete().open();
                mSearchSpeciesACComp.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, getGeospatialKosher()).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 && !lMultiple.getChildren().isEmpty()) {
        lMultiple.insertBefore(li, lMultiple.getFirstChild());
    } else {
        li.setParent(lMultiple);
    }
}
Also used : EventListener(org.zkoss.zk.ui.event.EventListener) IOException(java.io.IOException)

Example 30 with EventListener

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

the class PointComparison method afterCompose.

@Override
public void afterCompose() {
    super.afterCompose();
    lbPoints.setModel(new SimpleListModel<String[]>(points));
    lbPoints.setItemRenderer(new ListitemRenderer<String[]>() {

        @Override
        public void render(Listitem item, String[] data, int index) throws Exception {
            items.set(index, item);
            Listcell lc = new Listcell(String.valueOf(index + 1));
            lc.setParent(item);
            lc = new Listcell();
            Textbox txt1 = new Textbox(data[0] != null ? data[0] : "");
            lc.setSclass("txtCoordinate");
            txt1.setParent(lc);
            if (index != currentPoint)
                txt1.setDisabled(true);
            lc.setParent(item);
            lc = new Listcell();
            Textbox txt2 = new Textbox(data[1] != null ? data[1] : "");
            lc.setSclass("txtCoordinate");
            txt2.setParent(lc);
            if (index != currentPoint)
                txt2.setDisabled(true);
            lc.setParent(item);
            lc = new Listcell();
            Button b = new Button("edit");
            b.setSclass("btn-mini");
            b.setParent(lc);
            lc.setParent(item);
            b.addEventListener("onClick", new EventListener<Event>() {

                @Override
                public void onEvent(Event event) throws Exception {
                    enablePointClick();
                    disableEdit();
                    ((Textbox) event.getTarget().getParent().getPreviousSibling().getFirstChild()).setDisabled(false);
                    ((Textbox) event.getTarget().getParent().getPreviousSibling().getPreviousSibling().getFirstChild()).setDisabled(false);
                    ((Button) event.getTarget().getParent().getNextSibling().getFirstChild()).setDisabled(false);
                    currentPoint = Integer.parseInt(((Listcell) event.getTarget().getParent().getPreviousSibling().getPreviousSibling().getPreviousSibling()).getLabel());
                    currentPoint--;
                }
            });
            lc = new Listcell();
            b = new Button("save");
            b.setParent(lc);
            b.setSclass("btn-mini");
            lc.setParent(item);
            if (index != currentPoint)
                b.setDisabled(true);
            b.addEventListener("onClick", new EventListener<Event>() {

                @Override
                public void onEvent(Event event) throws Exception {
                    disableEdit();
                    currentPoint = Integer.parseInt(((Listcell) event.getTarget().getParent().getPreviousSibling().getPreviousSibling().getPreviousSibling().getPreviousSibling()).getLabel());
                    currentPoint--;
                    points.get(currentPoint)[1] = ((Textbox) event.getTarget().getParent().getPreviousSibling().getPreviousSibling().getFirstChild()).getValue();
                    points.get(currentPoint)[0] = ((Textbox) event.getTarget().getParent().getPreviousSibling().getPreviousSibling().getPreviousSibling().getFirstChild()).getValue();
                    MapComposer mc = getMapComposer();
                    layerName = mc.getNextAreaLayerName("Point");
                    mc.deactiveLayer(layers.get(currentPoint), true, false);
                    String pointGeom = "POINT(" + points.get(currentPoint)[0] + " " + points.get(currentPoint)[1] + ")";
                    MapLayer mapLayer = mc.addWKTLayer(pointGeom, layerName, "Point");
                    mapLayer.getMapLayerMetadata().setMoreInfo(LayersUtil.getMetadataForWKT(CommonData.lang(StringConstants.METADATA_USER_BOUNDING_BOX), pointGeom));
                    layers.set(currentPoint, mapLayer);
                }
            });
            lc = new Listcell();
            b = new Button("remove");
            b.setParent(lc);
            b.setSclass("btn-mini");
            lc.setParent(item);
            b.addEventListener("onClick", new EventListener<Event>() {

                @Override
                public void onEvent(Event event) throws Exception {
                    int point = Integer.parseInt(((Listcell) event.getTarget().getParent().getPreviousSibling().getPreviousSibling().getPreviousSibling().getPreviousSibling().getPreviousSibling()).getLabel());
                    ;
                    point--;
                    getMapComposer().deactiveLayer(layers.get(point), true, false);
                    if (currentPoint == point) {
                        currentPoint = -1;
                    }
                    points.remove(point);
                    layers.remove(point);
                    items.remove(point);
                    lbPoints.setModel(new SimpleListModel<Object>(points));
                }
            });
        }
    });
    lbResults.setItemRenderer(new ListitemRenderer<String[]>() {

        @Override
        public void render(Listitem item, String[] data, int index) throws Exception {
            for (int i = 0; i < data.length; i++) {
                Listcell lc = new Listcell(data[i]);
                lc.setParent(item);
            }
        }
    });
}
Also used : MapLayer(au.org.emii.portal.menu.MapLayer) MapComposer(au.org.emii.portal.composer.MapComposer) Event(org.zkoss.zk.ui.event.Event) JSONObject(org.json.simple.JSONObject) EventListener(org.zkoss.zk.ui.event.EventListener)

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