Changeset 37700
- Timestamp:
- 2023-04-21T21:24:08+12:00 (12 months ago)
- Location:
- main/trunk/gli
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/classes/dictionary.properties
r37698 r37700 399 399 CollectionPopupMenu.Rename:Rename 400 400 CollectionPopupMenu.Replace:Replace... 401 CollectionPopupMenu.Unzip:Unzip 401 402 #******************************* 402 403 # -
main/trunk/gli/src/org/greenstone/gatherer/collection/CollectionTree.java
r37191 r37700 30 30 import java.awt.dnd.DropTargetDropEvent; 31 31 import java.awt.event.*; 32 import java.io.File; 33 import java.util.Vector; 32 34 import javax.swing.*; 33 35 import javax.swing.tree.*; … … 37 39 import org.greenstone.gatherer.gui.tree.DragTree; 38 40 import org.greenstone.gatherer.gui.tree.DragTreeCellRenderer; 41 import org.greenstone.gatherer.util.UnzipTools; 39 42 40 43 … … 148 151 private JMenuItem explode_metadata_database = null; 149 152 private JMenuItem replace_srcdoc_with_html = null; 153 private JMenuItem unzip_file = null; 150 154 private JMenuItem delete = null; 151 155 private JMenuItem metaaudit = null; … … 287 291 } 288 292 289 // Meta-audit and deleteoptions293 // Meta-audit, delete and unzip options 290 294 metaaudit = new JMenuItem(Dictionary.get("Menu.Metadata_View", collection_tree.getSelectionDetails()), KeyEvent.VK_A); 291 295 metaaudit.addActionListener(this); … … 309 313 } 310 314 } 311 312 // Only meta-audit and delete (and possibly replace_srcdoc) are available if multiple items are selected... 315 316 // Unzip menu option is available if not remote GS 317 // and when all selected files are of .zip extension 318 if(!Gatherer.isGsdlRemote && firstSelectedNode.isZipFile()) { // test 1st selected node 319 unzip_file = new JMenuItem(Dictionary.get("CollectionPopupMenu.Unzip"), KeyEvent.VK_U); 320 unzip_file.addActionListener(this); 321 add(unzip_file); 322 323 // Now the menu is there, grey it out if not all the files are of the same type 324 if(!selectedFilesOfSameType(selection_paths)) { 325 unzip_file.setEnabled(false); 326 } 327 } 328 329 // Only meta-audit and delete (and possibly replace_srcdoc and unzip_file) 330 // are available if multiple items are selected... 313 331 if (selection_paths.length > 1) { 314 332 return; … … 397 415 // Replace source document with generated html (works with replace_srcdoc_with_html.pl) 398 416 else if (source == replace_srcdoc_with_html) { 399 java.io.File[] source_files = new java.io.File[selection_paths.length];417 File[] source_files = new File[selection_paths.length]; 400 418 for (int i = 0; i < selection_paths.length; i++) { 401 419 CollectionTreeNode node = (CollectionTreeNode) selection_paths[i].getLastPathComponent(); … … 405 423 } 406 424 425 else if (source == unzip_file) { 426 Vector<CollectionTreeNode> sourceNodes = new Vector(selection_paths.length); 427 // all selected shall be zip files at this stage 428 for (int i = 0; i < selection_paths.length; i++) { 429 CollectionTreeNode node = (CollectionTreeNode) selection_paths[i].getLastPathComponent(); 430 //System.err.println("Away to unzip file" + node.getFile().getPath()); 431 432 // unzip the zip file into its parent directory 433 // and maintain list of successfully unzipped files to delete 434 if(UnzipTools.unzipFile(node.getFile().getPath(), node.getFile().getParent()+File.separator)) { 435 sourceNodes.add(node); 436 } 437 } 438 439 // refresh collection view - now done in file/FileQueue::run() in synchronized(this) 440 //Gatherer.g_man.refreshCollectionTree(DragTree.COLLECTION_CONTENTS_CHANGED); 441 442 // for all zips that were successfully unzipped, delete the zip file itself 443 CollectionTreeNode[] unzippedNodes = new CollectionTreeNode[sourceNodes.size()]; 444 unzippedNodes = sourceNodes.toArray(unzippedNodes); 445 // Fire a delete action - refreshes collection tree on its own iff refresh not 446 // called on the tree before or after. But then the unzipped files didn't show. 447 // So now refresh collection tree done in file/FileQueue::run() in synchronized(this) 448 Gatherer.f_man.action(collection_tree, unzippedNodes, Gatherer.recycle_bin, null); 449 } 450 407 451 // Delete 408 452 else if (source == delete) { -
main/trunk/gli/src/org/greenstone/gatherer/collection/CollectionTreeNode.java
r23433 r37700 84 84 } 85 85 86 public boolean isZipFile() { 87 if(this.file != null) { 88 if(file.getPath().endsWith(".zip")) { 89 return true; 90 } 91 } 92 93 return false; 94 } 95 86 96 /** This method returns a string representation of the filenodes in the 87 97 * <i>Collection</i> Tree, that can then be displayed in the tree. If the -
main/trunk/gli/src/org/greenstone/gatherer/file/FileQueue.java
r34289 r37700 704 704 if (Gatherer.g_man != null && Gatherer.c_man.ready()) { 705 705 Gatherer.g_man.refreshWorkspaceTree(DragTree.COLLECTION_CONTENTS_CHANGED); 706 // Gatherer.g_man.refreshCollectionTree(DragTree.COLLECTION_CONTENTS_CHANGED); 706 // Need this next line back in to refresh the collection tree after 707 // rightclick>Unzip has finished unzipping and deleting the original zip file 708 // TODO: But why was it commented out originally? Should it not be active? 709 Gatherer.g_man.refreshCollectionTree(DragTree.COLLECTION_CONTENTS_CHANGED); 707 710 } 708 711 -
main/trunk/gli/src/org/greenstone/gatherer/util/UnzipTools.java
r19736 r37700 35 35 public class UnzipTools 36 36 { 37 static public voidunzipFile(String zip_file_path, String base_directory_path)37 static public boolean unzipFile(String zip_file_path, String base_directory_path) 38 38 { 39 boolean success = true; 39 40 try { 40 41 ZipFile zip_file = new ZipFile(new File(zip_file_path), ZipFile.OPEN_READ); … … 51 52 if (!zip_entry_file.exists() && !zip_entry_file.mkdirs()) { 52 53 System.err.println("Error: unable to create directory " + zip_entry_file); 54 success = false; 53 55 } 54 56 } … … 94 96 catch (Exception exception) { 95 97 exception.printStackTrace(); 98 success = false; 96 99 } 100 101 return success; 97 102 } 98 103 }
Note:
See TracChangeset
for help on using the changeset viewer.