Source Code Cross Referenced for GuiConsole.java in  » Scripting » Kawa » kawa » 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 » Scripting » Kawa » kawa 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package kawa;
002:
003:        import java.awt.*;
004:        import java.awt.event.*;
005:        import gnu.mapping.*;
006:        import gnu.text.Path;
007:
008:        import gnu.expr.Language;
009:        import kawa.standard.Scheme;
010:
011:        /** A Frame containing a Kawa read-eval-print loop.
012:         * @author Albert Ting <alt@artisan.com> (original base)
013:         * @author Per Bothner (extensive changes).
014:         */
015:
016:        public class GuiConsole extends Frame implements  ActionListener {
017:            private static String CLOSE = "Close";
018:            private static String EXIT = "Exit";
019:            private static String NEW = "New";
020:            private static String NEW_SHARED = "New (Shared)";
021:            private static String PURGE_MESSAGE = "Purge Buffer";
022:
023:            static int window_number = 0;
024:
025:            Language language;
026:            Environment environment;
027:            Future thread;
028:
029:            gnu.text.QueueReader in_r;
030:            OutPort out_p, err_p;
031:
032:            MessageArea message = null;
033:
034:            public static void main(String[] args) {
035:                Language language = Scheme.getInstance();
036:                new GuiConsole();
037:            }
038:
039:            public GuiConsole() {
040:                this (Language.getDefaultLanguage(), Environment.getCurrent(),
041:                        false);
042:            }
043:
044:            public GuiConsole(Language language, Environment penvironment,
045:                    boolean shared) {
046:                super ("Kawa");
047:                this .language = language;
048:
049:                in_r = new gnu.text.QueueReader();
050:                message = new MessageArea(in_r);
051:                window_number++;
052:                kawa.repl.exitIncrement();
053:
054:                out_p = new OutPort(message.getStdout(), true, Path
055:                        .valueOf("<msg_stdout>"));
056:                err_p = new OutPort(message.getStderr(), true, Path
057:                        .valueOf("<msg_stderr>"));
058:                InPort in_p = new GuiInPort(in_r, Path.valueOf("<msg_stdin>"),
059:                        out_p, message);
060:
061:                this .setLayout(new BorderLayout(0, 0));
062:
063:                this .add("Center", message);
064:
065:                setupMenus();
066:                //pack();
067:                setLocation(100 * window_number, 50 * window_number);
068:                setSize(700, 500);
069:                setVisible(true);
070:
071:                thread = new Future(new kawa.repl(language), penvironment,
072:                        in_p, out_p, err_p);
073:                Environment env = thread.getEnvironment();
074:                if (shared)
075:                    env.setIndirectDefines();
076:                this .environment = env;
077:                thread.start();
078:            }
079:
080:            void close() {
081:                in_r.appendEOF();
082:                dispose();
083:                // Give thread chance to finish and clean up
084:                try {
085:                    Thread.sleep(100);
086:                } catch (InterruptedException ex) {
087:                }
088:                // Thread.stop is deprecated in JDK 1.2, but I see no good
089:                // alternative.  (Thread.destroy is not implemented!)
090:                thread.stop();
091:                kawa.repl.exitDecrement();
092:            }
093:
094:            private void setupMenus() {
095:                MenuBar menubar;
096:                Menu fileMenu;
097:                Menu utilitiesMenu;
098:
099:                MenuItem menuItem;
100:
101:                WindowListener windowExitCmd = new WindowAdapter() {
102:                    public void windowClosing(WindowEvent e) {
103:                        close();
104:                    }
105:                };
106:
107:                // Create the menubar
108:                menubar = new MenuBar();
109:                fileMenu = new Menu("File");
110:                utilitiesMenu = new Menu("Utilities");
111:
112:                menubar.add(fileMenu);
113:                menubar.add(utilitiesMenu);
114:
115:                menuItem = new MenuItem(NEW);
116:                menuItem.addActionListener(this );
117:                fileMenu.add(menuItem);
118:
119:                menuItem = new MenuItem(NEW_SHARED);
120:                menuItem.addActionListener(this );
121:                fileMenu.add(menuItem);
122:
123:                menuItem = new MenuItem(CLOSE);
124:                menuItem.addActionListener(this );
125:                fileMenu.add(menuItem);
126:
127:                menuItem = new MenuItem(EXIT);
128:                menuItem.addActionListener(this );
129:                this .addWindowListener(windowExitCmd);
130:                fileMenu.add(menuItem);
131:
132:                menuItem = new MenuItem(PURGE_MESSAGE);
133:                menuItem.addActionListener(this );
134:                utilitiesMenu.add(menuItem);
135:
136:                this .setMenuBar(menubar);
137:            }
138:
139:            public void actionPerformed(ActionEvent e) {
140:                String cmd = e.getActionCommand();
141:
142:                if (cmd.equals(NEW))
143:                    new GuiConsole(language, Environment.getGlobal(), false);
144:                else if (cmd.equals(NEW_SHARED))
145:                    new GuiConsole(language, environment, true);
146:                else if (cmd.equals(EXIT))
147:                    System.exit(0);
148:                else if (cmd.equals(CLOSE))
149:                    close();
150:                else if (cmd.equals(PURGE_MESSAGE)) {
151:                    message.deleteOldText();
152:                } else
153:                    OutPort.outDefault().println("Unknown menu action: " + cmd);
154:            }
155:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.