private void applyChanges() {
    boolean changedFieldSet = false; // Watch if we need to rebuild entry editors

    // First remove the mappings for fields that have been deleted.
    // If these were re-added, they will be added below, so it doesn't
    // cause any harm to remove them here.
    for (Iterator<String> i = removedFields.iterator(); i.hasNext(); ) {
      String fieldName = i.next();
      metaData.remove(Globals.SELECTOR_META_PREFIX + fieldName);
      changedFieldSet = true;
    }

    // Cycle through all fields that we have created listmodels for:
    loop:
    for (Iterator<String> i = wordListModels.keySet().iterator(); i.hasNext(); ) {
      // For each field name, store the values:
      String fieldName = i.next();
      if ((fieldName == null) || FIELD_FIRST_LINE.equals(fieldName)) continue loop;
      DefaultListModel lm = wordListModels.get(fieldName);
      int start = 0;
      // Avoid storing the <new word> marker if it is there:
      if (lm.size() > 0)
        while ((start < lm.size()) && (lm.get(start)).equals(WORD_FIRSTLINE_TEXT)) start++;
      Vector<String> data = metaData.getData(Globals.SELECTOR_META_PREFIX + fieldName);
      boolean newField = false;
      if (data == null) {
        newField = true;
        data = new Vector<String>();
        changedFieldSet = true;

      } else data.clear();
      for (int wrd = start; wrd < lm.size(); wrd++) {
        String word = (String) lm.get(wrd);
        data.add(word);
      }
      if (newField) metaData.putData(Globals.SELECTOR_META_PREFIX + fieldName, data);
    }

    // System.out.println("TODO: remove metadata for removed selector field.");
    panel.markNonUndoableBaseChanged();

    // Update all selectors in the current BasePanel.
    if (changedFieldSet) {
      panel.rebuildAllEntryEditors();
    } else {
      panel.updateAllContentSelectors();
    }
    panel.addContentSelectorValuesToAutoCompleters();
  }
 private void runButtonActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_runButtonActionPerformed
   Substance[] substances = new Substance[selectedSubstanceNames.getSize()];
   for (int i = 0; i < substances.length; i++)
     substances[i] = (Substance) (system.get((String) (selectedSubstanceNames.get(i))));
   rss.start();
 } // GEN-LAST:event_runButtonActionPerformed
예제 #3
0
 public List<BufferedImage> getExamples() {
   List<BufferedImage> list = new ArrayList<BufferedImage>();
   for (int i = 0; i < model.size(); i++) {
     Example example = (Example) model.get(i);
     list.add(example.getBufferedImage());
   }
   return list;
 }
 private int findPos(DefaultListModel lm, String item) {
   for (int i = 0; i < lm.size(); i++) {
     String s = (String) lm.get(i);
     if (item.compareToIgnoreCase(s) < 0) { // item precedes s
       return i;
     }
   }
   return lm.size();
 }
 private void newWordAction() {
   if ((wordListModel.size() == 0) || !wordListModel.get(0).equals(WORD_FIRSTLINE_TEXT))
     wordListModel.add(0, WORD_FIRSTLINE_TEXT);
   wordList.setSelectedIndex(0);
   wPane.getVerticalScrollBar().setValue(0);
 }