/** Set the contents of the field selector list. */
  private void setupFieldSelector() {
    fieldListModel.clear();
    SortedSet<String> contents = new TreeSet<String>();
    for (String s : metaData) {
      if (s.startsWith(Globals.SELECTOR_META_PREFIX)) {
        contents.add(s.substring(Globals.SELECTOR_META_PREFIX.length()));
      }
    }
    if (contents.size() == 0) {
      // if nothing was added, put the default fields (as described in the help)
      fieldListModel.addElement("author");
      fieldListModel.addElement("journal");
      fieldListModel.addElement("keywords");
      fieldListModel.addElement("publisher");
    } else {
      for (String s : contents) {
        fieldListModel.addElement(s);
      }
    }

    if (currentField == null) {
      // if dialog is created for the whole database,
      // select the first field to avoid confusions in GUI usage
      fieldList.setSelectedIndex(0);
    } else {
      // a specific field has been chosen at the constructur
      // select this field
      int i = fieldListModel.indexOf(currentField);
      if (i != -1) {
        // field has been found in list, select it
        fieldList.setSelectedIndex(i);
      }
    }
  }
示例#2
0
 static SortedSet<TypeColorEntry> fromPainter(myjava.gui.syntax.Painter painter) {
   Token.Type[] types = Token.Type.values();
   SortedSet<TypeColorEntry> entries = new TreeSet<>();
   for (Token.Type type : types) {
     entries.add(new TypeColorEntry(type, painter.fromType(type)));
   }
   return entries;
 }
示例#3
0
  private void configChanged(String activeConfig) {
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    model.addElement("");
    SortedSet<String> alphaConfigs =
        new TreeSet<String>(
            new Comparator<String>() {
              Collator coll = Collator.getInstance();

              public int compare(String s1, String s2) {
                return coll.compare(label(s1), label(s2));
              }

              private String label(String c) {
                Map<String, String> m = configs.get(c);
                String label = m.get("$label"); // NOI18N
                return label != null ? label : c;
              }
            });
    for (Map.Entry<String, Map<String, String>> entry : configs.entrySet()) {
      String config = entry.getKey();
      if (config != null && entry.getValue() != null) {
        alphaConfigs.add(config);
      }
    }
    for (String c : alphaConfigs) {
      model.addElement(c);
    }
    configCombo.setModel(model);
    configCombo.setSelectedItem(activeConfig != null ? activeConfig : "");
    Map<String, String> m = configs.get(activeConfig);
    Map<String, String> def = configs.get(null);
    if (m != null) {
      // BEGIN Deprecated
      if (compProviderDeprecated != null) {
        compProviderDeprecated.configUpdated(m);
      }
      // END Deprecated
      for (J2SECategoryExtensionProvider compProvider : compProviders) {
        compProvider.configUpdated(m);
      }
      for (int i = 0; i < data.length; i++) {
        String v = m.get(keys[i]);
        if (v == null) {
          // display default value
          v = def.get(keys[i]);
        }
        data[i].setText(v);
      }
    } // else ??
    configDel.setEnabled(activeConfig != null);
  }
示例#4
0
 /**
  * Find a new name that isn't among the used names.
  *
  * @param prefix
  * @param usedNames
  * @return
  */
 public static String unusedName(String prefix, Iterator usedNames) {
   SortedSet u = new TreeSet();
   while (usedNames.hasNext()) {
     String curr = (String) usedNames.next();
     if (curr.startsWith(prefix)) {
       String postfix = curr.substring(prefix.length());
       u.add(postfix);
     }
   }
   int count = 0;
   while (u.contains(String.valueOf(count))) {
     count++;
   }
   return prefix + count;
 }
示例#5
0
 // Other methods
 public void add(Object element) {
   if (m_Models.add(element)) {
     fireContentsChanged(this, 0, getSize());
   }
 }