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


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2005 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.examples.readmetool;
011:
012:        import org.eclipse.jface.action.Action;
013:        import org.eclipse.jface.action.IMenuManager;
014:        import org.eclipse.jface.action.IStatusLineManager;
015:        import org.eclipse.jface.action.IToolBarManager;
016:        import org.eclipse.jface.action.MenuManager;
017:        import org.eclipse.jface.action.Separator;
018:        import org.eclipse.jface.dialogs.MessageDialog;
019:        import org.eclipse.swt.widgets.Shell;
020:        import org.eclipse.ui.IActionBars;
021:        import org.eclipse.ui.IEditorPart;
022:        import org.eclipse.ui.IWorkbenchPage;
023:        import org.eclipse.ui.IWorkbenchPart;
024:        import org.eclipse.ui.PlatformUI;
025:        import org.eclipse.ui.actions.LabelRetargetAction;
026:        import org.eclipse.ui.actions.RetargetAction;
027:        import org.eclipse.ui.texteditor.BasicTextEditorActionContributor;
028:
029:        /**
030:         * This class demonstrates action contribution for the readme editor.
031:         * A number of menu, toolbar, and status line contributions are defined
032:         * in the workbench window.  These actions are shared among all 
033:         * readme editors, and are only visible when a readme editor is 
034:         * active.  Otherwise, they are invisible.
035:         */
036:        public class ReadmeEditorActionBarContributor extends
037:                BasicTextEditorActionContributor {
038:            private EditorAction action1;
039:
040:            private RetargetAction action2;
041:
042:            private LabelRetargetAction action3;
043:
044:            private EditorAction handler2;
045:
046:            private EditorAction handler3;
047:
048:            private EditorAction handler4;
049:
050:            private EditorAction handler5;
051:
052:            private DirtyStateContribution dirtyStateContribution;
053:
054:            class EditorAction extends Action {
055:                private Shell shell;
056:
057:                private IEditorPart activeEditor;
058:
059:                public EditorAction(String label) {
060:                    super (label);
061:                }
062:
063:                public void setShell(Shell shell) {
064:                    this .shell = shell;
065:                }
066:
067:                public void run() {
068:                    String editorName = MessageUtil
069:                            .getString("Empty_Editor_Name"); //$NON-NLS-1$
070:                    if (activeEditor != null)
071:                        editorName = activeEditor.getTitle();
072:                    MessageDialog
073:                            .openInformation(shell,
074:                                    MessageUtil.getString("Readme_Editor"), //$NON-NLS-1$
075:                                    MessageUtil
076:                                            .format(
077:                                                    "ReadmeEditorActionExecuted", new Object[] { getText(), editorName })); //$NON-NLS-1$
078:                }
079:
080:                public void setActiveEditor(IEditorPart part) {
081:                    activeEditor = part;
082:                }
083:            }
084:
085:            /**
086:             * Creates a new ReadmeEditorActionBarContributor.
087:             */
088:            public ReadmeEditorActionBarContributor() {
089:                action1 = new EditorAction(MessageUtil
090:                        .getString("Editor_Action1")); //$NON-NLS-1$
091:                action1.setToolTipText(MessageUtil
092:                        .getString("Readme_Editor_Action1")); //$NON-NLS-1$
093:                action1
094:                        .setDisabledImageDescriptor(ReadmeImages.EDITOR_ACTION1_IMAGE_DISABLE);
095:                action1
096:                        .setImageDescriptor(ReadmeImages.EDITOR_ACTION1_IMAGE_ENABLE);
097:                action1
098:                        .setHoverImageDescriptor(ReadmeImages.EDITOR_ACTION1_IMAGE);
099:                PlatformUI.getWorkbench().getHelpSystem().setHelp(action1,
100:                        IReadmeConstants.EDITOR_ACTION1_CONTEXT);
101:
102:                action2 = new RetargetAction(IReadmeConstants.RETARGET2,
103:                        MessageUtil.getString("Editor_Action2")); //$NON-NLS-1$
104:                action2.setToolTipText(MessageUtil
105:                        .getString("Readme_Editor_Action2")); //$NON-NLS-1$
106:                action2
107:                        .setDisabledImageDescriptor(ReadmeImages.EDITOR_ACTION2_IMAGE_DISABLE);
108:                action2
109:                        .setImageDescriptor(ReadmeImages.EDITOR_ACTION2_IMAGE_ENABLE);
110:                action2
111:                        .setHoverImageDescriptor(ReadmeImages.EDITOR_ACTION2_IMAGE);
112:
113:                action3 = new LabelRetargetAction(
114:                        IReadmeConstants.LABELRETARGET3, MessageUtil
115:                                .getString("Editor_Action3")); //$NON-NLS-1$
116:                action3
117:                        .setDisabledImageDescriptor(ReadmeImages.EDITOR_ACTION3_IMAGE_DISABLE);
118:                action3
119:                        .setImageDescriptor(ReadmeImages.EDITOR_ACTION3_IMAGE_ENABLE);
120:                action3
121:                        .setHoverImageDescriptor(ReadmeImages.EDITOR_ACTION3_IMAGE);
122:
123:                handler2 = new EditorAction(MessageUtil
124:                        .getString("Editor_Action2")); //$NON-NLS-1$
125:                PlatformUI.getWorkbench().getHelpSystem().setHelp(action2,
126:                        IReadmeConstants.EDITOR_ACTION2_CONTEXT);
127:
128:                handler3 = new EditorAction(MessageUtil
129:                        .getString("Editor_Action3")); //$NON-NLS-1$
130:                handler3.setToolTipText(MessageUtil
131:                        .getString("Readme_Editor_Action3")); //$NON-NLS-1$
132:                PlatformUI.getWorkbench().getHelpSystem().setHelp(action3,
133:                        IReadmeConstants.EDITOR_ACTION3_CONTEXT);
134:
135:                handler4 = new EditorAction(MessageUtil
136:                        .getString("Editor_Action4")); //$NON-NLS-1$
137:                handler5 = new EditorAction(MessageUtil
138:                        .getString("Editor_Action5")); //$NON-NLS-1$
139:                handler5.setToolTipText(MessageUtil
140:                        .getString("Readme_Editor_Action5")); //$NON-NLS-1$
141:
142:                dirtyStateContribution = new DirtyStateContribution();
143:            }
144:
145:            /** (non-Javadoc)
146:             * Method declared on EditorActionBarContributor
147:             */
148:            public void contributeToMenu(IMenuManager menuManager) {
149:                // Run super.
150:                super .contributeToMenu(menuManager);
151:
152:                // Editor-specitic menu
153:                MenuManager readmeMenu = new MenuManager(MessageUtil
154:                        .getString("Readme_Menu")); //$NON-NLS-1$
155:                // It is important to append the menu to the
156:                // group "additions". This group is created
157:                // between "Project" and "Tools" menus
158:                // for this purpose.
159:                menuManager.insertAfter("additions", readmeMenu); //$NON-NLS-1$
160:                readmeMenu.add(action1);
161:                readmeMenu.add(action2);
162:                readmeMenu.add(action3);
163:            }
164:
165:            /** (non-Javadoc)
166:             * Method declared on EditorActionBarContributor
167:             */
168:            public void contributeToStatusLine(
169:                    IStatusLineManager statusLineManager) {
170:                // Run super.
171:                super .contributeToStatusLine(statusLineManager);
172:                // Test status line.	
173:                statusLineManager.setMessage(MessageUtil
174:                        .getString("Editor_is_active")); //$NON-NLS-1$
175:                statusLineManager.add(dirtyStateContribution);
176:            }
177:
178:            /** (non-Javadoc)
179:             * Method declared on EditorActionBarContributor
180:             */
181:            public void contributeToToolBar(IToolBarManager toolBarManager) {
182:                // Run super.
183:                super .contributeToToolBar(toolBarManager);
184:
185:                // Add toolbar stuff.
186:                toolBarManager.add(new Separator("ReadmeEditor")); //$NON-NLS-1$
187:                toolBarManager.add(action1);
188:                toolBarManager.add(action2);
189:                toolBarManager.add(action3);
190:            }
191:
192:            /** (non-Javadoc)
193:             * Method declared on IEditorActionBarContributor
194:             */
195:            public void dispose() {
196:                // Remove retarget actions as page listeners
197:                getPage().removePartListener(action2);
198:                getPage().removePartListener(action3);
199:            }
200:
201:            /** (non-Javadoc)
202:             * Method declared on IEditorActionBarContributor
203:             */
204:            public void init(IActionBars bars, IWorkbenchPage page) {
205:                super .init(bars, page);
206:                bars.setGlobalActionHandler(IReadmeConstants.RETARGET2,
207:                        handler2);
208:                bars.setGlobalActionHandler(IReadmeConstants.LABELRETARGET3,
209:                        handler3);
210:                bars.setGlobalActionHandler(
211:                        IReadmeConstants.ACTION_SET_RETARGET4, handler4);
212:                bars.setGlobalActionHandler(
213:                        IReadmeConstants.ACTION_SET_LABELRETARGET5, handler5);
214:
215:                // Hook retarget actions as page listeners
216:                page.addPartListener(action2);
217:                page.addPartListener(action3);
218:                IWorkbenchPart activePart = page.getActivePart();
219:                if (activePart != null) {
220:                    action2.partActivated(activePart);
221:                    action3.partActivated(activePart);
222:                }
223:            }
224:
225:            /** (non-Javadoc)
226:             * Method declared on IEditorActionBarContributor
227:             */
228:            public void setActiveEditor(IEditorPart editor) {
229:                // Run super.
230:                super .setActiveEditor(editor);
231:
232:                // Target shared actions to new editor
233:                action1.setActiveEditor(editor);
234:                handler2.setActiveEditor(editor);
235:                handler3.setActiveEditor(editor);
236:                handler4.setActiveEditor(editor);
237:                handler5.setActiveEditor(editor);
238:                dirtyStateContribution.editorChanged(editor);
239:            }
240:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.