Source Code Cross Referenced for ModelChangeElement.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » ui » nls » 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.nls 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2005, 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.pde.internal.ui.nls;
011:
012:        import java.util.Properties;
013:
014:        import org.eclipse.core.runtime.CoreException;
015:        import org.eclipse.pde.core.plugin.IFragmentModel;
016:        import org.eclipse.pde.internal.core.text.IDocumentAttributeNode;
017:        import org.eclipse.pde.internal.core.text.IDocumentTextNode;
018:        import org.eclipse.pde.internal.core.text.bundle.ManifestHeader;
019:        import org.eclipse.pde.internal.core.text.plugin.PluginAttribute;
020:        import org.eclipse.pde.internal.core.text.plugin.PluginElementNode;
021:        import org.eclipse.pde.internal.core.text.plugin.PluginExtensionPointNode;
022:
023:        public class ModelChangeElement {
024:
025:            private static final String DELIM = "."; //$NON-NLS-1$
026:            private static final String KEY_PREFIX = "%"; //$NON-NLS-1$
027:            private static final String FRAGMENT_PREFIX = "f"; //$NON-NLS-1$
028:
029:            private String fValue = ""; //$NON-NLS-1$
030:            private String fKey = ""; //$NON-NLS-1$
031:            private int fOffset = 0;
032:            private int fLength = 0;
033:            private boolean fExternalized = true;
034:            private ModelChange fParent;
035:            private Object fUnderlying;
036:
037:            public ModelChangeElement(ModelChange parent, Object incoming) {
038:                fParent = parent;
039:                fUnderlying = incoming;
040:                if (incoming instanceof  PluginElementNode) {
041:                    PluginElementNode elem = (PluginElementNode) incoming;
042:                    IDocumentTextNode text = elem.getTextNode();
043:                    fValue = elem.getText();
044:                    generateValidKey(elem.getParent().getName(), elem.getName());
045:                    fOffset = text.getOffset();
046:                    fLength = text.getLength();
047:                } else if (incoming instanceof  PluginAttribute) {
048:                    PluginAttribute attr = (PluginAttribute) incoming;
049:                    fValue = attr.getValue();
050:                    generateValidKey(
051:                            attr.getEnclosingElement().getXMLTagName(), attr
052:                                    .getName());
053:                    fOffset = attr.getValueOffset();
054:                    fLength = attr.getValueLength();
055:                } else if (incoming instanceof  PluginExtensionPointNode) {
056:                    PluginExtensionPointNode extP = (PluginExtensionPointNode) incoming;
057:                    fValue = extP.getName();
058:                    generateValidKey("extension-point", "name"); //$NON-NLS-1$ //$NON-NLS-2$
059:                    IDocumentAttributeNode attr = extP
060:                            .getDocumentAttribute("name"); //$NON-NLS-1$
061:                    fOffset = attr.getValueOffset();
062:                    fLength = attr.getValueLength();
063:                } else if (incoming instanceof  ManifestHeader) {
064:                    ManifestHeader header = (ManifestHeader) incoming;
065:                    fValue = header.getValue();
066:                    generateValidKey(header.getName());
067:                    fLength = fValue.length();
068:                    fOffset = header.getOffset() + header.getLength()
069:                            - header.getLineLimiter().length() - fLength;
070:                }
071:            }
072:
073:            public String getKey() {
074:                return fKey;
075:            }
076:
077:            public void setKey(String key) {
078:                fKey = key;
079:            }
080:
081:            public String getValue() {
082:                return fValue;
083:            }
084:
085:            public void setValue(String value) {
086:                fValue = value;
087:            }
088:
089:            public boolean isExternalized() {
090:                return fExternalized;
091:            }
092:
093:            public void setExternalized(boolean externalzied) {
094:                fExternalized = externalzied;
095:            }
096:
097:            public int getOffset() {
098:                return fOffset;
099:            }
100:
101:            public int getLength() {
102:                return fLength;
103:            }
104:
105:            private void generateValidKey(String pre, String mid) {
106:                generateValidKey(pre + DELIM + mid);
107:            }
108:
109:            private void generateValidKey(String key) {
110:                int suffix = 0;
111:                Properties properties = fParent.getProperties();
112:                String newKey = fParent.getParentModel() instanceof  IFragmentModel ? key
113:                        + DELIM + FRAGMENT_PREFIX
114:                        : key + DELIM;
115:                while (properties.containsKey(newKey + suffix))
116:                    suffix += 1;
117:                properties.setProperty(newKey + suffix, fValue);
118:                fKey = newKey + suffix;
119:            }
120:
121:            public String getExternKey() {
122:                return KEY_PREFIX + fKey;
123:            }
124:
125:            public boolean updateValue() {
126:                try {
127:                    String key = getExternKey();
128:                    if (fUnderlying instanceof  PluginElementNode) {
129:                        PluginElementNode elem = (PluginElementNode) fUnderlying;
130:                        elem.setText(key);
131:                    } else if (fUnderlying instanceof  PluginAttribute) {
132:                        PluginAttribute attr = (PluginAttribute) fUnderlying;
133:                        String attrName = attr.getName();
134:                        attr.getEnclosingElement().setXMLAttribute(attrName,
135:                                key);
136:                    } else if (fUnderlying instanceof  PluginExtensionPointNode) {
137:                        PluginExtensionPointNode extP = (PluginExtensionPointNode) fUnderlying;
138:                        extP.setName(key);
139:                    } else if (fUnderlying instanceof  ManifestHeader) {
140:                        ManifestHeader header = (ManifestHeader) fUnderlying;
141:                        header.setValue(key);
142:                    } else
143:                        return false;
144:                } catch (CoreException e) {
145:                    return false;
146:                }
147:                return true;
148:            }
149:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.