Source code: com/lanceolav/jreftree/Run.java
1 /**
2 * JRefTree is a GUI interface to organize and output bibliographic references.
3 * Copyright (C) 2003 Lance O. Eastgate.
4 *
5 * This file is part of JRefTree, and was created on Mar 17, 2003.
6 *
7 * JRefTree is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 *
21 * The author can be reached at jreftree@lanceolav.com.
22 */
23
24 /**
25 * CHANGE LOG
26 *
27 * New in version 0.9 alpha:
28 * -------------------------
29 * - importing references --- There are now three choices:
30 * -- add references to list only (all references in the imported files
31 * will have "selected"-status in the list)
32 * -- add references to current folder (all references in the imported files
33 * are added to the list and the current folder (folder is expanded),
34 * and they are set to "selected"-status)
35 * -- make new folder for each file (the references in each file are given
36 * a separate subfolder, the parentfolder is expanded, only references already
37 * existing in parentfolder will be set to "selected"-status)
38 *
39 * - bug fix: there was a bug where the new elements that were supposed to be
40 * placed last, weren't.
41 *
42 * - included a (editable) citeID (entries still sort on entryID, which is not editable)
43 * - "Rename folder" option added
44 * - "New Reference" option added
45 * - "Edit Reference" option added
46 * - more fields were included (month, pubtype, issn)
47 * - added statusbar (total number of refs in list and selected number of refs in list)
48 * - moved the "view full paper" button to the buttonpanel
49 */
50
51 /**
52 * TODO list (more "todo"s throughout the program as well):
53 * - move folders
54 * - select more than one folder (or select all subfolders of some branch)
55 * - import jrt files into a subfolder
56 * - include configuration option on whether a branch should be opened when
57 * updating a folder
58 * - IF opening a branch when updating a folder, show last ref, then first ref
59 * (same strategy as for list).
60 * - Sort button (and have different sorting categories)
61 * - Maybe allow the "key" that is displayed in the list and tree to vary
62 * (perhaps one could choose different keys for list and tree?)
63 * - Merge two folders
64 */
65
66 package com.lanceolav.jreftree;
67
68 import javax.swing.*;
69 import java.awt.*;
70 import java.io.File;
71
72 public class Run extends JFrame {
73
74 // Remember to check that Messages.displayTODO() is up-to-date
75 final private static String version = "0.95 alpha";
76 final private static String year = "2003";
77
78 private TheMenuBar menuBar;
79 private ScrollRecordPane paperDisplay;
80 private TreeAndListPane treeAndListPane;
81 private JSplitPane dataPane;
82 private StatusLine statusLine;
83
84 public Run(String[] args){
85 super("Java Reference Tree Organizer");
86 Messages.setVersion(version);
87 Messages.setYear(year);
88
89 Container c = getContentPane();
90 c.setLayout(new BorderLayout());
91
92 menuBar = new TheMenuBar();
93 treeAndListPane = new TreeAndListPane(menuBar, args);
94 paperDisplay = new ScrollRecordPane(menuBar, treeAndListPane.getButtonPane());
95 statusLine = new StatusLine(" ");
96
97 menuBar.addActionListener(treeAndListPane);
98 menuBar.addViewFullPaperActionListener(paperDisplay);
99 menuBar.addDownloadActionListener(paperDisplay);
100 treeAndListPane.addListSelectionListener(paperDisplay);
101 treeAndListPane.addListSelectionListener(statusLine);
102
103 dataPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, treeAndListPane, paperDisplay);
104 // Split spare space 0/100 between top and bottom:
105 dataPane.setContinuousLayout( true );
106 dataPane.setResizeWeight(0);
107
108 c.add(menuBar, BorderLayout.NORTH);
109 c.add(dataPane, BorderLayout.CENTER);
110 c.add(statusLine,BorderLayout.SOUTH);
111
112 final Dimension winSize = new Dimension(800,600);
113 final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
114 // can now use screenSize.width and screensize.height
115 final Point winLocation = new Point(
116 (screenSize.width-winSize.width)/2,
117 (screenSize.height-winSize.height)/2);
118
119 setLocation(winLocation);
120 setSize(winSize);
121 setVisible(true);
122 }
123
124 public static void main(String[] args) {
125 System.out.println("JRefTree version "+version+", Copyright (C) "+year+" Lance O. Eastgate.");
126 System.out.println("JRefTree comes with ABSOLUTELY NO WARRANTY; for details");
127 System.out.println("see 'Warranty' in the 'Help' menu. This is free software,");
128 System.out.println("and you are welcome to redistribute it under certain conditions;");
129 System.out.println("see 'Copyright' in the Help menu for details.");
130 System.out.println("The full license can be found in the file COPYING.");
131
132 if (args.length > 0) {
133 if (args[0].startsWith("-h") || args[0].startsWith("--h")) {
134 System.out.println();
135 System.out.println("Usage: java -jar jreftree.jar [<ISI (Web of Knowledge) export files>]");
136 System.exit(0);
137 }
138 }
139
140 File workingDir;
141 String fileSeparator = System.getProperty("file.separator");
142 String homeDir = System.getProperty("user.home");
143 if (homeDir==null) { workingDir = new File("JRefTreeProjects"); }
144 else { workingDir = new File (homeDir+fileSeparator+"JRefTreeProjects"); }
145
146 if (!workingDir.exists()) {
147 workingDir.mkdir();
148 }
149 else if (workingDir.isFile()) {
150 System.err.println("Can't create directory: "+
151 workingDir.getAbsolutePath()+" is a file.");
152 System.exit(1);
153 }
154
155 System.setProperty("user.dir",workingDir.getAbsolutePath());
156 //System.getProperties().list(System.out);
157
158 File paperDir = new File (workingDir,"papers");
159 if (!paperDir.exists()) {
160 paperDir.mkdir();
161 }
162 else if (paperDir.isFile()) {
163 System.err.println("Can't create directory: "+
164 paperDir.getAbsolutePath()+" is a file.");
165 System.exit(1);
166 }
167
168
169 Run app = new Run(args);
170 app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
171 }
172 }