* @param args command line array; each element is assumed to be a report
* file name.
*/
public static void main(String[] args) {
Getopts g = new Getopts("a:c:d:e:f:g:h:i:l:np:qr:s:wx:E:R:o:", args);
if (g.error()) { // Any bad command line argument?
usage(null); // If so, whine and exit
}
// Get user's preferences, if any.
Preferences prefs = Preferences.userRoot().node("/jimm/datavision");
// Set look & feel.
try {
javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
// Default L&F will be used if any problems occur, most probably,
// ClassNotFound.
}
DataVision dv = new DataVision();
// Language
if (g.hasOption('g') || g.hasOption('i'))
I18N.setLanguage(new Locale(g.option('g', "").toLowerCase(),
g.option('i', "").toUpperCase()));
dv.layoutEngineChoiceFromOptions(g);
dv.dataSourceFromOptions(g);
if (dv.hasLayoutEngine()) {
if (dv.usesGUI()) // Can ask for password via GUI
ErrorHandler.useGUI(true);
else if (!g.hasOption('n') && !g.hasOption('p') && !g.hasOption('e'))
usage(I18N.get("DataVision.n_or_p"));
}
dv.paramXMLFile = g.option('r', null); // Parameter XML file name or null
dv.reportDir = g.option('R', null); // Report Directory or null
dv.outputDir = g.option('o', null); // Output Directory or null
// Store the report directory in the preferences for this package
// These values are stored in the root package jimm.datavision
if (dv.reportDir != null) {
prefs.put("reportDir",dv.reportDir);
}
if (dv.outputDir != null) {
prefs.put("outputDir",dv.outputDir);
}
if (g.argc() == 0) {
if (startupDialog()) // Returns true if we should exit
return;
if (dv.hasLayoutEngine()) // Have layout engine but no file
usage(I18N.get("DataVision.xml_req"));
else {
try {
dv.designReport(g, null);
}
catch (Exception e) { // Global catch-all
ErrorHandler.error(e);
}
}
}
else { // Loop over input files
dv.numReports = g.argc();
for (int i = 0; i < g.argc(); ++i) {
File f = new File(g.argv(i));
try {
if (dv.hasLayoutEngine())
dv.runReport(g, f);
else
dv.designReport(g, f);