Changeset 9114
- Timestamp:
- 2005-02-18T16:09:11+13:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/file/FileManager.java
r8783 r9114 43 43 import org.greenstone.gatherer.collection.CollectionTreeNode; 44 44 import org.greenstone.gatherer.gui.LongProgressBar; 45 import org.greenstone.gatherer.gui.NewFolder Prompt;45 import org.greenstone.gatherer.gui.NewFolderOrFilePrompt; 46 46 import org.greenstone.gatherer.gui.tree.DragTree; 47 47 import org.greenstone.gatherer.util.DragComponent; … … 53 53 */ 54 54 public class FileManager { 55 56 public static int FILE_TYPE = 0; 57 public static int FOLDER_TYPE = 1; 55 58 56 59 static public int countFolderDepth(File file) { … … 125 128 } 126 129 130 public void newDummyDoc(DragTree tree, CollectionTreeNode parent_node){ 131 newFolderOrDummyDoc(tree, parent_node, FILE_TYPE); 132 } 133 127 134 public void newFolder(DragTree tree, CollectionTreeNode parent_node) { 135 newFolderOrDummyDoc(tree, parent_node, FOLDER_TYPE); 136 } 137 protected void newFolderOrDummyDoc(DragTree tree, CollectionTreeNode parent_node, int type) { 128 138 // Ask the user for the directories name. 129 NewFolderPrompt new_folder_prompt = new NewFolderPrompt(parent_node); 139 String extension = ""; 140 if (type == FILE_TYPE) { 141 extension = ".nul"; 142 } 143 NewFolderOrFilePrompt new_folder_prompt = new NewFolderOrFilePrompt(parent_node, type, extension); 130 144 String name = new_folder_prompt.display(); 131 145 new_folder_prompt.dispose(); … … 136 150 File folder_file = new File(parent_node.getFile(), name); 137 151 //... check if it already exists. 138 if(folder_file.exists()) { 139 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("FileActions.Folder_Already_Exists", name), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 152 if(folder_file.exists()) { 153 if (type == FILE_TYPE) { 154 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("FileActions.File_Already_Exists_No_Create", name), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 155 } else { 156 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("FileActions.Folder_Already_Exists", name), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 157 } 140 158 } 141 159 // Otherwise create it. 142 160 else { 143 folder_file.mkdirs(); 144 145 // Update the parent node to show the new folder 146 parent_node.refresh(); 147 148 // Refresh workspace tree (collection tree is done automatically) 149 Gatherer.g_man.refreshWorkspaceTree(DragTree.COLLECTION_CONTENTS_CHANGED); 150 } 161 try { 162 if (type == FILE_TYPE) { 163 folder_file.createNewFile(); 164 } else { 165 folder_file.mkdirs(); 166 } 167 // Update the parent node to show the new folder 168 parent_node.refresh(); 169 170 // Refresh workspace tree (collection tree is done automatically) 171 Gatherer.g_man.refreshWorkspaceTree(DragTree.COLLECTION_CONTENTS_CHANGED); 172 } catch (Exception e) { 173 if (type == FILE_TYPE) { 174 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("FileActions.File_Create_Error", name), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 175 } else { 176 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("FileActions.Folder_Create_Error", name), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 177 } 178 } 179 } 180 151 181 folder_file = null; 152 182 model = null;
Note:
See TracChangeset
for help on using the changeset viewer.