Search in sources :

Example 6 with Checkbox

use of org.zkoss.zul.Checkbox in project spatial-portal by AtlasOfLivingAustralia.

the class MapComposer method setLayersVisible.

public void setLayersVisible(boolean show) {
    PortalSession portalSession = (PortalSession) Executions.getCurrent().getDesktop().getSession().getAttribute(StringConstants.PORTAL_SESSION);
    for (Listitem li : activeLayersList.getItems()) {
        if (li.getValue() == null || !"Map options".equals(((MapLayer) li.getValue()).getName())) {
            Checkbox cb = (Checkbox) li.getFirstChild().getFirstChild();
            if (show && !cb.isChecked()) {
                openLayersJavascript.execute(openLayersJavascript.getIFrameReferences() + openLayersJavascript.activateMapLayer((MapLayer) li.getValue(), false, true) + openLayersJavascript.updateMapLayerIndexes(portalSession.getActiveLayers()));
            } else if (!show && cb.isChecked()) {
                openLayersJavascript.removeMapLayerNow((MapLayer) li.getValue());
            }
            cb.setChecked(show);
            cb.setTooltiptext(show ? "Hide" : "Show");
        }
    }
    refreshContextualMenu();
}
Also used : Checkbox(org.zkoss.zul.Checkbox) PortalSession(au.org.emii.portal.session.PortalSession) HasMapLayer(au.org.emii.portal.menu.HasMapLayer) MapLayer(au.org.emii.portal.menu.MapLayer)

Example 7 with Checkbox

use of org.zkoss.zul.Checkbox in project spatial-portal by AtlasOfLivingAustralia.

the class AreaMerge method afterCompose.

@Override
public void afterCompose() {
    super.afterCompose();
    btnOk.setDisabled(false);
    txtLayerName.setValue(getMapComposer().getNextAreaLayerName(CommonData.lang(StringConstants.DEFAULT_AREA_LAYER_NAME)));
    List<MapLayer> layers = getMapComposer().getPolygonLayers();
    for (int i = 0; i < layers.size(); i++) {
        //must be non-envelope or "cl" layer-field that is not
        // 'grid as contextual'
        MapLayer ml = layers.get(i);
        boolean isGrid = false;
        if (ml.getFacets() != null && ml.testWKT() != null && ml.getWKT().startsWith(StringConstants.ENVELOPE)) {
            String wkt = ml.getWKT();
            //get fid
            String fid = wkt.substring(9, wkt.indexOf(','));
            if (fid.startsWith("cl")) {
                JSONArray ja = CommonData.getLayerListJSONArray();
                for (int j = 0; j < ja.size() && !isGrid; j++) {
                    JSONObject field = (JSONObject) ja.get(j);
                    JSONObject layer = (JSONObject) field.get("layer");
                    if (field.get(StringConstants.ID).toString().equalsIgnoreCase(fid)) {
                        isGrid = "a".equalsIgnoreCase(field.get(StringConstants.TYPE).toString()) || "b".equalsIgnoreCase(field.get(StringConstants.TYPE).toString());
                    }
                }
            } else {
                isGrid = true;
            }
        }
        if (ml.getFacets() == null || !isGrid) {
            Checkbox cb = new Checkbox();
            cb.setLabel(layers.get(i).getDisplayName());
            cb.setValue(layers.get(i));
            cb.setParent(vboxAreas);
        }
    }
}
Also used : JSONObject(org.json.simple.JSONObject) Checkbox(org.zkoss.zul.Checkbox) MapLayer(au.org.emii.portal.menu.MapLayer) JSONArray(org.json.simple.JSONArray)

Example 8 with Checkbox

use of org.zkoss.zul.Checkbox in project spatial-portal by AtlasOfLivingAustralia.

the class AreaMerge method mergeAreas.

void mergeAreas() {
    List<Facet> facets = new ArrayList<Facet>();
    List<Geometry> wkt = new ArrayList<Geometry>();
    WKTReader wktReader = new WKTReader();
    String layerDisplayNames = "";
    for (int i = 0; i < vboxAreas.getChildren().size(); i++) {
        Checkbox cb = (Checkbox) vboxAreas.getChildren().get(i);
        if (cb.isChecked()) {
            MapLayer ml = cb.getValue();
            if (layerDisplayNames.length() > 0) {
                layerDisplayNames += ", ";
            }
            layerDisplayNames += ml.getDisplayName();
            if (ml != null) {
                if (ml.getFacets() != null) {
                    facets.addAll(ml.getFacets());
                }
                try {
                    //get actual WKT when 'envelope' is specified
                    String w = ml.getWKT();
                    if (w.startsWith(StringConstants.ENVELOPE)) {
                        //should only be one pid
                        String pid = w.substring(w.indexOf(',') + 1, w.length() - 1);
                        w = Util.readUrl(CommonData.getLayersServer() + "/shape/wkt/" + pid);
                    }
                    Geometry g = wktReader.read(w);
                    if (g != null) {
                        wkt.add(g);
                    }
                } catch (ParseException e) {
                    LOGGER.error("cannot parse WKT for map layer: " + ml.getDisplayName() + " for WKT: " + ml.getWKT());
                }
            } else {
                String swkt = null;
                if (CommonData.getSettings().getProperty(CommonData.AUSTRALIA_NAME).equalsIgnoreCase(cb.getLabel())) {
                    swkt = CommonData.getSettings().getProperty(CommonData.AUSTRALIA_WKT);
                } else if ("Current Extent".equalsIgnoreCase(cb.getLabel())) {
                    swkt = getMapComposer().getViewArea();
                } else {
                    LOGGER.error("cannot determine what this checked area is: " + cb.getLabel());
                }
                if (swkt != null) {
                    try {
                        Geometry g = wktReader.read(swkt);
                        if (g != null) {
                            wkt.add(g);
                        }
                    } catch (ParseException e) {
                        LOGGER.error("cannot parse WKT for map layer: " + ml.getDisplayName() + " for WKT: " + swkt);
                    }
                }
            }
        }
    }
    //produce single geometry
    Geometry geometry = null;
    if (!wkt.isEmpty()) {
        geometry = wkt.get(0);
        for (int i = 1; i < wkt.size(); i++) {
            geometry = GeometryCombiner.combine(geometry, wkt.get(i));
        }
    }
    String finalWkt = (geometry == null) ? null : geometry.toString();
    MapComposer mc = getMapComposer();
    layerName = (mc.getMapLayer(txtLayerName.getValue()) == null) ? txtLayerName.getValue() : mc.getNextAreaLayerName(txtLayerName.getValue());
    MapLayer mapLayer = mc.addWKTLayer(finalWkt, layerName, txtLayerName.getValue());
    //if possible, use facets instead of WKT with biocache
    if (wkt.size() == facets.size()) {
        //change to a single OR facet.
        //Because all facet areas are single or multiple, ORs just need to OR for joining.
        String fq = facets.get(0).toString();
        for (int i = 1; i < facets.size(); i++) {
            fq += " OR " + facets.get(i).toString();
        }
        List<Facet> array = new ArrayList<Facet>();
        array.add(Facet.parseFacet(fq));
        mapLayer.setFacets(array);
    }
    DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    java.util.Calendar calendar = java.util.Calendar.getInstance();
    calendar.setTimeInMillis(System.currentTimeMillis());
    String metadata = "";
    metadata += "Merged WKT layers\nLayers: " + layerDisplayNames + "\n";
    metadata += "Name: " + layerName + " <br />\n";
    metadata += "Date: " + formatter.format(calendar.getTime()) + " <br />\n";
    mapLayer.getMapLayerMetadata().setMoreInfo(metadata);
    //reapply layer name
    getMapComposer().getMapLayer(layerName).setDisplayName(txtLayerName.getValue());
    getMapComposer().redrawLayersList();
    ok = true;
    this.detach();
}
Also used : MapLayer(au.org.emii.portal.menu.MapLayer) ArrayList(java.util.ArrayList) WKTReader(com.vividsolutions.jts.io.WKTReader) Geometry(com.vividsolutions.jts.geom.Geometry) MapComposer(au.org.emii.portal.composer.MapComposer) Checkbox(org.zkoss.zul.Checkbox) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) ParseException(com.vividsolutions.jts.io.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Facet(au.org.ala.legend.Facet)

Example 9 with Checkbox

use of org.zkoss.zul.Checkbox in project adempiere by adempiere.

the class WDeleteEntity method zkInit.

private void zkInit() throws Exception {
    //Form Init()
    form.appendChild(mainLayout);
    mainLayout.setWidth("100%");
    mainLayout.setHeight("100%");
    clientLabel.setText(Msg.getElement(Env.getCtx(), "AD_Client_ID"));
    tableLabel.setText(Msg.getElement(Env.getCtx(), "AD_Table_ID"));
    dryRun = new Checkbox(Msg.getMsg(Env.getCtx(), "DryRun"));
    dryRun.setChecked(true);
    ConfirmPanel panel = new ConfirmPanel(false, false, false, false, false, false, false);
    bRefresh = panel.createButton(ConfirmPanel.A_REFRESH);
    bRefresh.addActionListener(this);
    //	
    parameterPanel.appendChild(parameterLayout);
    North north = new North();
    north.setStyle("border: none");
    mainLayout.appendChild(north);
    north.appendChild(parameterPanel);
    Rows rows = null;
    Row row = null;
    parameterLayout.setWidth("100%");
    rows = parameterLayout.newRows();
    row = rows.newRow();
    row.appendChild(clientLabel.rightAlign());
    row.appendChild(clientPick);
    row.appendChild(tableLabel.rightAlign());
    row.appendChild(tablePick);
    //	For Button
    row = rows.newRow();
    row.appendChild(new Hbox());
    row.appendChild(dryRun);
    row.appendChild(new Hbox());
    row.appendChild(bRefresh);
    //	
    centerPanel.appendChild(centerLayout);
    centerLayout.setWidth("100%");
    Center center = new Center();
    mainLayout.appendChild(center);
    center.setStyle("border: none");
    center.appendChild(centerPanel);
    tree = new Tree();
    treeCols = new Treecols();
    treeCol = new Treecol("");
    treeCol2 = new Treecol();
    centerPanel.appendChild(tree);
    treeCols.appendChild(treeCol);
    treeCols.appendChild(treeCol2);
    tree.appendChild(treeCols);
    center.setFlex(true);
    center.setAutoscroll(true);
    South south = new South();
    south.appendChild(southPanel);
    southPanel.appendChild(southLayout);
    southPanel.setWidth("100%");
    mainLayout.appendChild(south);
    Rows rows2 = southLayout.newRows();
    Row south_row = rows2.newRow();
    south_row.appendChild(confirmPanel);
    confirmPanel.addActionListener(this);
}
Also used : Treecol(org.zkoss.zul.Treecol) Hbox(org.zkoss.zul.Hbox) Treecols(org.zkoss.zul.Treecols) Center(org.zkoss.zkex.zul.Center) ConfirmPanel(org.adempiere.webui.component.ConfirmPanel) Checkbox(org.zkoss.zul.Checkbox) South(org.zkoss.zkex.zul.South) Tree(org.zkoss.zul.Tree) North(org.zkoss.zkex.zul.North) Row(org.adempiere.webui.component.Row) Rows(org.adempiere.webui.component.Rows)

Example 10 with Checkbox

use of org.zkoss.zul.Checkbox in project adempiere by adempiere.

the class LoginPanel method initComponents.

private void initComponents() {
    lblUserId = new Label();
    lblUserId.setId("lblUserId");
    lblUserId.setValue("User ID");
    lblPassword = new Label();
    lblPassword.setId("lblPassword");
    lblPassword.setValue("Password");
    lblLanguage = new Label();
    lblLanguage.setId("lblLanguage");
    lblLanguage.setValue("Language");
    txtUserId = new Textbox();
    txtUserId.setId("txtUserId");
    //txtUserId.setCols(25);
    txtUserId.setMaxlength(40);
    //txtUserId.setWidth("220px");
    // Elaine 2009/02/06
    txtUserId.addEventListener(Events.ON_CHANGE, this);
    txtPassword = new Textbox();
    txtPassword.setId("txtPassword");
    txtPassword.setType("password");
    //txtPassword.setCols(25);
    //txtPassword.setWidth("220px");
    lstLanguage = new Combobox();
    lstLanguage.setAutocomplete(true);
    lstLanguage.setAutodrop(true);
    lstLanguage.setId("lstLanguage");
    lstLanguage.addEventListener(Events.ON_SELECT, this);
    //lstLanguage.setWidth("220px");
    // Update Language List
    lstLanguage.getItems().clear();
    ArrayList<String> supported = Env.getSupportedLanguages();
    String[] availableLanguages = Language.getNames();
    for (String langName : availableLanguages) {
        Language language = Language.getLanguage(langName);
        if (!language.isBaseLanguage()) {
            if (!supported.contains(language.getAD_Language()))
                continue;
        }
        lstLanguage.appendItem(langName, language.getAD_Language());
    }
    chkRememberMe = new Checkbox(Msg.getMsg(Language.getBaseAD_Language(), "RememberMe"));
    chkRememberMe.setId("chkRememberMe");
    // Make the default language the language of client System
    String defaultLanguage = MClient.get(ctx, 0).getAD_Language();
    for (int i = 0; i < lstLanguage.getItemCount(); i++) {
        Comboitem li = lstLanguage.getItemAtIndex(i);
        if (li.getValue().equals(defaultLanguage)) {
            lstLanguage.setSelectedIndex(i);
            languageChanged(li.getLabel());
            break;
        }
    }
}
Also used : Language(org.compiere.util.Language) Combobox(org.adempiere.webui.component.Combobox) Checkbox(org.zkoss.zul.Checkbox) Label(org.adempiere.webui.component.Label) Textbox(org.adempiere.webui.component.Textbox) Comboitem(org.zkoss.zul.Comboitem)

Aggregations

Checkbox (org.zkoss.zul.Checkbox)10 MapLayer (au.org.emii.portal.menu.MapLayer)5 MapComposer (au.org.emii.portal.composer.MapComposer)2 PortalSession (au.org.emii.portal.session.PortalSession)2 Row (org.adempiere.webui.component.Row)2 Rows (org.adempiere.webui.component.Rows)2 JSONArray (org.json.simple.JSONArray)2 JSONObject (org.json.simple.JSONObject)2 ParseException (org.json.simple.parser.ParseException)2 CheckEvent (org.zkoss.zk.ui.event.CheckEvent)2 Event (org.zkoss.zk.ui.event.Event)2 EventListener (org.zkoss.zk.ui.event.EventListener)2 Tree (org.zkoss.zul.Tree)2 Treecol (org.zkoss.zul.Treecol)2 Treecols (org.zkoss.zul.Treecols)2 Vbox (org.zkoss.zul.Vbox)2 Facet (au.org.ala.legend.Facet)1 HasMapLayer (au.org.emii.portal.menu.HasMapLayer)1 SelectedArea (au.org.emii.portal.menu.SelectedArea)1 BoundingBox (au.org.emii.portal.value.BoundingBox)1