Source Code Cross Referenced for GreyOutMenuFrig.java in  » UML » jrefactory » org » acm » seguin » ide » 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 » UML » jrefactory » org.acm.seguin.ide.jedit 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:            JavaStylePlugin.java - a Java pretty printer plugin for jEdit
003:            Copyright (c) 1999 Andreas "Mad" Schaefer (andreas.schaefer@madplanet.ch)
004:            Copyright (c) 2000,2001 Dirk Moebius (dmoebius@gmx.net)
005:            jEdit buffer options:
006:            :tabSize=4:indentSize=4:noTabs=false:maxLineLen=0:
007:            This program is free software; you can redistribute it and/or
008:            modify it under the terms of the GNU General Public License
009:            as published by the Free Software Foundation; either version 2
010:            of the License, or any later version.
011:            This program is distributed in the hope that it will be useful,
012:            but WITHOUT ANY WARRANTY; without even the implied warranty of
013:            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:            GNU General Public License for more details.
015:            You should have received a copy of the GNU General Public License
016:            along with this program; if not, write to the Free Software
017:            Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
018:         */
019:        package org.acm.seguin.ide.jedit;
020:
021:        import org.gjt.sp.jedit.View;
022:        import org.gjt.sp.jedit.Buffer;
023:        import org.gjt.sp.jedit.jEdit;
024:        import org.gjt.sp.jedit.textarea.JEditTextArea;
025:
026:        import java.awt.Component;
027:        import java.awt.Container;
028:        import javax.swing.JMenu;
029:        import javax.swing.JMenuItem;
030:        import java.awt.event.ContainerListener;
031:        import java.awt.event.ContainerEvent;
032:        import javax.swing.event.MenuListener;
033:        import javax.swing.event.MenuEvent;
034:        import net.sourceforge.jrefactory.action.CurrentSummary;
035:        import org.acm.seguin.summary.MethodSummary;
036:        import org.acm.seguin.summary.FieldSummary;
037:
038:        /**
039:         *  A plugin for pretty printing the current jEdit buffer, using the PrettyPrinter of the JREFactory suite.
040:         *
041:         * @author     Mike Atkinson (<a href="mailto:javastyle@ladyshot.demon.co.uk"> Mike@ladyshot.demon.co.uk</a> )
042:         * @author     Dirk Moebius (<a href="mailto:dmoebius@gmx.net"> dmoebius@gmx.net </a> )
043:         * @since      1.0
044:         * @created    14 July 2003
045:         * @version    $Version: $
046:         */
047:        public class GreyOutMenuFrig {
048:            private static View view = null;
049:            private static Object javastyleMenuFound = null;
050:
051:            private static MenuListener javastyleMenuListener = new JavastyleMenuListener();
052:            private static MenuListener javastyleMenuListener2 = new JavastyleMenuListener2();
053:
054:            /**
055:             *  Description of the Method
056:             *
057:             * @since    v 1.0
058:             */
059:            public static void checkMenus() {
060:                view = jEdit.getActiveView();
061:                if (view == null) {
062:                    return;
063:                }
064:                javax.swing.JMenuBar menuBar = view.getJMenuBar();
065:                javax.swing.MenuElement[] menus = menuBar.getSubElements();
066:                for (int i = 0; i < menus.length; i++) {
067:                    if (menus[i] instanceof  JMenu) {
068:                        String label = ((JMenu) menus[i]).getLabel();
069:                        //System.out.println("menu[" + i + "] = \"" + label + "\"");
070:                        if ("Plugins".equals(label)) {
071:                            if (javastyleMenuFound != menus[i]) {
072:                                addMenuListener((JMenu) menus[i],
073:                                        javastyleMenuListener);
074:                                javastyleMenuFound = menus[i];
075:                            }
076:                            break;
077:                        }
078:                    }
079:                }
080:
081:            }
082:
083:            /**
084:             *  Description of the Class
085:             *
086:             * @author    Mike Atkinson MRA
087:             * @since     v 1.0
088:             */
089:            private static class JavastyleMenuListener implements  MenuListener {
090:                /**
091:                 *  Description of the Method
092:                 *
093:                 * @param  e  Description of Parameter
094:                 * @since     v 1.0
095:                 */
096:                public void menuCanceled(MenuEvent e) {
097:                    //System.out.println("JavaStyleMenuListener: menuCanceled("+e+")");
098:                }
099:
100:                /**
101:                 *  Description of the Method
102:                 *
103:                 * @param  e  Description of Parameter
104:                 * @since     v 1.0
105:                 */
106:                public void menuDeselected(MenuEvent e) {
107:                    //System.out.println("JavaStyleMenuListener: menuDeselected("+e+")");
108:                }
109:
110:                /**
111:                 *  Description of the Method
112:                 *
113:                 * @param  e  Description of Parameter
114:                 * @since     v 1.0
115:                 */
116:                public void menuSelected(MenuEvent e) {
117:                    //System.out.println("JavaStyleMenuListener: menuSelected(" + e + ")");
118:                    JMenuItem source = (JMenuItem) e.getSource();
119:                    if (source instanceof  JMenu) {
120:                        int count = ((JMenu) source).getItemCount();
121:                        //System.out.println("  itemCount="+count);
122:                        for (int i = 0; i < count; i++) {
123:                            Component item = ((JMenu) source)
124:                                    .getMenuComponent(i);
125:                            if (item != null && item instanceof  JMenu) {
126:                                if ("JavaStyle".equals(((JMenu) item)
127:                                        .getLabel())) {
128:                                    addMenuListener((JMenu) item,
129:                                            javastyleMenuListener2);
130:                                } else {
131:                                    addMenuListener((JMenu) item,
132:                                            javastyleMenuListener);
133:                                }
134:                            }
135:                        }
136:                    }
137:                }
138:            }
139:
140:            /**
141:             *  Description of the Class
142:             *
143:             * @author    Mike Atkinson MRA
144:             * @since     v 1.0
145:             */
146:            private static class JavastyleMenuListener2 implements  MenuListener {
147:                /**
148:                 *  Description of the Method
149:                 *
150:                 * @param  e  Description of Parameter
151:                 * @since     v 1.0
152:                 */
153:                public void menuCanceled(MenuEvent e) {
154:                    //System.out.println("JavaStyleMenuListener2: menuCanceled("+e+")");
155:                }
156:
157:                /**
158:                 *  Description of the Method
159:                 *
160:                 * @param  e  Description of Parameter
161:                 * @since     v 1.0
162:                 */
163:                public void menuDeselected(MenuEvent e) {
164:                    //System.out.println("JavaStyleMenuListener2: menuDeselected("+e+")");
165:                }
166:
167:                /**
168:                 *  Description of the Method
169:                 *
170:                 * @param  e  Description of Parameter
171:                 * @since     v 1.0
172:                 */
173:                public void menuSelected(MenuEvent e) {
174:                    //System.out.println("JavaStyleMenuListener2: menuSelected("+e+")");
175:                    JMenuItem source = (JMenuItem) e.getSource();
176:                    if (source instanceof  JMenu) {
177:                        int count = ((JMenu) source).getItemCount();
178:                        //System.out.println("  itemCount="+count);
179:                        for (int i = 0; i < count; i++) {
180:                            Component item = ((JMenu) source)
181:                                    .getMenuComponent(i);
182:                            if (item != null && item instanceof  JMenuItem) {
183:                                String label = ((JMenuItem) item).getLabel();
184:                                if ("Reformat Buffer".equals(label)) {
185:                                    //System.out.println(" grey out reformat buffer?");
186:                                    Buffer buffer = view.getBuffer();
187:                                    item.setEnabled(buffer.getName().endsWith(
188:                                            ".java"));
189:                                } else if ("Check current buffer".equals(label)) {
190:                                    //System.out.println(" grey out reformat buffer?");
191:                                    Buffer buffer = view.getBuffer();
192:                                    item.setEnabled(buffer.getName().endsWith(
193:                                            ".java"));
194:                                } else if ("In Current File".equals(label)) {
195:                                    //System.out.println(" grey out reformat buffer?");
196:                                    Buffer buffer = view.getBuffer();
197:                                    item.setEnabled(buffer.getName().endsWith(
198:                                            ".java"));
199:                                } else if ("Refactor".equals(label)) {
200:                                    //System.out.println(" grey out method refactorings?");
201:                                    try {
202:                                        CurrentSummary cs = CurrentSummary
203:                                                .get();
204:                                        JEditTextArea textArea = view
205:                                                .getTextArea();
206:                                        Object summary = cs.getCurrentSummary();
207:                                        item.setEnabled(summary != null);
208:                                        addMenuListener((JMenu) item,
209:                                                javastyleMenuListener2);
210:                                    } catch (Exception ex) {
211:                                        item.setEnabled(false);
212:                                    }
213:
214:                                } else if ("Method refactorings".equals(label)) {
215:                                    //System.out.println(" grey out method refactorings?");
216:                                    try {
217:                                        CurrentSummary cs = CurrentSummary
218:                                                .get();
219:                                        JEditTextArea textArea = view
220:                                                .getTextArea();
221:                                        Object summary = cs.getCurrentSummary();
222:                                        if (summary != null && textArea != null) {
223:                                            //System.out.println("JavaStylePlugin.getLineNumber() -> " + textArea.getCaretLine());
224:                                            cs.lineNo = textArea.getCaretLine();
225:                                            item
226:                                                    .setEnabled(summary != null
227:                                                            && summary instanceof  MethodSummary);
228:                                        } else {
229:                                            item.setEnabled(false);
230:                                        }
231:                                    } catch (Exception ex) {
232:                                        item.setEnabled(false);
233:                                    }
234:
235:                                } else if ("Field refactorings".equals(label)) {
236:                                    //System.out.println(" grey out field refactorings?");
237:                                    try {
238:                                        CurrentSummary cs = CurrentSummary
239:                                                .get();
240:                                        JEditTextArea textArea = view
241:                                                .getTextArea();
242:                                        Object summary = cs.getCurrentSummary();
243:                                        if (summary != null && textArea != null) {
244:                                            //System.out.println("JavaStylePlugin.getLineNumber() -> " + textArea.getCaretLine());
245:                                            cs.lineNo = textArea.getCaretLine();
246:                                            item
247:                                                    .setEnabled(summary != null
248:                                                            && summary instanceof  FieldSummary);
249:                                        } else {
250:                                            item.setEnabled(false);
251:                                        }
252:                                    } catch (Exception ex) {
253:                                        item.setEnabled(false);
254:                                    }
255:                                } else if (item != null
256:                                        && item instanceof  JMenu) {
257:                                    addMenuListener((JMenu) item,
258:                                            javastyleMenuListener2);
259:                                }
260:                            }
261:                        }
262:                    }
263:                }
264:            }
265:
266:            public static void addMenuListener(JMenu item,
267:                    MenuListener menuListener) {
268:                MenuListener[] listeners = item.getMenuListeners();
269:                if (listeners == null) {
270:                    item.addMenuListener(menuListener);
271:                } else {
272:                    for (int i = 0; i < listeners.length; i++) {
273:                        if (listeners[i] == menuListener) {
274:                            return;
275:                        }
276:                        item.addMenuListener(menuListener);
277:                    }
278:                }
279:            }
280:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.