Exemple #1
0
 @Override
 public String getShortDescription() {
   StringBuilder sb = new StringBuilder();
   sb.append("<b>");
   if (Globals.prefs.getBoolean(JabRefPreferences.GROUP_SHOW_DYNAMIC)) {
     sb.append("<i>").append(StringUtil.quoteForHTML(getName())).append("</i>");
   } else {
     sb.append(StringUtil.quoteForHTML(getName()));
   }
   sb.append("</b> - ");
   sb.append(Globals.lang("dynamic group"));
   sb.append("<b>");
   sb.append(searchField);
   sb.append("</b>");
   sb.append(Globals.lang("contains"));
   sb.append(" <b>");
   sb.append(StringUtil.quoteForHTML(searchExpression));
   sb.append("</b>)");
   switch (getHierarchicalContext()) {
     case INCLUDING:
       sb.append(", ").append(Globals.lang("includes subgroups"));
       break;
     case REFINING:
       sb.append(", ").append(Globals.lang("refines supergroup"));
       break;
     default:
       break;
   }
   return sb.toString();
 }
Exemple #2
0
  public static String getDescriptionForPreview(
      String field, String expr, boolean caseSensitive, boolean regExp) {
    String header =
        regExp
            ? Globals.lang(
                "This group contains entries whose <b>%0</b> field contains the regular expression <b>%1</b>",
                field, StringUtil.quoteForHTML(expr))
            : Globals.lang(
                "This group contains entries whose <b>%0</b> field contains the keyword <b>%1</b>",
                field, StringUtil.quoteForHTML(expr));
    String caseSensitiveText =
        caseSensitive ? Globals.lang("case sensitive") : Globals.lang("case insensitive");
    String footer =
        regExp
            ? Globals.lang("Entries cannot be manually assigned to or removed from this group.")
            : Globals.lang(
                "Additionally, entries whose <b>%0</b> field does not contain "
                    + "<b>%1</b> can be assigned manually to this group by selecting them "
                    + "then using either drag and drop or the context menu. "
                    + "This process adds the term <b>%1</b> to "
                    + "each entry's <b>%0</b> field. "
                    + "Entries can be removed manually from this group by selecting them "
                    + "then using the context menu. "
                    + "This process removes the term <b>%1</b> from "
                    + "each entry's <b>%0</b> field.",
                field, StringUtil.quoteForHTML(expr));

    return String.format("%s (%s). %s", header, caseSensitiveText, footer);
  }
Exemple #3
0
 /** Returns a String representation of this object that can be used to reconstruct it. */
 @Override
 public String toString() {
   return KeywordGroup.ID
       + StringUtil.quote(name, AbstractGroup.SEPARATOR, AbstractGroup.QUOTE_CHAR)
       + AbstractGroup.SEPARATOR
       + context.ordinal()
       + AbstractGroup.SEPARATOR
       + StringUtil.quote(searchField, AbstractGroup.SEPARATOR, AbstractGroup.QUOTE_CHAR)
       + AbstractGroup.SEPARATOR
       + StringUtil.quote(searchExpression, AbstractGroup.SEPARATOR, AbstractGroup.QUOTE_CHAR)
       + AbstractGroup.SEPARATOR
       + StringUtil.booleanToBinaryString(caseSensitive)
       + AbstractGroup.SEPARATOR
       + StringUtil.booleanToBinaryString(regExp)
       + AbstractGroup.SEPARATOR;
 }
Exemple #4
0
 private CustomEntryType(String name_, String reqStr, String optStr) {
   name = StringUtil.capitalizeFirst(name_);
   if (reqStr.isEmpty()) {
     req = new String[0];
   } else {
     parseRequiredFields(reqStr);
   }
   if (optStr.isEmpty()) {
     opt = new String[0];
   } else {
     opt = optStr.split(";");
   }
 }
Exemple #5
0
 public CustomEntryType(String name_, String[] req_, String[] priOpt_, String[] secOpt_) {
   name = StringUtil.capitalizeFirst(name_);
   parseRequiredFields(req_);
   priOpt = priOpt_;
   opt = Util.arrayConcat(priOpt_, secOpt_);
 }
Exemple #6
0
 /**
  * Parses s and recreates the KeywordGroup from it.
  *
  * @param s The String representation obtained from KeywordGroup.toString()
  */
 public static AbstractGroup fromString(String s, BibtexDatabase db, int version)
     throws Exception {
   if (!s.startsWith(KeywordGroup.ID)) {
     throw new Exception(
         "Internal error: KeywordGroup cannot be created from \""
             + s
             + "\". "
             + "Please report this on www.sf.net/projects/jabref");
   }
   QuotedStringTokenizer tok =
       new QuotedStringTokenizer(
           s.substring(KeywordGroup.ID.length()),
           AbstractGroup.SEPARATOR,
           AbstractGroup.QUOTE_CHAR);
   switch (version) {
     case 0:
       {
         String name = tok.nextToken();
         String field = tok.nextToken();
         String expression = tok.nextToken();
         // assume caseSensitive=false and regExp=true for old groups
         return new KeywordGroup(
             StringUtil.unquote(name, AbstractGroup.QUOTE_CHAR),
             StringUtil.unquote(field, AbstractGroup.QUOTE_CHAR),
             StringUtil.unquote(expression, AbstractGroup.QUOTE_CHAR),
             false,
             true,
             GroupHierarchyType.INDEPENDENT);
       }
     case 1:
     case 2:
       {
         String name = tok.nextToken();
         String field = tok.nextToken();
         String expression = tok.nextToken();
         boolean caseSensitive = Integer.parseInt(tok.nextToken()) == 1;
         boolean regExp = Integer.parseInt(tok.nextToken()) == 1;
         return new KeywordGroup(
             StringUtil.unquote(name, AbstractGroup.QUOTE_CHAR),
             StringUtil.unquote(field, AbstractGroup.QUOTE_CHAR),
             StringUtil.unquote(expression, AbstractGroup.QUOTE_CHAR),
             caseSensitive,
             regExp,
             GroupHierarchyType.INDEPENDENT);
       }
     case 3:
       {
         String name = tok.nextToken();
         int context = Integer.parseInt(tok.nextToken());
         String field = tok.nextToken();
         String expression = tok.nextToken();
         boolean caseSensitive = Integer.parseInt(tok.nextToken()) == 1;
         boolean regExp = Integer.parseInt(tok.nextToken()) == 1;
         return new KeywordGroup(
             StringUtil.unquote(name, AbstractGroup.QUOTE_CHAR),
             StringUtil.unquote(field, AbstractGroup.QUOTE_CHAR),
             StringUtil.unquote(expression, AbstractGroup.QUOTE_CHAR),
             caseSensitive,
             regExp,
             GroupHierarchyType.getByNumber(context));
       }
     default:
       throw new UnsupportedVersionException("KeywordGroup", version);
   }
 }