Source Code Cross Referenced for BundleTextChangeListener.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » core » text » bundle » 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.core.text.bundle 
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.core.text.bundle;
011:
012:        import org.eclipse.jface.text.BadLocationException;
013:        import org.eclipse.jface.text.IDocument;
014:        import org.eclipse.osgi.util.NLS;
015:        import org.eclipse.pde.core.IModelChangedEvent;
016:        import org.eclipse.pde.internal.core.PDECoreMessages;
017:        import org.eclipse.pde.internal.core.text.AbstractKeyValueTextChangeListener;
018:        import org.eclipse.pde.internal.core.text.IDocumentKey;
019:        import org.eclipse.pde.internal.core.util.PropertiesUtil;
020:        import org.eclipse.text.edits.InsertEdit;
021:        import org.eclipse.text.edits.TextEdit;
022:
023:        public class BundleTextChangeListener extends
024:                AbstractKeyValueTextChangeListener {
025:
026:            public BundleTextChangeListener(IDocument document) {
027:                super (document, false);
028:            }
029:
030:            public BundleTextChangeListener(IDocument document,
031:                    boolean generateReadableNames) {
032:                super (document, generateReadableNames);
033:            }
034:
035:            public TextEdit[] getTextOperations() {
036:                TextEdit[] ops = super .getTextOperations();
037:                try {
038:                    if (ops.length == 0
039:                            || !PropertiesUtil.isNewlineNeeded(fDocument))
040:                        return ops;
041:                } catch (BadLocationException e) {
042:                }
043:
044:                TextEdit[] result = new TextEdit[ops.length + 1];
045:                result[ops.length] = new InsertEdit(PropertiesUtil
046:                        .getInsertOffset(fDocument), fSep);
047:                if (fReadableNames != null)
048:                    fReadableNames
049:                            .put(
050:                                    result[ops.length],
051:                                    PDECoreMessages.BundleTextChangeListener_editNames_newLine);
052:                System.arraycopy(ops, 0, result, 0, ops.length);
053:                return result;
054:            }
055:
056:            /*
057:             * (non-Javadoc)
058:             * 
059:             * This method is overwritten in the BundleTextChangeListener so that newly inserted headers
060:             * will have their separator inserted at the start of the change rather than the end when there
061:             * is not already a new line at the end of the manifest. This allows the "Add a new line at the
062:             * end of the file" change to go at the bottom of the preview as the user would expect. Previously
063:             * it was added before all inserts so the new headers would appear on new lines.
064:             * 
065:             * @see org.eclipse.pde.internal.core.text.AbstractKeyValueTextChangeListener#insertKey(org.eclipse.pde.internal.core.text.IDocumentKey, java.lang.String)
066:             */
067:            protected void insertKey(IDocumentKey key, String name) {
068:                int offset = PropertiesUtil.getInsertOffset(fDocument);
069:                StringBuffer buffer = new StringBuffer(key.write());
070:                try {
071:                    // if the file does not end in a new line and the key to insert does, move the new line
072:                    // to the start of the key.
073:                    if (PropertiesUtil.isNewlineNeeded(fDocument)
074:                            && buffer
075:                                    .substring(buffer.length() - fSep.length())
076:                                    .equals(fSep)) {
077:                        buffer.insert(0, fSep);
078:                        buffer.setLength(buffer.length() - fSep.length());
079:                    }
080:                } catch (BadLocationException e) {
081:                }
082:                InsertEdit edit = new InsertEdit(offset, buffer.toString());
083:                fOperationTable.put(key, edit);
084:                if (fReadableNames != null)
085:                    fReadableNames.put(edit, name);
086:            }
087:
088:            public void modelChanged(IModelChangedEvent event) {
089:                Object[] objects = event.getChangedObjects();
090:                for (int i = 0; i < objects.length; i++) {
091:                    Object object = objects[i];
092:                    if (object instanceof  PDEManifestElement)
093:                        object = ((PDEManifestElement) object).getHeader();
094:                    else if (object instanceof  PackageFriend)
095:                        object = ((PackageFriend) object).getHeader();
096:
097:                    if (object instanceof  ManifestHeader) {
098:                        ManifestHeader header = (ManifestHeader) object;
099:                        Object op = fOperationTable.remove(header);
100:                        if (fReadableNames != null)
101:                            fReadableNames.remove(op);
102:
103:                        if (header.getValue() == null
104:                                || header.getValue().trim().length() == 0) {
105:                            String name = fReadableNames == null ? null
106:                                    : NLS
107:                                            .bind(
108:                                                    PDECoreMessages.BundleTextChangeListener_editNames_remove,
109:                                                    header.fName);
110:                            deleteKey(header, name);
111:                        } else {
112:                            String name = fReadableNames == null ? null
113:                                    : NLS
114:                                            .bind(
115:                                                    header.getOffset() == -1 ? PDECoreMessages.BundleTextChangeListener_editNames_insert
116:                                                            : PDECoreMessages.BundleTextChangeListener_editNames_modify,
117:                                                    header.fName);
118:                            modifyKey(header, name);
119:                        }
120:                    }
121:                }
122:            }
123:
124:        }
w_w__w.j___ava___2___s__.co__m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.