Source Code Cross Referenced for AbstractRulerActionDelegate.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » texteditor » 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.texteditor 
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.texteditor;
011:
012:        import org.eclipse.swt.events.MouseEvent;
013:        import org.eclipse.swt.events.MouseListener;
014:        import org.eclipse.swt.widgets.Control;
015:        import org.eclipse.swt.widgets.Event;
016:
017:        import org.eclipse.jface.action.IAction;
018:        import org.eclipse.jface.action.IMenuListener;
019:        import org.eclipse.jface.action.IMenuManager;
020:        import org.eclipse.jface.viewers.ISelection;
021:
022:        import org.eclipse.jface.text.source.IVerticalRulerInfo;
023:
024:        import org.eclipse.ui.IActionDelegate2;
025:        import org.eclipse.ui.IEditorActionDelegate;
026:        import org.eclipse.ui.IEditorPart;
027:        import org.eclipse.ui.actions.ActionDelegate;
028:
029:        /**
030:         * This class serves as an adapter for actions contributed to the vertical ruler's
031:         * context menu. This adapter provides the contributed actions access to their editor
032:         * and the editor's vertical ruler. These actions gain only limited access to the vertical
033:         * ruler as defined by <code>IVerticalRulerInfo</code>.  The adapter updates the
034:         * adapter (inner) action on menu and mouse action on the vertical ruler.<p>
035:         * Extending classes must implement the factory method
036:         * <code>createAction(ITextEditor editor, IVerticalRulerInfo)</code>.
037:         *
038:         * @since 2.0
039:         */
040:        public abstract class AbstractRulerActionDelegate extends
041:                ActionDelegate implements  IEditorActionDelegate,
042:                IActionDelegate2, MouseListener, IMenuListener {
043:
044:            /** The editor. */
045:            private ITextEditor fEditor;
046:            /** The action calling the action delegate. */
047:            private IAction fCallerAction;
048:            /** The underlying action. */
049:            private IAction fAction;
050:
051:            /**
052:             * The factory method creating the underlying action.
053:             *
054:             * @param editor the editor the action to be created will work on
055:             * @param rulerInfo the vertical ruler the action to be created will work on
056:             * @return the created action
057:             */
058:            protected abstract IAction createAction(ITextEditor editor,
059:                    IVerticalRulerInfo rulerInfo);
060:
061:            /*
062:             * @see IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart)
063:             */
064:            public void setActiveEditor(IAction callerAction,
065:                    IEditorPart targetEditor) {
066:                if (fEditor != null) {
067:                    IVerticalRulerInfo rulerInfo = (IVerticalRulerInfo) fEditor
068:                            .getAdapter(IVerticalRulerInfo.class);
069:                    if (rulerInfo != null) {
070:                        Control control = rulerInfo.getControl();
071:                        if (control != null && !control.isDisposed())
072:                            control.removeMouseListener(this );
073:                    }
074:
075:                    if (fEditor instanceof  ITextEditorExtension)
076:                        ((ITextEditorExtension) fEditor)
077:                                .removeRulerContextMenuListener(this );
078:                }
079:
080:                fEditor = (ITextEditor) (targetEditor == null ? null
081:                        : targetEditor.getAdapter(ITextEditor.class));
082:                fCallerAction = callerAction;
083:                fAction = null;
084:
085:                if (fEditor != null) {
086:                    if (fEditor instanceof  ITextEditorExtension)
087:                        ((ITextEditorExtension) fEditor)
088:                                .addRulerContextMenuListener(this );
089:
090:                    IVerticalRulerInfo rulerInfo = (IVerticalRulerInfo) fEditor
091:                            .getAdapter(IVerticalRulerInfo.class);
092:                    if (rulerInfo != null) {
093:                        fAction = createAction(fEditor, rulerInfo);
094:                        update();
095:
096:                        Control control = rulerInfo.getControl();
097:                        if (control != null && !control.isDisposed())
098:                            control.addMouseListener(this );
099:                    }
100:                }
101:            }
102:
103:            /*
104:             * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
105:             */
106:            public void run(IAction callerAction) {
107:                if (fAction != null)
108:                    fAction.run();
109:            }
110:
111:            /*
112:             * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
113:             * @since 3.2
114:             */
115:            public void runWithEvent(IAction action, Event event) {
116:                if (fAction != null)
117:                    fAction.runWithEvent(event);
118:            }
119:
120:            /*
121:             * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
122:             */
123:            public void selectionChanged(IAction action, ISelection selection) {
124:                /*
125:                 * This is a ruler action - don't update on selection.
126:                 * The call was introduced to support annotation roll-overs
127:                 * but this seems not to be needed.
128:                 */
129:                //		update();
130:            }
131:
132:            /**
133:             * Updates to the current state.
134:             */
135:            private void update() {
136:                if (fAction instanceof  IUpdate) {
137:                    ((IUpdate) fAction).update();
138:                    if (fCallerAction != null) {
139:                        fCallerAction.setText(fAction.getText());
140:                        fCallerAction.setEnabled(fAction.isEnabled());
141:                    }
142:                }
143:            }
144:
145:            /*
146:             * @see IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager)
147:             */
148:            public void menuAboutToShow(IMenuManager manager) {
149:                update();
150:            }
151:
152:            /*
153:             * @see MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
154:             */
155:            public void mouseDoubleClick(MouseEvent e) {
156:            }
157:
158:            /*
159:             * @see MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
160:             */
161:            public void mouseDown(MouseEvent e) {
162:                update();
163:            }
164:
165:            /*
166:             * @see MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
167:             */
168:            public void mouseUp(MouseEvent e) {
169:            }
170:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.