示例#1
0
 NoteTemplatesPanel() {
   multiLanguage = new KDComboBox(Language.SUPPORT_LANGUAGES);
   lang = Language.locale2Language(Locale.getDefault());
   lstTemplates = new KDList();
   cbUseOrgFilter =
       new KDCheckBox(
           MultiLanguageUtil.getMLS("ui.NoteFileDialogEx.useOrgFilter", "只显示当前组织的模板"));
   TableLayout2 layout = new TableLayout2(2, 2);
   layout.setFixedHeight(0, 20);
   layout.setRatableHeight(1, 1);
   layout.setRatableWidth(0, 1);
   layout.setRatableWidth(1, 1);
   layout.setRowsSpacing(TableLayout2.ALL, 3);
   setLayout(layout);
   //    add(cbUseOrgFilter, TableLayout2.param(0, 0));
   add(
       CtrlSwingUtilities.createLabelContainer(
           multiLanguage,
           MultiLanguageUtil.getMLS("ui.NoteFileDialogEx.temLanguage", "模板语言"),
           80),
       TableLayout2.param(0, 1));
   multiLanguage.setSelectedItem(lang);
   add(new KDScrollPane(lstTemplates), TableLayout2.param(1, 0, 1, 1));
 }
示例#2
0
  private void refreshTemplateList() {
    TreeUINode selectedNode = _tree.getTreeUI().getSelectionNode();
    HashMap cacheValues = (HashMap) selectedNode.getUserObject();
    super.btnOk.setEnabled(false);
    _lstFile.removeAllElements();
    HashMap vals = null;
    if (cacheValues == null) {
      if (selectedNode.isChildrenLoaded()) return;
      vals = expandNode(selectedNode, getNoteDir());
    } else {
      vals = cacheValues;
    }
    if (vals == null) return;
    String names[] = (String[]) (String[]) vals.get("name");
    String alias[] = (String[]) (String[]) vals.get("alias");
    String categories[] = (String[]) (String[]) vals.get("category");
    String orgss[] = (String[]) (String[]) vals.get("eas_template_relation_orgs");
    if (names != null && log.isDebugEnabled())
      log.debug((new StringBuilder()).append("entries:").append(names.length).toString());
    boolean doFilter = _rightPanel.cbUseOrgFilter.isSelected();
    int idxKDFStart = 0;
    IBizContent bizCtn = _tree.getBizContent();
    for (int i = 0; i < names.length; i++) {
      boolean isKDF = "kdrs-form".equals(categories[i]);
      boolean isR1 = "r1-print".equals(categories[i]);
      if (!isKDF && !isR1 || !_rightPanel.lang.equal(Language.readTempLang(names[i])) && !isKDF)
        continue;
      try {
        boolean isCanUse =
            NoteUseUtil.isCanUse(
                bizCtn,
                (new StringBuilder())
                    .append(((ResObjectNode) selectedNode).getResPath())
                    .append("/")
                    .append(names[i])
                    .toString());
        if (!isCanUse) continue;
      } catch (KDRSException ex) {
        log.debug(
            (new StringBuilder())
                .append(selectedNode)
                .append("获取属性:NoteUseUtil.")
                .append("user_enabled_users")
                .append("失败")
                .toString());
        continue;
      }
      if (doFilter
          && (orgss[i] == null
              || orgss[i].length() == 0
              || orgss[i].indexOf(NoteUtil.getCurrentOrgUnitId()) == -1)) {
        if (log.isDebugEnabled())
          log.debug(
              (new StringBuilder())
                  .append("ignore teplate/r1templat:")
                  .append(names[i])
                  .toString());
        continue;
      }
      ListElement element = new ListElement(names[i], alias[i], categories[i]);
      element.setSeleted(true);
      int idx = idxKDFStart;
      if (isR1) {
        int j = 0;
        do {
          if (j >= idxKDFStart) break;
          if (element.compareTo(_lstFile.getElement(j)) < 0) {
            idx = j;
            break;
          }
          j++;
        } while (true);
        idxKDFStart++;
      } else if (isKDF) {
        int j = _lstFile.getElementCount() - 1;
        do {
          if (j < idxKDFStart) break;
          if (element.compareTo(_lstFile.getElement(j)) > 0) {
            idx = j + 1;
            break;
          }
          j--;
        } while (true);
      }
      _lstFile.insertElement(element, idx);
    }

    if (_lstFile.getElementCount() > 0) _lstFile.setSelectedIndex(0);
    btnOk.setEnabled(_lstFile.getSelectedIndex() != -1);
  }