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


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 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 Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.ui.internal;
011:
012:        import org.eclipse.core.runtime.Assert;
013:        import org.eclipse.jface.action.ContributionItem;
014:        import org.eclipse.swt.SWT;
015:        import org.eclipse.swt.events.SelectionAdapter;
016:        import org.eclipse.swt.events.SelectionEvent;
017:        import org.eclipse.swt.graphics.Image;
018:        import org.eclipse.swt.widgets.Menu;
019:        import org.eclipse.swt.widgets.MenuItem;
020:        import org.eclipse.ui.IWorkingSet;
021:        import org.eclipse.ui.IWorkingSetManager;
022:        import org.eclipse.ui.PlatformUI;
023:        import org.eclipse.ui.actions.WorkingSetFilterActionGroup;
024:        import org.eclipse.jface.resource.ImageDescriptor;
025:
026:        /**
027:         * Menu contribution item which shows a working set.
028:         * 
029:         * @since 2.1
030:         */
031:        public class WorkingSetMenuContributionItem extends ContributionItem {
032:            private Image image;
033:
034:            private int id;
035:
036:            private IWorkingSet workingSet;
037:
038:            private WorkingSetFilterActionGroup actionGroup;
039:
040:            /**
041:             * Returns the id of this menu contribution item
042:             * 
043:             * @param id numerical id
044:             * @return String string id
045:             */
046:            public static String getId(int id) {
047:                return WorkingSetMenuContributionItem.class.getName()
048:                        + "." + id; //$NON-NLS-1$
049:            }
050:
051:            /**
052:             * Creates a new instance of the receiver.
053:             * 
054:             * @param id sequential id of the new instance
055:             * @param actionGroup the action group this contribution item is created in
056:             */
057:            public WorkingSetMenuContributionItem(int id,
058:                    WorkingSetFilterActionGroup actionGroup,
059:                    IWorkingSet workingSet) {
060:                super (getId(id));
061:                Assert.isNotNull(actionGroup);
062:                Assert.isNotNull(workingSet);
063:                this .id = id;
064:                this .actionGroup = actionGroup;
065:                this .workingSet = workingSet;
066:            }
067:
068:            /**
069:             * Adds a menu item for the working set.
070:             * Overrides method from ContributionItem.
071:             * 
072:             * @see org.eclipse.jface.action.ContributionItem#fill(Menu,int)
073:             */
074:            public void fill(Menu menu, int index) {
075:                MenuItem mi = new MenuItem(menu, SWT.RADIO, index);
076:                mi.setText("&" + id + " " + workingSet.getLabel()); //$NON-NLS-1$  //$NON-NLS-2$
077:                mi.setSelection(workingSet.equals(actionGroup.getWorkingSet()));
078:                mi.addSelectionListener(new SelectionAdapter() {
079:                    public void widgetSelected(SelectionEvent e) {
080:                        IWorkingSetManager manager = PlatformUI.getWorkbench()
081:                                .getWorkingSetManager();
082:                        actionGroup.setWorkingSet(workingSet);
083:                        manager.addRecentWorkingSet(workingSet);
084:                    }
085:                });
086:                if (image == null) {
087:                    ImageDescriptor imageDescriptor = workingSet
088:                            .getImageDescriptor();
089:                    if (imageDescriptor != null)
090:                        image = imageDescriptor.createImage();
091:                }
092:                mi.setImage(image);
093:            }
094:
095:            /**
096:             * Overridden to always return true and force dynamic menu building.
097:             */
098:            public boolean isDynamic() {
099:                return true;
100:            }
101:
102:            /*
103:             * @see org.eclipse.jface.action.ContributionItem#dispose()
104:             * @since 3.3
105:             */
106:            public void dispose() {
107:                if (image != null && !image.isDisposed())
108:                    image.dispose();
109:                image = null;
110:
111:                super.dispose();
112:            }
113:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.