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


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 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.core.plugin;
011:
012:        import java.io.PrintWriter;
013:        import java.util.ArrayList;
014:        import java.util.Locale;
015:        import java.util.Vector;
016:
017:        import org.eclipse.core.runtime.CoreException;
018:        import org.eclipse.osgi.service.resolver.BundleDescription;
019:        import org.eclipse.osgi.service.resolver.ExportPackageDescription;
020:        import org.eclipse.pde.core.plugin.IPluginLibrary;
021:        import org.eclipse.pde.core.plugin.IPluginModelBase;
022:        import org.eclipse.pde.core.plugin.IPluginObject;
023:        import org.eclipse.pde.core.plugin.ISharedPluginModel;
024:        import org.eclipse.pde.internal.core.ClasspathUtilCore;
025:        import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase;
026:        import org.eclipse.pde.internal.core.util.PDEXMLHelper;
027:        import org.w3c.dom.Node;
028:        import org.w3c.dom.NodeList;
029:
030:        public class PluginLibrary extends PluginObject implements 
031:                IPluginLibrary {
032:
033:            private static final long serialVersionUID = 1L;
034:            private String[] fContentFilters;
035:            private boolean fExported = false;
036:            private String fType;
037:
038:            public PluginLibrary() {
039:            }
040:
041:            public boolean isValid() {
042:                return fName != null;
043:            }
044:
045:            public String[] getContentFilters() {
046:                IPluginModelBase model = (IPluginModelBase) getModel();
047:                if (ClasspathUtilCore.hasBundleStructure(model)) {
048:                    BundleDescription desc = model.getBundleDescription();
049:                    if (desc != null) {
050:                        ArrayList list = new ArrayList();
051:                        ExportPackageDescription[] exports = desc
052:                                .getExportPackages();
053:                        for (int i = 0; i < exports.length; i++) {
054:                            list.add(exports[i].getName());
055:                        }
056:                        return (String[]) list.toArray(new String[list.size()]);
057:                    }
058:                }
059:                if (!isExported())
060:                    return new String[0];
061:                return isFullyExported() ? new String[] { "**" } : fContentFilters; //$NON-NLS-1$
062:            }
063:
064:            /* (non-Javadoc)
065:             * @see org.eclipse.pde.core.plugin.IPluginLibrary#addContentFilter(java.lang.String)
066:             */
067:            public void addContentFilter(String filter) throws CoreException {
068:            }
069:
070:            /* (non-Javadoc)
071:             * @see org.eclipse.pde.core.plugin.IPluginLibrary#removeContentFilter(java.lang.String)
072:             */
073:            public void removeContentFilter(String filter) throws CoreException {
074:            }
075:
076:            public String[] getPackages() {
077:                return new String[0];
078:            }
079:
080:            public boolean isExported() {
081:                return fExported;
082:            }
083:
084:            public boolean isFullyExported() {
085:                return fExported
086:                        && (fContentFilters == null || fContentFilters.length == 0);
087:            }
088:
089:            public String getType() {
090:                return fType;
091:            }
092:
093:            public void load(String name) {
094:                fName = name;
095:                fExported = true;
096:            }
097:
098:            void load(Node node) {
099:                fName = getNodeAttribute(node, "name"); //$NON-NLS-1$
100:                fType = getNodeAttribute(node, "type"); //$NON-NLS-1$
101:                NodeList children = node.getChildNodes();
102:                Vector exports = new Vector();
103:                boolean all = false;
104:                for (int i = 0; i < children.getLength(); i++) {
105:                    Node child = children.item(i);
106:                    if (child.getNodeType() == Node.ELEMENT_NODE) {
107:                        String tag = child.getNodeName().toLowerCase(
108:                                Locale.ENGLISH);
109:                        if (tag.equals("export")) { //$NON-NLS-1$
110:                            String ename = getNodeAttribute(child, "name"); //$NON-NLS-1$
111:                            if (ename != null) {
112:                                ename = ename.trim();
113:                                if (ename.equals("*")) { //$NON-NLS-1$
114:                                    all = true;
115:                                } else {
116:                                    exports.add(ename);
117:                                }
118:                            }
119:                        }
120:                    }
121:                }
122:                if (exports.size() > 0) {
123:                    fContentFilters = new String[exports.size()];
124:                    exports.copyInto(fContentFilters);
125:                }
126:                fExported = all || exports.size() > 0;
127:            }
128:
129:            public void setContentFilters(String[] filters)
130:                    throws CoreException {
131:                ensureModelEditable();
132:                ArrayList oldValue = createArrayList(fContentFilters);
133:                fContentFilters = filters;
134:                firePropertyChanged(P_CONTENT_FILTERS, oldValue,
135:                        createArrayList(filters));
136:            }
137:
138:            public void setPackages(String[] packages) throws CoreException {
139:            }
140:
141:            public void setExported(boolean value) throws CoreException {
142:                ensureModelEditable();
143:                Boolean oldValue = new Boolean(fExported);
144:                fExported = value;
145:                firePropertyChanged(P_EXPORTED, oldValue, new Boolean(value));
146:            }
147:
148:            public void setType(String type) throws CoreException {
149:                ensureModelEditable();
150:                String oldValue = fType;
151:                fType = type;
152:                firePropertyChanged(P_TYPE, oldValue, type);
153:            }
154:
155:            public void restoreProperty(String name, Object oldValue,
156:                    Object newValue) throws CoreException {
157:                if (name.equals(P_CONTENT_FILTERS)) {
158:                    ArrayList list = (ArrayList) newValue;
159:                    if (list != null)
160:                        setContentFilters((String[]) list
161:                                .toArray(new String[list.size()]));
162:                    else
163:                        setContentFilters(null);
164:                    return;
165:                }
166:                if (name.equals(P_EXPORTED)) {
167:                    setExported(((Boolean) newValue).booleanValue());
168:                    return;
169:                }
170:                if (name.equals(P_TYPE)) {
171:                    setType(newValue != null ? newValue.toString() : null);
172:                    return;
173:                }
174:                super .restoreProperty(name, oldValue, newValue);
175:            }
176:
177:            private ArrayList createArrayList(String[] array) {
178:                if (array == null)
179:                    return null;
180:                ArrayList list = new ArrayList();
181:                for (int i = 0; i < array.length; i++) {
182:                    list.add(array[i]);
183:                }
184:                return list;
185:            }
186:
187:            /* (non-Javadoc)
188:             * @see org.eclipse.pde.core.IWritable#write(java.lang.String, java.io.PrintWriter)
189:             */
190:            public void write(String indent, PrintWriter writer) {
191:                // Get the model
192:                IPluginModelBase modelBase = getPluginModel();
193:                // check to see if the model is a bundle model
194:                if ((modelBase instanceof  IBundlePluginModelBase) == false) {
195:                    writer.print(indent);
196:                    writer
197:                            .print("<library name=\"" + PDEXMLHelper.getWritableString(getName()) + "\""); //$NON-NLS-1$ //$NON-NLS-2$
198:                    if (fType != null)
199:                        writer.print(" type=\"" + fType + "\""); //$NON-NLS-1$ //$NON-NLS-2$
200:                    if (!isExported()) {
201:                        writer.println("/>"); //$NON-NLS-1$
202:                    } else {
203:                        writer.println(">"); //$NON-NLS-1$
204:                        String indent2 = indent + "   "; //$NON-NLS-1$
205:                        if (isExported()) {
206:                            if (isFullyExported()) {
207:                                writer
208:                                        .println(indent2
209:                                                + "<export name=\"*\"/>"); //$NON-NLS-1$
210:                            } else {
211:                                for (int i = 0; i < fContentFilters.length; i++) {
212:                                    writer.println(indent2 + "<export name=\"" //$NON-NLS-1$
213:                                            + fContentFilters[i] + "\"/>"); //$NON-NLS-1$
214:                                }
215:                            }
216:                        }
217:                        writer.println(indent + "</library>"); //$NON-NLS-1$
218:                    }
219:                } else
220:                    writer.print(PDEXMLHelper.getWritableString(getName()));
221:            }
222:
223:            /* (non-Javadoc)
224:             * @see org.eclipse.pde.internal.core.plugin.PluginObject#reconnect(org.eclipse.pde.core.plugin.ISharedPluginModel, org.eclipse.pde.core.plugin.IPluginObject)
225:             */
226:            public void reconnect(ISharedPluginModel model, IPluginObject parent) {
227:                super .reconnect(model, parent);
228:                // No transient fields
229:            }
230:
231:            /* (non-Javadoc)
232:             * @see org.eclipse.pde.internal.core.plugin.PluginObject#writeDelimeter(java.io.PrintWriter)
233:             */
234:            public void writeDelimeter(PrintWriter writer) {
235:                writer.println(',');
236:                writer.print(' ');
237:            }
238:
239:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.