예제 #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);
 }