Source Code Cross Referenced for SimpleCSHelpDetails.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.core.resources.IFile;
013:        import org.eclipse.core.resources.IWorkspaceRoot;
014:        import org.eclipse.core.runtime.Path;
015:        import org.eclipse.jface.window.Window;
016:        import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSHelpObject;
017:        import org.eclipse.pde.internal.core.util.PDETextHelper;
018:        import org.eclipse.pde.internal.ui.PDEPlugin;
019:        import org.eclipse.pde.internal.ui.PDEUIMessages;
020:        import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
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.simple.SimpleCSInputContext;
024:        import org.eclipse.pde.internal.ui.parts.ComboPart;
025:        import org.eclipse.pde.internal.ui.util.FileExtensionsFilter;
026:        import org.eclipse.swt.SWT;
027:        import org.eclipse.swt.events.ModifyEvent;
028:        import org.eclipse.swt.events.ModifyListener;
029:        import org.eclipse.swt.events.SelectionAdapter;
030:        import org.eclipse.swt.events.SelectionEvent;
031:        import org.eclipse.swt.graphics.Color;
032:        import org.eclipse.swt.layout.GridData;
033:        import org.eclipse.swt.widgets.Button;
034:        import org.eclipse.swt.widgets.Composite;
035:        import org.eclipse.swt.widgets.Label;
036:        import org.eclipse.swt.widgets.Text;
037:        import org.eclipse.ui.dialogs.ElementTreeSelectionDialog;
038:        import org.eclipse.ui.forms.IFormColors;
039:        import org.eclipse.ui.forms.widgets.ExpandableComposite;
040:        import org.eclipse.ui.forms.widgets.FormToolkit;
041:        import org.eclipse.ui.forms.widgets.Section;
042:        import org.eclipse.ui.model.WorkbenchContentProvider;
043:        import org.eclipse.ui.model.WorkbenchLabelProvider;
044:
045:        /**
046:         * SimpleCSHelpDetailsSection
047:         *
048:         */
049:        public class SimpleCSHelpDetails extends CSAbstractSubDetails {
050:
051:            private Text fHelpText;
052:
053:            private ComboPart fHelpCombo;
054:
055:            private Label fHelpLabel;
056:
057:            private Button fHelpBrowse;
058:
059:            private ISimpleCSHelpObject fHelpObject;
060:
061:            private Section fHelpSection;
062:
063:            private boolean fBlockListeners;
064:
065:            private static final String F_NO_HELP = PDEUIMessages.SimpleCSCommandDetails_6;
066:
067:            private static final String F_HELP_CONTEXT_ID = PDEUIMessages.SimpleCSHelpDetails_HelpContextID;
068:
069:            private static final String F_HELP_DOCUMENT_LINK = PDEUIMessages.SimpleCSHelpDetails_HelpDocumentLink;
070:
071:            /**
072:             * @param section
073:             */
074:            public SimpleCSHelpDetails(ICSMaster section) {
075:                super (section, SimpleCSInputContext.CONTEXT_ID);
076:                fHelpObject = null;
077:                fBlockListeners = false;
078:
079:                fHelpText = null;
080:                fHelpCombo = null;
081:                fHelpLabel = null;
082:                fHelpBrowse = null;
083:
084:                fHelpSection = null;
085:            }
086:
087:            /* (non-Javadoc)
088:             * @see org.eclipse.pde.internal.ui.editor.cheatsheet.CSAbstractDetails#setData(java.lang.Object)
089:             */
090:            public void setData(ISimpleCSHelpObject object) {
091:                // Set data
092:                fHelpObject = object;
093:            }
094:
095:            /* (non-Javadoc)
096:             * @see org.eclipse.pde.internal.ui.editor.cheatsheet.simple.details.ISimpleCSDetails#createDetails(org.eclipse.swt.widgets.Composite)
097:             */
098:            public void createDetails(Composite parent) {
099:
100:                int columnSpan = 3;
101:                FormToolkit toolkit = getToolkit();
102:
103:                GridData data = null;
104:                Label label = null;
105:                Color foreground = toolkit.getColors().getColor(
106:                        IFormColors.TITLE);
107:
108:                // Create help section
109:                fHelpSection = toolkit.createSection(parent,
110:                        Section.DESCRIPTION | ExpandableComposite.TITLE_BAR
111:                                | ExpandableComposite.TWISTIE);
112:                fHelpSection.clientVerticalSpacing = FormLayoutFactory.SECTION_HEADER_VERTICAL_SPACING;
113:                fHelpSection.setText(PDEUIMessages.SimpleCSSharedUIFactory_1);
114:                fHelpSection
115:                        .setDescription(PDEUIMessages.SimpleCSSharedUIFactory_2);
116:                fHelpSection.setLayout(FormLayoutFactory.createClearGridLayout(
117:                        false, 1));
118:                data = new GridData(GridData.FILL_HORIZONTAL);
119:                fHelpSection.setLayoutData(data);
120:
121:                // Create container for help section		
122:                Composite helpSectionClient = toolkit
123:                        .createComposite(fHelpSection);
124:                helpSectionClient.setLayout(FormLayoutFactory
125:                        .createSectionClientGridLayout(false, columnSpan));
126:
127:                // Attribute: href		
128:                // Attribute: contextId
129:                label = toolkit.createLabel(helpSectionClient,
130:                        PDEUIMessages.SimpleCSHelpDetails_Type, SWT.WRAP);
131:                label.setForeground(foreground);
132:
133:                // Attribute: href		
134:                // Attribute: contextId
135:                fHelpCombo = new ComboPart();
136:                fHelpCombo.createControl(helpSectionClient, toolkit,
137:                        SWT.READ_ONLY);
138:                GridData comboData = new GridData(GridData.FILL_HORIZONTAL);
139:                comboData.horizontalSpan = columnSpan - 1;
140:                fHelpCombo.getControl().setLayoutData(comboData);
141:                fHelpCombo.add(F_NO_HELP);
142:                fHelpCombo.add(F_HELP_CONTEXT_ID);
143:                fHelpCombo.add(F_HELP_DOCUMENT_LINK);
144:                fHelpCombo.setText(F_NO_HELP);
145:
146:                // Attribute: href		
147:                // Attribute: contextId
148:                fHelpLabel = toolkit.createLabel(helpSectionClient,
149:                        PDEUIMessages.SimpleCSHelpDetails_Value, SWT.WRAP);
150:                fHelpLabel.setForeground(foreground);
151:
152:                // Attribute: href		
153:                // Attribute: contextId
154:                fHelpText = toolkit.createText(helpSectionClient, null);
155:                data = new GridData(GridData.FILL_HORIZONTAL);
156:                fHelpText.setLayoutData(data);
157:                // Browse Button
158:                fHelpBrowse = toolkit.createButton(helpSectionClient,
159:                        PDEUIMessages.GeneralInfoSection_browse, SWT.PUSH);
160:
161:                // Bind widgets
162:                toolkit.paintBordersFor(helpSectionClient);
163:                fHelpSection.setClient(helpSectionClient);
164:                // Mark as a details part to enable cut, copy, paste, etc.
165:                markDetailsPart(fHelpSection);
166:            }
167:
168:            /* (non-Javadoc)
169:             * @see org.eclipse.pde.internal.ui.editor.cheatsheet.simple.details.ISimpleCSDetails#hookListeners()
170:             */
171:            public void hookListeners() {
172:
173:                // Attribute: href		
174:                // Attribute: contextId		
175:                fHelpCombo.addSelectionListener(new SelectionAdapter() {
176:                    public void widgetSelected(SelectionEvent e) {
177:                        // Ensure data object is defined
178:                        if (fHelpObject == null) {
179:                            return;
180:                        }
181:                        String selection = fHelpCombo.getSelection();
182:                        if (selection.equals(F_NO_HELP) == false) {
183:                            // Help was selected
184:                            if (selection.equals(F_HELP_CONTEXT_ID)) {
185:                                // Help context ID was selected, clear the help 
186:                                // document link value
187:                                fHelpObject.setHref(null);
188:                                fHelpBrowse.setEnabled(false);
189:                            } else {
190:                                // Help document link was selected, clear the help 
191:                                // context ID value
192:                                fHelpObject.setContextId(null);
193:                                fHelpBrowse.setEnabled(true);
194:                            }
195:                            // Make the label and text field visible
196:                            fHelpLabel.setVisible(true);
197:                            fHelpText.setVisible(true);
198:                            fHelpBrowse.setVisible(true);
199:                            // Set the focus on the text field
200:                            fHelpText.setFocus();
201:                            // Clear the previous contents of the text field
202:                            // (Will cause field to become dirty)
203:                            fHelpText.setText(""); //$NON-NLS-1$
204:                            fHelpText.setToolTipText(""); //$NON-NLS-1$
205:                        } else {
206:                            // No help was selected
207:                            // Make the label and text field invisible
208:                            fHelpLabel.setVisible(false);
209:                            fHelpText.setVisible(false);
210:                            fHelpBrowse.setVisible(false);
211:                            // Clear values for help in model
212:                            fHelpObject.setContextId(null);
213:                            fHelpObject.setHref(null);
214:                        }
215:                    }
216:                });
217:                // Attribute: href		
218:                // Attribute: contextId		
219:                fHelpText.addModifyListener(new ModifyListener() {
220:                    public void modifyText(ModifyEvent e) {
221:                        // Block UI updates
222:                        if (fBlockListeners) {
223:                            return;
224:                        }
225:                        // Ensure data object is defined
226:                        if (fHelpObject == null) {
227:                            return;
228:                        }
229:                        String selection = fHelpCombo.getSelection();
230:                        if (selection.equals(F_HELP_CONTEXT_ID)) {
231:                            // Help context ID was selected, save the field contents
232:                            // as such
233:                            fHelpObject.setContextId(fHelpText.getText());
234:                        } else {
235:                            // Help document link was selected, save the field contents
236:                            // as such
237:                            fHelpObject.setHref(fHelpText.getText());
238:                        }
239:                        // Update tooltip
240:                        fHelpText.setToolTipText(fHelpText.getText());
241:                    }
242:                });
243:
244:                fHelpBrowse.addSelectionListener(new SelectionAdapter() {
245:                    public void widgetSelected(SelectionEvent e) {
246:                        handleButtonSelectedEventBrowse(e);
247:                    }
248:                });
249:            }
250:
251:            /**
252:             * @param event
253:             */
254:            private void handleButtonSelectedEventBrowse(SelectionEvent event) {
255:                // Create the dialog
256:                ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
257:                        getManagedForm().getForm().getShell(),
258:                        new WorkbenchLabelProvider(),
259:                        new WorkbenchContentProvider());
260:                // Disable multiple selection
261:                dialog.setAllowMultiple(false);
262:                // Title
263:                dialog
264:                        .setTitle(PDEUIMessages.SimpleCSHelpDetails_helpDocumentSelection);
265:                // Message
266:                dialog
267:                        .setMessage(PDEUIMessages.SimpleCSHelpDetails_selectHelpDocument);
268:                // Add valid file extensions to filter by
269:                FileExtensionsFilter filter = new FileExtensionsFilter();
270:                filter.addFileExtension("htm"); //$NON-NLS-1$
271:                filter.addFileExtension("html"); //$NON-NLS-1$
272:                filter.addFileExtension("shtml"); //$NON-NLS-1$
273:                filter.addFileExtension("xhtml"); //$NON-NLS-1$
274:                dialog.addFilter(filter);
275:                // Set the input as all workspace projects
276:                IWorkspaceRoot root = PDEPlugin.getWorkspace().getRoot();
277:                dialog.setInput(root);
278:                // Set the initial selection using the existing path (if any)
279:                Path path = new Path(fHelpText.getText());
280:                // Path must be non-empty, absolute and have at least two segments
281:                if ((path.isEmpty() == false) && path.isAbsolute()
282:                        && (path.segmentCount() > 1)) {
283:                    IFile helpDocumentFile = root.getFile(path);
284:                    dialog.setInitialSelection(helpDocumentFile);
285:                }
286:                // Open the dialog
287:                if (dialog.open() == Window.OK) {
288:                    // Get the selection
289:                    Object result = dialog.getFirstResult();
290:                    // Ensure a file was selected
291:                    if ((result instanceof  IFile) == false) {
292:                        return;
293:                    }
294:                    IFile file = (IFile) result;
295:                    // Ensure there was a selection
296:                    if (file == null) {
297:                        return;
298:                    }
299:                    // Get the absolute path
300:                    String absolutePath = file.getFullPath().toPortableString();
301:                    // Update the field
302:                    fHelpText.setText(absolutePath);
303:                }
304:            }
305:
306:            /* (non-Javadoc)
307:             * @see org.eclipse.pde.internal.ui.editor.cheatsheet.simple.details.ISimpleCSDetails#updateFields()
308:             */
309:            public void updateFields() {
310:                // Ensure data object is defined
311:                if (fHelpObject == null) {
312:                    return;
313:                }
314:
315:                boolean editable = isEditableElement();
316:                boolean expanded = false;
317:
318:                // Block model updates
319:                fBlockListeners = true;
320:                // Attribute: contextId
321:                // Attribute: href		
322:                if (PDETextHelper.isDefined(fHelpObject.getContextId())) {
323:                    fHelpText.setText(fHelpObject.getContextId());
324:                    fHelpText.setToolTipText(fHelpObject.getContextId());
325:                    fHelpCombo.setText(F_HELP_CONTEXT_ID);
326:                    expanded = true;
327:                } else if (PDETextHelper.isDefined(fHelpObject.getHref())) {
328:                    fHelpText.setText(fHelpObject.getHref());
329:                    fHelpText.setToolTipText(fHelpObject.getHref());
330:                    fHelpCombo.setText(F_HELP_DOCUMENT_LINK);
331:                    expanded = true;
332:                } else {
333:                    fHelpCombo.setText(F_NO_HELP);
334:                }
335:                // Unblock model updates
336:                fBlockListeners = false;
337:
338:                fHelpSection.setExpanded(expanded);
339:                fHelpText.setEnabled(editable);
340:                fHelpText.setVisible(expanded);
341:                fHelpLabel.setVisible(expanded);
342:                fHelpBrowse.setVisible(expanded);
343:                fHelpCombo.setEnabled(editable);
344:            }
345:
346:            /* (non-Javadoc)
347:             * @see org.eclipse.ui.forms.AbstractFormPart#commit(boolean)
348:             */
349:            public void commit(boolean onSave) {
350:                super .commit(onSave);
351:                // NO-OP
352:                // No form entries
353:            }
354:
355:        }
w___ww_.__ja__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.