Removed catalog package

This commit is contained in:
Denis Molony 2016-12-15 18:48:51 +11:00
parent 528c4418ba
commit fc9d408f35
7 changed files with 0 additions and 279 deletions

View File

@ -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;
}
}

View File

@ -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<AppleFileSource>
@SuppressWarnings("unchecked")
public Enumeration<DefaultMutableTreeNode> 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 ());
}
}

View File

@ -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 ();
}

View File

@ -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<DefaultMutableTreeNode> getEnumeration ();
public String getMenuText ();
}

View File

@ -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 ();
// }
// });
}
}

View File

@ -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<DefaultMutableTreeNode> children = root.children ();
if (children != null)
while (children.hasMoreElements ())
printDescendants (children.nextElement (), out);
}
});
}
@Override
public String getMenuText ()
{
return "Create catalog text";
}
}

View File

@ -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<DefaultMutableTreeNode> 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";
}
}