/** 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);
      }
    }
  }
Exemple #2
0
 public void dbClearList() {
   dbItems.removeAllElements();
   dbItemsK.removeAllElements();
   dbItemsK2.removeAllElements();
   lm.clear();
   this.setModel(lm);
 }
Exemple #3
0
 public void setPluginHosts(final List<String> pluginHosts) {
   final DefaultListModel model = (DefaultListModel) myUrlsList.getModel();
   model.clear();
   for (String host : pluginHosts) {
     //noinspection unchecked
     model.addElement(host);
   }
 }
Exemple #4
0
 /** Called to populate the List of users */
 private void populateUsers() {
   listModel.clear();
   users = control.list_users();
   for (int i = 0; i < users.length; i++) {
     listModel.addElement(users[i]);
   }
   userList.setSelectedIndex(0);
 }
  public void populate(List<String> items) {
    model.clear();

    Iterator<String> iterator = items.iterator();

    while (iterator.hasNext()) {
      String item = iterator.next();
      model.addElement(item);
    }
  }
 private void disconnect() {
   if (session != null && session.isConnected()) {
     session.disconnect();
   }
   jToggleButtonConnect.setSelected(false);
   jToggleButtonConnect.setText("Connect");
   jToggleButtonRegister.setSelected(false);
   onlineUsers.clear();
   jToggleButtonRegister.setText("Register");
 }
Exemple #7
0
  private void listOfNamesValueChanged(javax.swing.event.ListSelectionEvent evt) {
    // TODO add your handling code here:
    int index = listOfNames.getSelectedIndex();
    // System.out.println(index);
    listModel3.clear();
    listModel4.clear();
    for (int i = 0; i < 5; i++) {
      listModel3.addElement((answers.get(index))[i]);
    }
    answerList.setModel(listModel3);

    for (int i = 0; i < 5; i++) {
      if ((answers.get(index))[i] == correct[i]) {
        listModel4.addElement("2/2");
      } else {
        listModel4.addElement("0/2");
      }
    }
    pointList.setModel(listModel4);
  }
 void syncLists() {
   JList list = webPanels[1 - panelIndex].instanceList;
   DefaultListModel model1 = (DefaultListModel) instanceList.getModel();
   DefaultListModel model2 = (DefaultListModel) list.getModel();
   model2.clear();
   int n = model1.getSize();
   for (int i = 0; i < n; i++)
     model2.addElement(model1.get(i));
   list.setSelectedIndices(new int[] {});
   enableButtons(instanceList);
   webPanels[1 - panelIndex].enableButtons(list);
 }
 private void register() {
   if (session != null && session.isConnected()) {
     onlineUsers.clear();
     // get the current list
     Message msg = session.sendMessage("", "list", "");
     System.out.println("LIST: " + msg.getBody());
     StringTokenizer st = new StringTokenizer(msg.getBody(), "\n");
     while (st.hasMoreTokens()) {
       onlineUsers.addElement(new HostItem(st.nextToken()));
     }
     session.postMessage("", "register", "");
   }
 }
 /** Filter the list of displayed genomes so we only show this with the text the user entered. */
 private void rebuildGenomeList(String filterText) {
   if (genomeListModel == null) {
     genomeListModel = new DefaultListModel();
     UIUtilities.invokeOnEventThread(
         new Runnable() {
           @Override
           public void run() {
             genomeList.setModel(genomeListModel);
           }
         });
   }
   genomeListModel.clear();
   filterText = filterText.toLowerCase().trim();
   for (GenomeListItem listItem : allListItems) {
     if (listItem.getDisplayableName().toLowerCase().contains(filterText)) {
       genomeListModel.addElement(listItem);
     }
   }
 }
 private void deregister() {
   onlineUsers.clear();
   if (session != null && session.isConnected()) {
     session.postMessage("", "deregister", "");
   }
 }
 protected void reset() {
   fCounterPanel.reset();
   fProgressIndicator.reset();
   fFailureView.clear();
   fFailures.clear();
 }
Exemple #13
0
  private void updateHints() {
    String text = classSearchField.getText().trim();

    // Ignore empty text
    if (text.trim().length() == 0) {
      hideHints();
      return;
    }

    // Updating hints window if needed
    if (!CompareUtils.equals(lastSearchedText, text)) {
      // Saving old selection
      Object oldSelection = classSearchHintsList.getSelectedValue();

      // Clearing list
      DefaultListModel model = (DefaultListModel) classSearchHintsList.getModel();
      model.clear();

      // Look for classes
      List<JarEntry> found =
          jarStructure.findSimilarEntries(
              text,
              new Filter<JarEntry>() {
                @Override
                public boolean accept(JarEntry object) {
                  return object.getType().equals(JarEntryType.javaEntry);
                }
              });
      if (found.size() > 0) {
        classSearchField.setForeground(Color.BLACK);

        // Filling list with results
        for (JarEntry entry : found) {
          model.addElement(entry);
        }

        // Updating visible rows
        classSearchHintsList.setVisibleRowCount(Math.min(model.size(), 10));

        // Restoring selection if possible
        int index = oldSelection != null ? model.indexOf(oldSelection) : 0;
        classSearchHintsList.setSelectedIndex(index != -1 ? index : 0);

        // Packing popup
        classSearchHintsPopup.pack();

        // Displaying hints window
        if (!classSearchHintsPopup.isVisible()) {
          classSearchHintsPopup.setVisible(true);
        }
      } else {
        classSearchField.setForeground(Color.RED);

        // Hiding hints window
        if (classSearchHintsPopup.isVisible()) {
          classSearchHintsPopup.setVisible(false);
        }
      }

      lastSearchedText = text;
    }
  }
 /**
  * Clears the certificateModel and adds all available certificates.
  *
  * @param certificates the available certificates
  */
 public void setCertificates(List<Certificate> certificates) {
   certificateModel.clear();
   for (Certificate cert : certificates) {
     certificateModel.addElement(cert);
   }
 }
 public void clearFormEntry() {
   formEntry.clear();
   listModel.clear();
   revalidate();
 }