Source Code Cross Referenced for CompCSEnclosingTextDetails.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » ui » editor » cheatsheet » comp » 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.comp.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.comp.details;
011:
012:        import org.eclipse.osgi.util.NLS;
013:        import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSConstants;
014:        import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSIntro;
015:        import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSOnCompletion;
016:        import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSTaskObject;
017:        import org.eclipse.pde.internal.core.util.PDETextHelper;
018:        import org.eclipse.pde.internal.ui.PDEPlugin;
019:        import org.eclipse.pde.internal.ui.PDEPluginImages;
020:        import org.eclipse.pde.internal.ui.PDEUIMessages;
021:        import org.eclipse.pde.internal.ui.editor.cheatsheet.CSAbstractSubDetails;
022:        import org.eclipse.pde.internal.ui.editor.cheatsheet.ICSMaster;
023:        import org.eclipse.pde.internal.ui.editor.cheatsheet.comp.CompCSInputContext;
024:        import org.eclipse.pde.internal.ui.parts.PDESourceViewer;
025:        import org.eclipse.swt.SWT;
026:        import org.eclipse.swt.custom.CTabFolder;
027:        import org.eclipse.swt.custom.CTabItem;
028:        import org.eclipse.swt.custom.StackLayout;
029:        import org.eclipse.swt.dnd.Clipboard;
030:        import org.eclipse.swt.events.SelectionAdapter;
031:        import org.eclipse.swt.events.SelectionEvent;
032:        import org.eclipse.swt.graphics.Color;
033:        import org.eclipse.swt.layout.GridData;
034:        import org.eclipse.swt.layout.GridLayout;
035:        import org.eclipse.swt.widgets.Composite;
036:        import org.eclipse.swt.widgets.Control;
037:        import org.eclipse.swt.widgets.Label;
038:        import org.eclipse.ui.forms.FormColors;
039:        import org.eclipse.ui.forms.IFormColors;
040:        import org.eclipse.ui.forms.widgets.ExpandableComposite;
041:        import org.eclipse.ui.forms.widgets.Section;
042:
043:        /**
044:         * CompCSEnclosingTextDetails
045:         *
046:         */
047:        public class CompCSEnclosingTextDetails extends CSAbstractSubDetails {
048:
049:            private ICompCSTaskObject fDataTaskObject;
050:
051:            private Section fEnclosingTextSection;
052:
053:            private PDESourceViewer fIntroductionViewer;
054:
055:            private PDESourceViewer fConclusionViewer;
056:
057:            private CTabFolder fTabFolder;
058:
059:            private final static int F_INTRODUCTION_TAB = 0;
060:
061:            private final static int F_CONCLUSION_TAB = 1;
062:
063:            private final static int F_NO_TAB = -1;
064:
065:            private Composite fNotebookComposite;
066:
067:            private StackLayout fNotebookLayout;
068:
069:            private Composite fIntroductionComposite;
070:
071:            private Composite fConclusionComposite;
072:
073:            private String fTaskObjectLabelName;
074:
075:            private CompCSIntroductionTextListener fIntroductionListener;
076:
077:            private CompCSConclusionTextListener fConclusionListener;
078:
079:            /**
080:             * 
081:             */
082:            public CompCSEnclosingTextDetails(int type, ICSMaster section) {
083:                super (section, CompCSInputContext.CONTEXT_ID);
084:
085:                fDataTaskObject = null;
086:
087:                fEnclosingTextSection = null;
088:
089:                fIntroductionViewer = null;
090:                fConclusionViewer = null;
091:
092:                fTabFolder = null;
093:                fNotebookComposite = null;
094:                fNotebookLayout = null;
095:
096:                fIntroductionComposite = null;
097:                fConclusionComposite = null;
098:
099:                fIntroductionListener = new CompCSIntroductionTextListener();
100:                fConclusionListener = new CompCSConclusionTextListener();
101:
102:                defineTaskObjectLabelName(type);
103:            }
104:
105:            /**
106:             * @param object
107:             */
108:            public void setData(ICompCSTaskObject object) {
109:                // Set data
110:                fDataTaskObject = object;
111:                // Set data on introduction text listener
112:                fIntroductionListener.setData(object);
113:                // Set data on conclusion text listener
114:                fConclusionListener.setData(object);
115:            }
116:
117:            /* (non-Javadoc)
118:             * @see org.eclipse.ui.forms.AbstractFormPart#commit(boolean)
119:             */
120:            public void commit(boolean onSave) {
121:                super .commit(onSave);
122:                // Only required for form entries
123:            }
124:
125:            /**
126:             * 
127:             */
128:            private void defineTaskObjectLabelName(int type) {
129:                if (type == ICompCSConstants.TYPE_TASK) {
130:                    fTaskObjectLabelName = PDEUIMessages.CompCSDependenciesDetails_task;
131:                } else {
132:                    fTaskObjectLabelName = PDEUIMessages.CompCSDependenciesDetails_group;
133:                }
134:            }
135:
136:            /* (non-Javadoc)
137:             * @see org.eclipse.pde.internal.ui.editor.cheatsheet.ICSDetails#createDetails(org.eclipse.swt.widgets.Composite)
138:             */
139:            public void createDetails(Composite parent) {
140:                // Create the main section
141:                int style = Section.DESCRIPTION | ExpandableComposite.TITLE_BAR;
142:                String description = NLS
143:                        .bind(
144:                                PDEUIMessages.CompCSEnclosingTextDetails_SectionDescription,
145:                                fTaskObjectLabelName);
146:                fEnclosingTextSection = getPage().createUISection(parent,
147:                        PDEUIMessages.CompCSEnclosingTextDetails_EnclosingText,
148:                        description, style);
149:                // Configure the section
150:                // The source viewers get clipped when the label above it wraps.
151:                // Prevent this by making the section fill vertically in addition to
152:                // horizontally
153:                GridData data = new GridData(GridData.FILL_BOTH);
154:                fEnclosingTextSection.setLayoutData(data);
155:                // Create the container for the main section
156:                Composite sectionClient = getPage().createUISectionContainer(
157:                        fEnclosingTextSection, 1);
158:                // Create the tab folder
159:                createUITabFolder(sectionClient);
160:                // Create the introduction folder tab
161:                createUIIntroductionTab();
162:                // Create the conclusion folder tab
163:                createUIConclusionTab();
164:                // Create the notebook composite
165:                createUINotebookComposite(sectionClient);
166:                // Create the introduction text
167:                createUIIntroductionViewer();
168:                // Create the conclusion text
169:                createUIConclusionViewer();
170:                // Bind widgets
171:                getToolkit().paintBordersFor(sectionClient);
172:                fEnclosingTextSection.setClient(sectionClient);
173:                // Mark as a details part to enable cut, copy, paste, etc.		
174:                markDetailsPart(fEnclosingTextSection);
175:            }
176:
177:            /**
178:             * @param parent
179:             */
180:            private void createUITabFolder(Composite parent) {
181:                fTabFolder = new CTabFolder(parent, SWT.FLAT | SWT.TOP);
182:                GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
183:                data.heightHint = 2;
184:                fTabFolder.setLayoutData(data);
185:
186:                getToolkit().adapt(fTabFolder, true, true);
187:
188:                FormColors colors = getToolkit().getColors();
189:                colors.initializeSectionToolBarColors();
190:                Color selectedColor = colors.getColor(IFormColors.TB_BG);
191:                fTabFolder.setSelectionBackground(new Color[] { selectedColor,
192:                        colors.getBackground() }, new int[] { 100 }, true);
193:            }
194:
195:            /**
196:             * 
197:             */
198:            private void createUIIntroductionTab() {
199:                CTabItem item = new CTabItem(fTabFolder, SWT.NULL);
200:                item
201:                        .setText(PDEUIMessages.CompCSEnclosingTextDetails_Introduction);
202:                item.setImage(PDEPlugin.getDefault().getLabelProvider().get(
203:                        PDEPluginImages.DESC_CSINTRO_OBJ));
204:            }
205:
206:            /**
207:             * 
208:             */
209:            private void createUIConclusionTab() {
210:                CTabItem item = new CTabItem(fTabFolder, SWT.NULL);
211:                item
212:                        .setText(PDEUIMessages.CompCSEnclosingTextDetails_Conclusion);
213:                item.setImage(PDEPlugin.getDefault().getLabelProvider().get(
214:                        PDEPluginImages.DESC_CSCONCLUSION_OBJ));
215:            }
216:
217:            /**
218:             * @param parent
219:             */
220:            private void createUINotebookComposite(Composite parent) {
221:                fNotebookComposite = getToolkit().createComposite(parent);
222:                GridData data = new GridData(GridData.FILL_HORIZONTAL);
223:                fNotebookComposite.setLayoutData(data);
224:                fNotebookLayout = new StackLayout();
225:                fNotebookComposite.setLayout(fNotebookLayout);
226:            }
227:
228:            /**
229:             * 
230:             */
231:            private void createUIIntroductionViewer() {
232:                // Create composite
233:                fIntroductionComposite = createUIContainer(fNotebookComposite,
234:                        1);
235:                // Create label
236:                String description = NLS
237:                        .bind(
238:                                PDEUIMessages.CompCSEnclosingTextDetails_IntroductionDescription,
239:                                fTaskObjectLabelName);
240:                final Label label = getToolkit().createLabel(
241:                        fIntroductionComposite, description, SWT.WRAP);
242:                GridData data = new GridData(GridData.FILL_HORIZONTAL);
243:                label.setLayoutData(data);
244:                // Create the source viewer
245:                fIntroductionViewer = new PDESourceViewer(getPage());
246:                fIntroductionViewer.createUI(fIntroductionComposite, 60, 60);
247:                // Note: Must paint border for parent composite; otherwise, the border
248:                // goes missing on the text widget when using the Windows XP Classic
249:                // theme
250:                getToolkit().paintBordersFor(fIntroductionComposite);
251:            }
252:
253:            /* (non-Javadoc)
254:             * @see org.eclipse.pde.internal.ui.editor.PDEDetails#doGlobalAction(java.lang.String)
255:             */
256:            public boolean doGlobalAction(String actionId) {
257:                // Determine which tab is selected
258:                int index = fTabFolder.getSelectionIndex();
259:                // Do the global action on the source viewer on that tab
260:                PDESourceViewer viewer = null;
261:
262:                if (index == F_INTRODUCTION_TAB) {
263:                    viewer = fIntroductionViewer;
264:                } else if (index == F_CONCLUSION_TAB) {
265:                    viewer = fConclusionViewer;
266:                }
267:
268:                return viewer.doGlobalAction(actionId);
269:            }
270:
271:            /**
272:             * 
273:             */
274:            private void createUIConclusionViewer() {
275:                // Create composite
276:                fConclusionComposite = createUIContainer(fNotebookComposite, 1);
277:                // Create label
278:                String description = NLS
279:                        .bind(
280:                                PDEUIMessages.CompCSEnclosingTextDetails_ConclusionDescription,
281:                                fTaskObjectLabelName);
282:                final Label label = getToolkit().createLabel(
283:                        fConclusionComposite, description, SWT.WRAP);
284:                GridData data = new GridData(GridData.FILL_HORIZONTAL);
285:                label.setLayoutData(data);
286:                // Create the source viewer
287:                fConclusionViewer = new PDESourceViewer(getPage());
288:                fConclusionViewer.createUI(fConclusionComposite, 60, 60);
289:                // Note: Must paint border for parent composite; otherwise, the border
290:                // goes missing on the text widget when using the Windows XP Classic
291:                // theme
292:                getToolkit().paintBordersFor(fConclusionComposite);
293:            }
294:
295:            /**
296:             * @param parent
297:             * @param columns
298:             * @return
299:             */
300:            private Composite createUIContainer(Composite parent, int columns) {
301:                Composite container = getToolkit().createComposite(parent);
302:                GridLayout layout = new GridLayout();
303:                layout.marginWidth = 2;
304:                layout.marginHeight = 2;
305:                layout.numColumns = columns;
306:                container.setLayout(layout);
307:                return container;
308:            }
309:
310:            /* (non-Javadoc)
311:             * @see org.eclipse.pde.internal.ui.editor.cheatsheet.ICSDetails#hookListeners()
312:             */
313:            public void hookListeners() {
314:                // Create the listeners for the introduction text
315:                createListenersIntroductionViewer();
316:                // Create the listeners for the conclusion text
317:                createListenersConclusionViewer();
318:                // Create the listeners for the tab folder
319:                createListenersTabFolder();
320:            }
321:
322:            /**
323:             * 
324:             */
325:            private void createListenersIntroductionViewer() {
326:                fIntroductionViewer.createUIListeners();
327:                // Create document listener
328:                fIntroductionViewer.getDocument().addDocumentListener(
329:                        fIntroductionListener);
330:            }
331:
332:            /**
333:             * 
334:             */
335:            private void createListenersConclusionViewer() {
336:                fConclusionViewer.createUIListeners();
337:                // Create document listener
338:                fConclusionViewer.getDocument().addDocumentListener(
339:                        fConclusionListener);
340:            }
341:
342:            /**
343:             * 
344:             */
345:            private void createListenersTabFolder() {
346:                fTabFolder.addSelectionListener(new SelectionAdapter() {
347:                    public void widgetSelected(SelectionEvent e) {
348:                        updateTabFolder();
349:                    }
350:                });
351:            }
352:
353:            /**
354:             * 
355:             */
356:            private void updateTabFolder() {
357:
358:                int index = fTabFolder.getSelectionIndex();
359:                Control oldControl = fNotebookLayout.topControl;
360:
361:                if (index == F_NO_TAB) {
362:                    // Select the introduction contents by default
363:                    fNotebookLayout.topControl = fIntroductionComposite;
364:                    // Select the introduction tab by default to match
365:                    // Does not trigger selection adapter (only user UI selections do)
366:                    fTabFolder.setSelection(F_INTRODUCTION_TAB);
367:                } else if (index == F_INTRODUCTION_TAB) {
368:                    fNotebookLayout.topControl = fIntroductionComposite;
369:                } else if (index == F_CONCLUSION_TAB) {
370:                    fNotebookLayout.topControl = fConclusionComposite;
371:                }
372:
373:                if (oldControl != fNotebookLayout.topControl) {
374:                    fNotebookComposite.layout();
375:                }
376:
377:            }
378:
379:            /* (non-Javadoc)
380:             * @see org.eclipse.pde.internal.ui.editor.cheatsheet.ICSDetails#updateFields()
381:             */
382:            public void updateFields() {
383:                // Ensure data object is defined
384:                if (fDataTaskObject == null) {
385:                    return;
386:                }
387:                boolean editable = isEditableElement();
388:                // Update tab folder
389:                updateTabFolder();
390:                // Update introduction text
391:                updateIntroductionViewer(editable);
392:                // Update conclusion text
393:                updateConclusionViewer(editable);
394:            }
395:
396:            /**
397:             * @param editable
398:             */
399:            private void updateIntroductionViewer(boolean editable) {
400:                ICompCSIntro intro = fDataTaskObject.getFieldIntro();
401:
402:                // Block listener from handling this update
403:                fIntroductionListener.setBlockEvents(true);
404:                if ((intro != null)
405:                        && PDETextHelper.isDefined(intro.getFieldContent())) {
406:                    fIntroductionViewer.getDocument().set(
407:                            intro.getFieldContent());
408:                } else {
409:                    fIntroductionViewer.getDocument().set(""); //$NON-NLS-1$
410:                }
411:                // Unblock for user updates
412:                fIntroductionListener.setBlockEvents(false);
413:
414:                fIntroductionViewer.getViewer().setEditable(editable);
415:            }
416:
417:            /**
418:             * @param editable
419:             */
420:            private void updateConclusionViewer(boolean editable) {
421:                ICompCSOnCompletion conclusion = fDataTaskObject
422:                        .getFieldOnCompletion();
423:
424:                // Block listener from handling this update
425:                fConclusionListener.setBlockEvents(true);
426:                if ((conclusion != null)
427:                        && PDETextHelper
428:                                .isDefined(conclusion.getFieldContent())) {
429:                    fConclusionViewer.getDocument().set(
430:                            conclusion.getFieldContent());
431:                } else {
432:                    fConclusionViewer.getDocument().set(""); //$NON-NLS-1$
433:                }
434:                // Unblock for user updates
435:                fConclusionListener.setBlockEvents(false);
436:
437:                fConclusionViewer.getViewer().setEditable(editable);
438:            }
439:
440:            /* (non-Javadoc)
441:             * @see org.eclipse.ui.forms.AbstractFormPart#dispose()
442:             */
443:            public void dispose() {
444:                // Set the context menu to null to prevent the editor context menu
445:                // from being disposed along with the source viewer
446:                if (fIntroductionViewer != null) {
447:                    fIntroductionViewer.unsetMenu();
448:                    fIntroductionViewer = null;
449:                }
450:                if (fConclusionViewer != null) {
451:                    fConclusionViewer.unsetMenu();
452:                    fConclusionViewer = null;
453:                }
454:                super .dispose();
455:            }
456:
457:            /* (non-Javadoc)
458:             * @see org.eclipse.pde.internal.ui.editor.PDEDetails#canPaste(org.eclipse.swt.dnd.Clipboard)
459:             */
460:            public boolean canPaste(Clipboard clipboard) {
461:                // Determine which tab is selected
462:                int index = fTabFolder.getSelectionIndex();
463:                // Check if the source viewer on that tab can paste
464:                PDESourceViewer viewer = null;
465:
466:                if (index == F_INTRODUCTION_TAB) {
467:                    viewer = fIntroductionViewer;
468:                } else if (index == F_CONCLUSION_TAB) {
469:                    viewer = fConclusionViewer;
470:                }
471:
472:                return viewer.canPaste();
473:            }
474:        }
w_w__w__._j__a___v___a__2s___.co__m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.