Search in sources :

Example 1 with Comboitem

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

the class TabulationComposer method onChange$cbTabLayer1.

public void onChange$cbTabLayer1(Event event) {
    String f1DisplayNames = cbTabLayers1.getSelectedItem().getValue();
    List<String> f2DisplayNamess = getFieldDisplayName2(f1DisplayNames);
    if (!cbTabLayers2.getChildren().isEmpty()) {
        cbTabLayers2.getChildren().clear();
    }
    if (f2DisplayNamess != null) {
        for (int i = 0; i < f2DisplayNamess.size(); i++) {
            String f2 = f2DisplayNamess.get(i);
            Comboitem ci = new Comboitem(f2);
            ci.setValue(f2);
            ci.setParent(cbTabLayers2);
        }
        cbTabLayers2.setSelectedIndex(0);
    } else {
        LOGGER.debug("f2DisplayNames == null");
    }
}
Also used : Comboitem(org.zkoss.zul.Comboitem)

Example 2 with Comboitem

use of org.zkoss.zul.Comboitem 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 3 with Comboitem

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

the class WDeleteEntity method loadValues.

// dispose
/**
	 * Clear View
	 */
private void loadValues() {
    //	Client
    Comboitem o = clientPick.getSelectedItem();
    if (o != null) {
        setClientId(((KeyNamePair) o.getValue()).getKey());
    }
    //	Table
    o = tablePick.getSelectedItem();
    if (o != null) {
        setTableId(((KeyNamePair) o.getValue()).getKey());
    }
    //	Dry Run
    setDryRun(dryRun.isChecked());
}
Also used : Comboitem(org.zkoss.zul.Comboitem)

Example 4 with Comboitem

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

the class Combobox method setValue.

/** 
     * Set selected item for the list box based on the value of list item
     * set selected to none if no item found matching the value given or 
     * value is null
     * @param value Value of ListItem to set as selected
     */
public void setValue(Object value) {
    setSelectedItem(null);
    if (value == null) {
        return;
    }
    List<Comboitem> items = getItems();
    for (Comboitem item : items) {
        if (value.getClass() != item.getValue().getClass()) {
            // if the classes of value and item are different convert both to String
            String stringValue = value.toString();
            String stringItem = item.getValue().toString();
            if (stringValue.equals(stringItem)) {
                setSelectedItem(item);
                break;
            }
        } else {
            if (value.equals(item.getValue())) {
                setSelectedItem(item);
                break;
            }
        }
    }
}
Also used : Comboitem(org.zkoss.zul.Comboitem)

Example 5 with Comboitem

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

the class FindWindow method refreshUserQueries.

private void refreshUserQueries() {
    String value = m_sLast;
    if (fQueryName.getItemCount() > 0) {
        // The list is initialized
        value = fQueryName.getValue();
    }
    userQueries = MUserQuery.get(Env.getCtx(), m_AD_Tab_ID);
    fQueryName.getItems().clear();
    boolean selected = false;
    fQueryName.appendItem(m_sNew);
    for (int i = 0; i < userQueries.length; i++) {
        Comboitem ci = fQueryName.appendItem(userQueries[i].getName());
        if (value.equals(userQueries[i].getName())) {
            fQueryName.setSelectedItem(ci);
            parseUserQuery(userQueries[i]);
            selected = true;
        }
    }
    if (!selected) {
        fQueryName.setSelectedIndex(-1);
        fQueryName.setText(m_sTipText);
        createFields();
    }
}
Also used : Comboitem(org.zkoss.zul.Comboitem)

Aggregations

Comboitem (org.zkoss.zul.Comboitem)21 UserPreference (org.adempiere.webui.util.UserPreference)5 Iterator (java.util.Iterator)4 HttpClient (org.apache.commons.httpclient.HttpClient)4 GetMethod (org.apache.commons.httpclient.methods.GetMethod)4 KeyNamePair (org.compiere.util.KeyNamePair)4 JSONArray (org.json.simple.JSONArray)4 JSONObject (org.json.simple.JSONObject)4 JSONParser (org.json.simple.parser.JSONParser)4 ComboItem (org.adempiere.webui.component.ComboItem)3 MapLayer (au.org.emii.portal.menu.MapLayer)2 WrongValueException (org.zkoss.zk.ui.WrongValueException)2 FieldDTO (au.org.ala.spatial.dto.FieldDTO)1 LayerSelection (au.org.ala.spatial.util.LayerSelection)1 ValueChangeEvent (org.adempiere.exceptions.ValueChangeEvent)1 Combobox (org.adempiere.webui.component.Combobox)1 Label (org.adempiere.webui.component.Label)1 Textbox (org.adempiere.webui.component.Textbox)1 Language (org.compiere.util.Language)1 Event (org.zkoss.zk.ui.event.Event)1