コード例 #1
0
 /**
  * 删除保存在首选项中的所有与指定条件相关的数据
  *
  * @param key 条件名
  */
 private void deletePreference(String[] key) {
   if (key == null || key.length == 0) {
     return;
   }
   for (int i = 0; i < key.length; i++) {
     customFilters.remove(key[i]);
     customFiltersAddtion.remove(key[i]);
     customFiltersIndex.remove(key[i]);
     customFilterList.remove(key[i]);
   }
   PreferenceStore.saveMap(IPreferenceConstants.MATCH_CONDITION, customFilters);
   PreferenceStore.saveCustomCondition(
       IPreferenceConstants.MATCH_CONDITION_ADDITION, customFiltersAddtion);
   PreferenceStore.saveCustomCondition(
       IPreferenceConstants.MATCH_CONDITION_INDEX, customFiltersIndex);
 }
コード例 #2
0
  /**
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.dialogs.Dialog#okPressed()
   */
  @Override
  protected void okPressed() {
    // 保存自定义条件
    String filterNameStr = filterNameTxt.getText();
    if (filterNameStr == null || "".equals(filterNameStr)) {
      MessageDialog.openInformation(getShell(), "", "请输入过滤器名称!");
      return;
    }
    if (btnIsRemoveFromSrc != null) { // 未安装TE时,该功能被屏蔽,按钮未被初始化。
      if (btnIsRemoveFromSrc.getSelection()) {
        // TODO 将符合条件的匹配从可连接的记忆库中同时删除。该功能在与匹配来源的记忆库无法连接时禁用。
      }
    }
    StringBuilder xpath = new StringBuilder();
    String link = andBtn.getSelection() ? " and " : " or ";
    ArrayList<String[]> tempValue = new ArrayList<String[]>();
    for (DynaComposite comp : conditionList) { // 得到所有自定义条件组合的xpath
      String tempXpath = comp.getXpath(true);
      if (RESULT_FAILED.equals(tempXpath)) {
        return;
      }
      xpath.append(link).append(tempXpath);
      tempValue.add(comp.getTempIndex());
    }

    appendCheckCondition(xpath);

    if (xpath.length() > 0) {
      xpath.delete(0, xpath.indexOf(link) + link.length());
      customFilters.put(filterNameStr, xpath.toString());
      String[] additions = {link.trim(), "" + getCheck()};
      customFiltersIndex.put(filterNameStr, tempValue);
      ArrayList<String[]> tempValue1 = new ArrayList<String[]>();
      tempValue1.add(additions);
      customFiltersAddtion.put(filterNameStr, tempValue1);
      PreferenceStore.saveMap(
          IPreferenceConstants.MATCH_CONDITION, new TreeMap<String, String>(customFilters));
      PreferenceStore.saveCustomCondition(
          IPreferenceConstants.MATCH_CONDITION_INDEX, customFiltersIndex);
      PreferenceStore.saveCustomCondition(
          IPreferenceConstants.MATCH_CONDITION_ADDITION, customFiltersAddtion);
      reload();
    }
  }