Source Code Cross Referenced for SimpleCSDefinitionPage.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » ui » editor » cheatsheet » simple » 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 
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;
011:
012:        import org.eclipse.jface.text.source.ISourceViewer;
013:        import org.eclipse.jface.viewers.ISelection;
014:        import org.eclipse.pde.core.IModelChangedEvent;
015:        import org.eclipse.pde.core.IModelChangedListener;
016:        import org.eclipse.pde.internal.core.AbstractModel;
017:        import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSConstants;
018:        import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSModel;
019:        import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSObject;
020:        import org.eclipse.pde.internal.core.text.IDocumentRange;
021:        import org.eclipse.pde.internal.core.util.PDETextHelper;
022:        import org.eclipse.pde.internal.ui.IHelpContextIds;
023:        import org.eclipse.pde.internal.ui.IPDEUIConstants;
024:        import org.eclipse.pde.internal.ui.PDEPlugin;
025:        import org.eclipse.pde.internal.ui.PDEPluginImages;
026:        import org.eclipse.pde.internal.ui.PDEUIMessages;
027:        import org.eclipse.pde.internal.ui.editor.PDEFormPage;
028:        import org.eclipse.pde.internal.ui.editor.PDEMasterDetailsBlock;
029:        import org.eclipse.pde.internal.ui.editor.PDESourcePage;
030:        import org.eclipse.swt.custom.StyledText;
031:        import org.eclipse.ui.PlatformUI;
032:        import org.eclipse.ui.forms.IManagedForm;
033:        import org.eclipse.ui.forms.editor.FormEditor;
034:        import org.eclipse.ui.forms.editor.IFormPage;
035:        import org.eclipse.ui.forms.widgets.ScrolledForm;
036:
037:        /**
038:         * SimpleCSPage
039:         *
040:         */
041:        public class SimpleCSDefinitionPage extends PDEFormPage implements 
042:                IModelChangedListener {
043:
044:            public static final String PAGE_ID = "simpleCSPage"; //$NON-NLS-1$
045:
046:            private SimpleCSBlock fBlock;
047:
048:            /**
049:             * @param editor
050:             */
051:            public SimpleCSDefinitionPage(FormEditor editor) {
052:                super (editor, PAGE_ID, PDEUIMessages.SimpleCSPage_0);
053:                fBlock = new SimpleCSBlock(this );
054:            }
055:
056:            /* (non-Javadoc)
057:             * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#getHelpResource()
058:             */
059:            protected String getHelpResource() {
060:                return IPDEUIConstants.PLUGIN_DOC_ROOT
061:                        + "guide/tools/editors/simple_cs_editor/editor.htm"; //$NON-NLS-1$
062:            }
063:
064:            /* (non-Javadoc)
065:             * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
066:             */
067:            protected void createFormContent(IManagedForm managedForm) {
068:                // Bug: Two veritical scrollbars appear when resizing the editor
069:                // vertically
070:                // Note: Scrolled form #1 created here
071:                ScrolledForm form = managedForm.getForm();
072:                // Set page title
073:                ISimpleCSModel model = (ISimpleCSModel) getModel();
074:                // Ensure the model was loaded properly
075:                if ((model == null) || (model.isLoaded() == false)) {
076:                    Exception e = null;
077:                    if (model instanceof  AbstractModel) {
078:                        e = ((AbstractModel) model).getException();
079:                    }
080:                    // Create a formatted error page
081:                    createFormErrorContent(
082:                            managedForm,
083:                            PDEUIMessages.SimpleCSPage_msgCheatSheetLoadFailure,
084:                            PDEUIMessages.SimpleCSPage_msgCheatSheetParsingFailure,
085:                            e);
086:                    return;
087:                }
088:                // Create the rest of the actions in the form title area
089:                super .createFormContent(managedForm);
090:                // Form image
091:                form.setImage(PDEPlugin.getDefault().getLabelProvider().get(
092:                        PDEPluginImages.DESC_CHEATSHEET_OBJ));
093:                // Form title
094:                String title = PDETextHelper.translateReadText(model
095:                        .getSimpleCS().getTitle());
096:                if (title.length() > 0) {
097:                    form.setText(title);
098:                } else {
099:                    form.setText(PDEUIMessages.SimpleCSPage_0);
100:                }
101:                // Create the masters details block
102:                // Note: Scrolled form #2 created here
103:                fBlock.createContent(managedForm);
104:                // Force the selection in the masters tree section to load the 
105:                // proper details section
106:                fBlock.getMastersSection().fireSelection();
107:                // Register this page to be informed of model change events
108:                model.addModelChangedListener(this );
109:                // Set context-sensitive help
110:                PlatformUI.getWorkbench().getHelpSystem().setHelp(
111:                        form.getBody(), IHelpContextIds.SIMPLE_CS_EDITOR);
112:            }
113:
114:            /* (non-Javadoc)
115:             * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#dispose()
116:             */
117:            public void dispose() {
118:
119:                ISimpleCSModel simpleCSModel = (ISimpleCSModel) getModel();
120:                if (simpleCSModel != null) {
121:                    simpleCSModel.removeModelChangedListener(this );
122:                }
123:                super .dispose();
124:            }
125:
126:            /* (non-Javadoc)
127:             * @see org.eclipse.pde.core.IModelChangedListener#modelChanged(org.eclipse.pde.core.IModelChangedEvent)
128:             */
129:            public void modelChanged(IModelChangedEvent event) {
130:
131:                if (event.getChangeType() == IModelChangedEvent.CHANGE) {
132:                    Object[] objects = event.getChangedObjects();
133:                    // Ensure right type
134:                    if ((objects[0] instanceof  ISimpleCSObject) == false) {
135:                        return;
136:                    }
137:                    ISimpleCSObject object = (ISimpleCSObject) objects[0];
138:                    if (object == null) {
139:                        // Ignore
140:                    } else if (object.getType() == ISimpleCSConstants.TYPE_CHEAT_SHEET) {
141:                        String changeProperty = event.getChangedProperty();
142:                        if ((changeProperty != null)
143:                                && changeProperty
144:                                        .equals(ISimpleCSConstants.ATTRIBUTE_TITLE)) {
145:                            // Has to be a String if the property is a title
146:                            // Update the form page title
147:                            getManagedForm().getForm().setText(
148:                                    PDETextHelper
149:                                            .translateReadText((String) event
150:                                                    .getNewValue()));
151:                        }
152:                    }
153:                } else if (event.getChangeType() == IModelChangedEvent.WORLD_CHANGED) {
154:                    handleModelEventWorldChanged(event);
155:                }
156:                // Inform the block
157:                fBlock.modelChanged(event);
158:            }
159:
160:            /**
161:             * @param event
162:             */
163:            private void handleModelEventWorldChanged(IModelChangedEvent event) {
164:                // Page will be updated on refresh
165:                markStale();
166:            }
167:
168:            /**
169:             * @return
170:             */
171:            public ISelection getSelection() {
172:                return fBlock.getSelection();
173:            }
174:
175:            /**
176:             * @return
177:             */
178:            public PDEMasterDetailsBlock getBlock() {
179:                return fBlock;
180:            }
181:
182:            /* (non-Javadoc)
183:             * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#refresh()
184:             */
185:            protected void refresh() {
186:                super .refresh();
187:                ScrolledForm form = getManagedForm().getForm();
188:                ISimpleCSModel model = (ISimpleCSModel) getModel();
189:                String oldTitle = form.getText();
190:                String newTitle = model.getSimpleCS().getTitle();
191:                if (newTitle.equals(oldTitle) == false) {
192:                    // Update form page title
193:                    form.setText(PDETextHelper.translateReadText(newTitle));
194:                }
195:            }
196:
197:            /* (non-Javadoc)
198:             * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#setActive(boolean)
199:             */
200:            public void setActive(boolean active) {
201:                super .setActive(active);
202:
203:                if (active == false) {
204:                    // Switching away from this page
205:                    return;
206:                }
207:                // Switching into this page
208:                // Get source page
209:                IFormPage page = getPDEEditor().findPage(
210:                        SimpleCSInputContext.CONTEXT_ID);
211:                // Ensure we got the source page
212:                if ((page instanceof  PDESourcePage) == false) {
213:                    return;
214:                }
215:                PDESourcePage sourcePage = (PDESourcePage) page;
216:                // Get the source viewer
217:                ISourceViewer viewer = sourcePage.getViewer();
218:                // Ensure the viewer is defined
219:                if (viewer == null) {
220:                    return;
221:                }
222:                // Get the styled text
223:                StyledText text = viewer.getTextWidget();
224:                // Ensure the styled text is defined
225:                if (text == null) {
226:                    return;
227:                }
228:                // Get the cursor offset
229:                int offset = text.getCaretOffset();
230:                // Ensure the offset is defined
231:                if (offset < 0) {
232:                    return;
233:                }
234:                // Get the range the offset is on
235:                IDocumentRange range = sourcePage.getRangeElement(offset, true);
236:                // Adapt the range to a node representable in the master tree viewer
237:                range = sourcePage.adaptRange(range);
238:                // Ensure the range is defined
239:                if (range == null) {
240:                    return;
241:                }
242:                // Select the node in the master tree viewer if defined
243:                fBlock.getMastersSection().setFormInput(range);
244:            }
245:
246:        }
ww_w_.___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.