Module org.hdfgroup.hdfview
Package hdf.view.TreeView

# Interface TreeView

All Known Implementing Classes:
  `DefaultTreeView`

public interface TreeView
TreeView defines APIs for opening a file and displaying the file structure in a tree structure. TreeView uses folders and leaf nodes to represent groups and data objects in the file. You can expand or collapse folders to navigate data objects in the file. From the TreeView, you can open the data content or metadata of the selected object. You can select object(s) to delete or add new objects to the file.

Version:
  2.4 9/6/2007
Author:
  Peter X. Cao

- ## Method Summary

  Modifier and Type
  Method
  Description
  `org.eclipse.swt.widgets.TreeItem`
  `addObject(HObject newObject, Group parentGroup)`
  Adds an already created HObject to the tree under the TreeItem containing the specified parent group.
  `void`
  `closeFile(FileFormat file)`
  close a file
  `org.eclipse.swt.widgets.TreeItem`
  `findTreeItem(HObject obj)`
  `List<FileFormat>`
  `getCurrentFiles()`
  `HObject`
  `getCurrentObject()`
  `FileFormat`
  `getSelectedFile()`
  Gets the selected the file.
  `org.eclipse.swt.widgets.Tree`
  `getTree()`
  `FileFormat`
  `openFile(String filename, int accessID)`
  Opens a file and retrieves the file structure of the file.
  `FileFormat`
  `reopenFile(FileFormat theFile, int newFileAccessMode)`
  Reopens a file and retrieves the file structure of the file.
  `void`
  `saveFile(FileFormat file)`
  save a file
  `void`
  `setDefaultDisplayMode(boolean displaymode)`
  change the display option.
  `DataView`
  `showDataContent(HObject dataObject)`
  Display the content of a data object.

- ## Method Details

  - ### openFile

    FileFormat openFile(String filename, int accessID) throws Exception
    Opens a file and retrieves the file structure of the file. It also can be used to create a new file by setting the accessID to FileFormat.CREATE. Subclasses must implement this function to take appropriate steps to open a file.
    Parameters:
      `filename` - the name of the file to open.
      `accessID` - identifier for the file access. Valid value of accessID is:
      - FileFormat.READ --- allow read-only access to file.
      - FileFormat.WRITE --- allow read and write access to file.
      - FileFormat.CREATE --- create a new file.
    Returns:
      the FileFormat of this file if successful; otherwise returns null.
    Throws:
      `Exception` - if a failure occurred

  - ### reopenFile

    FileFormat reopenFile(FileFormat theFile, int newFileAccessMode) throws Exception
    Reopens a file and retrieves the file structure of the file. Subclasses must implement this function to take appropriate steps to re-open a file.
    Parameters:
      `theFile` - the file to re-open.
      `newFileAccessMode` - identifier for the new file access. Valid value of newFileAccessMode is:
      - FileFormat.READ --- allow read-only access to file.
      - FileFormat.WRITE --- allow read and write access to file.
      - FileFormat.CREATE --- create a new file.
    Returns:
      the FileFormat of this file if successful; otherwise returns null.
    Throws:
      `Exception` - if a failure occurred

  - ### closeFile

    void closeFile(FileFormat file) throws Exception
    close a file
    Parameters:
      `file` - the file to close
    Throws:
      `Exception` - if a failure occurred

  - ### saveFile

    void saveFile(FileFormat file) throws Exception
    save a file
    Parameters:
      `file` - the file to save
    Throws:
      `Exception` - if a failure occurred

  - ### setDefaultDisplayMode

    void setDefaultDisplayMode(boolean displaymode)
    change the display option.
    Parameters:
      `displaymode` - the default displaymode

  - ### getSelectedFile

    FileFormat getSelectedFile()
    Gets the selected the file. When multiple files are open, we need to know which file is currently selected.
    Returns:
      the FileFormat of the selected file.

  - ### getCurrentObject

    HObject getCurrentObject()
    Returns:
      the current selected object in the tree.

  - ### showDataContent

    DataView showDataContent(HObject dataObject) throws Exception
    Display the content of a data object.
    Parameters:
      `dataObject` - the data object
    Returns:
      the dataview that displays the data content
    Throws:
      `Exception` - if a failure occurred

  - ### addObject

    org.eclipse.swt.widgets.TreeItem addObject(HObject newObject, Group parentGroup)
    Adds an already created HObject to the tree under the TreeItem containing the specified parent group.
    Parameters:
      `newObject` - the object to add.
      `parentGroup` - the parent group to add the object to.
    Returns:
      the TreeItem object

  - ### getTree

    org.eclipse.swt.widgets.Tree getTree()
    Returns:
      the Tree which holds the file structure.

  - ### getCurrentFiles

    List<FileFormat> getCurrentFiles()
    Returns:
      the list of currently open files.

  - ### findTreeItem

    org.eclipse.swt.widgets.TreeItem findTreeItem(HObject obj)
    Parameters:
      `obj` - the object to find
    Returns:
      the tree item that contains the given data object.