Package com.lowagie.tools.plugins

Source Code of com.lowagie.tools.plugins.TreeViewPDF

/*
* $Id: TreeViewPDF.java 45 2007-05-15 22:02:53Z chammer $
* Copyright (c) 2005-2007 Carsten Hammer, Bruno Lowagie
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

/*
* This class was originally published under the MPL by Carsten Hammer.
* It was a part of iText, a Java-PDF library. You can now use it under
* the MIT License; for backward compatibility you can also use it under
* the MPL version 1.1: http://www.mozilla.org/MPL/
* A copy of the MPL license is bundled with the source code FYI.
*/

package com.lowagie.tools.plugins;

import java.beans.PropertyVetoException;
import java.io.File;

import javax.swing.JOptionPane;

import com.lowagie.tools.AbstractTool;
import com.lowagie.tools.Toolbox;
import com.lowagie.tools.arguments.FileArgument;
import com.lowagie.tools.arguments.StringArgument;
import com.lowagie.tools.arguments.filters.PdfFilter;
import com.lowagie.tools.swing.PdfInformationPanel;
import com.lowagie.tools.swing.TreeViewInternalFrame;

/**
* Allows you to inspect an existing PDF file.
*/
public class TreeViewPDF extends AbstractTool {
  static {
    addVersion("$Id: TreeViewPDF.java 45 2007-05-15 22:02:53Z chammer $");
  }

  /** The argument referencing the PDF file to inspect. */
  FileArgument inputfile;

  /**
   * Constructs an TreeViewPDF object.
   */
  public TreeViewPDF() {
    inputfile = new FileArgument(this, "srcfile", "The file you want to inspect", false,
        new PdfFilter());
    inputfile.setLabel(new PdfInformationPanel());
    arguments.add(inputfile);
  }

  /**
   * @see com.lowagie.tools.AbstractTool#createFrame()
   */
  protected void createFrame() {
    TreeViewInternalFrame internalframe = new TreeViewInternalFrame("Pdf Analysis", true, false, true);
    inputfile.addPropertyChangeListener(internalframe);

    this.internalFrame = internalframe;
    internalFrame.setJMenuBar(getMenubar());
    internalFrame.setSize(500, 300);

    System.out.println("=== Pdf Analysis OPENED ===");
  }

  /**
   * @see com.lowagie.tools.AbstractTool#execute()
   */
  public void execute() {
    try {
      if (getValue("srcfile") == null) {
        throw new InstantiationException("You need to choose a sourcefile");
      }
    }
    catch (Exception e) {
      JOptionPane.showMessageDialog(internalFrame, e.getMessage(),
          e.getClass().getName(), JOptionPane.ERROR_MESSAGE);
      System.err.println(e.getMessage());
    }
  }

    /**
     *
     * @see com.lowagie.tools.AbstractTool#valueHasChanged(com.lowagie.tools.arguments.StringArgument)
     * @param arg StringArgument
     */
    public void valueHasChanged(StringArgument arg) {
    // do nothing
  }

    /**
     *
     * @see com.lowagie.tools.AbstractTool#getDestPathPDF()
     * @throws InstantiationException
     * @return File
     */
    protected File getDestPathPDF() throws InstantiationException {
    throw new InstantiationException("There is no file to show.");
  }

    /**
     * Inspects an existing PDF file.
     *
     * @param args String[]
     */
    public static void main(String[] args) {
    try {
      Toolbox toolbox = new Toolbox();
      AbstractTool tool = toolbox.createFrame("TreeViewPDF");
      if (args.length > 1) {
        System.err.println(tool.getUsage());
      }
      tool.setMainArguments(args);
      tool.execute();
    }
    catch (PropertyVetoException ex) {
      ex.printStackTrace();
    }
    catch (ClassNotFoundException ex) {
      ex.printStackTrace();
    }
    catch (IllegalAccessException ex) {
      ex.printStackTrace();
    }
    catch (InstantiationException ex) {
      ex.printStackTrace();
    }
  }
}
TOP

Related Classes of com.lowagie.tools.plugins.TreeViewPDF

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.