Source Code Cross Referenced for ExtensionPointHelper.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » internal » texteditor » rulers » 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.internal.texteditor.rulers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 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.internal.texteditor.rulers;
011:
012:        import java.net.URL;
013:
014:        import org.osgi.framework.Bundle;
015:
016:        import com.ibm.icu.text.MessageFormat;
017:
018:        import org.eclipse.core.runtime.Assert;
019:        import org.eclipse.core.runtime.FileLocator;
020:        import org.eclipse.core.runtime.IConfigurationElement;
021:        import org.eclipse.core.runtime.IExtension;
022:        import org.eclipse.core.runtime.ILog;
023:        import org.eclipse.core.runtime.IStatus;
024:        import org.eclipse.core.runtime.InvalidRegistryObjectException;
025:        import org.eclipse.core.runtime.Path;
026:        import org.eclipse.core.runtime.Platform;
027:        import org.eclipse.core.runtime.Status;
028:
029:        import org.eclipse.ui.internal.texteditor.TextEditorPlugin;
030:
031:        public final class ExtensionPointHelper {
032:
033:            private final IConfigurationElement fElement;
034:            private final String fName;
035:            private final ILog fLog;
036:
037:            public ExtensionPointHelper(IConfigurationElement element, ILog log)
038:                    throws InvalidRegistryObjectException {
039:                Assert.isLegal(element != null);
040:                Assert.isLegal(log != null);
041:                fLog = log;
042:                fElement = element;
043:                fName = element.getName();
044:                // see if we have a conventional 'id' attribute
045:            }
046:
047:            public String getDefaultAttribute(String attribute, String dflt)
048:                    throws InvalidRegistryObjectException {
049:                String value = fElement.getAttribute(attribute);
050:                return value == null ? dflt : value;
051:            }
052:
053:            public String getNonNullAttribute(String attribute)
054:                    throws InvalidRegistryObjectException {
055:                String value = fElement.getAttribute(attribute);
056:                if (value == null)
057:                    fail(MessageFormat
058:                            .format(
059:                                    RulerColumnMessages.ExtensionPointHelper_missing_attribute_msg,
060:                                    new Object[] { fName, attribute }));
061:                return value;
062:            }
063:
064:            public float getDefaultAttribute(String attribute, float dflt) {
065:                String value = getDefaultAttribute(attribute, null);
066:                if (value == null)
067:                    return dflt;
068:
069:                try {
070:                    return Float.valueOf(value).floatValue();
071:                } catch (NumberFormatException x) {
072:                    fail(MessageFormat
073:                            .format(
074:                                    RulerColumnMessages.ExtensionPointHelper_invalid_number_attribute_msg,
075:                                    new Object[] { attribute, fName }));
076:                    return dflt;
077:                }
078:            }
079:
080:            public boolean getDefaultAttribute(String attribute, boolean dflt) {
081:                String value = getDefaultAttribute(attribute, null);
082:                if (value == null)
083:                    return dflt;
084:
085:                try {
086:                    return Boolean.valueOf(value).booleanValue();
087:                } catch (NumberFormatException x) {
088:                    fail(MessageFormat
089:                            .format(
090:                                    RulerColumnMessages.ExtensionPointHelper_invalid_number_attribute_msg,
091:                                    new Object[] { fName, attribute }));
092:                    return dflt;
093:                }
094:            }
095:
096:            public void fail(String message)
097:                    throws InvalidRegistryObjectException {
098:                String id = findId(fElement);
099:                String extensionPointId = fElement.getDeclaringExtension()
100:                        .getExtensionPointUniqueIdentifier();
101:                Object[] args = { fElement.getContributor().getName(), id,
102:                        extensionPointId };
103:                String blame = MessageFormat
104:                        .format(
105:                                RulerColumnMessages.ExtensionPointHelper_invalid_contribution_msg,
106:                                args);
107:
108:                IStatus status = new Status(IStatus.WARNING,
109:                        TextEditorPlugin.PLUGIN_ID, IStatus.OK,
110:                        blame + message, null);
111:                fLog.log(status);
112:                throw new InvalidRegistryObjectException();
113:            }
114:
115:            public static String findId(IConfigurationElement element) {
116:                String id = null;
117:                while (element != null && id == null) {
118:                    id = element.getAttribute("id"); //$NON-NLS-1$
119:                    if (id != null)
120:                        break;
121:                    Object parent = element.getParent();
122:                    if (parent instanceof  IExtension) {
123:                        id = ((IExtension) parent).getUniqueIdentifier();
124:                        break;
125:                    } else if (parent instanceof  IConfigurationElement) {
126:                        element = (IConfigurationElement) parent;
127:                    } else {
128:                        break;
129:                    }
130:                }
131:                return id == null ? "<unknown>" : id; //$NON-NLS-1$
132:            }
133:
134:            public URL getDefaultResourceURL(String attribute, URL dflt) {
135:                String value = getDefaultAttribute(attribute, null);
136:                if (value == null)
137:                    return dflt;
138:
139:                Bundle bundle = getBundle();
140:                if (bundle == null)
141:                    return dflt;
142:
143:                Path path = new Path(value);
144:                return FileLocator.find(bundle, path, null);
145:            }
146:
147:            private Bundle getBundle() {
148:                String namespace = fElement.getDeclaringExtension()
149:                        .getContributor().getName();
150:                Bundle bundle = Platform.getBundle(namespace);
151:                return bundle;
152:            }
153:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.