From fc9d408f3584c686bbdcdc3c2c7e3f7cadb56f3b Mon Sep 17 00:00:00 2001 From: Denis Molony Date: Thu, 15 Dec 2016 18:48:51 +1100 Subject: [PATCH] Removed catalog package --- .../catalog/AbstractCatalogCreator.java | 13 --- .../catalog/AbstractDiskCreator.java | 35 ------- .../diskbrowser/catalog/CatalogLister.java | 12 --- .../diskbrowser/catalog/DiskLister.java | 19 ---- .../catalog/DocumentCreatorFactory.java | 43 --------- .../catalog/TextCatalogCreator.java | 93 ------------------- .../diskbrowser/catalog/TextDiskCreator.java | 64 ------------- 7 files changed, 279 deletions(-) delete mode 100755 src/com/bytezone/diskbrowser/catalog/AbstractCatalogCreator.java delete mode 100755 src/com/bytezone/diskbrowser/catalog/AbstractDiskCreator.java delete mode 100755 src/com/bytezone/diskbrowser/catalog/CatalogLister.java delete mode 100755 src/com/bytezone/diskbrowser/catalog/DiskLister.java delete mode 100755 src/com/bytezone/diskbrowser/catalog/DocumentCreatorFactory.java delete mode 100755 src/com/bytezone/diskbrowser/catalog/TextCatalogCreator.java delete mode 100755 src/com/bytezone/diskbrowser/catalog/TextDiskCreator.java diff --git a/src/com/bytezone/diskbrowser/catalog/AbstractCatalogCreator.java b/src/com/bytezone/diskbrowser/catalog/AbstractCatalogCreator.java deleted file mode 100755 index 41c4a79..0000000 --- a/src/com/bytezone/diskbrowser/catalog/AbstractCatalogCreator.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.bytezone.diskbrowser.catalog; - -import javax.swing.tree.DefaultMutableTreeNode; - -public abstract class AbstractCatalogCreator implements CatalogLister -{ - DefaultMutableTreeNode node; - - public void setNode (DefaultMutableTreeNode node) - { - this.node = node; - } -} \ No newline at end of file diff --git a/src/com/bytezone/diskbrowser/catalog/AbstractDiskCreator.java b/src/com/bytezone/diskbrowser/catalog/AbstractDiskCreator.java deleted file mode 100755 index 05a7a61..0000000 --- a/src/com/bytezone/diskbrowser/catalog/AbstractDiskCreator.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.bytezone.diskbrowser.catalog; - -import java.util.Enumeration; - -import javax.swing.JTree; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.DefaultTreeModel; - -import com.bytezone.diskbrowser.disk.FormattedDisk; -import com.bytezone.diskbrowser.gui.DiskSelectedEvent; - -public abstract class AbstractDiskCreator implements DiskLister -{ - FormattedDisk disk; - - public void setDisk (FormattedDisk disk) - { - this.disk = disk; - } - - // should return List - @SuppressWarnings("unchecked") - public Enumeration getEnumeration () - { - JTree tree = disk.getCatalogTree (); - DefaultTreeModel treeModel = (DefaultTreeModel) tree.getModel (); - DefaultMutableTreeNode node = (DefaultMutableTreeNode) treeModel.getRoot (); - return node.breadthFirstEnumeration (); - } - - public void diskSelected (DiskSelectedEvent e) - { - setDisk (e.getFormattedDisk ()); - } -} \ No newline at end of file diff --git a/src/com/bytezone/diskbrowser/catalog/CatalogLister.java b/src/com/bytezone/diskbrowser/catalog/CatalogLister.java deleted file mode 100755 index 6620542..0000000 --- a/src/com/bytezone/diskbrowser/catalog/CatalogLister.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.bytezone.diskbrowser.catalog; - -import javax.swing.tree.DefaultMutableTreeNode; - -public interface CatalogLister -{ - public void setNode (DefaultMutableTreeNode node); - - public void createCatalog (); - - public String getMenuText (); -} \ No newline at end of file diff --git a/src/com/bytezone/diskbrowser/catalog/DiskLister.java b/src/com/bytezone/diskbrowser/catalog/DiskLister.java deleted file mode 100755 index 81e2003..0000000 --- a/src/com/bytezone/diskbrowser/catalog/DiskLister.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.bytezone.diskbrowser.catalog; - -import java.util.Enumeration; - -import javax.swing.tree.DefaultMutableTreeNode; - -import com.bytezone.diskbrowser.disk.FormattedDisk; -import com.bytezone.diskbrowser.gui.DiskSelectionListener; - -public interface DiskLister extends DiskSelectionListener -{ - public void setDisk (FormattedDisk disk); - - public void createDisk (); - - public Enumeration getEnumeration (); - - public String getMenuText (); -} \ No newline at end of file diff --git a/src/com/bytezone/diskbrowser/catalog/DocumentCreatorFactory.java b/src/com/bytezone/diskbrowser/catalog/DocumentCreatorFactory.java deleted file mode 100755 index d1d9822..0000000 --- a/src/com/bytezone/diskbrowser/catalog/DocumentCreatorFactory.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.bytezone.diskbrowser.catalog; - -import com.bytezone.diskbrowser.gui.MenuHandler; - -public class DocumentCreatorFactory -{ - public CatalogLister catalogLister; - public DiskLister diskLister; - - private DocumentCreatorFactory (MenuHandler mh) - { - // try - // { - // Class.forName ("com.lowagie.text.Document"); - // catalogLister = new PDFCatalogCreator (); - // diskLister = new PDFDiskCreator (); - // } - // catch (ClassNotFoundException e) - // { - // catalogLister = new TextCatalogCreator (); - // diskLister = new TextDiskCreator (); - // } - - // mh.createCatalogFileItem.setText (catalogLister.getMenuText ()); - // mh.createDiskFileItem.setText (diskLister.getMenuText ()); - // - // mh.createCatalogFileItem.addActionListener (new ActionListener () - // { - // public void actionPerformed (ActionEvent e) - // { - // catalogLister.createCatalog (); - // } - // }); - - // mh.createDiskFileItem.addActionListener (new ActionListener () - // { - // public void actionPerformed (ActionEvent e) - // { - // diskLister.createDisk (); - // } - // }); - } -} \ No newline at end of file diff --git a/src/com/bytezone/diskbrowser/catalog/TextCatalogCreator.java b/src/com/bytezone/diskbrowser/catalog/TextCatalogCreator.java deleted file mode 100755 index dce2205..0000000 --- a/src/com/bytezone/diskbrowser/catalog/TextCatalogCreator.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.bytezone.diskbrowser.catalog; - -import java.awt.EventQueue; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.Enumeration; - -import javax.swing.JOptionPane; -import javax.swing.tree.DefaultMutableTreeNode; - -import com.bytezone.diskbrowser.disk.DiskFactory; -import com.bytezone.diskbrowser.disk.FormattedDisk; -import com.bytezone.diskbrowser.gui.TreeBuilder.FileNode; - -class TextCatalogCreator extends AbstractCatalogCreator -{ - @Override - public void createCatalog () - { - Object o = node.getUserObject (); - if (!(o instanceof FileNode)) - { - JOptionPane.showMessageDialog (null, "Please select a folder from the Disk Tree", - "Info", JOptionPane.INFORMATION_MESSAGE); - return; - } - File f = ((FileNode) o).file; - final File f2 = new File (f.getAbsolutePath () + "/Catalog.txt"); - JOptionPane.showMessageDialog (null, - "About to create file : " + f2.getAbsolutePath (), "Info", - JOptionPane.INFORMATION_MESSAGE); - - EventQueue.invokeLater (new Runnable () - { - @Override - public void run () - { - FileWriter out = null; - try - { - out = new FileWriter (f2); - printDescendants (node, out); - } - catch (IOException e) - { - JOptionPane.showMessageDialog (null, - "Error creating catalog : " + e.getMessage (), "Bugger", - JOptionPane.INFORMATION_MESSAGE); - } - finally - { - try - { - if (out != null) - out.close (); - } - catch (IOException e) - { - e.printStackTrace (); - } - } - } - - private void printDescendants (DefaultMutableTreeNode root, FileWriter out) - throws IOException - { - Object o = root.getUserObject (); - if (o instanceof FileNode) - { - File f = ((FileNode) root.getUserObject ()).file; - if (!f.isDirectory ()) - { - FormattedDisk fd = DiskFactory.createDisk (f.getAbsolutePath ()); - out.write ( - fd.getCatalog ().getDataSource ().getText () + String.format ("%n")); - } - } - - Enumeration children = root.children (); - if (children != null) - while (children.hasMoreElements ()) - printDescendants (children.nextElement (), out); - } - }); - } - - @Override - public String getMenuText () - { - return "Create catalog text"; - } -} \ No newline at end of file diff --git a/src/com/bytezone/diskbrowser/catalog/TextDiskCreator.java b/src/com/bytezone/diskbrowser/catalog/TextDiskCreator.java deleted file mode 100755 index 03bfb27..0000000 --- a/src/com/bytezone/diskbrowser/catalog/TextDiskCreator.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.bytezone.diskbrowser.catalog; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.Enumeration; - -import javax.swing.tree.DefaultMutableTreeNode; - -import com.bytezone.diskbrowser.applefile.AppleFileSource; - -class TextDiskCreator extends AbstractDiskCreator -{ - @Override - public void createDisk () - { - File f = new File ("D:\\DiskDetails.txt"); - FileWriter out = null; - - try - { - out = new FileWriter (f); - printDisk (out); - } - catch (IOException e) - { - e.printStackTrace (); - } - finally - { - if (out != null) - try - { - out.close (); - } - catch (IOException e) - { - e.printStackTrace (); - } - } - } - - private void printDisk (FileWriter out) throws IOException - { - Enumeration children = getEnumeration (); - - if (children == null) - return; - - while (children.hasMoreElements ()) - { - DefaultMutableTreeNode node = children.nextElement (); - AppleFileSource afs = (AppleFileSource) node.getUserObject (); - out.write (afs.getDataSource ().getText () + String.format ("%n")); - } - - } - - @Override - public String getMenuText () - { - return "create text disk"; - } -} \ No newline at end of file