示例#1
0
  protected void loadCollection(
      Class typeClass, String name, JaWEComponent controller, Properties properties) {
    String id = ResourceManager.getResourceString(properties, "JaWETypes." + name + ".Id");
    if (id == null) {
      return;
    }
    String dispName = "";
    ImageIcon icon = null;
    Color color = Color.DARK_GRAY;
    try {
      String langDepName =
          ResourceManager.getResourceString(properties, "JaWETypes." + name + ".LangDepName");
      dispName = controller.getSettings().getLanguageDependentString(langDepName);
      icon = new ImageIcon(ResourceManager.getResource(properties, "JaWETypes." + name + ".Icon"));
      color =
          Utils.getColor(
              ResourceManager.getResourceString(properties, "JaWETypes." + name + ".Color"));
    } catch (Exception e) {
      System.err.println(
          "JaWETypes->loadCollection: Failed to load collection "
              + typeClass
              + " with name "
              + name);
    }

    JaWEType jtype = new JaWEType(typeClass, id, dispName, icon, color);

    allTypes.put(id, jtype);
    allTypesMapping.put("JaWETypes." + name + ".Id", id);
  }
示例#2
0
  protected void loadTypes(
      Class typeClass, String name, List list, JaWEComponent controller, Properties properties) {
    List types =
        ResourceManager.getResourceStrings(properties, "JaWETypes." + name + ".Id.", false);

    String orderStr = properties.getProperty("JaWETypes." + name + ".Order", "");
    String[] order = Utils.tokenize(orderStr, ",");
    for (int i = 0; i < order.length; i++) {
      order[i] = order[i].trim();
    }

    if (order.length > 0) {
      List types2 = new ArrayList();
      for (int i = 0; i < order.length; i++) {
        if (types.contains(order[i])) {
          types2.add(order[i]);
        }
      }
      for (int i = 0; i < types.size(); i++) {
        if (!types2.contains(types.get(i))) {
          types2.add(types.get(i));
        }
      }
      types = types2;
    }
    for (int i = 0; i < types.size(); i++) {
      String id =
          ResourceManager.getResourceString(
              properties, "JaWETypes." + name + ".Id." + types.get(i));
      if (id.trim().equals("")) {
        if (allTypesMapping.containsKey("JaWETypes." + name + ".Id." + types.get(i))) {
          String defId = (String) allTypesMapping.get("JaWETypes." + name + ".Id." + types.get(i));
          JaWEType jtype = (JaWEType) allTypes.get(defId);
          if (list.contains(jtype)) {
            list.remove(jtype);
          }
          allTypes.remove(defId);
        }
        continue;
      }
      String dispName = null;
      ImageIcon icon = null;
      Color color = null;
      try {
        String langDepName =
            ResourceManager.getResourceString(
                properties, "JaWETypes." + name + ".LangDepName." + types.get(i));
        dispName = controller.getSettings().getLanguageDependentString(langDepName);
      } catch (Exception e) {
        System.err.println(
            "JaWETypes->locaTypes: Failed to load type " + typeClass + " for name " + name);
      }
      try {
        icon =
            new ImageIcon(
                ResourceManager.getResource(
                    properties, "JaWETypes." + name + ".Icon." + types.get(i)));
      } catch (Exception e) {
      }
      try {
        color =
            Utils.getColor(
                ResourceManager.getResourceString(
                    properties, "JaWETypes." + name + ".Color." + types.get(i)));
      } catch (Exception e) {
      }

      JaWEType jtype;
      if (allTypes.containsKey(id)) {
        jtype = (JaWEType) allTypes.get(id);
        if (list.contains(jtype)) {
          list.remove(jtype);
        }
      } else {
        jtype = new JaWEType(typeClass, id);
        if (color == null) {
          color = Color.DARK_GRAY;
        }
      }

      if (dispName != null) {
        jtype.setDisplayName(dispName);
      }

      if (icon != null) {
        jtype.setIcon(icon);
      }

      if (color != null) {
        jtype.setColor(color);
      }

      list.add(jtype);
      allTypes.put(id, jtype);
      allTypesMapping.put("JaWETypes." + name + ".Id." + types.get(i), id);

      try {
        String templateXML =
            ResourceManager.getResourceString(
                properties, "JaWETypes." + name + "." + XPDL_TEMPLATE + "." + types.get(i));
        if (templateXML != null && !templateXML.equals("")) {
          Document doc = parseDocument(templateXML, true);
          XMLElement tmpl = createTemplateElement(doc);
          templateMap.put(id, tmpl);
        }

      } catch (Exception e) {
      }
    }
  }