001/***************************************************************************** 002 * Copyright by The HDF Group. * 003 * Copyright by the Board of Trustees of the University of Illinois. * 004 * All rights reserved. * 005 * * 006 * This file is part of the HDF Java Products distribution. * 007 * The full copyright notice, including terms governing use, modification, * 008 * and redistribution, is contained in the files COPYING and Copyright.html. * 009 * COPYING can be found at the root of the source code distribution tree. * 010 * Or, see http://hdfgroup.org/products/hdf-java/doc/Copyright.html. * 011 * If you do not have access to either file, you may request a copy from * 012 * help@hdfgroup.org. * 013 ****************************************************************************/ 014 015package hdf.view; 016 017import java.util.List; 018 019import javax.swing.JTree; 020import javax.swing.tree.TreeNode; 021 022import hdf.object.FileFormat; 023import hdf.object.Group; 024import hdf.object.HObject; 025 026/** 027 * 028 * <p> 029 * TreeView defines APIs for open a file and display the file structure in tree 030 * structure. 031 * </p> 032 * 033 * <p> 034 * TreeView uses folders and leaf nodes to represent groups and data objects in 035 * the file. You can expand or collapse folders to navigate data objects in the 036 * file. 037 * </p> 038 * 039 * <p> 040 * From the TreeView, you can open data content or metadata of selected object. 041 * You can select object(s) to delete or add new object to the file. 042 * </p> 043 * 044 * @author Peter X. Cao 045 * @version 2.4 9/6/2007 046 */ 047public abstract interface TreeView { 048 /** 049 * Opens a file and retrieves the file structure of the file. It also can be 050 * used to create a new file by setting the accessID to FileFormat.CREATE. 051 * 052 * <p> 053 * Subclasses must implement this function to take appropriate steps to open 054 * a file. 055 * </p> 056 * 057 * @param filename 058 * the name of the file to open. 059 * @param accessID 060 * identifier for the file access. Valid value of accessID is: 061 * <ul> 062 * <li>FileFormat.READ --- allow read-only access to file.</li> 063 * <li>FileFormat.WRITE --- allow read and write access to file.</li> 064 * <li>FileFormat.CREATE --- create a new file.</li> 065 * </ul> 066 * 067 * @return the FileFormat of this file if successful; otherwise returns 068 * null. 069 */ 070 public abstract FileFormat openFile(String filename, int accessID) throws Exception; 071 public abstract FileFormat reopenFile(FileFormat theFile) 072 throws Exception; 073 074 /** 075 * close a file 076 * 077 * @param file 078 * the file to close 079 */ 080 public abstract void closeFile(FileFormat file) throws Exception; 081 082 /** 083 * save a file 084 * 085 * @param file 086 * the file to save 087 */ 088 public abstract void saveFile(FileFormat file) throws Exception; 089 090 /** 091 * Gets the selected the file. When multiple files are open, we need to know 092 * which file is currently selected. 093 * 094 * @return the FileFormat of the selected file. 095 */ 096 public abstract FileFormat getSelectedFile(); 097 098 /** 099 * Gets a list of selected objects in the tree. Obtaining a list of current 100 * selected objects is necessary for copy/paste/delete objects. 101 * 102 * @return a list of selected object in the tree. 103 */ 104 public abstract List<?> getSelectedObjects(); 105 106 /** 107 * @return the current selected object in the tree. 108 */ 109 public abstract HObject getCurrentObject(); 110 111 /** 112 * Display the content of a data object. 113 * 114 * @param dataObject 115 * the data object 116 * @return the dataview that displays the data content 117 * @throws Exception 118 */ 119 public abstract DataView showDataContent(HObject dataObject) 120 throws Exception; 121 122 /** 123 * Displays the meta data of a data object. 124 * 125 * @param dataObject 126 * the data object 127 * @return the MetaDataView that displays the MetaData of the data object 128 * @throws Exception 129 */ 130 public abstract MetaDataView showMetaData(HObject dataObject) 131 throws Exception; 132 133 /** 134 * Adds a new data object to the file. 135 * 136 * @param newObject 137 * the new object to add. 138 * @param parentGroup 139 * the parent group the object is to add to. 140 * @throws Exception 141 */ 142 public abstract void addObject(HObject newObject, Group parentGroup) 143 throws Exception; 144 145 /** 146 * Returns the JTree which holds the file structure. 147 * 148 * @return the JTree which holds the file structure. 149 */ 150 public abstract JTree getTree(); 151 152 /** 153 * Returns the list of current open files.. 154 */ 155 public abstract List<FileFormat> getCurrentFiles(); 156 157 /** 158 * Returns the tree node that contains the given data object. 159 */ 160 public abstract TreeNode findTreeNode(HObject obj); 161 162}