Class ExportTreeController

java.lang.Object
introspector.controller.ExportTreeController

public class ExportTreeController extends Object
This controller defines how to export a tree into different formats.
  • Field Details

    • trees

      private final List<JTree> trees
      The tree views associated with the action
    • frame

      private final JFrame frame
      The parent frame
  • Constructor Details

    • ExportTreeController

      public ExportTreeController(JFrame frame, List<JTree> trees)
      Constructor of the controller.
      Parameters:
      frame - the parent frame
      trees - the JTrees where the tree is displayed
    • ExportTreeController

      public ExportTreeController(JFrame frame, JTree tree)
      Constructor of the controller.
      Parameters:
      frame - the parent frame
      tree - the JTree where the tree is displayed
  • Method Details

    • exportToTxt

      public boolean exportToTxt(String filename, boolean expandSelectedNode)
      Exports the selected node to a text file.
      Parameters:
      filename - the name of the text file.
      expandSelectedNode - true means it is the selected node to be exported; false is the whole tree
      Returns:
      whether the export action was successful.
    • exportToTxt

      public boolean exportToTxt(JLabel statusLabel, boolean expandSelectedNode)
      Exports the selected node to a text file and shows the success or failure message.
      Parameters:
      statusLabel - the label where the success or failure message is shown
      expandSelectedNode - true means it is the selected node to be exported; false is the whole tree
      Returns:
      whether the export action was successful.
    • exportToHtml

      public boolean exportToHtml(String filename, boolean expandSelectedNode)
      Exports the selected node to a HTML file.
      Parameters:
      filename - the name of the HTML file.
      expandSelectedNode - true means it is the selected node to be exported; false is the whole tree
      Returns:
      whether the export action was successful.
    • exportToHtml

      public boolean exportToHtml(JLabel statusLabel, boolean expandSelectedNode)
      Exports the selected node to an HTML file and shows the success or failure message.
      Parameters:
      statusLabel - the label where the success or failure message is shown
      expandSelectedNode - true means it is the selected node to be exported; false is the whole tree
      Returns:
      whether the export action was successful.
    • removeFileExtension

      public static String removeFileExtension(String fileName)
      Removes the extension of a file name.
      Parameters:
      fileName - the name of the file
      Returns:
      the name of the file without the extension