Source Code Cross Referenced for BuildSetMenu.java in  » IDE-Eclipse » ui-ide » org » eclipse » ui » internal » ide » actions » 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 » IDE Eclipse » ui ide » org.eclipse.ui.internal.ide.actions 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2004, 2006 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         * IBM - Initial API and implementation
010:         * hzhou@actuate.com - Fix for  Bug 71695 - 
011:         * [WorkingSets]Removed Working Set is still shown under the menu item 
012:         * when it is the recently used working set
013:         *******************************************************************************/package org.eclipse.ui.internal.ide.actions;
014:
015:        import org.eclipse.core.resources.ResourcesPlugin;
016:        import org.eclipse.jface.action.ActionContributionItem;
017:        import org.eclipse.jface.action.ContributionItem;
018:        import org.eclipse.jface.action.IAction;
019:        import org.eclipse.jface.action.IMenuListener;
020:        import org.eclipse.jface.action.IMenuManager;
021:        import org.eclipse.jface.action.MenuManager;
022:        import org.eclipse.jface.action.Separator;
023:        import org.eclipse.swt.widgets.Menu;
024:        import org.eclipse.ui.IWorkbenchWindow;
025:        import org.eclipse.ui.IWorkingSet;
026:        import org.eclipse.ui.application.IActionBarConfigurer;
027:
028:        /**
029:         * Sub-menu off project menu for showing MRU list of working set builds.
030:         * 
031:         * @since 3.0
032:         */
033:        public class BuildSetMenu extends ContributionItem {
034:            private IActionBarConfigurer actionBars;
035:
036:            boolean dirty = true;
037:
038:            private IMenuListener menuListener = new IMenuListener() {
039:                public void menuAboutToShow(IMenuManager manager) {
040:                    manager.markDirty();
041:                    dirty = true;
042:                }
043:            };
044:
045:            private IAction selectBuildWorkingSetAction;
046:
047:            private IWorkbenchWindow window;
048:
049:            /**
050:             * Create a new instance of the receiver.
051:             * @param window
052:             * @param actionBars
053:             */
054:            public BuildSetMenu(IWorkbenchWindow window,
055:                    IActionBarConfigurer actionBars) {
056:                this .window = window;
057:                this .actionBars = actionBars;
058:                selectBuildWorkingSetAction = new SelectBuildWorkingSetAction(
059:                        window, actionBars);
060:            }
061:
062:            /**
063:             * Adds a mnemonic accelerator to actions in the MRU list of
064:             * recently built working sets.
065:             * @param action the action to add
066:             * @param index the index to add it at
067:             */
068:            private void addMnemonic(BuildSetAction action, int index) {
069:                StringBuffer label = new StringBuffer();
070:                //add the numerical accelerator
071:                if (index < 9) {
072:                    label.append('&');
073:                    label.append(index);
074:                    label.append(' ');
075:                }
076:                label.append(action.getWorkingSet().getLabel());
077:                action.setText(label.toString());
078:            }
079:
080:            /* (non-Javadoc)
081:             * @see org.eclipse.jface.action.IContributionItem#fill(org.eclipse.swt.widgets.Menu, int)
082:             */
083:            public void fill(Menu menu, int index) {
084:                if (getParent() instanceof  MenuManager) {
085:                    ((MenuManager) getParent()).addMenuListener(menuListener);
086:                }
087:                if (!dirty) {
088:                    return;
089:                }
090:                fillMenu(menu);
091:                dirty = false;
092:            }
093:
094:            /**
095:             * Fills the menu with Show View actions.
096:             * @param menu The menu being filled.
097:             */
098:            private void fillMenu(Menu menu) {
099:                boolean isAutoBuilding = ResourcesPlugin.getWorkspace()
100:                        .isAutoBuilding();
101:
102:                //build MRU list of recently built working sets:
103:                IWorkingSet[] sets = window.getWorkbench()
104:                        .getWorkingSetManager().getRecentWorkingSets();
105:                BuildSetAction last = BuildSetAction.lastBuilt;
106:                IWorkingSet lastSet = null;
107:                //add build action for the last working set that was built
108:                int accel = 1;
109:                if (last != null) {
110:                    // add it only if it has not been removed
111:                    boolean found = false;
112:                    for (int i = 0; i < sets.length; i++) {
113:                        if (sets[i].equals(last.getWorkingSet())) {
114:                            found = true;
115:                            break;
116:                        }
117:                    }
118:                    if (found) {
119:                        last.setChecked(true);
120:                        last.setEnabled(!isAutoBuilding);
121:                        last
122:                                .setActionDefinitionId("org.eclipse.ui.project.buildLast"); //$NON-NLS-1$
123:                        addMnemonic(last, accel++);
124:                        new ActionContributionItem(last).fill(menu, -1);
125:                        lastSet = last.getWorkingSet();
126:                    } else {
127:                        BuildSetAction.lastBuilt = null;
128:                    }
129:                }
130:                //add build actions for the most recently used working sets
131:                for (int i = 0; i < sets.length; i++) {
132:                    if (lastSet != null && lastSet.equals(sets[i])) {
133:                        continue;
134:                    }
135:                    BuildSetAction action = new BuildSetAction(sets[i], window,
136:                            actionBars);
137:                    addMnemonic(action, accel++);
138:                    action.setEnabled(!isAutoBuilding);
139:                    new ActionContributionItem(action).fill(menu, -1);
140:                }
141:                //add the action to select a different working set
142:                if (sets.length > 0) {
143:                    new Separator().fill(menu, -1);
144:                }
145:                selectBuildWorkingSetAction.setEnabled(!isAutoBuilding);
146:                new ActionContributionItem(selectBuildWorkingSetAction).fill(
147:                        menu, -1);
148:            }
149:
150:            public boolean isDirty() {
151:                return dirty;
152:            }
153:
154:            /**
155:             * Overridden to always return true and force dynamic menu building.
156:             */
157:            public boolean isDynamic() {
158:                return true;
159:            }
160:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.