org.acm.seguin.ide.jedit.action

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 » UML » jrefactory » org.acm.seguin.ide.jedit.action 
org.acm.seguin.ide.jedit.action

Creating custom actions.

ProjectViewer allows other plugin developers too interact with the file trees by creating custom actions to be executed on the nodes. Actions can be added to the tree's context menu or to the viewer's toolbar. It's recommended to extend the context menu, since there's only so much useful space in the toolbar for new actions.

Creating a new action is very simple:

  • Create a new class that extends {@link projectviewer.action.Action Action}.
  • Implement the {@link projectviewer.action.Action#actionPerformed(ActionEvent) actionPerformed()} method to execute the desired operations.
  • Register the action in the context menu ({@link projectviewer.vpt.VPTContextMenu#registerAction(Action) registerAction()}) or in the toolbar ({@link projectviewer.ProjectViewer#registerAction(Action) registerAction()}) by calling the appropriate method.

The menu item show in the context menu is provided by the {@link projectviewer.action.Action#getMenuItem() getMenuItem()} of the Action class. Subclasses are welcome to override this method to provide other kinds of menu items (a sub-menu, for example). For the toolbar button, the {@link projectviewer.action.Action#getButton() getButton()} method is used.

Before showing the menu item in the context menu, ProjectViewer will call the {@link projectviewer.action.Action#prepareForNode(VPTNode) prepareForNode()} method in all actions registered in the context menu. This allows each action to decide if it should be shown for the given node and what message to show, for example. For the toolbar buttons, this method is never called, so the toolbar buttons should be able to be executed regardless of the current tree selection. If your action depends on a certain kind of node, add it to the context menu, and not to the toolbar. If you want to add it to the toolbar, check for the node type in your actionPerformed() implementation.

Another important thing to notice in the prepareForNode() method is that the actions should check is the node is of a certain type, and not if the node is not of a certain type. For example, use "node.isFile()" and not "!node.isDirectory()". This ensures that the action will not do anything wrong if a different node type is added in the future to PV, or if another plugin adds a new node type to PV.

It's important to notice that the instance given to the registerAction methods is not the instance used by the viewer instances. Those instances are used as prototypes, and the viewers use {@link projectviewer.action.Action#clone() clone()} to get instances for the specific viewer. After the cloning, the {@link projectviewer.action.Action#setViewer(ProjectViewer) setViewer()} method is called, so the actions have a reference to the viewers where they are being used. This also means that you should not use the constructor of your Action implementation to instantiate GUI components. Instantiations of GUI components should be done lazily in the getMenuItem() or getButton() methods. The default implementation already does this, so you should only worry about this if you are overriding one of these methods.

Java Source File NameTypeComment
Action.javaClass An action defines an action to be taken when the user presses some menu item in the tree's context menu or a button on the toolbar.
HideAction.javaClass Removes all the files below the root from a project, and then calls the initial project importer.
JEditUndoAction.javaClass Stores the undo operation.
ReloadAction.javaClass Removes all the files below the root from a project, and then calls the initial project importer.
ReloadAllAction.javaClass
ShowAction.javaClass Removes all the files below the root from a project, and then calls the initial project importer.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.