Exemple #1
0
  public void loadTags() {
    if (this.tagFilenames != null
        && this.tagFilenames.length > 0
        && viewer.getSwingGUI().getCurrentPage() > 0) {
      // grab tag text and update tags
      currentTagFilename = this.tagFilenames[viewer.getSwingGUI().getCurrentPage() - 1] + ".txt";

      try (FileReader fr = new FileReader(currentTagFilename);
          BufferedReader br = new BufferedReader(fr)) {
        StringBuilder sb = new StringBuilder();
        String line = br.readLine();

        while (line != null) {
          sb.append(line);
          sb.append(System.lineSeparator());
          line = br.readLine();
        }
        tags.setText(sb.toString());
      } catch (FileNotFoundException ex) {
        // just don't do anything, the tag file doesn't exist which is ok.
        // expected result: keep whatever text is in 'tags' UI element
      } catch (IOException ex) {
        Logger.getLogger(PDFViewer.class.getName()).log(Level.SEVERE, null, ex);
      }
    }

    // request focus for tags
    tags.requestFocus();
  }
Exemple #2
0
  public void resetViewer() {
    // create main preview pane
    JInternalFrame rootContainer = new JInternalFrame("Preview Pane");

    // Setup the viewer
    viewer = new Viewer(rootContainer, null);
    // load properties from jar
    viewer.loadProperties("jar:/.properties.xml");
    viewer.setupViewer();
    viewer
        .getSwingGUI()
        .addPageChangeListener(
            new DocumentListener() {
              @Override
              public void insertUpdate(DocumentEvent e) {
                // new page inserted in view, load tags
                loadTags();
              }

              @Override
              public void removeUpdate(DocumentEvent e) {}

              @Override
              public void changedUpdate(DocumentEvent e) {}
            });

    // Add the viewer to the frame
    frame.add(rootContainer, BorderLayout.CENTER);

    // Require for internalFrame to be displayed
    rootContainer.setVisible(true);

    // shouldn't do this here, but need it for now
    if (this.tagFilenames != null && this.tagFilenames.length > 0) {
      viewer.executeCommand(Commands.OPENFILE, new File[] {new File(TMP_FILE)});
    }
  }
Exemple #3
0
 public void showPreviousPage() {
   // previous page (page change event will load tags)
   viewer.executeCommand(Commands.BACKPAGE, null);
 }
Exemple #4
0
 public void showNextPage() {
   // next page (page change event will load tags)
   viewer.executeCommand(Commands.FORWARDPAGE, null);
 }