Source Code Cross Referenced for ReadmeEditor.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, 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.examples.readmetool;
011:
012:        import org.eclipse.core.runtime.IProgressMonitor;
013:        import org.eclipse.jface.action.IMenuManager;
014:        import org.eclipse.jface.action.MenuManager;
015:        import org.eclipse.jface.action.Separator;
016:        import org.eclipse.swt.custom.StyledText;
017:        import org.eclipse.swt.dnd.DND;
018:        import org.eclipse.swt.dnd.DropTargetEvent;
019:        import org.eclipse.swt.dnd.DropTargetListener;
020:        import org.eclipse.swt.dnd.TextTransfer;
021:        import org.eclipse.swt.dnd.Transfer;
022:        import org.eclipse.swt.widgets.Composite;
023:        import org.eclipse.ui.IEditorInput;
024:        import org.eclipse.ui.IFileEditorInput;
025:        import org.eclipse.ui.dnd.IDragAndDropService;
026:        import org.eclipse.ui.editors.text.TextEditor;
027:        import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
028:
029:        /**
030:         * This class implements the Readme editor.  Since the readme
031:         * editor is mostly just a text editor, there is very little
032:         * implemented in this actual class.  It can be regarded as
033:         * simply decorating the text editor with a content outline.
034:         */
035:        public class ReadmeEditor extends TextEditor {
036:            protected ReadmeContentOutlinePage page;
037:
038:            /**
039:             * Creates a new ReadmeEditor.
040:             */
041:            public ReadmeEditor() {
042:                super ();
043:            }
044:
045:            /* (non-Javadoc)
046:             * @see org.eclipse.ui.texteditor.StatusTextEditor#createPartControl(org.eclipse.swt.widgets.Composite)
047:             */
048:            public void createPartControl(Composite parent) {
049:                super .createPartControl(parent);
050:
051:                StyledText tw = getSourceViewer().getTextWidget();
052:
053:                // Add a 'TextTransfer' drop target to the editor
054:                int ops = DND.DROP_DEFAULT | DND.DROP_COPY;
055:                Transfer[] transfers = { TextTransfer.getInstance() };
056:                DropTargetListener editorListener = new DropTargetListener() {
057:
058:                    public void dragEnter(DropTargetEvent event) {
059:                        event.detail = DND.DROP_COPY;
060:                    }
061:
062:                    public void dragLeave(DropTargetEvent event) {
063:                    }
064:
065:                    public void dragOperationChanged(DropTargetEvent event) {
066:                        event.detail = DND.DROP_COPY;
067:                    }
068:
069:                    public void dragOver(DropTargetEvent event) {
070:                        event.feedback = DND.FEEDBACK_SCROLL
071:                                | DND.FEEDBACK_SELECT;
072:                    }
073:
074:                    public void drop(DropTargetEvent event) {
075:                        if (TextTransfer.getInstance().isSupportedType(
076:                                event.currentDataType)) {
077:                            String text = (String) event.data;
078:                            getSourceViewer().getTextWidget().insert(text);
079:                        }
080:                    }
081:
082:                    public void dropAccept(DropTargetEvent event) {
083:                    }
084:
085:                };
086:
087:                IDragAndDropService dtSvc = (IDragAndDropService) getSite()
088:                        .getService(IDragAndDropService.class);
089:                dtSvc.addMergedDropTarget(tw, ops, transfers, editorListener);
090:            }
091:
092:            /** (non-Javadoc)
093:             * Method declared on IEditorPart
094:             */
095:            public void doSave(IProgressMonitor monitor) {
096:                super .doSave(monitor);
097:                if (page != null)
098:                    page.update();
099:            }
100:
101:            /** (non-Javadoc)
102:             * Method declared on IAdaptable
103:             */
104:            public Object getAdapter(Class key) {
105:                if (key.equals(IContentOutlinePage.class)) {
106:                    IEditorInput input = getEditorInput();
107:                    if (input instanceof  IFileEditorInput) {
108:                        page = new ReadmeContentOutlinePage(
109:                                ((IFileEditorInput) input).getFile());
110:                        return page;
111:                    }
112:                }
113:                return super .getAdapter(key);
114:            }
115:
116:            /** (non-Javadoc)
117:             * Method declared on AbstractTextEditor
118:             */
119:            protected void editorContextMenuAboutToShow(IMenuManager parentMenu) {
120:                super .editorContextMenuAboutToShow(parentMenu);
121:                parentMenu.add(new Separator());
122:                IMenuManager subMenu = new MenuManager(MessageUtil
123:                        .getString("Add")); //$NON-NLS-1$
124:                parentMenu.add(subMenu);
125:                if (subMenu != null) {
126:                    // Add readme actions with various attributes
127:                    Object[][] att = new Object[][] { {
128:                            IReadmeConstants.MARKER_ATT_ID, new Integer(1234) } };
129:                    subMenu
130:                            .add(new AddReadmeMarkerAction(
131:                                    this ,
132:                                    MessageUtil
133:                                            .getString("Add_readme_marker_action_label") + "1", //$NON-NLS-1$ //$NON-NLS-2$
134:                                    att,
135:                                    MessageUtil
136:                                            .getString("Readme_marker_message_example") + " id=1234")); //$NON-NLS-1$ //$NON-NLS-2$
137:
138:                    att = new Object[][] { { IReadmeConstants.MARKER_ATT_LEVEL,
139:                            new Integer(7) } };
140:                    subMenu
141:                            .add(new AddReadmeMarkerAction(
142:                                    this ,
143:                                    MessageUtil
144:                                            .getString("Add_readme_marker_action_label") + "2", //$NON-NLS-1$ //$NON-NLS-2$
145:                                    att,
146:                                    MessageUtil
147:                                            .getString("Readme_marker_message_example") + " level=7")); //$NON-NLS-1$ //$NON-NLS-2$
148:
149:                    att = new Object[][] {
150:                            { IReadmeConstants.MARKER_ATT_LEVEL, new Integer(7) },
151:                            { IReadmeConstants.MARKER_ATT_DEPT, "infra" } }; //$NON-NLS-1$
152:                    subMenu
153:                            .add(new AddReadmeMarkerAction(
154:                                    this ,
155:                                    MessageUtil
156:                                            .getString("Add_readme_marker_action_label") + "3", //$NON-NLS-1$ //$NON-NLS-2$
157:                                    att,
158:                                    MessageUtil
159:                                            .getString("Readme_marker_message_example") + " level=7, department=infra")); //$NON-NLS-1$ //$NON-NLS-2$
160:
161:                    att = new Object[][] { { IReadmeConstants.MARKER_ATT_CODE,
162:                            "red" } }; //$NON-NLS-1$
163:                    subMenu
164:                            .add(new AddReadmeMarkerAction(
165:                                    this ,
166:                                    MessageUtil
167:                                            .getString("Add_readme_marker_action_label") + "4", //$NON-NLS-1$ //$NON-NLS-2$
168:                                    att,
169:                                    MessageUtil
170:                                            .getString("Readme_marker_message_example") + " code=red")); //$NON-NLS-1$ //$NON-NLS-2$
171:
172:                    att = new Object[][] { { IReadmeConstants.MARKER_ATT_LANG,
173:                            "english" } }; //$NON-NLS-1$
174:                    subMenu
175:                            .add(new AddReadmeMarkerAction(
176:                                    this ,
177:                                    MessageUtil
178:                                            .getString("Add_readme_marker_action_label") + "5", //$NON-NLS-1$ //$NON-NLS-2$
179:                                    att,
180:                                    MessageUtil
181:                                            .getString("Readme_marker_message_example") + " language=english")); //$NON-NLS-1$ //$NON-NLS-2$
182:
183:                    att = new Object[][] {
184:                            { IReadmeConstants.MARKER_ATT_ID, new Integer(1234) },
185:                            { IReadmeConstants.MARKER_ATT_LEVEL, new Integer(7) },
186:                            { IReadmeConstants.MARKER_ATT_DEPT, "infra" }, //$NON-NLS-1$
187:                            { IReadmeConstants.MARKER_ATT_CODE, "red" }, //$NON-NLS-1$
188:                            { IReadmeConstants.MARKER_ATT_LANG, "english" } }; //$NON-NLS-1$
189:                    subMenu
190:                            .add(new AddReadmeMarkerAction(
191:                                    this ,
192:                                    MessageUtil
193:                                            .getString("Add_readme_marker_action_label") + "6", //$NON-NLS-1$ //$NON-NLS-2$
194:                                    att,
195:                                    MessageUtil
196:                                            .getString("Readme_marker_message_example") + //$NON-NLS-1$
197:                                            " id=1234, level=7, department=infra, code=red, language=english")); //$NON-NLS-1$
198:
199:                    att = new Object[0][0];
200:                    subMenu
201:                            .add(new AddReadmeMarkerAction(
202:                                    this ,
203:                                    MessageUtil
204:                                            .getString("Add_readme_marker_action_label") + "7", //$NON-NLS-1$ //$NON-NLS-2$
205:                                    att,
206:                                    MessageUtil
207:                                            .getString("Readme_marker_message_example") + " No attributes specified")); //$NON-NLS-1$ //$NON-NLS-2$
208:                }
209:            }
210:
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.