Source Code Cross Referenced for EditAction.java in  » Swing-Library » jEdit » org » gjt » sp » jedit » 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 » Swing Library » jEdit » org.gjt.sp.jedit 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * EditAction.java - jEdit action listener
003:         * :tabSize=8:indentSize=8:noTabs=false:
004:         * :folding=explicit:collapseFolds=1:
005:         *
006:         * Copyright (C) 1998, 2003 Slava Pestov
007:         *
008:         * This program is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public License
010:         * as published by the Free Software Foundation; either version 2
011:         * of the License, or any later version.
012:         *
013:         * This program is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         * GNU General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public License
019:         * along with this program; if not, write to the Free Software
020:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
021:         */
022:
023:        package org.gjt.sp.jedit;
024:
025:        //{{{ Imports
026:        import java.awt.event.ActionEvent;
027:        import java.awt.event.ActionListener;
028:        import java.awt.Component;
029:
030:        import org.gjt.sp.util.Log;
031:
032:        //}}}
033:
034:        /**
035:         * An action that can be bound to a menu item, tool bar button or keystroke.
036:         *
037:         * @see jEdit#getAction(String)
038:         * @see jEdit#getActionNames()
039:         * @see ActionSet
040:         *
041:         * @author Slava Pestov
042:         * @version $Id: EditAction.java 11177 2007-12-01 09:50:50Z k_satoda $
043:         */
044:        public abstract class EditAction {
045:            //{{{ Private members
046:            private String name;
047:
048:            protected Object[] args;
049:
050:            //}}}
051:
052:            //{{{ EditAction constructors
053:            /**
054:             * Creates a new edit action with the specified name.
055:             * @param name The action name
056:             */
057:            public EditAction(String name) {
058:                this .name = name;
059:            }
060:
061:            public EditAction(String name, Object[] newArgs) {
062:                this .name = name;
063:                this .args = newArgs;
064:            } //}}}
065:
066:            //{{{ getName() method
067:            /**
068:             * Returns the internal name of this action.
069:             */
070:            public String getName() {
071:                return name;
072:            } //}}}
073:
074:            // {{{ setName() method
075:            /**
076:             * Changes the name of an action
077:             * @param newName
078:             * @since jEdit 4.3pre4
079:             */
080:            public void setName(String newName) {
081:                name = newName;
082:            }// }}}
083:
084:            //{{{ getLabel() method
085:            /**
086:             * Returns the action's label. This returns the
087:             * value of the property named by {@link #getName()} suffixed
088:             * with <code>.label</code>.
089:             * 
090:             */
091:            public String getLabel() {
092:                if (args != null) {
093:                    return jEdit.getProperty(name + ".label", args);
094:                }
095:                return jEdit.getProperty(name + ".label");
096:            } //}}}
097:
098:            //{{{ getMouseOverText() method
099:            /**
100:             * Returns the action's mouse over message. This returns the
101:             * value of the property named by {@link #getName()} suffixed
102:             * with <code>.mouse-over</code>.
103:             */
104:            public final String getMouseOverText() {
105:                return jEdit.getProperty(name + ".mouse-over");
106:            } //}}}
107:
108:            //{{{ invoke() method
109:            /**
110:             * Invokes the action. This is an implementation of the Command pattern,
111:             * and concrete actions should override this.
112:             * 
113:             * @param view The view
114:             * @since jEdit 2.7pre2
115:             * abstract since jEdit 4.3pre7
116:             */
117:            abstract public void invoke(View view);
118:
119:            /**
120:             * 
121:             * @param view
122:             * @param newArgs new argument list
123:             * @since jEdit 4.3pre7
124:             */
125:            final public void invoke(View view, Object[] newArgs) {
126:                args = newArgs;
127:                invoke(view);
128:            } //}}}
129:
130:            //{{{ getView() method
131:            /**
132:             * @deprecated Call <code>GUIUtilities.getView()</code> instead.
133:             */
134:            public static View getView(Component comp) {
135:                // moved to GUIUtilities as it makes no sense being here.
136:                return GUIUtilities.getView(comp);
137:            } //}}}
138:
139:            //{{{ isToggle() method
140:            /**
141:             * Returns if this edit action should be displayed as a check box
142:             * in menus. This returns the
143:             * value of the property named by {@link #getName()} suffixed
144:             * with <code>.toggle</code>.
145:             *
146:             * @since jEdit 2.2pre4
147:             */
148:            public final boolean isToggle() {
149:                return jEdit.getBooleanProperty(name + ".toggle");
150:            } //}}}
151:
152:            //{{{ isSelected() method
153:            /**
154:             * If this edit action is a toggle, returns if it is selected or not.
155:             * @param comp The component
156:             * @since jEdit 4.2pre1
157:             */
158:            public boolean isSelected(Component comp) {
159:                return false;
160:            } //}}}
161:
162:            //{{{ noRepeat() method
163:            /**
164:             * Returns if this edit action should not be repeated. Returns false
165:             * by default.
166:             * @since jEdit 2.7pre2
167:             */
168:            public boolean noRepeat() {
169:                return false;
170:            } //}}}
171:
172:            //{{{ noRecord() method
173:            /**
174:             * Returns if this edit action should not be recorded. Returns false
175:             * by default.
176:             * @since jEdit 2.7pre2
177:             */
178:            public boolean noRecord() {
179:                return false;
180:            } //}}}
181:
182:            //{{{ noRememberLast() method
183:            /**
184:             * Returns if this edit action should not be remembered as the most
185:             * recently invoked action.
186:             * @since jEdit 4.2pre1
187:             */
188:            public boolean noRememberLast() {
189:                return false;
190:            } //}}}
191:
192:            //{{{ getCode() method
193:            /**
194:             * Returns the BeanShell code that will replay this action.
195:             * BeanShellAction.getCode() returns something more interesting for Actions that were loaded
196:             * from the actions.xml file. 
197:             * You do not need to override this method if your action name is unique,
198:             * this EditAction was added to an ActionSet and that to an ActionContext of jEdit.
199:             * 
200:             * concrete since jEdit 4.3pre7
201:             * @since jEdit 2.7pre2
202:             * 
203:             */
204:            public String getCode() {
205:                return "jEdit.getAction(" + name + ").invoke(view); ";
206:            }
207:
208:            //}}}
209:
210:            //{{{ toString() method
211:            public String toString() {
212:                return name;
213:            } //}}}
214:
215:            //{{{ Wrapper class
216:            /**
217:             * 'Wrap' EditActions in this class to turn them into AWT
218:             * ActionListeners, that can be attached to buttons, menu items, etc.
219:             */
220:            public static class Wrapper implements  ActionListener {
221:
222:                private ActionContext context;
223:                private String actionName;
224:
225:                /**
226:                 * Creates a new action listener wrapper.
227:                 * @since jEdit 4.2pre1
228:                 */
229:                public Wrapper(ActionContext context, String actionName) {
230:                    this .context = context;
231:                    this .actionName = actionName;
232:                }
233:
234:                /**
235:                 * Called when the user selects this action from a menu.
236:                 * It passes the action through the
237:                 * {@link org.gjt.sp.jedit.gui.InputHandler#invokeAction(EditAction)}
238:                 * method, which performs any recording or repeating.
239:                 *
240:                 * @param evt The action event
241:                 */
242:                public void actionPerformed(ActionEvent evt) {
243:                    EditAction action = context.getAction(actionName);
244:                    if (action == null) {
245:                        Log.log(Log.WARNING, this , "Unknown action: "
246:                                + actionName);
247:                    } else
248:                        context.invokeAction(evt, action);
249:                }
250:
251:            } //}}}
252:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.