Search in sources :

Example 1 with Category

use of org.talend.designer.components.exchange.model.Category in project tdi-studio-se by Talend.

the class ExchangeWebService method searchCategoryExtensionJSONArray.

/**
     * 
     * DOC hcyi Comment method "searchCategoryExtensionJSONArray".
     * 
     * @param typeExtension
     * @return
     */
public static List<Category> searchCategoryExtensionJSONArray(String typeExtension) {
    List<Category> fCategorys = new ArrayList<Category>();
    JSONObject tokenMessage = new JSONObject();
    try {
        tokenMessage.put("typeExtension", typeExtension);
        JSONObject token = new us.monoid.json.JSONObject();
        token.put("extension", tokenMessage);
        String u = exchangeWSServer + "listCategoryExtension.php?data=" + token;
        JSONObject resultObj = readJsonFromUrl(u);
        if (resultObj != null) {
            JSONObject p = (JSONObject) resultObj.get("listCategory");
            JSONArray resultArry = p.getJSONArray("category");
            if (resultArry != null) {
                for (int i = 0; i < resultArry.length(); i++) {
                    JSONObject extensionObj = resultArry.getJSONObject(i);
                    if (extensionObj != null) {
                        Category fCategory = ExchangeFactory.eINSTANCE.createCategory();
                        fCategory.setCategoryId(extensionObj.getString("id_category"));
                        fCategory.setCategoryName(extensionObj.getString("name"));
                        fCategorys.add(fCategory);
                    }
                }
            }
        }
    } catch (JSONException e) {
    //
    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return fCategorys;
}
Also used : Category(org.talend.designer.components.exchange.model.Category) JSONObject(us.monoid.json.JSONObject) ArrayList(java.util.ArrayList) JSONArray(us.monoid.json.JSONArray) JSONException(us.monoid.json.JSONException) IOException(java.io.IOException) JSONException(us.monoid.json.JSONException) IOException(java.io.IOException)

Example 2 with Category

use of org.talend.designer.components.exchange.model.Category in project tdi-studio-se by Talend.

the class ImportCompatibleEcoComponentsComposite method initCategoryCombo.

public void initCategoryCombo() {
    if (categoryCombo.getItemCount() > 0) {
        return;
    }
    Iterator<Category> cListIterator = fCategorys.iterator();
    while (cListIterator.hasNext()) {
        Category category = cListIterator.next();
        // now hide the Category : Component ,Hadoop Configuration
        if ("Component".equals(category.getCategoryName()) || "Hadoop Configuration".equals(category.getCategoryName())) {
            cListIterator.remove();
            continue;
        }
        categoryCombo.add(category.getCategoryName());
    }
    categoryCombo.select(0);
    categoryCombo.pack();
}
Also used : Category(org.talend.designer.components.exchange.model.Category)

Aggregations

Category (org.talend.designer.components.exchange.model.Category)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 JSONArray (us.monoid.json.JSONArray)1 JSONException (us.monoid.json.JSONException)1 JSONObject (us.monoid.json.JSONObject)1