Source Code Cross Referenced for NotificationManager.java in  » Testing » KeY » de » uka » ilkd » key » gui » notification » 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 » Testing » KeY » de.uka.ilkd.key.gui.notification 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // This file is part of KeY - Integrated Deductive Software Design
002:        // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
003:        //                         Universitaet Koblenz-Landau, Germany
004:        //                         Chalmers University of Technology, Sweden
005:        //
006:        // The KeY system is protected by the GNU General Public License. 
007:        // See LICENSE.TXT for details.
008:        /*
009:         * Created on 17.03.2005
010:         */
011:        package de.uka.ilkd.key.gui.notification;
012:
013:        import java.util.ArrayList;
014:        import java.util.Iterator;
015:        import java.util.List;
016:
017:        import de.uka.ilkd.key.gui.AutoModeListener;
018:        import de.uka.ilkd.key.gui.KeYMediator;
019:        import de.uka.ilkd.key.gui.notification.actions.*;
020:        import de.uka.ilkd.key.gui.notification.events.NotificationEvent;
021:        import de.uka.ilkd.key.proof.ProofEvent;
022:
023:        /**
024:         * The notificatin manager controls the list of active 
025:         * notification tasks. It receives KeY System events and looks 
026:         * for an appropriate task   
027:         * @author bubel
028:         */
029:        public class NotificationManager {
030:
031:            /** list of notification tasks */
032:            private List notificationTasks = new ArrayList();
033:
034:            /** true if we are currently in automode */
035:            private boolean automode;
036:
037:            private KeYMediator mediator;
038:
039:            // Dummy task to avoid null pointer checks
040:            private static final NotificationTask DUMMY_TASK = new NotificationTask() {
041:
042:                protected void executeImpl(NotificationEvent event,
043:                        NotificationManager manager) {
044:                }
045:
046:                public int getEventID() {
047:                    return NotificationEventID.RESERVED;
048:                }
049:            };
050:
051:            private NotificationListener notificationListener;
052:
053:            /**
054:             * %%HACK: move these methods
055:             * set default with or without sound
056:             */
057:            public void setDefaultNotification(boolean sound) {
058:
059:                notificationTasks.clear();
060:
061:                final ProofClosedNotification pcn = new ProofClosedNotification();
062:                final GeneralFailureNotification gfn = new GeneralFailureNotification();
063:                final GeneralInformationNotification gin = new GeneralInformationNotification();
064:                final AbandonNotification an = new AbandonNotification();
065:                final ExitKeYNotification en = new ExitKeYNotification();
066:
067:                if (sound) {
068:                    pcn.addNotificationAction(new ProofClosedSoundPlay());
069:                    gfn.addNotificationAction(new GeneralFailureSoundPlay());
070:                    gin
071:                            .addNotificationAction(new GeneralInformationSoundPlay());
072:                    an.addNotificationAction(new AbandonTaskSoundPlay());
073:                    en.addNotificationAction(new ExitKeYSoundPlay());
074:                }
075:
076:                gfn.addNotificationAction(new GeneralFailureJTextPaneDisplay(
077:                        mediator.mainFrame()));
078:                gin
079:                        .addNotificationAction(new GeneralInformationJTextPaneDisplay(
080:                                mediator.mainFrame()));
081:                pcn.addNotificationAction(new ProofClosedJTextPaneDisplay(
082:                        mediator.mainFrame()));
083:
084:                addNotificationTask(pcn);
085:                addNotificationTask(gfn);
086:                addNotificationTask(gin);
087:                addNotificationTask(an);
088:                addNotificationTask(en);
089:            }
090:
091:            /**
092:             * creates an instance of the notification manager    
093:             */
094:            public NotificationManager(KeYMediator mediator) {
095:
096:                notificationListener = new NotificationListener();
097:                this .mediator = mediator;
098:                mediator.addAutoModeListener(notificationListener);
099:            }
100:
101:            /**
102:             * adds a notification task to this manager     
103:             * @param task the NotificationTask to be added
104:             */
105:            public void addNotificationTask(NotificationTask task) {
106:                notificationTasks.add(task);
107:            }
108:
109:            /**
110:             * removes the given notification task from the list of active
111:             * tasks
112:             * @param task the task to be removed 
113:             */
114:            public void removeNotificationTask(NotificationTask task) {
115:                notificationTasks.remove(task);
116:            }
117:
118:            /**
119:             * returns the registered notifications
120:             * @return the registered notifications
121:             */
122:            public Iterator getNotificationTasks() {
123:                return notificationTasks.iterator();
124:            }
125:
126:            /**
127:             * find the notificatin task associated with the given event id
128:             * @param eventId int identifying the event
129:             * @return the notificatin task associated with the given event id
130:             */
131:            private NotificationTask getNotificationTask(int eventId) {
132:                final Iterator it = getNotificationTasks();
133:                while (it.hasNext()) {
134:                    final NotificationTask task = (NotificationTask) it.next();
135:                    if (task.getEventID() == eventId) {
136:                        return task;
137:                    }
138:                }
139:                return DUMMY_TASK;
140:            }
141:
142:            /**
143:             * @return true if the prover is currently in automode
144:             */
145:            public boolean inAutoMode() {
146:                return automode;
147:            }
148:
149:            // Listener section with inner classes used to receive 
150:            // KeY system events
151:            private class NotificationListener implements  AutoModeListener {
152:
153:                /**
154:                 * auto mode started
155:                 */
156:                public void autoModeStarted(ProofEvent e) {
157:                    automode = true;
158:                }
159:
160:                /**
161:                 * auto mode stopped
162:                 */
163:                public void autoModeStopped(ProofEvent e) {
164:                    automode = false;
165:                }
166:
167:            }
168:
169:            /**
170:             * dispatches the received notification event an triggers
171:             * the corresponding task
172:             * @param event
173:             */
174:            public void notify(NotificationEvent event) {
175:                getNotificationTask(event.getEventID()).execute(event,
176:                        NotificationManager.this);
177:            }
178:
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.