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


001:        package fr.aliacom.commands;
002:
003:        import fr.aliacom.form.common.FormContext;
004:        import fr.aliacom.form.common.IForm;
005:        import fr.aliacom.form.common.ToolkitManager;
006:        import fr.aliacom.util.InterpreterPool;
007:        import fr.aliacom.util.JythonInterpreter;
008:
009:        /**
010:         * Instances of PythonCommand execute execute python script
011:         * with jython.
012:         * 
013:         * @author tom
014:         *
015:         * (c) 2001, 2003 Thomas Cataldo
016:         */
017:        class PythonCommand extends ASyncCommand {
018:
019:            private String script;
020:            private IForm form;
021:            private FormContext ctx;
022:
023:            /**
024:             * Create a python command that will execute a python script.
025:             * The script is loaded from the script repository provided by the 
026:             * running {@link fr.aliacom.form.common.IApplication}.
027:             * 
028:             * When this script is executed, all the {@link fr.aliacom.form.common.FormVariable}
029:             * defined in the given context will apear as real python variables.
030:             * A special variable named <code>FORM</code> is automagically added the python
031:             * variables before execution. It will referenced the {@link IForm} instance passed
032:             * to this constructor.
033:             * 
034:             * A variable named <code>LOG</code> is also added. This is a reference to
035:             * a log4j logger.
036:             * 
037:             * You should notice that (f.getFormContext() == ctx) might be false. Thanks to this,
038:             * sub-parts of the UI (tabs,...) can be created dynamically from XML without poluting
039:             * the FormContext of the main window. Consider 2 tabs in the main window 
040:             * with a textfield in each tab, created from the same XML file. The XML contains
041:             * something like <code>&lt;textField id="myText"/&gt;</code>. When a PythonCommand 
042:             * linked to a button in the tab is executed, you clearly want it to refer to the
043:             * correct TextField. 
044:             *   
045:             * 
046:             * @param form the form referenced by the <code>FORM</code> variable in the script.
047:             * @param script the script to execute, loaded by an 
048:             * {@link fr.aliacom.form.storage.IScriptRepository}.
049:             * @param ctx the variables defined when the script is executed
050:             */
051:            public PythonCommand(IForm form, String script, FormContext ctx) {
052:                this .script = script;
053:                this .form = form;
054:                this .ctx = ctx;
055:            }
056:
057:            public void doIt() {
058:                log.debug("Running command (" + script + ")");
059:                try {
060:                    JythonInterpreter interp = InterpreterPool.getInstance()
061:                            .getInterpreter();
062:                    interp.executeByName(script, (ctx == null ? form
063:                            .getFormContext() : ctx));
064:                    interp.release();
065:                } catch (Exception ie) {
066:                    log.fatal("Error occured while running " + script, ie);
067:                    /* sync execution would deadlock the event queue
068:                     * as python command are already executed in that
069:                     * queue.
070:                     */
071:                    ToolkitManager.getToolkit().asyncExec(new ErrorHandler(ie));
072:                }
073:            }
074:
075:            private final class ErrorHandler implements  Runnable {
076:                private Throwable t;
077:
078:                public ErrorHandler(Throwable t) {
079:                    this .t = t;
080:                }
081:
082:                public void run() {
083:                    ToolkitManager.getToolkit().handleError(
084:                            ToolkitManager.getToolkit().getMainWindow(), t);
085:                }
086:            }
087:
088:            /**
089:             * Method getForm.
090:             * @return IForm
091:             */
092:            public IForm getForm() {
093:                return form;
094:            }
095:
096:            public FormContext getContext() {
097:                return ctx;
098:            }
099:
100:            /**
101:             * @param form
102:             */
103:            public void setForm(IForm form) {
104:                this.form = form;
105:            }
106:
107:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.