/** 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
 public boolean removeElement(Object element) {
   boolean removed = m_Models.remove(element);
   if (removed) {
     fireContentsChanged(this, 0, getSize());
   }
   return removed;
 }
예제 #6
0
 public Object lastElement() {
   // Return the appropriate element
   return m_Models.last();
 }
예제 #7
0
 public Iterator iterator() {
   return m_Models.iterator();
 }
예제 #8
0
 public boolean contains(Object element) {
   return m_Models.contains(element);
 }
예제 #9
0
 public void clear() {
   m_Models.clear();
   fireContentsChanged(this, 0, getSize());
 }
예제 #10
0
 public void addAll(Object elements[]) {
   Collection c = Arrays.asList(elements);
   m_Models.addAll(c);
   fireContentsChanged(this, 0, getSize());
 }
예제 #11
0
 // Other methods
 public void add(Object element) {
   if (m_Models.add(element)) {
     fireContentsChanged(this, 0, getSize());
   }
 }
예제 #12
0
 public Object getElementAt(int index) {
   // Return the appropriate element
   return m_Models.toArray()[index];
 }
예제 #13
0
 // ListModel methods
 public int getSize() {
   // Return the model size
   return m_Models.size();
 }