示例#1
0
  private void loadTopicsFromFile() throws IOException {
    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle("ExtempFiller2");
    chooser.setFileFilter(
        new FileFilter() {
          @Override
          public boolean accept(File f) {
            return f.isDirectory() || f.getName().toLowerCase().endsWith(".txt");
          }

          @Override
          public String getDescription() {
            return "Text Files";
          }
        });
    int response = chooser.showOpenDialog(this);
    if (response == JFileChooser.APPROVE_OPTION) {
      // get everything currently researched
      java.util.List<String> researched = managerPanel.getTopics();
      // load everything from file
      File file = chooser.getSelectedFile();
      Scanner readScanner = new Scanner(file);
      while (readScanner.hasNext()) {
        String topic = readScanner.nextLine();
        if (!researched.contains(topic)) {
          Topic t = new Topic(topic);
          managerPanel.addTopic(t);
          inQueue.add(new InMessage(InMessage.Type.RESEARCH, t));
        }
      }
    }
  }
示例#2
0
 public void setTopics(java.util.List<Topic> topics) {
   managerPanel.setResearchedTopics(topics);
 }
示例#3
0
 public void removeTopic(Topic topic) {
   managerPanel.removeTopic(topic);
 }
示例#4
0
 public void setTopicState(Topic topic, TopicState state) {
   managerPanel.setTopicState(topic, state);
 }
示例#5
0
 public void setEnabled(boolean value) {
   managerPanel.setEnabled(value);
 }