Source Code Cross Referenced for SimpleCSIntroDetails.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » ui » editor » cheatsheet » simple » details » 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 » Eclipse plug in development » org.eclipse.pde.internal.ui.editor.cheatsheet.simple.details 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2006, 2007 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.pde.internal.ui.editor.cheatsheet.simple.details;
011:
012:        import org.eclipse.jface.text.DocumentEvent;
013:        import org.eclipse.jface.text.IDocument;
014:        import org.eclipse.jface.text.IDocumentListener;
015:        import org.eclipse.jface.viewers.ISelection;
016:        import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSIntro;
017:        import org.eclipse.pde.internal.ui.PDEUIMessages;
018:        import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
019:        import org.eclipse.pde.internal.ui.editor.cheatsheet.CSAbstractDetails;
020:        import org.eclipse.pde.internal.ui.editor.cheatsheet.ICSMaster;
021:        import org.eclipse.pde.internal.ui.editor.cheatsheet.simple.SimpleCSInputContext;
022:        import org.eclipse.pde.internal.ui.parts.PDESourceViewer;
023:        import org.eclipse.swt.SWT;
024:        import org.eclipse.swt.dnd.Clipboard;
025:        import org.eclipse.swt.graphics.Color;
026:        import org.eclipse.swt.layout.GridData;
027:        import org.eclipse.swt.widgets.Composite;
028:        import org.eclipse.swt.widgets.Label;
029:        import org.eclipse.ui.forms.IFormColors;
030:        import org.eclipse.ui.forms.IFormPart;
031:        import org.eclipse.ui.forms.IManagedForm;
032:        import org.eclipse.ui.forms.widgets.ExpandableComposite;
033:        import org.eclipse.ui.forms.widgets.Section;
034:
035:        /**
036:         * SimpleCSIntroDetails
037:         *
038:         */
039:        public class SimpleCSIntroDetails extends CSAbstractDetails {
040:
041:            private ISimpleCSIntro fIntro;
042:
043:            private PDESourceViewer fContentViewer;
044:
045:            private Section fMainSection;
046:
047:            private SimpleCSHelpDetails fHelpSection;
048:
049:            private boolean fBlockEvents;
050:
051:            /**
052:             * @param elementSection
053:             */
054:            public SimpleCSIntroDetails(ICSMaster elementSection) {
055:                super (elementSection, SimpleCSInputContext.CONTEXT_ID);
056:                fIntro = null;
057:
058:                fContentViewer = null;
059:                fMainSection = null;
060:                fHelpSection = new SimpleCSHelpDetails(elementSection);
061:                fBlockEvents = false;
062:            }
063:
064:            /**
065:             * @param object
066:             */
067:            public void setData(ISimpleCSIntro object) {
068:                // Set data
069:                fIntro = object;
070:                // Set data on help section
071:                fHelpSection.setData(object);
072:            }
073:
074:            /* (non-Javadoc)
075:             * @see org.eclipse.pde.internal.ui.editor.cheatsheet.CSAbstractDetails#selectionChanged(org.eclipse.ui.forms.IFormPart, org.eclipse.jface.viewers.ISelection)
076:             */
077:            public void selectionChanged(IFormPart part, ISelection selection) {
078:                // Get the first selected object
079:                Object object = getFirstSelectedObject(selection);
080:                // Ensure we have the right type
081:                if ((object == null)
082:                        || (object instanceof  ISimpleCSIntro) == false) {
083:                    return;
084:                }
085:                // Set data
086:                setData((ISimpleCSIntro) object);
087:                // Update the UI given the new data
088:                updateFields();
089:            }
090:
091:            /* (non-Javadoc)
092:             * @see org.eclipse.ui.forms.AbstractFormPart#initialize(org.eclipse.ui.forms.IManagedForm)
093:             */
094:            public void initialize(IManagedForm form) {
095:                super .initialize(form);
096:                // Unfortunately this has to be explicitly called for sub detail
097:                // sections through its main section parent; since, it never is 
098:                // registered directly.
099:                // Initialize managed form for help section
100:                fHelpSection.initialize(form);
101:            }
102:
103:            /* (non-Javadoc)
104:             * @see org.eclipse.pde.internal.ui.editor.cheatsheet.simple.SimpleCSAbstractDetails#createDetails(org.eclipse.swt.widgets.Composite)
105:             */
106:            public void createDetails(Composite parent) {
107:
108:                GridData data = null;
109:
110:                // Create main section
111:                fMainSection = getToolkit().createSection(parent,
112:                        Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
113:                fMainSection.clientVerticalSpacing = FormLayoutFactory.SECTION_HEADER_VERTICAL_SPACING;
114:                fMainSection.setText(PDEUIMessages.SimpleCSIntroDetails_2);
115:                fMainSection
116:                        .setDescription(PDEUIMessages.SimpleCSIntroDetails_3);
117:                fMainSection.setLayout(FormLayoutFactory.createClearGridLayout(
118:                        false, 1));
119:                data = new GridData(GridData.FILL_HORIZONTAL);
120:                fMainSection.setLayoutData(data);
121:
122:                // Align the master and details section headers (misalignment caused
123:                // by section toolbar icons)
124:                getPage().alignSectionHeaders(getMasterSection().getSection(),
125:                        fMainSection);
126:
127:                // Create container for main section
128:                Composite mainSectionClient = getToolkit().createComposite(
129:                        fMainSection);
130:                mainSectionClient.setLayout(FormLayoutFactory
131:                        .createSectionClientGridLayout(false, 2));
132:
133:                // description:  Content (Element)
134:                createUIFieldContent(mainSectionClient);
135:
136:                // Bind widgets
137:                getToolkit().paintBordersFor(mainSectionClient);
138:                fMainSection.setClient(mainSectionClient);
139:                markDetailsPart(fMainSection);
140:
141:                fHelpSection.createDetails(parent);
142:            }
143:
144:            /**
145:             * @param parent
146:             */
147:            private void createUIFieldContent(Composite parent) {
148:                GridData data = null;
149:                // Create the label
150:                Color foreground = getToolkit().getColors().getColor(
151:                        IFormColors.TITLE);
152:                Label label = getToolkit().createLabel(parent,
153:                        PDEUIMessages.SimpleCSDescriptionDetails_0, SWT.WRAP);
154:                label.setForeground(foreground);
155:                int style = GridData.VERTICAL_ALIGN_BEGINNING
156:                        | GridData.HORIZONTAL_ALIGN_END;
157:                data = new GridData(style);
158:                label.setLayoutData(data);
159:                // Create the source viewer
160:                fContentViewer = new PDESourceViewer(getPage());
161:                fContentViewer.createUI(parent, 90, 60);
162:                // Needed to align vertically with form entry field and allow space
163:                // for a possible field decoration			
164:                ((GridData) fContentViewer.getViewer().getTextWidget()
165:                        .getLayoutData()).horizontalIndent = FormLayoutFactory.CONTROL_HORIZONTAL_INDENT;
166:            }
167:
168:            /* (non-Javadoc)
169:             * @see org.eclipse.pde.internal.ui.editor.PDEDetails#doGlobalAction(java.lang.String)
170:             */
171:            public boolean doGlobalAction(String actionId) {
172:                return fContentViewer.doGlobalAction(actionId);
173:            }
174:
175:            /* (non-Javadoc)
176:             * @see org.eclipse.pde.internal.ui.editor.cheatsheet.simple.SimpleCSAbstractDetails#hookListeners()
177:             */
178:            public void hookListeners() {
179:                // description: Content (Element)
180:                createUIListenersContentViewer();
181:                fHelpSection.hookListeners();
182:            }
183:
184:            /**
185:             * 
186:             */
187:            private void createUIListenersContentViewer() {
188:                fContentViewer.createUIListeners();
189:                // Create document listener
190:                fContentViewer.getDocument().addDocumentListener(
191:                        new IDocumentListener() {
192:                            public void documentAboutToBeChanged(
193:                                    DocumentEvent event) {
194:                                // NO-OP
195:                            }
196:
197:                            public void documentChanged(DocumentEvent event) {
198:                                // Check whether to handle this event
199:                                if (fBlockEvents) {
200:                                    return;
201:                                }
202:                                // Ensure data object is defined
203:                                if (fIntro == null) {
204:                                    return;
205:                                }
206:                                // Get the text from the event
207:                                IDocument document = event.getDocument();
208:                                if (document == null) {
209:                                    return;
210:                                }
211:                                // Get the text from the event
212:                                String text = document.get().trim();
213:
214:                                if (fIntro.getDescription() != null) {
215:                                    fIntro.getDescription().setContent(text);
216:                                }
217:                            }
218:                        });
219:            }
220:
221:            /* (non-Javadoc)
222:             * @see org.eclipse.pde.internal.ui.editor.cheatsheet.simple.SimpleCSAbstractDetails#updateFields()
223:             */
224:            public void updateFields() {
225:                // Ensure data object is defined
226:                if (fIntro == null) {
227:                    return;
228:                }
229:
230:                fHelpSection.updateFields();
231:
232:                if (fIntro.getDescription() == null) {
233:                    return;
234:                }
235:
236:                // description:  Content (Element)
237:                fBlockEvents = true;
238:                fContentViewer.getDocument().set(
239:                        fIntro.getDescription().getContent());
240:                fBlockEvents = false;
241:
242:                boolean editable = isEditableElement();
243:                fContentViewer.getViewer().setEditable(editable);
244:            }
245:
246:            /* (non-Javadoc)
247:             * @see org.eclipse.ui.forms.AbstractFormPart#dispose()
248:             */
249:            public void dispose() {
250:                // Set the context menu to null to prevent the editor context menu
251:                // from being disposed along with the source viewer
252:                if (fContentViewer != null) {
253:                    fContentViewer.unsetMenu();
254:                    fContentViewer = null;
255:                }
256:
257:                super .dispose();
258:            }
259:
260:            /* (non-Javadoc)
261:             * @see org.eclipse.pde.internal.ui.editor.PDEDetails#canPaste(org.eclipse.swt.dnd.Clipboard)
262:             */
263:            public boolean canPaste(Clipboard clipboard) {
264:                return fContentViewer.canPaste();
265:            }
266:
267:            /* (non-Javadoc)
268:             * @see org.eclipse.ui.forms.AbstractFormPart#commit(boolean)
269:             */
270:            public void commit(boolean onSave) {
271:                super .commit(onSave);
272:                // Only required for form entries
273:                // No need to call for sub details, because they contain no form entries
274:            }
275:
276:        }
w__ww._j_a_v___a___2___s__.__c_o__m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.