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


001:        /*******************************************************************************
002:         * Copyright (c) 2003, 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.bundle;
011:
012:        import java.io.InputStream;
013:        import java.io.PrintWriter;
014:        import java.net.MalformedURLException;
015:        import java.net.URL;
016:
017:        import org.eclipse.core.resources.IResource;
018:        import org.eclipse.core.runtime.CoreException;
019:        import org.eclipse.osgi.service.resolver.BundleDescription;
020:        import org.eclipse.pde.core.IEditable;
021:        import org.eclipse.pde.core.IEditableModel;
022:        import org.eclipse.pde.core.IModelChangedEvent;
023:        import org.eclipse.pde.core.build.IBuildModel;
024:        import org.eclipse.pde.core.plugin.IExtensions;
025:        import org.eclipse.pde.core.plugin.IExtensionsModelFactory;
026:        import org.eclipse.pde.core.plugin.IPluginAttribute;
027:        import org.eclipse.pde.core.plugin.IPluginBase;
028:        import org.eclipse.pde.core.plugin.IPluginElement;
029:        import org.eclipse.pde.core.plugin.IPluginExtension;
030:        import org.eclipse.pde.core.plugin.IPluginExtensionPoint;
031:        import org.eclipse.pde.core.plugin.IPluginImport;
032:        import org.eclipse.pde.core.plugin.IPluginLibrary;
033:        import org.eclipse.pde.core.plugin.IPluginModelFactory;
034:        import org.eclipse.pde.core.plugin.IPluginObject;
035:        import org.eclipse.pde.core.plugin.ISharedExtensionsModel;
036:        import org.eclipse.pde.internal.core.AbstractNLModel;
037:        import org.eclipse.pde.internal.core.NLResourceHelper;
038:        import org.eclipse.pde.internal.core.PDEManager;
039:        import org.eclipse.pde.internal.core.ibundle.IBundle;
040:        import org.eclipse.pde.internal.core.ibundle.IBundleModel;
041:        import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase;
042:        import org.eclipse.pde.internal.core.plugin.PluginImport;
043:        import org.eclipse.pde.internal.core.plugin.PluginLibrary;
044:        import org.eclipse.pde.internal.core.text.plugin.PluginModelBase;
045:
046:        public abstract class BundlePluginModelBase extends AbstractNLModel
047:                implements  IBundlePluginModelBase, IPluginModelFactory {
048:
049:            private IBundleModel fBundleModel;
050:            private ISharedExtensionsModel fExtensionsModel;
051:            private BundlePluginBase fBundlePluginBase;
052:            private IBuildModel fBuildModel;
053:            private BundleDescription fBundleDescription;
054:
055:            public BundlePluginModelBase() {
056:                getPluginBase();
057:            }
058:
059:            /*
060:             * (non-Javadoc)
061:             * 
062:             * @see org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase#getBundleModel()
063:             */
064:            public IBundleModel getBundleModel() {
065:                return fBundleModel;
066:            }
067:
068:            public IResource getUnderlyingResource() {
069:                return fBundleModel.getUnderlyingResource();
070:            }
071:
072:            /*
073:             * (non-Javadoc)
074:             * 
075:             * @see org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase#getExtensionsModel()
076:             */
077:            public ISharedExtensionsModel getExtensionsModel() {
078:                return fExtensionsModel;
079:            }
080:
081:            public void dispose() {
082:                if (fBundleModel != null) {
083:                    if (fBundlePluginBase != null)
084:                        fBundleModel
085:                                .removeModelChangedListener(fBundlePluginBase);
086:                    fBundleModel.dispose();
087:                    fBundleModel = null;
088:                }
089:                if (fExtensionsModel != null) {
090:                    if (fBundlePluginBase != null)
091:                        fExtensionsModel
092:                                .removeModelChangedListener(fBundlePluginBase);
093:                    fExtensionsModel.dispose();
094:                    fExtensionsModel = null;
095:                }
096:                super .dispose();
097:            }
098:
099:            public void save() {
100:                if (fBundleModel != null
101:                        && fBundleModel instanceof  IEditableModel) {
102:                    IEditableModel emodel = (IEditableModel) fBundleModel;
103:                    if (emodel.isDirty())
104:                        emodel.save();
105:                }
106:                if (fExtensionsModel != null
107:                        && fExtensionsModel instanceof  IEditableModel) {
108:                    IEditableModel emodel = (IEditableModel) fExtensionsModel;
109:                    if (emodel.isDirty())
110:                        emodel.save();
111:                }
112:            }
113:
114:            /*
115:             * (non-Javadoc)
116:             * 
117:             * @see org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase#setBundleModel(org.eclipse.pde.internal.core.ibundle.IBundleModel)
118:             */
119:            public void setBundleModel(IBundleModel bundleModel) {
120:                if (fBundleModel != null && fBundlePluginBase != null) {
121:                    fBundleModel.removeModelChangedListener(fBundlePluginBase);
122:                }
123:                fBundleModel = bundleModel;
124:                if (fBundleModel != null && fBundlePluginBase != null)
125:                    bundleModel.addModelChangedListener(fBundlePluginBase);
126:            }
127:
128:            /*
129:             * (non-Javadoc)
130:             * 
131:             * @see org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase#setExtensionsModel(org.eclipse.pde.core.plugin.IExtensionsModel)
132:             */
133:            public void setExtensionsModel(
134:                    ISharedExtensionsModel extensionsModel) {
135:                if (fExtensionsModel != null && fBundlePluginBase != null) {
136:                    fExtensionsModel
137:                            .removeModelChangedListener(fBundlePluginBase);
138:                }
139:                fExtensionsModel = extensionsModel;
140:                if (fExtensionsModel instanceof  PluginModelBase) {
141:                    ((PluginModelBase) fExtensionsModel)
142:                            .setLocalization(getBundleLocalization());
143:                }
144:                if (extensionsModel != null && fBundlePluginBase != null)
145:                    extensionsModel.addModelChangedListener(fBundlePluginBase);
146:            }
147:
148:            public IBuildModel getBuildModel() {
149:                return fBuildModel;
150:            }
151:
152:            public void setBuildModel(IBuildModel buildModel) {
153:                fBuildModel = buildModel;
154:            }
155:
156:            public IPluginBase getPluginBase() {
157:                return getPluginBase(true);
158:            }
159:
160:            public IExtensions getExtensions() {
161:                return getPluginBase();
162:            }
163:
164:            /* (non-Javadoc)
165:             * @see org.eclipse.pde.core.IModelChangeProvider#fireModelChanged(org.eclipse.pde.core.IModelChangedEvent)
166:             */
167:            public void fireModelChanged(IModelChangedEvent event) {
168:                super .fireModelChanged(event);
169:                Object[] objects = event.getChangedObjects();
170:                if (objects != null && objects.length > 0) {
171:                    if (objects[0] instanceof  IPluginImport) {
172:                        fBundlePluginBase
173:                                .updateImport((IPluginImport) objects[0]);
174:                    }
175:                }
176:            }
177:
178:            /*
179:             * (non-Javadoc)
180:             * 
181:             * @see org.eclipse.pde.core.plugin.IPluginModelBase#getPluginBase(boolean)
182:             */
183:            public IPluginBase getPluginBase(boolean createIfMissing) {
184:                if (fBundlePluginBase == null && createIfMissing) {
185:                    fBundlePluginBase = (BundlePluginBase) createPluginBase();
186:                    if (fBundleModel != null)
187:                        fBundleModel.addModelChangedListener(fBundlePluginBase);
188:                    setLoaded(true);
189:                }
190:                return fBundlePluginBase;
191:            }
192:
193:            public IExtensions getExtensions(boolean createIfMissing) {
194:                return getPluginBase(createIfMissing);
195:            }
196:
197:            /*
198:             * (non-Javadoc)
199:             * 
200:             * @see org.eclipse.pde.core.plugin.IPluginModelBase#getPluginFactory()
201:             */
202:            public IPluginModelFactory getPluginFactory() {
203:                return this ;
204:            }
205:
206:            /*
207:             * (non-Javadoc)
208:             * 
209:             * @see org.eclipse.pde.core.plugin.ISharedPluginModel#getFactory()
210:             */
211:            public IExtensionsModelFactory getFactory() {
212:                if (fExtensionsModel != null)
213:                    return fExtensionsModel.getFactory();
214:                return null;
215:            }
216:
217:            /*
218:             * (non-Javadoc)
219:             * 
220:             * @see org.eclipse.pde.core.plugin.ISharedPluginModel#getInstallLocation()
221:             */
222:            public String getInstallLocation() {
223:                if (fBundleModel != null)
224:                    return fBundleModel.getInstallLocation();
225:                return null;
226:            }
227:
228:            public String getBundleLocalization() {
229:                IBundle bundle = fBundleModel != null ? fBundleModel
230:                        .getBundle() : null;
231:                return bundle != null ? bundle.getLocalization() : null;
232:
233:            }
234:
235:            protected NLResourceHelper createNLResourceHelper() {
236:                String localization = getBundleLocalization();
237:                return localization == null ? null : new NLResourceHelper(
238:                        localization, PDEManager.getNLLookupLocations(this ));
239:            }
240:
241:            public URL getNLLookupLocation() {
242:                try {
243:                    return new URL("file:" + getInstallLocation()); //$NON-NLS-1$ //$NON-NLS-2$
244:                } catch (MalformedURLException e) {
245:                    return null;
246:                }
247:            }
248:
249:            /*
250:             * (non-Javadoc)
251:             * 
252:             * @see org.eclipse.pde.core.IModel#isEditable()
253:             */
254:            public boolean isEditable() {
255:                if (fBundleModel != null && fBundleModel.isEditable() == false)
256:                    return false;
257:                if (fExtensionsModel != null
258:                        && fExtensionsModel.isEditable() == false)
259:                    return false;
260:                return true;
261:            }
262:
263:            /*
264:             * (non-Javadoc)
265:             * 
266:             * @see org.eclipse.pde.core.IModel#isInSync()
267:             */
268:            public boolean isInSync() {
269:                return ((fBundleModel == null || fBundleModel.isInSync()) && (fExtensionsModel == null || fExtensionsModel
270:                        .isInSync()));
271:            }
272:
273:            /*
274:             * (non-Javadoc)
275:             * 
276:             * @see org.eclipse.pde.core.IModel#isValid()
277:             */
278:            public boolean isValid() {
279:                return ((fBundleModel == null || fBundleModel.isValid()) && (fExtensionsModel == null || fExtensionsModel
280:                        .isValid()));
281:            }
282:
283:            /*
284:             * (non-Javadoc)
285:             * 
286:             * @see org.eclipse.pde.core.IModel#load()
287:             */
288:            public void load() throws CoreException {
289:            }
290:
291:            /*
292:             * (non-Javadoc)
293:             * 
294:             * @see org.eclipse.pde.core.IModel#load(java.io.InputStream, boolean)
295:             */
296:            public void load(InputStream source, boolean outOfSync)
297:                    throws CoreException {
298:            }
299:
300:            /*
301:             * (non-Javadoc)
302:             * 
303:             * @see org.eclipse.pde.core.IModel#reload(java.io.InputStream, boolean)
304:             */
305:            public void reload(InputStream source, boolean outOfSync)
306:                    throws CoreException {
307:            }
308:
309:            /**
310:             * @return Returns the enabled.
311:             */
312:            public boolean isEnabled() {
313:                return true;
314:            }
315:
316:            public void setEnabled(boolean enabled) {
317:            }
318:
319:            /*
320:             * (non-Javadoc)
321:             * 
322:             * @see org.eclipse.pde.internal.core.AbstractModel#updateTimeStamp()
323:             */
324:            protected void updateTimeStamp() {
325:            }
326:
327:            public IPluginImport createImport() {
328:                PluginImport iimport = new PluginImport();
329:                iimport.setModel(this );
330:                iimport.setParent(getPluginBase());
331:                return iimport;
332:            }
333:
334:            public IPluginImport createImport(String pluginId) {
335:                PluginImport iimport = new PluginImport(this , pluginId);
336:                iimport.setParent(getPluginBase());
337:                return iimport;
338:            }
339:
340:            public IPluginLibrary createLibrary() {
341:                PluginLibrary library = new PluginLibrary();
342:                library.setModel(this );
343:                library.setParent(getPluginBase());
344:                return library;
345:            }
346:
347:            public IPluginAttribute createAttribute(IPluginElement element) {
348:                if (fExtensionsModel != null)
349:                    return fExtensionsModel.getFactory().createAttribute(
350:                            element);
351:                return null;
352:            }
353:
354:            public IPluginElement createElement(IPluginObject parent) {
355:                if (fExtensionsModel != null)
356:                    return fExtensionsModel.getFactory().createElement(parent);
357:                return null;
358:            }
359:
360:            public IPluginExtension createExtension() {
361:                if (fExtensionsModel != null)
362:                    return fExtensionsModel.getFactory().createExtension();
363:                return null;
364:            }
365:
366:            public IPluginExtensionPoint createExtensionPoint() {
367:                if (fExtensionsModel != null)
368:                    return fExtensionsModel.getFactory().createExtensionPoint();
369:                return null;
370:            }
371:
372:            public boolean isBundleModel() {
373:                return true;
374:            }
375:
376:            /*
377:             * (non-Javadoc)
378:             * 
379:             * @see org.eclipse.pde.core.plugin.IPluginModelBase#getBundleDescription()
380:             */
381:            public BundleDescription getBundleDescription() {
382:                return fBundleDescription;
383:            }
384:
385:            /*
386:             * (non-Javadoc)
387:             * 
388:             * @see org.eclipse.pde.core.plugin.IPluginModelBase#setBundleDescription(org.eclipse.osgi.service.resolver.BundleDescription)
389:             */
390:            public void setBundleDescription(BundleDescription description) {
391:                fBundleDescription = description;
392:            }
393:
394:            /*
395:             * (non-Javadoc)
396:             * 
397:             * @see org.eclipse.pde.core.IEditable#isDirty()
398:             */
399:            public boolean isDirty() {
400:                if (fBundleModel != null && (fBundleModel instanceof  IEditable)
401:                        && ((IEditable) fBundleModel).isDirty())
402:                    return true;
403:                if (fExtensionsModel != null
404:                        && (fExtensionsModel instanceof  IEditable)
405:                        && ((IEditable) fExtensionsModel).isDirty())
406:                    return true;
407:                return false;
408:            }
409:
410:            /*
411:             * (non-Javadoc)
412:             * 
413:             * @see org.eclipse.pde.core.IEditable#save(java.io.PrintWriter)
414:             */
415:            public void save(PrintWriter writer) {
416:                // Does nothing - individual models are saved instead
417:            }
418:
419:            /*
420:             * (non-Javadoc)
421:             * 
422:             * @see org.eclipse.pde.core.IEditable#setDirty(boolean)
423:             */
424:            public void setDirty(boolean dirty) {
425:                //does nothing
426:            }
427:
428:            public String toString() {
429:                IPluginBase base = getPluginBase();
430:                if (base != null)
431:                    return base.getId();
432:                return super.toString();
433:            }
434:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.