Source Code Cross Referenced for JGraphpadBshPlugin.java in  » Graphic-Library » jgraphpad » com » jgraph » bshplugin » 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 » Graphic Library » jgraphpad » com.jgraph.bshplugin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * $Id: JGraphpadBshPlugin.java,v 1.1.1.1 2005/08/04 11:21:58 gaudenz Exp $
003:         * Copyright (c) 2001-2005, Gaudenz Alder
004:         * 
005:         * All rights reserved.
006:         * 
007:         * See LICENSE file for license details. If you are unable to locate
008:         * this file please contact info (at) jgraph (dot) com.
009:         */
010:        package com.jgraph.bshplugin;
011:
012:        import java.awt.Component;
013:
014:        import javax.swing.JTabbedPane;
015:
016:        import org.w3c.dom.Node;
017:
018:        import bsh.EvalError;
019:        import bsh.Interpreter;
020:        import bsh.util.JConsole;
021:
022:        import com.jgraph.JGraphEditor;
023:        import com.jgraph.editor.JGraphEditorPlugin;
024:        import com.jgraph.editor.factory.JGraphEditorFactoryMethod;
025:        import com.jgraph.pad.factory.JGraphpadPane;
026:        import com.jgraph.pad.util.JGraphpadFocusManager;
027:
028:        /**
029:         * Plugin for using Bsh in JGraphpad Pro. Adds a shell console to the bottom
030:         * tabs in the main window.
031:         */
032:        public class JGraphpadBshPlugin implements  JGraphEditorPlugin {
033:
034:            /**
035:             * Initializes the plugin by registering all factory methods.
036:             * 
037:             * @param editor
038:             *            The enclosing editor for the plugin.
039:             * @param configuration
040:             *            The object to configure the plugin with.
041:             */
042:            public void initialize(JGraphEditor editor, Node configuration) {
043:                editor.getFactory().addMethod(new FactoryMethod(editor));
044:                editor.getFactory().addMethod(
045:                        new ExtendedBottomTabFactoryMethod(editor));
046:            }
047:
048:            /**
049:             * Factory method to construct a bsh console.
050:             */
051:            public static class FactoryMethod extends JGraphEditorFactoryMethod {
052:
053:                /**
054:                 * Defines the default name for factory methods of this kind.
055:                 */
056:                public static String NAME = "createBshConsole";
057:
058:                /**
059:                 * References the enclosing editor.
060:                 */
061:                protected JGraphEditor editor;
062:
063:                /**
064:                 * Constructs a new factory method for the specified enclosing editor
065:                 * using {@link #NAME}.
066:                 * 
067:                 * @param editor
068:                 *            The editor that contains the factory method.
069:                 */
070:                public FactoryMethod(JGraphEditor editor) {
071:                    super (NAME);
072:                    this .editor = editor;
073:                }
074:
075:                /*
076:                 * (non-Javadoc)
077:                 */
078:                public Component createInstance(Node configuration) {
079:                    JConsole console = new JConsole();
080:                    Interpreter interpreter = new Interpreter(console);
081:                    try {
082:
083:                        // Assings the editor and mgr variable in the shell so the
084:                        // editor and last focused graph are accessible.
085:                        interpreter.set("editor", editor);
086:                        interpreter.set("mgr", JGraphpadFocusManager
087:                                .getCurrentGraphFocusManager());
088:                    } catch (EvalError e) {
089:                        // ignore
090:                    }
091:                    new Thread(interpreter).start();
092:                    interpreter
093:                            .print("Use the editor and mgr variables, eg. \"print(editor);\""
094:                                    + " to access the enclosing application\n");
095:                    return console;
096:                }
097:            }
098:
099:            /**
100:             * Utility class to add the property sheet to the bottom tab of the main
101:             * application window. This factory method replaces the original factory
102:             * method and keeps a reference to it. When it is invoked it uses the
103:             * original factory method to create the original object and then adds its
104:             * own tabs to that object before returning it.
105:             */
106:            public static class ExtendedBottomTabFactoryMethod extends
107:                    JGraphEditorFactoryMethod {
108:
109:                /**
110:                 * Reference to factory method that was replaced.
111:                 */
112:                protected JGraphEditorFactoryMethod previous = null;
113:
114:                /**
115:                 * References the enclosing editor.
116:                 */
117:                protected JGraphEditor editor;
118:
119:                /**
120:                 * Constructs a new factory method for the specified enclosing editor
121:                 * using JGraphpadPane.BottomTabFactoryMethod.NAME.
122:                 * 
123:                 * @param editor
124:                 *            The editor that contains the factory method.
125:                 */
126:                public ExtendedBottomTabFactoryMethod(JGraphEditor editor) {
127:                    super (JGraphpadPane.BottomTabFactoryMethod.NAME);
128:                    previous = editor.getFactory().getMethod(
129:                            JGraphpadPane.BottomTabFactoryMethod.NAME);
130:                    this .editor = editor;
131:                }
132:
133:                /*
134:                 * (non-Javadoc)
135:                 */
136:                public Component createInstance(Node configuration) {
137:                    if (previous != null) {
138:                        Component component = previous
139:                                .createInstance(configuration);
140:                        if (component instanceof  JTabbedPane) {
141:                            JTabbedPane tabPane = (JTabbedPane) component;
142:
143:                            Component bshPanel = editor.getFactory()
144:                                    .executeMethod(FactoryMethod.NAME);
145:                            if (bshPanel != null)
146:                                tabPane.addTab("Shell", bshPanel);
147:
148:                        }
149:                        return component;
150:                    }
151:                    return null;
152:                }
153:
154:            }
155:
156:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.