Exemplo n.º 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));
        }
      }
    }
  }
Exemplo n.º 2
0
 public void setTopics(java.util.List<Topic> topics) {
   managerPanel.setResearchedTopics(topics);
 }
Exemplo n.º 3
0
 public void removeTopic(Topic topic) {
   managerPanel.removeTopic(topic);
 }
Exemplo n.º 4
0
 public void setTopicState(Topic topic, TopicState state) {
   managerPanel.setTopicState(topic, state);
 }
Exemplo n.º 5
0
 public void setEnabled(boolean value) {
   managerPanel.setEnabled(value);
 }