Source Code Cross Referenced for StatusTextEditor.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » texteditor » 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 workbench » org.eclipse.ui.texteditor 
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.texteditor;
011:
012:        import org.eclipse.swt.SWT;
013:        import org.eclipse.swt.custom.StackLayout;
014:        import org.eclipse.swt.layout.FillLayout;
015:        import org.eclipse.swt.widgets.Composite;
016:        import org.eclipse.swt.widgets.Control;
017:
018:        import org.eclipse.core.runtime.CoreException;
019:        import org.eclipse.core.runtime.IStatus;
020:
021:        import org.eclipse.ui.IEditorInput;
022:
023:        /**
024:         * Capable of handling input elements that have an associated status with them.
025:         * @since 2.0
026:         */
027:        public class StatusTextEditor extends AbstractTextEditor {
028:
029:            /** The root composite of this editor */
030:            private Composite fParent;
031:            /** The layout used to manage the regular and the status page */
032:            private StackLayout fStackLayout;
033:            /** The root composite for the regular page */
034:            private Composite fDefaultComposite;
035:            /** The status page */
036:            private Control fStatusControl;
037:
038:            /*
039:             * @see IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
040:             */
041:            public void createPartControl(Composite parent) {
042:
043:                fParent = new Composite(parent, SWT.NONE);
044:                fStackLayout = new StackLayout();
045:                fParent.setLayout(fStackLayout);
046:
047:                fDefaultComposite = new Composite(fParent, SWT.NONE);
048:                fDefaultComposite.setLayout(new FillLayout());
049:                super .createPartControl(fDefaultComposite);
050:
051:                updatePartControl(getEditorInput());
052:            }
053:
054:            /**
055:             * Checks if the status of the given input is OK. If not the
056:             * status control is shown rather than the default control.
057:             *
058:             * @param input the input whose status is checked
059:             */
060:            public void updatePartControl(IEditorInput input) {
061:
062:                if (fStatusControl != null) {
063:                    fStatusControl.dispose();
064:                    fStatusControl = null;
065:                }
066:
067:                Control front = null;
068:                if (fParent != null && input != null) {
069:                    if (getDocumentProvider() instanceof  IDocumentProviderExtension) {
070:                        IDocumentProviderExtension extension = (IDocumentProviderExtension) getDocumentProvider();
071:                        IStatus status = extension.getStatus(input);
072:                        if (!isErrorStatus(status)) {
073:                            front = fDefaultComposite;
074:                        } else {
075:                            fStatusControl = createStatusControl(fParent,
076:                                    status);
077:                            front = fStatusControl;
078:                        }
079:                    }
080:                }
081:
082:                if (fStackLayout.topControl != front) {
083:                    fStackLayout.topControl = front;
084:                    fParent.layout();
085:                    updateStatusFields();
086:                }
087:            }
088:
089:            /*
090:             * @see org.eclipse.ui.texteditor.AbstractTextEditor#validateEditorInputState()
091:             * @since 3.3
092:             */
093:            public boolean validateEditorInputState() {
094:                if (!super .validateEditorInputState())
095:                    return false;
096:
097:                if (getDocumentProvider() instanceof  IDocumentProviderExtension) {
098:                    IDocumentProviderExtension extension = (IDocumentProviderExtension) getDocumentProvider();
099:                    IStatus status = extension.getStatus(getEditorInput());
100:                    return !isErrorStatus(status)
101:                            && status.getSeverity() != IStatus.CANCEL;
102:                }
103:
104:                return true;
105:            }
106:
107:            /**
108:             * Returns whether the given status indicates an error. Subclasses may override.
109:             *
110:             * @param status the status to be checked
111:             * @return <code>true</code> if the status indicates an error, <code>false</code> otherwise\
112:             * @since 3.0
113:             */
114:            protected boolean isErrorStatus(IStatus status) {
115:                return status != null && status.getSeverity() == IStatus.ERROR;
116:            }
117:
118:            /**
119:             * Creates the status control for the given status.
120:             * May be overridden by subclasses.
121:             *
122:             * @param parent the parent control
123:             * @param status the status
124:             * @return the new status control
125:             */
126:            protected Control createStatusControl(Composite parent,
127:                    IStatus status) {
128:                InfoForm infoForm = new InfoForm(parent);
129:                infoForm.setHeaderText(getStatusHeader(status));
130:                infoForm.setBannerText(getStatusBanner(status));
131:                infoForm.setInfo(getStatusMessage(status));
132:                return infoForm.getControl();
133:            }
134:
135:            /**
136:             * Returns a header for the given status
137:             *
138:             * @param status the status whose message is returned
139:             * @return a header for the given status
140:             */
141:            protected String getStatusHeader(IStatus status) {
142:                return ""; //$NON-NLS-1$
143:            }
144:
145:            /**
146:             * Returns a banner for the given status.
147:             *
148:             * @param status the status whose message is returned
149:             * @return a banner for the given status
150:             */
151:            protected String getStatusBanner(IStatus status) {
152:                return ""; //$NON-NLS-1$
153:            }
154:
155:            /**
156:             * Returns a message for the given status.
157:             *
158:             * @param status the status whose message is returned
159:             * @return a message for the given status
160:             */
161:            protected String getStatusMessage(IStatus status) {
162:                return status.getMessage();
163:            }
164:
165:            /*
166:             * @see AbstractTextEditor#updateStatusField(String)
167:             */
168:            protected void updateStatusField(String category) {
169:                IDocumentProvider provider = getDocumentProvider();
170:                if (provider instanceof  IDocumentProviderExtension) {
171:                    IDocumentProviderExtension extension = (IDocumentProviderExtension) provider;
172:                    IStatus status = extension.getStatus(getEditorInput());
173:                    if (isErrorStatus(status)) {
174:                        IStatusField field = getStatusField(category);
175:                        if (field != null) {
176:                            field.setText(fErrorLabel);
177:                            return;
178:                        }
179:                    }
180:                }
181:
182:                super .updateStatusField(category);
183:            }
184:
185:            /*
186:             * @see AbstractTextEditor#doSetInput(IEditorInput)
187:             */
188:            protected void doSetInput(IEditorInput input) throws CoreException {
189:                super .doSetInput(input);
190:                if (fParent != null && !fParent.isDisposed())
191:                    updatePartControl(getEditorInput());
192:            }
193:
194:            /*
195:             * @see ITextEditor#doRevertToSaved()
196:             */
197:            public void doRevertToSaved() {
198:                // http://dev.eclipse.org/bugs/show_bug.cgi?id=19014
199:                super .doRevertToSaved();
200:                if (fParent != null && !fParent.isDisposed())
201:                    updatePartControl(getEditorInput());
202:            }
203:
204:            /*
205:             * @see AbstractTextEditor#sanityCheckState(IEditorInput)
206:             */
207:            protected void sanityCheckState(IEditorInput input) {
208:                // http://dev.eclipse.org/bugs/show_bug.cgi?id=19014
209:                super .sanityCheckState(input);
210:                if (fParent != null && !fParent.isDisposed())
211:                    updatePartControl(getEditorInput());
212:            }
213:
214:            /*
215:             * @see org.eclipse.ui.texteditor.AbstractTextEditor#handleEditorInputChanged()
216:             * @since 3.1
217:             */
218:            protected void handleEditorInputChanged() {
219:                super .handleEditorInputChanged();
220:                if (fParent != null && !fParent.isDisposed())
221:                    updatePartControl(getEditorInput());
222:            }
223:
224:            /*
225:             * @see org.eclipse.ui.texteditor.AbstractTextEditor#handleElementContentReplaced()
226:             * @since 3.1
227:             */
228:            protected void handleElementContentReplaced() {
229:                super.handleElementContentReplaced();
230:                if (fParent != null && !fParent.isDisposed())
231:                    updatePartControl(getEditorInput());
232:            }
233:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.