Source Code Cross Referenced for Controller.java in  » Database-Client » dbmjui » fr » aliacom » dbmjui » 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 » Database Client » dbmjui » fr.aliacom.dbmjui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package fr.aliacom.dbmjui;
002:
003:        import java.beans.PropertyChangeEvent;
004:        import java.beans.PropertyChangeListener;
005:
006:        import org.apache.log4j.Logger;
007:
008:        import fr.aliacom.common.ui.ITabbedPane;
009:        import fr.aliacom.common.ui.ITable;
010:        import fr.aliacom.dbmjui.ui.CommandStateHelper;
011:        import fr.aliacom.form.common.FormContext;
012:        import fr.aliacom.form.common.IForm;
013:        import fr.aliacom.form.common.ToolkitManager;
014:        import fr.aliacom.form.common.events.ITabbedPaneListener;
015:
016:        /**
017:         * Holds and provides references on DBMJUI major ui components.
018:         * 
019:         * This component also handles instance un/registrations
020:         * and selections in the instances list.
021:         * 
022:         * @author tom
023:         *
024:         *  (C) 2001, 2003 Thomas Cataldo
025:         */
026:        public final class Controller implements  IInstanceSelectionListener,
027:                IRegistryListener, ITabbedPaneListener, PropertyChangeListener {
028:
029:            private static Controller singleton;
030:            private ITable dbiList;
031:            private ITable logs;
032:            private DbInstance current;
033:            private ITabbedPane documents;
034:            private InstanceSelectionSupport iss;
035:            private Logger log;
036:
037:            static {
038:                singleton = new Controller();
039:            }
040:
041:            /**
042:             * Return the dbmjui controller instance.
043:             * 
044:             * @return the controller instance
045:             */
046:            public static Controller getInstance() {
047:                return singleton;
048:            }
049:
050:            private Controller() {
051:                log = Logger.getLogger(Controller.class);
052:                log.info("Creating DBMJUI Controller");
053:                IForm form = ToolkitManager.getToolkit().getMainWindow();
054:                FormContext ctx = form.getFormContext();
055:                dbiList = (ITable) ctx.get("dbiList").getValue();
056:                logs = (ITable) ctx.get("logs").getValue();
057:                documents = (ITabbedPane) ctx.get("tabs").getValue();
058:                DbRegistry registry = DbRegistry.getInstance();
059:                registry.addRegistryListener(this );
060:                iss = new InstanceSelectionSupport();
061:                addInstanceSelectionListener(this );
062:                documents.addTabbedPaneListener(this );
063:                log.info("DBMJUI Controller created");
064:            }
065:
066:            /**
067:             * When the instance selected in the dbi list changes,
068:             * the controller will stop listening to state changes
069:             * in the previously selected instance, and will listen to
070:             * changes in the newly selected one.
071:             * 
072:             * It will then request an update of the commands in the UI so that only
073:             * those working with the state of selected instance are available.
074:             * 
075:             * @see fr.aliacom.dbmjui.IInstanceSelectionListener#instanceSelected(fr.aliacom.dbmjui.DbInstance)
076:             */
077:            public void instanceSelected(DbInstance dbi) {
078:                log.debug("instance selected");
079:                int oldState = DbState.WARM_STATE;
080:                if (current != null) {
081:                    current.getInformations().removePropertyChangeListener(
082:                            "state", this );
083:                    oldState = current.getInformations().getState();
084:                }
085:                current = dbi;
086:                current.getInformations().addPropertyChangeListener("state",
087:                        this );
088:                setCommandState(oldState, dbi.getInformations().getState());
089:            }
090:
091:            /**
092:             * Called when an instance is registered in dbmjui.
093:             * This might happen at application startup, when loading saved
094:             * registrations, or at runtime, when using the registration wizard.
095:             *
096:             * @param dbi the newly registered instance 
097:             */
098:            public void instanceRegistered(final DbInstance dbi) {
099:                log.debug("instance registered");
100:                final Runnable task = new Runnable() {
101:                    public void run() {
102:                        dbiList.addRow(dbi.getInformations());
103:                    }
104:                };
105:                ToolkitManager.getToolkit().asyncExec(task);
106:            }
107:
108:            /**
109:             * @param dbi called when an instance is unregistered
110:             */
111:            public void instanceUnregistered(final DbInstance dbi) {
112:                log.debug("instance unregistered");
113:                final Runnable task = new Runnable() {
114:                    public void run() {
115:                        dbiList.removeRow(dbi.getInformations());
116:                    }
117:                };
118:                ToolkitManager.getToolkit().asyncExec(task);
119:            }
120:
121:            /**
122:             * Allows scripts to easily get a reference on the selected instance.
123:             * 
124:             * @return the instance selected in the dbi list, or null if none.
125:             */
126:            public DbInstance getCurrentInstance() {
127:                return current;
128:            }
129:
130:            /**
131:             * @see fr.aliacom.form.common.events.ITabbedPaneListener#tabAdded(int)
132:             */
133:            public void tabAdded(int tabIndex) {
134:                if (current != null) {
135:                    documents.setTabTitle(current.getFullName() + " - "
136:                            + documents.getTabTitle(tabIndex), tabIndex);
137:                }
138:            }
139:
140:            /**
141:             * @see fr.aliacom.form.common.events.ITabbedPaneListener#tabRemoved(int)
142:             */
143:            public void tabRemoved(int tabIndex) {
144:            }
145:
146:            public void fireInstanceSelectionChangeEvent(DbInstance dbi) {
147:                iss.fireInstanceSelectionChangeEvent(dbi);
148:            }
149:
150:            public void addInstanceSelectionListener(
151:                    IInstanceSelectionListener sl) {
152:                iss.addInstanceSelectionListener(sl);
153:            }
154:
155:            public void removeInstanceSelectionListener(
156:                    IInstanceSelectionListener sl) {
157:                iss.removeInstanceSelectionListener(sl);
158:            }
159:
160:            /**
161:             * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
162:             */
163:            public void propertyChange(PropertyChangeEvent evt) {
164:                log.debug("Controller : instance state change !");
165:                setCommandState(((Integer) evt.getOldValue()).intValue(),
166:                        ((Integer) evt.getNewValue()).intValue());
167:            }
168:
169:            private void setCommandState(int oldState, int newState) {
170:                CommandStateHelper.setCommandStates(oldState, newState);
171:            }
172:
173:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.