Source Code Cross Referenced for TestPlugin.java in  » XML-UI » XUI » net » xoetrope » builder » editor » plugin » test » 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 » XML UI » XUI » net.xoetrope.builder.editor.plugin.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.xoetrope.builder.editor.plugin.test;
002:
003:        import java.util.Vector;
004:
005:        import java.awt.AWTEvent;
006:        import java.awt.BorderLayout;
007:        import java.awt.Component;
008:        import java.awt.Dimension;
009:        import java.awt.Frame;
010:        import java.awt.event.ActionEvent;
011:        import java.awt.event.ActionListener;
012:        import java.awt.event.KeyEvent;
013:        import javax.swing.AbstractAction;
014:        import javax.swing.ImageIcon;
015:        import javax.swing.JButton;
016:        import javax.swing.JDialog;
017:        import javax.swing.JFrame;
018:        import javax.swing.JMenu;
019:        import javax.swing.JMenuItem;
020:        import javax.swing.JOptionPane;
021:        import javax.swing.JPanel;
022:        import javax.swing.JTextPane;
023:
024:        import net.xoetrope.builder.editor.XComponentSizer;
025:        import net.xoetrope.builder.editor.XEditorProject;
026:        import net.xoetrope.builder.editor.XPageResource;
027:        import net.xoetrope.builder.editor.XuiDefaults;
028:        import net.xoetrope.builder.editor.plugin.XEditorPlugin;
029:        import net.xoetrope.swing.XImage;
030:        import net.xoetrope.xui.XPage;
031:
032:        /**
033:         * A simple plugin to help test the plugin behaviour
034:         * <p> Copyright (c) Xoetrope Ltd., 2002-2003</p>
035:         * <p> $Revision: 1.13 $</p>
036:         * <p> License: see License.txt</p>
037:         */
038:        public class TestPlugin extends XEditorPlugin implements  ActionListener {
039:            private JPanel pluginPanel, propertiesPanel;
040:            private JMenu pluginMenu, editorMenu;
041:            private XEditorProject currentProject;
042:            private Vector currentComponents;
043:            private XPageResource activePage;
044:
045:            public TestPlugin() {
046:            }
047:
048:            public void setFrame(JFrame appFrame) {
049:            }
050:
051:            /**
052:             * Process a menu commands for a plugin
053:             * @param command the command id
054:             * @param evt the original event
055:             * @param selected the selected state of the toolbar or menu item or false if no state exists
056:             */
057:            public int processCommand(int command, AWTEvent evt,
058:                    boolean selected) {
059:                JOptionPane.showMessageDialog(null,
060:                        "Hello from the test plugin");
061:                return 0;
062:            }
063:
064:            public JPanel getMainPanel() {
065:                if (pluginPanel == null) {
066:                    pluginPanel = new JPanel();
067:                    pluginPanel.setPreferredSize(new Dimension(10, 100));
068:
069:                    pluginPanel.setLayout(new BorderLayout());
070:                    JTextPane textPane = new JTextPane();
071:                    textPane
072:                            .setText("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed enim. Nunc lectus. Phasellus a turpis ac neque pharetra vulputate. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nunc vulputate dapibus eros. Duis eleifend augue ac odio. Aenean ut pede nec ipsum fermentum varius. Cras luctus lacus at pede. Mauris faucibus sagittis augue. Proin eget orci in quam cursus ultrices. Duis tellus sapien, bibendum nec, nonummy at, pellentesque a, dolor. Ut nec odio. In at turpis. Nullam id eros at felis fermentum luctus. Cras ultrices. Sed dictum, leo id pulvinar fermentum, dui nulla dapibus purus, non pulvinar wisi augue in wisi. Etiam in dolor. Ut a turpis at dolor consequat vulputate. \n\n"
073:                                    + "Proin lobortis. Pellentesque laoreet pellentesque elit. Aenean sodales lorem. Duis sollicitudin augue eget dui. Mauris volutpat tellus in sem. Maecenas neque. Nulla facilisi. Nullam eu augue. Quisque quam dolor, porttitor id, fringilla sed, mattis quis, sapien. Aliquam magna odio, fringilla eu, tincidunt a, congue ut, justo. Morbi et dolor. Etiam placerat, risus ut ullamcorper hendrerit, libero nulla adipiscing nisl, ut ullamcorper sapien orci eu pede. Fusce nisl. Sed bibendum varius orci. Fusce ac urna condimentum ligula sodales gravida. Phasellus sit amet tortor nec quam mattis vehicula. Nullam tempus. Vestibulum non nunc id enim venenatis adipiscing. Quisque turpis. Vivamus velit magna, tincidunt sit amet, fermentum non, vestibulum at, metus. \n\n"
074:                                    + "Morbi suscipit, lorem non placerat aliquet, pede velit vulputate odio, ac volutpat erat risus vitae mi. Suspendisse tellus dui, vulputate ut, dignissim at, posuere at, purus. Aenean mattis magna ac dui. Integer lorem erat, porta quis, lacinia quis, placerat id, lorem. Pellentesque tristique pede in magna. In vehicula vestibulum libero. Phasellus purus pede, viverra sed, pellentesque quis, blandit non, est. Phasellus a turpis et sapien volutpat euismod. Maecenas ultricies. Phasellus id velit. Nam a enim. Morbi consequat enim sit amet orci. Nunc odio. Integer ornare metus quis metus. \n\n"
075:                                    + "Aenean convallis. Donec interdum arcu vitae ligula. Praesent augue urna, vestibulum eu, rhoncus a, placerat sed, tellus. Aliquam nec leo. In tincidunt. Aenean sit amet elit. Aenean at massa. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse eget nisl at ligula ultricies fermentum. Duis eget sapien vitae elit egestas ultrices. In sed nulla. Aenean felis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; \n\n"
076:                                    + "Suspendisse lectus nulla, bibendum vel, porttitor vel, porttitor eget, wisi. Morbi rhoncus. Donec at mi. Suspendisse potenti. In porta, diam sed imperdiet imperdiet, lacus eros venenatis wisi, at eleifend ante lorem at orci. Ut id mi. Fusce elit dui, sodales ut, laoreet quis, hendrerit quis, nunc. Donec a augue sit amet massa volutpat ullamcorper. Nulla convallis sollicitudin turpis. Sed odio. Sed vel eros. ");
077:                    pluginPanel.add(textPane, BorderLayout.CENTER);
078:                }
079:                return pluginPanel;
080:            }
081:
082:            public JPanel getPropertiesPanel() {
083:                if (propertiesPanel == null) {
084:                    propertiesPanel = new JPanel();
085:                    propertiesPanel.setPreferredSize(new Dimension(100, 100));
086:                    propertiesPanel.setVisible(true);
087:                }
088:
089:                return propertiesPanel;
090:            }
091:
092:            /**
093:             * Gets the dialog for this plugin. The dialog must be modal. Once dismissed
094:             * no further interaction with the plugin should take place
095:             * @param applicationFrame the main application fram
096:             * @return the dialog
097:             */
098:            public JDialog getDialog(Frame applicationFrame) {
099:                return null;
100:            }
101:
102:            /**
103:             * Get the menuItem or the sub menu that plugs into the context/popup menu for
104:             * the selected components. The functions on this menu should all operate on
105:             * the selection or individual component selecte.
106:             * @return the JMenu or JMenuItem or null if no menu is being provided.
107:             */
108:            public JMenuItem getContextMenu() {
109:                if ((currentComponents != null)
110:                        && (currentComponents.size() == 1)) {
111:                    XComponentSizer sizer = ((XComponentSizer) currentComponents
112:                            .elementAt(0));
113:                    Component target = sizer.getTarget();
114:                    if ((target instanceof  JButton)
115:                            || (target instanceof  XImage)) {
116:                        JMenu contextMenu = new JMenu("TestPlugin");
117:                        contextMenu.setFont(XuiDefaults.defaultFont);
118:
119:                        NavigateAction navigateAction = new NavigateAction(
120:                                "Go to page...",
121:                                null,
122:                                "Pick the page to show when this button is clicked",
123:                                new Integer(KeyEvent.VK_G));
124:                        JMenuItem navigateItem = new JMenuItem(navigateAction);
125:                        navigateItem.setFont(XuiDefaults.defaultFont);
126:                        contextMenu.add(navigateItem);
127:
128:                        contextMenu.addSeparator();
129:
130:                        navigateAction = new NavigateAction(
131:                                "Home",
132:                                null,
133:                                "Show the 'Home' page when this button is clicked",
134:                                new Integer(KeyEvent.VK_H));
135:                        navigateItem = new JMenuItem(navigateAction);
136:                        navigateItem.setFont(XuiDefaults.defaultFont);
137:                        contextMenu.add(navigateItem);
138:
139:                        navigateAction = new NavigateAction(
140:                                "Previous",
141:                                null,
142:                                "Go to the previous page when this button is clicked",
143:                                new Integer(KeyEvent.VK_P));
144:                        navigateItem = new JMenuItem(navigateAction);
145:                        navigateItem.setFont(XuiDefaults.defaultFont);
146:                        contextMenu.add(navigateItem);
147:
148:                        return contextMenu;
149:                    }
150:                }
151:                return null;
152:            }
153:
154:            /**
155:             * Gets a menuItem to insert on the plugins menu
156:             * @return
157:             */
158:            public JMenuItem getPluginMenu() {
159:                if (pluginMenu != null)
160:                    return pluginMenu;
161:
162:                pluginMenu = new JMenu(getName());
163:                pluginMenu.setFont(XuiDefaults.defaultFont);
164:                JMenuItem optionMenu = new JMenuItem("Plugin Action");
165:                optionMenu.setFont(XuiDefaults.defaultFont);
166:                optionMenu.addActionListener(this );
167:                pluginMenu.add(optionMenu);
168:
169:                optionMenu = new JMenuItem("More Plugin Action");
170:                optionMenu.setFont(XuiDefaults.defaultFont);
171:                optionMenu.addActionListener(this );
172:                pluginMenu.add(optionMenu);
173:
174:                optionMenu = new JMenuItem("Plugin Test Action");
175:                optionMenu.setFont(XuiDefaults.defaultFont);
176:                optionMenu.addActionListener(this );
177:                pluginMenu.add(optionMenu);
178:
179:                pluginMenu.addSeparator();
180:
181:                optionMenu = new JMenuItem("Test Plugin Action");
182:                optionMenu.setFont(XuiDefaults.defaultFont);
183:                optionMenu.addActionListener(this );
184:                pluginMenu.add(optionMenu);
185:
186:                return pluginMenu;
187:            }
188:
189:            /**
190:             * Gets the main menu to show on the main menu bar
191:             * @return
192:             */
193:            public JMenu getMenu() {
194:                if (editorMenu != null)
195:                    return editorMenu;
196:
197:                editorMenu = new JMenu("Testing");
198:                editorMenu.setFont(XuiDefaults.defaultFont);
199:
200:                JMenuItem optionMenu = new JMenuItem("Testing 1");
201:                optionMenu.setFont(XuiDefaults.defaultFont);
202:                optionMenu.addActionListener(this );
203:                editorMenu.add(optionMenu);
204:
205:                optionMenu = new JMenuItem("Testing 2");
206:                optionMenu.setFont(XuiDefaults.defaultFont);
207:                optionMenu.addActionListener(this );
208:                editorMenu.add(optionMenu);
209:
210:                optionMenu = new JMenuItem("Testing 3");
211:                optionMenu.setFont(XuiDefaults.defaultFont);
212:                optionMenu.addActionListener(this );
213:                editorMenu.add(optionMenu);
214:
215:                return editorMenu;
216:            }
217:
218:            public String getName() {
219:                return "Test Plugin";
220:            }
221:
222:            /**
223:             * Get the name of the deployment jar file that house the plugin's runtime
224:             * components
225:             * @return the short name of the jar file
226:             */
227:            public String[] getDeploymentJarNames() {
228:                String[] jarNames = { "testPlugin.jar" };
229:                return jarNames;
230:            }
231:
232:            /**
233:             * Tells the plugin to save its data
234:             * @return 0 for success, non zero otherwise
235:             */
236:            public int save() {
237:                return 0;
238:            }
239:
240:            public void setActivePage(XPageResource page) {
241:                activePage = page;
242:            }
243:
244:            public void setActiveComponents(Vector comps) {
245:                currentComponents = comps;
246:            }
247:
248:            public void setActiveProject(XEditorProject project) {
249:                currentProject = project;
250:            }
251:
252:            public boolean isDialogPlugin() {
253:                return false;
254:            }
255:
256:            public int getPluginType() {
257:                return this .PAGE_EDITOR;
258:            }
259:
260:            /**
261:             * Set the activation/deactivation state of the plugin
262:             * @param newState
263:             */
264:            public void setState(int newState) {
265:            }
266:
267:            public int getState() {
268:                return ACTIVATED;
269:            }
270:
271:            /**
272:             * Get an array of components to add to the toolbar
273:             * @return
274:             */
275:            public Component[] getToolbarComponents() {
276:                return null;
277:            }
278:
279:            /**
280:             * Get the name used on the tabbar for a plugin's components
281:             * @return the tab name
282:             */
283:            public String getToolbarName() {
284:                return null;
285:            }
286:
287:            //----------------------------------------------------------------------------
288:            public void cut() {
289:            }
290:
291:            public void copy() {
292:            }
293:
294:            public void paste() {
295:            }
296:
297:            public void delete() {
298:            }
299:
300:            public void actionPerformed(ActionEvent evt) {
301:                String command = evt.getActionCommand();
302:                if (command.compareTo("Show editor") == 0)
303:                    // Setup the plugin Window
304:                    currentProject.getEditor().addPluginPanel(this );
305:                else if (command.compareTo("Show properties") == 0)
306:                    // Add the plugin properties pane
307:                    currentProject.getEditor().addPluginEditor(this );
308:                else if (command.compareTo("Show menu") == 0)
309:                    // Add the plugin menu
310:                    currentProject.getEditor().addPluginMenu(this );
311:                else
312:                    JOptionPane.showMessageDialog(null,
313:                            "Hello from the test plugin - "
314:                                    + ((JMenuItem) evt.getSource()).getText());
315:            }
316:
317:            class NavigateAction extends AbstractAction {
318:                public NavigateAction(String text, ImageIcon icon, String desc,
319:                        Integer mnemonic) {
320:                    super (text, icon);
321:                    putValue(SHORT_DESCRIPTION, desc);
322:                    putValue("MnemonicKey"/*Action.MNEMONIC_KEY*/, mnemonic);
323:                }
324:
325:                public void actionPerformed(ActionEvent e) {
326:                    if ((currentComponents != null)
327:                            && (currentComponents.size() == 1)) {
328:                        XComponentSizer sizer = ((XComponentSizer) currentComponents
329:                                .elementAt(0));
330:                        Component comp = sizer.getTarget();
331:                        XPage page = sizer.getPage();
332:
333:                        String command = e.getActionCommand();
334:                        if (command.indexOf("Plugin Action") >= 0) {
335:                            JOptionPane.showMessageDialog(null,
336:                                    "Hello from the test plugin action- "
337:                                            + ((JMenuItem) e.getSource())
338:                                                    .getText());
339:                        }
340:                    }
341:                }
342:            }
343:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.