Source Code Cross Referenced for App.java in  » Project-Management » memoranda » net » sf » memoranda » ui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Project Management » memoranda » net.sf.memoranda.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sf.memoranda.ui;
002:
003:        import java.awt.Dimension;
004:        import java.awt.Frame;
005:        import java.awt.Toolkit;
006:        import java.util.Calendar;
007:
008:        import javax.swing.ImageIcon;
009:        import javax.swing.JFrame;
010:        import javax.swing.JLabel;
011:        import javax.swing.UIManager;
012:
013:        import net.sf.memoranda.EventNotificationListener;
014:        import net.sf.memoranda.EventsScheduler;
015:        import net.sf.memoranda.util.Configuration;
016:        import net.sf.memoranda.util.Local;
017:        import snoozesoft.systray4j.SysTrayMenu;
018:        import snoozesoft.systray4j.SysTrayMenuEvent;
019:        import snoozesoft.systray4j.SysTrayMenuIcon;
020:        import snoozesoft.systray4j.SysTrayMenuItem;
021:        import snoozesoft.systray4j.SysTrayMenuListener;
022:
023:        /**
024:         * 
025:         * Copyright (c) 2003 Memoranda Team. http://memoranda.sf.net
026:         */
027:
028:        /*$Id: App.java,v 1.28 2007/03/20 06:21:46 alexeya Exp $*/
029:        public class App implements  SysTrayMenuListener {
030:            // boolean packFrame = false;
031:
032:            static AppFrame frame = null;
033:            static SysTrayMenu menu = null;
034:
035:            static SysTrayMenuIcon icon = null;
036:            static SysTrayMenuIcon iconEv = null;
037:            static SysTrayMenuItem itemExit = null;
038:            static SysTrayMenuItem itemMinimize = null;
039:            static SysTrayMenuItem itemRestore = null;
040:
041:            public static boolean sysTrayDisabled = true;
042:
043:            public static final String GUIDE_URL = "http://memoranda.sourceforge.net/guide.html";
044:            public static final String BUGS_TRACKER_URL = "http://sourceforge.net/tracker/?group_id=90997&atid=595566";
045:            public static final String WEBSITE_URL = "http://memoranda.sourceforge.net";
046:
047:            private JFrame splash = null;
048:
049:            static {
050:                if (!Configuration.get("DISABLE_SYSTRAY").equals("yes")) {
051:                    icon = new SysTrayMenuIcon(AppFrame.class
052:                            .getResource("resources/icons/jnotes"
053:                                    + SysTrayMenuIcon.getExtension()));
054:                    iconEv = new SysTrayMenuIcon(AppFrame.class
055:                            .getResource("resources/icons/jnotes_ev"
056:                                    + SysTrayMenuIcon.getExtension()));
057:                    itemExit = new SysTrayMenuItem(Local.getString("Exit"),
058:                            "exit");
059:                    itemMinimize = new SysTrayMenuItem(Local
060:                            .getString("Minimize"), "minimize");
061:                    itemRestore = new SysTrayMenuItem(Local
062:                            .getString("Restore"), "restore");
063:                    menu = new SysTrayMenu(icon, "Memoranda");
064:                    sysTrayDisabled = false;
065:                    if (!SysTrayMenu.isAvailable()) {
066:                        System.out.println("[DEBUG] SysTray is now disabled.");
067:                        Configuration.put("DISABLE_SYSTRAY", "yes");
068:                        Configuration.put("ASK_ON_EXIT", "yes");
069:                        Configuration.put("ON_CLOSE", "exit");
070:                        Configuration.saveConfig();
071:                        sysTrayDisabled = true;
072:                    }
073:                } else
074:                    /* DEBUG */
075:                    System.out.println("System tray icon is disabled");
076:            }
077:
078:            /*========================================================================*/
079:            /* Note: Please DO NOT edit the version/build info manually!
080:               The actual values are substituted by the Ant build script using 
081:               'version' property and datestamp.*/
082:
083:            public static final String VERSION_INFO = "@VERSION@";
084:            public static final String BUILD_INFO = "@BUILD@";
085:
086:            /*========================================================================*/
087:
088:            public static AppFrame getFrame() {
089:                return frame;
090:            }
091:
092:            public void show() {
093:                if (frame.isVisible()) {
094:                    frame.toFront();
095:                    frame.requestFocus();
096:                } else
097:                    init();
098:            }
099:
100:            public App(boolean fullmode) {
101:                super ();
102:                if (fullmode)
103:                    fullmode = !Configuration.get("START_MINIMIZED").equals(
104:                            "yes");
105:                /* DEBUG */
106:                if (!fullmode)
107:                    System.out.println("Minimized mode");
108:                if (!Configuration.get("SHOW_SPLASH").equals("no"))
109:                    showSplash();
110:                System.out.println(VERSION_INFO);
111:                try {
112:                    if (Configuration.get("LOOK_AND_FEEL").equals("system"))
113:                        UIManager.setLookAndFeel(UIManager
114:                                .getSystemLookAndFeelClassName());
115:                    else if (Configuration.get("LOOK_AND_FEEL").equals(
116:                            "kunststoff"))
117:                        UIManager
118:                                .setLookAndFeel("com.incors.plaf.kunststoff.KunststoffLookAndFeel");
119:                    else if (Configuration.get("LOOK_AND_FEEL").equals(
120:                            "default"))
121:                        UIManager.setLookAndFeel(UIManager
122:                                .getCrossPlatformLookAndFeelClassName());
123:                    else if (Configuration.get("LOOK_AND_FEEL").toString()
124:                            .length() > 0)
125:                        UIManager.setLookAndFeel(Configuration.get(
126:                                "LOOK_AND_FEEL").toString());
127:
128:                } catch (Exception e) {
129:                    new ExceptionDialog(
130:                            e,
131:                            "Error when initializing a pluggable look-and-feel. Default LF will be used.",
132:                            "Make sure that specified look-and-feel library classes are on the CLASSPATH.");
133:                }
134:                if (Configuration.get("FIRST_DAY_OF_WEEK").equals("")) {
135:                    String fdow;
136:                    if (Calendar.getInstance().getFirstDayOfWeek() == 2)
137:                        fdow = "mon";
138:                    else
139:                        fdow = "sun";
140:                    Configuration.put("FIRST_DAY_OF_WEEK", fdow);
141:                    Configuration.saveConfig();
142:                    /* DEBUG */
143:                    System.out.println("[DEBUG] first day of week is set to "
144:                            + fdow);
145:                }
146:                if (!sysTrayDisabled) {
147:                    icon.addSysTrayMenuListener(this );
148:                    iconEv.addSysTrayMenuListener(this );
149:                    itemExit.addSysTrayMenuListener(this );
150:                    itemMinimize.addSysTrayMenuListener(this );
151:                    itemRestore.addSysTrayMenuListener(this );
152:                    menu.addItem(itemExit, 0);
153:                    menu.addSeparator(1);
154:                    menu.addItem(itemRestore, 2);
155:                    EventsScheduler
156:                            .addListener(new EventNotificationListener() {
157:                                public void eventIsOccured(
158:                                        net.sf.memoranda.Event ev) {
159:                                }
160:
161:                                public void eventsChanged() {
162:                                    if (EventsScheduler.isEventScheduled()) {
163:                                        net.sf.memoranda.Event ev = EventsScheduler
164:                                                .getFirstScheduledEvent();
165:                                        menu.setToolTip(ev.getTimeString()
166:                                                + " - " + ev.getText());
167:                                        menu.setIcon(iconEv);
168:                                    } else {
169:                                        menu.setToolTip("Memoranda");
170:                                        menu.setIcon(icon);
171:                                    }
172:                                }
173:                            });
174:                }
175:                EventsScheduler.init();
176:                frame = new AppFrame();
177:                if (fullmode) {
178:                    init();
179:                }
180:                if (!Configuration.get("SHOW_SPLASH").equals("no"))
181:                    splash.dispose();
182:            }
183:
184:            void init() {
185:                if (!sysTrayDisabled) {
186:                    menu.removeAll();
187:                    menu.addItem(itemExit, 0);
188:                    menu.addSeparator(1);
189:                    menu.addItem(itemMinimize, 2);
190:                }
191:                /*
192:                 * if (packFrame) { frame.pack(); } else { frame.validate(); }
193:                 * 
194:                 * Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
195:                 * 
196:                 * Dimension frameSize = frame.getSize(); if (frameSize.height >
197:                 * screenSize.height) { frameSize.height = screenSize.height; } if
198:                 * (frameSize.width > screenSize.width) { frameSize.width =
199:                 * screenSize.width; }
200:                 * 
201:                 * 
202:                 * Make the window fullscreen - On Request of users This seems not to
203:                 * work on sun's version 1.4.1_01 Works great with 1.4.2 !!! So update
204:                 * your J2RE or J2SDK.
205:                 */
206:                /* Used to maximize the screen if the JVM Version if 1.4 or higher */
207:                /* --------------------------------------------------------------- */
208:                double JVMVer = Double.valueOf(
209:                        System.getProperty("java.version").substring(0, 3))
210:                        .doubleValue();
211:
212:                frame.pack();
213:                if (JVMVer >= 1.4) {
214:                    frame.setExtendedState(Frame.MAXIMIZED_BOTH);
215:                } else {
216:                    frame.setExtendedState(Frame.NORMAL);
217:                }
218:                /* --------------------------------------------------------------- */
219:                /* Added By Jeremy Whitlock (jcscoobyrs) 07-Nov-2003 at 15:54:24 */
220:
221:                // Not needed ???
222:                frame.setVisible(true);
223:                frame.toFront();
224:                frame.requestFocus();
225:
226:            }
227:
228:            public static void closeWindow() {
229:                if (frame == null)
230:                    return;
231:                frame.dispose();
232:                //long m1 = Runtime.getRuntime().freeMemory();
233:                //frame = null;
234:                if (!sysTrayDisabled) {
235:                    menu.removeAll();
236:                    menu.addItem(itemExit, 0);
237:                    menu.addSeparator(1);
238:                    menu.addItem(itemRestore, 2);
239:                } else
240:                    System.out
241:                            .println("Memoranda is active in a 'daemon mode'. To restore the window, run the application again.");
242:                //CurrentProject.free();
243:                System.gc(); // ??? Are we really need it?
244:                //long m2 = Runtime.getRuntime().freeMemory();
245:                /* DEBUG *///System.out.println("Window closed. "+(m2-m1)/1024);
246:            }
247:
248:            /**
249:             * @see snoozesoft.systray4j.SysTrayMenuListener#menuItemSelected(snoozesoft.systray4j.SysTrayMenuEvent)
250:             */
251:            public void menuItemSelected(SysTrayMenuEvent e) {
252:                if (e.getActionCommand().equals("restore"))
253:                    show();
254:                else if (e.getActionCommand().equals("minimize"))
255:                    closeWindow();
256:                else if (e.getActionCommand().equals("exit")) {
257:                    if (frame != null)
258:                        frame.doExit();
259:                    else
260:                        System.exit(0);
261:                }
262:            }
263:
264:            /**
265:             * @see snoozesoft.systray4j.SysTrayMenuListener#iconLeftClicked(snoozesoft.systray4j.SysTrayMenuEvent)
266:             */
267:            public void iconLeftClicked(SysTrayMenuEvent arg0) {
268:                show();
269:            }
270:
271:            /**
272:             * @see snoozesoft.systray4j.SysTrayMenuListener#iconLeftDoubleClicked(snoozesoft.systray4j.SysTrayMenuEvent)
273:             */
274:            public void iconLeftDoubleClicked(SysTrayMenuEvent arg0) {
275:                show();
276:            }
277:
278:            /**
279:             * Method showSplash.
280:             */
281:            private void showSplash() {
282:                splash = new JFrame();
283:                ImageIcon spl = new ImageIcon(App.class
284:                        .getResource("resources/splash.png"));
285:                JLabel l = new JLabel();
286:                l.setSize(400, 300);
287:                l.setIcon(spl);
288:                splash.getContentPane().add(l);
289:                splash.setSize(400, 300);
290:                Dimension screenSize = Toolkit.getDefaultToolkit()
291:                        .getScreenSize();
292:                splash.setLocation((screenSize.width - 400) / 2,
293:                        (screenSize.height - 300) / 2);
294:                splash.setUndecorated(true);
295:                splash.setVisible(true);
296:            }
297:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.