Search in sources :

Example 1 with Component

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");
    }
}
Also used : MapComposer(au.org.emii.portal.composer.MapComposer) MapLayer(au.org.emii.portal.menu.MapLayer) Listitem(org.zkoss.zul.Listitem) Component(org.zkoss.zk.ui.Component)

Example 2 with Component

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");
    }
}
Also used : MapComposer(au.org.emii.portal.composer.MapComposer) MapLayer(au.org.emii.portal.menu.MapLayer) Listitem(org.zkoss.zul.Listitem) Component(org.zkoss.zk.ui.Component)

Example 3 with Component

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;
}
Also used : Checkbox(org.zkoss.zul.Checkbox) SelectedArea(au.org.emii.portal.menu.SelectedArea) MapLayer(au.org.emii.portal.menu.MapLayer) Component(org.zkoss.zk.ui.Component) Vbox(org.zkoss.zul.Vbox) ParseException(org.json.simple.parser.ParseException)

Example 4 with Component

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);
}
Also used : HashMap(java.util.HashMap) JSONArray(org.json.simple.JSONArray) JSONObject(org.json.simple.JSONObject) Event(org.zkoss.zk.ui.event.Event) JSONParser(org.json.simple.parser.JSONParser) JSONObject(org.json.simple.JSONObject) ParseException(org.json.simple.parser.ParseException) EventListener(org.zkoss.zk.ui.event.EventListener) Component(org.zkoss.zk.ui.Component) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with Component

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