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


001:        /* ====================================================================
002:         * The JRefactory License, Version 1.0
003:         *
004:         * Copyright (c) 2001 JRefactory.  All rights reserved.
005:         *
006:         * Redistribution and use in source and binary forms, with or without
007:         * modification, are permitted provided that the following conditions
008:         * are met:
009:         *
010:         * 1. Redistributions of source code must retain the above copyright
011:         *    notice, this list of conditions and the following disclaimer.
012:         *
013:         * 2. Redistributions in binary form must reproduce the above copyright
014:         *    notice, this list of conditions and the following disclaimer in
015:         *    the documentation and/or other materials provided with the
016:         *    distribution.
017:         *
018:         * 3. The end-user documentation included with the redistribution,
019:         *    if any, must include the following acknowledgment:
020:         *       "This product includes software developed by the
021:         *        JRefactory (http://www.sourceforge.org/projects/jrefactory)."
022:         *    Alternately, this acknowledgment may appear in the software itself,
023:         *    if and wherever such third-party acknowledgments normally appear.
024:         *
025:         * 4. The names "JRefactory" must not be used to endorse or promote
026:         *    products derived from this software without prior written
027:         *    permission. For written permission, please contact seguin@acm.org.
028:         *
029:         * 5. Products derived from this software may not be called "JRefactory",
030:         *    nor may "JRefactory" appear in their name, without prior written
031:         *    permission of Chris Seguin.
032:         *
033:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
034:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
035:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
036:         * DISCLAIMED.  IN NO EVENT SHALL THE CHRIS SEGUIN OR
037:         * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
038:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
039:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
040:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
041:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
042:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
043:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
044:         * SUCH DAMAGE.
045:         * ====================================================================
046:         *
047:         * This software consists of voluntary contributions made by many
048:         * individuals on behalf of JRefactory.  For more information on
049:         * JRefactory, please see
050:         * <http://www.sourceforge.org/projects/jrefactory>.
051:         */
052:        package org.acm.seguin.ide.command;
053:
054:        import javax.swing.JMenu;
055:        import javax.swing.JMenuBar;
056:        import javax.swing.JMenuItem;
057:        import javax.swing.JCheckBoxMenuItem;
058:        import javax.swing.JPanel;
059:        import javax.swing.event.MenuListener;
060:        import javax.swing.event.MenuEvent;
061:        import java.awt.event.ActionListener;
062:        import java.awt.event.ActionEvent;
063:        import org.acm.seguin.ide.common.UndoAdapter;
064:        import org.acm.seguin.io.Saveable;
065:        import org.acm.seguin.uml.SaveMenuSelection;
066:        import net.sourceforge.jrefactory.uml.UMLPackage;
067:        import net.sourceforge.jrefactory.action.SaveImageAction;
068:        import net.sourceforge.jrefactory.uml.LinedPanel;
069:        import net.sourceforge.jrefactory.uml.render.SaveAdapter;
070:        import net.sourceforge.jrefactory.uml.print.PrintAdapter;
071:        import net.sourceforge.jrefactory.uml.print.PrintSetupAdapter;
072:        import org.acm.seguin.refactor.undo.UndoStack;
073:
074:        /**
075:         *  Creates the menubar for the command line program
076:         *
077:         *@author     Chris Seguin
078:         *@author     <a href="mailto:JRefactory@ladyshot.demon.co.uk">Mike Atkinson</a>
079:         *@version    $Id: CommandLineMenu.java,v 1.6 2003/12/02 23:39:32 mikeatkinson Exp $
080:         *@created    October 18, 2001
081:         */
082:        public class CommandLineMenu {
083:            private JMenuItem undoMenuItem;
084:
085:            /**
086:             *  Gets the MenuBar attribute of the CommandLineMenu object
087:             *
088:             *@param  panel  Description of Parameter
089:             *@return        The MenuBar value
090:             */
091:            public JMenuBar getMenuBar(JPanel panel) {
092:                JMenuBar menubar = new JMenuBar();
093:                menubar.add(createFileMenu(panel));
094:                menubar.add(createEditMenu());
095:
096:                if (panel instanceof  LinedPanel) {
097:                    menubar.add(createZoomMenu(panel));
098:                }
099:
100:                if (panel instanceof  UMLPackage) {
101:                    menubar.add(createRearangeMenu(panel));
102:                    menubar.add(createViewMenu((UMLPackage) panel));
103:                }
104:
105:                return menubar;
106:            }
107:
108:            /**
109:             *  Creates edit menu
110:             *
111:             *@return    returns the edit menu
112:             */
113:            private JMenu createEditMenu() {
114:                JMenu editMenu = new JMenu("Edit");
115:                editMenu.addMenuListener(new MenuListener() {
116:                    public void menuCanceled(MenuEvent e) {
117:                    }
118:
119:                    public void menuDeselected(MenuEvent e) {
120:                    }
121:
122:                    public void menuSelected(MenuEvent e) {
123:                        undoMenuItem
124:                                .setEnabled(!UndoStack.get().isStackEmpty());
125:                    }
126:                });
127:                undoMenuItem = new JMenuItem("Undo Refactoring");
128:                undoMenuItem.addActionListener(new UndoAdapter());
129:                editMenu.add(undoMenuItem);
130:                return editMenu;
131:            }
132:
133:            /**
134:             *  Creates the file menu
135:             *
136:             *@param  panel  the panel
137:             *@return        the file menu
138:             */
139:            private JMenu createFileMenu(JPanel panel) {
140:                JMenu fileMenu = new JMenu("File");
141:
142:                JMenuItem saveMenuItem = new JMenuItem("Save");
143:                if (panel instanceof  Saveable) {
144:                    saveMenuItem.addActionListener(new SaveMenuSelection(
145:                            (Saveable) panel));
146:                } else {
147:                    saveMenuItem.setEnabled(false);
148:                }
149:                fileMenu.add(saveMenuItem);
150:
151:                //JMenuItem jpgMenuItem = new JMenuItem("JPG");
152:                //if (panel instanceof UMLPackage) {
153:                //    jpgMenuItem.addActionListener(new SaveAdapter((UMLPackage) panel, ".jpg"));
154:                //} else {
155:                //    jpgMenuItem.setEnabled(false);
156:                //}
157:                //fileMenu.add(jpgMenuItem);
158:                JMenuItem jpgMenuItem = new JMenuItem(new SaveImageAction(
159:                        panel, "JPG"));
160:                fileMenu.add(jpgMenuItem);
161:                JMenuItem pngMenuItem = new JMenuItem(new SaveImageAction(
162:                        panel, "PNG"));
163:                fileMenu.add(pngMenuItem);
164:
165:                fileMenu.addSeparator();
166:
167:                JMenuItem printSetupMenuItem = new JMenuItem("Print Setup");
168:                printSetupMenuItem.addActionListener(new PrintSetupAdapter());
169:                fileMenu.add(printSetupMenuItem);
170:
171:                JMenuItem printMenuItem = new JMenuItem("Print");
172:                if (panel instanceof  UMLPackage) {
173:                    printMenuItem.addActionListener(new PrintAdapter(
174:                            (UMLPackage) panel));
175:                } else {
176:                    printMenuItem.setEnabled(false);
177:                }
178:                fileMenu.add(printMenuItem);
179:
180:                fileMenu.addSeparator();
181:
182:                JMenuItem exitMenuItem = new JMenuItem("Exit");
183:                exitMenuItem.addActionListener(new ExitMenuSelection());
184:                fileMenu.add(exitMenuItem);
185:                return fileMenu;
186:            }
187:
188:            /**
189:             *  Creates the zoom menu
190:             *
191:             *@param  panel  the panel
192:             *@return        the zoom menu
193:             */
194:            private JMenu createViewMenu(UMLPackage panel) {
195:                JMenu viewMenu = new JMenu("View");
196:                JMenuItem item = new JMenuItem("fast");
197:                item.addActionListener(new ViewAdapter(panel, "fast"));
198:                viewMenu.add(item);
199:                item = new JMenuItem("medium");
200:                item.addActionListener(new ViewAdapter(panel, "medium"));
201:                viewMenu.add(item);
202:                item = new JMenuItem("quality");
203:                item.addActionListener(new ViewAdapter(panel, "quality"));
204:                viewMenu.add(item);
205:                viewMenu.addSeparator();
206:                item = new JCheckBoxMenuItem("show private");
207:                item.setSelected(panel.isViewPrivate());
208:                item.addActionListener(new ViewAdapter(panel, "private"));
209:                viewMenu.add(item);
210:                item = new JCheckBoxMenuItem("show extenal");
211:                item.setSelected(panel.isViewExternal());
212:                item.addActionListener(new ViewAdapter(panel, "external"));
213:                viewMenu.add(item);
214:
215:                return viewMenu;
216:            }
217:
218:            /**
219:             *  Creates the zoom menu
220:             *
221:             *@param  panel  the panel
222:             *@return        the zoom menu
223:             */
224:            private JMenu createZoomMenu(JPanel panel) {
225:                LinedPanel linedPanel = (LinedPanel) panel;
226:                JMenu zoomMenu = new JMenu("Zoom");
227:                JMenuItem tenPercent = new JMenuItem("10%");
228:                tenPercent.addActionListener(new ZoomAdapter(linedPanel, 0.1));
229:                zoomMenu.add(tenPercent);
230:                JMenuItem twentyFivePercent = new JMenuItem("25%");
231:                twentyFivePercent.addActionListener(new ZoomAdapter(linedPanel,
232:                        0.25));
233:                zoomMenu.add(twentyFivePercent);
234:                JMenuItem thirtyThreePercent = new JMenuItem("33%");
235:                thirtyThreePercent.addActionListener(new ZoomAdapter(
236:                        linedPanel, 0.33));
237:                zoomMenu.add(thirtyThreePercent);
238:                JMenuItem fiftyPercent = new JMenuItem("50%");
239:                fiftyPercent
240:                        .addActionListener(new ZoomAdapter(linedPanel, 0.5));
241:                zoomMenu.add(fiftyPercent);
242:                JMenuItem sixtySixPercent = new JMenuItem("66%");
243:                sixtySixPercent.addActionListener(new ZoomAdapter(linedPanel,
244:                        0.66));
245:                zoomMenu.add(sixtySixPercent);
246:                JMenuItem normal = new JMenuItem("100%");
247:                normal.addActionListener(new ZoomAdapter(linedPanel, 1.0));
248:                zoomMenu.add(normal);
249:                JMenuItem twoHunderd = new JMenuItem("200%");
250:                twoHunderd.addActionListener(new ZoomAdapter(linedPanel, 2.0));
251:                zoomMenu.add(twoHunderd);
252:                return zoomMenu;
253:            }
254:
255:            /**
256:             *  Creates the zoom menu
257:             *
258:             *@param  panel  the panel
259:             *@return        the zoom menu
260:             */
261:            private JMenu createRearangeMenu(JPanel panel) {
262:                final UMLPackage linedPanel = (UMLPackage) panel;
263:                JMenu rearangeMenu = new JMenu("Rearange");
264:                JMenuItem rearange = new JMenuItem("Rearange UML");
265:                rearange.addActionListener(new ActionListener() {
266:                    public void actionPerformed(ActionEvent evt) {
267:                        linedPanel.rearragePositions(2000, 50, 1.0);
268:                        linedPanel.reset();
269:                    }
270:                });
271:                rearangeMenu.add(rearange);
272:
273:                JMenuItem nudge = new JMenuItem("Nudge UML");
274:                nudge.addActionListener(new ActionListener() {
275:                    public void actionPerformed(ActionEvent evt) {
276:                        linedPanel.rearragePositions(10, 50, 0.2);
277:                        linedPanel.reset();
278:                    }
279:                });
280:                rearangeMenu.add(nudge);
281:                return rearangeMenu;
282:            }
283:        }
284:        //  EOF
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.