KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > antlr > works > stats > Statistics


1 package org.antlr.works.stats;
2
3 import org.antlr.xjlib.appkit.app.XJApplicationDelegate;
4 import org.antlr.xjlib.appkit.swing.XJLookAndFeel;
5 import org.antlr.xjlib.appkit.utils.XJAlert;
6 import org.antlr.works.IDE;
7 import org.antlr.works.dialog.DialogPersonalInfo;
8 import org.antlr.works.dialog.DialogReports;
9 import org.antlr.works.dialog.DialogReportsDelegate;
10 import org.antlr.works.prefs.AWPrefs;
11 import org.antlr.works.utils.Localizable;
12
13 import java.util.List JavaDoc;
14 /*
15
16 [The "BSD licence"]
17 Copyright (c) 2005-2006 Jean Bovet
18 All rights reserved.
19
20 Redistribution and use in source and binary forms, with or without
21 modification, are permitted provided that the following conditions
22 are met:
23
24 1. Redistributions of source code must retain the above copyright
25 notice, this list of conditions and the following disclaimer.
26 2. Redistributions in binary form must reproduce the above copyright
27 notice, this list of conditions and the following disclaimer in the
28 documentation and/or other materials provided with the distribution.
29 3. The name of the author may not be used to endorse or promote products
30 derived from this software without specific prior written permission.
31
32 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
33 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
34 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
35 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
36 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
38 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
39 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
41 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42
43 */

44
45 /** This class is used to report manually the statistics without having to launch AW completely.
46  * We still rely on the XJLibrary and most of AW settings but at least only one dialog is displayed.
47  */

48
49 public class Statistics extends XJApplicationDelegate implements DialogReportsDelegate {
50
51     public void appDidLaunch(String JavaDoc[] args, List JavaDoc<String JavaDoc> documentsToOpenAtStartup) {
52         AWPrefs.setLookAndFeel(XJLookAndFeel.applyLookAndFeel(AWPrefs.getLookAndFeel()));
53
54         if(args.length >= 2 && args[1].equals("-erase")) {
55             StatisticsManager.reset(StatisticsReporter.TYPE_GUI);
56             StatisticsManager.reset(StatisticsReporter.TYPE_GRAMMAR);
57             StatisticsManager.reset(StatisticsReporter.TYPE_RUNTIME);
58             XJAlert.display(null, "Statistics", "The statistics have been successfully erased.");
59             System.exit(0);
60         } else {
61             /** Ask the user to register if it didn't register on this machine previously */
62             if(!AWPrefs.isUserRegistered()) {
63                 AWPrefs.setServerID("");
64                 new DialogPersonalInfo(null).runModal();
65                 AWPrefs.setUserRegistered(true);
66             }
67
68             DialogReports reports = new DialogReports(null, false);
69             reports.setDelegate(this);
70             reports.runModal();
71         }
72     }
73
74     public void reportsCancelled() {
75         System.exit(0);
76     }
77
78     public void reportsSend(boolean success) {
79         System.exit(0);
80     }
81
82     public String JavaDoc appVersionShort() {
83         return Localizable.getLocalizedString(Localizable.APP_VERSION_SHORT);
84     }
85
86     public String JavaDoc appVersionLong() {
87         return Localizable.getLocalizedString(Localizable.APP_VERSION_LONG);
88     }
89
90     public Class JavaDoc appPreferencesClass() {
91         return IDE.class;
92     }
93
94     public boolean appHasPreferencesMenuItem() {
95         return false;
96     }
97
98     public boolean supportsPersistence() {
99         return false;
100     }
101
102 }
103
Popular Tags