1 /* Copyright (C) 2005-2011 Fabio Riccardi */
2 
3 package com.lightcrafts.ui.metadata.test;
4 
5 import com.lightcrafts.platform.Platform;
6 
7 import javax.swing.*;
8 import javax.swing.tree.DefaultTreeSelectionModel;
9 import javax.swing.tree.TreeNode;
10 import javax.swing.tree.TreeSelectionModel;
11 import java.io.File;
12 
13 public class MetadataExplorer {
14 
main(String[] args)15     public static void main(String[] args) {
16         // Find a file system root to explore:
17         File root;
18         if (args.length > 0) {
19             root = new File(args[0]);
20         }
21         else {
22             String dir = System.getProperty("user.dir");
23             root = new File(dir);
24         }
25         // The ImageInfo thumbnails mechanism needs dcraw for raw files:
26         System.loadLibrary("DCRaw");
27         if ( Platform.isMac() ) {
28             System.loadLibrary("MacOSX");
29         }
30 
31         // Make a JTree to represent the files:
32         TreeNode rootNode = new FileNode(root);
33         JTree tree = new JTree(rootNode);
34 
35         // Enforce a single-row selection model on the tree:
36         TreeSelectionModel selectModel = new DefaultTreeSelectionModel();
37         selectModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
38         tree.setSelectionModel(selectModel);
39 
40         // The metadata display:
41         DirectoryUpdater dirs = new DirectoryUpdater(tree);
42 
43         // The thumbnail display:
44         ThumbnailUpdater thumbs = new ThumbnailUpdater(tree);
45 
46         // The preview display:
47         PreviewUpdater previews = new PreviewUpdater(tree);
48 
49         // The file tree and the metadata tables go in a split pane:
50         JSplitPane split = new JSplitPane(
51             JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(tree), dirs
52         );
53 
54         // The thumbnails and previews go in their own frames:
55         JFrame thumbFrame = new JFrame("Thumbnails");
56         thumbFrame.setContentPane(thumbs);
57         thumbFrame.setLocation(700, 20);
58         thumbFrame.pack();
59         JFrame previewFrame = new JFrame("Previews");
60         previewFrame.setContentPane(previews);
61         previewFrame.setLocation(700, 200);
62         previewFrame.pack();
63 
64         // Show a frame holding all this stuff:
65         JFrame frame = new JFrame("Metadata Explorer");
66         frame.setContentPane(split);
67         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
68         frame.setLocation(0, 20);
69         frame.setSize(600, 800);
70 
71         previewFrame.setVisible(true);
72         thumbFrame.setVisible(true);
73         frame.setVisible(true);
74     }
75 }
76