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


001:        /*******************************************************************************
002:         * Copyright (c) 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.core.plugin;
011:
012:        import java.util.ArrayList;
013:
014:        import org.eclipse.core.runtime.PlatformObject;
015:        import org.eclipse.osgi.service.resolver.BundleDescription;
016:
017:        /**
018:         * A ModelEntry object has an ID and keeps track of all workspace plug-ins and target
019:         * plug-ins that have that ID.
020:         * <p>
021:         * This class is not meant to be extended or instantiated by clients.
022:         * </p>
023:         * 
024:         * @since 3.3
025:         */
026:        public class ModelEntry extends PlatformObject {
027:
028:            private String fId;
029:            protected ArrayList fWorkspaceEntries = new ArrayList(1);
030:            protected ArrayList fExternalEntries = new ArrayList(1);
031:
032:            /**
033:             * Constructor
034:             * 
035:             * @param id the entry ID
036:             */
037:            public ModelEntry(String id) {
038:                fId = id;
039:            }
040:
041:            /**
042:             * Returns all the workspace plug-ins that have the model entry ID
043:             * 
044:             * @return an array of workspace plug-ins that have the model entry ID
045:             */
046:            public IPluginModelBase[] getWorkspaceModels() {
047:                return (IPluginModelBase[]) fWorkspaceEntries
048:                        .toArray(new IPluginModelBase[fWorkspaceEntries.size()]);
049:            }
050:
051:            /**
052:             * Returns all plug-ins in the target platform that have the model entry ID.
053:             * The returned result contains both plug-ins that are enabled (ie. checked on the
054:             * <b>Plug-in Development > Target Platform</b> preference page) and disabled.
055:             * 
056:             * @return an array of plug-ins in the target platform that have the model entry ID
057:             */
058:            public IPluginModelBase[] getExternalModels() {
059:                return (IPluginModelBase[]) fExternalEntries
060:                        .toArray(new IPluginModelBase[fExternalEntries.size()]);
061:            }
062:
063:            /**
064:             * Returns the plug-in model for the best match plug-in with the given ID.
065:             * A null value is returned if no such bundle is found in the workspace or target platform.
066:             * <p>
067:             * A workspace plug-in is always preferably returned over a target plug-in.
068:             * A plug-in that is checked/enabled on the Target Platform preference page is always
069:             * preferably returned over a target plug-in that is unchecked/disabled.
070:             * </p>
071:             * <p>
072:             * In the case of a tie among workspace plug-ins or among target plug-ins,
073:             * the plug-in with the highest version is returned.
074:             * </p>
075:             * <p>
076:             * In the case of a tie among more than one suitable plug-in that have the same version, 
077:             * one of those plug-ins is randomly returned.
078:             * </p>
079:             * 
080:             * @return the plug-in model for the best match plug-in with the given ID
081:             */
082:            public IPluginModelBase getModel() {
083:                IPluginModelBase model = getBestCandidate(getWorkspaceModels());
084:                if (model == null)
085:                    model = getBestCandidate(getExternalModels());
086:                return model;
087:            }
088:
089:            private IPluginModelBase getBestCandidate(IPluginModelBase[] models) {
090:                IPluginModelBase model = null;
091:                for (int i = 0; i < models.length; i++) {
092:                    if (models[i].getBundleDescription() == null)
093:                        continue;
094:
095:                    if (model == null) {
096:                        model = models[i];
097:                        continue;
098:                    }
099:
100:                    if (!model.isEnabled() && models[i].isEnabled()) {
101:                        model = models[i];
102:                        continue;
103:                    }
104:
105:                    BundleDescription current = model.getBundleDescription();
106:                    BundleDescription candidate = models[i]
107:                            .getBundleDescription();
108:                    if (!current.isResolved() && candidate.isResolved()) {
109:                        model = models[i];
110:                        continue;
111:                    }
112:
113:                    if (current.getVersion().compareTo(candidate.getVersion()) < 0) {
114:                        model = models[i];
115:                    }
116:                }
117:                return model;
118:            }
119:
120:            /**
121:             * Returns all the plug-ins, with the model entry ID, that are currently active.
122:             * <p>
123:             * Workspace plug-ins are always active.  
124:             * Target plug-ins are only active if:
125:             * <ul>
126:             * <li>they are checked on the <b>Plug-in Development > Target Platform</b> preference page</li>
127:             * <li>there does not exist a workspace plug-in that has the same ID</li>
128:             * </ul>
129:             * </p>
130:             * 
131:             * @return an array of the currently active plug-ins with the model entry ID
132:             */
133:            public IPluginModelBase[] getActiveModels() {
134:                if (fWorkspaceEntries.size() > 0)
135:                    return getWorkspaceModels();
136:
137:                if (fExternalEntries.size() > 0) {
138:                    ArrayList list = new ArrayList(fExternalEntries.size());
139:                    for (int i = 0; i < fExternalEntries.size(); i++) {
140:                        IPluginModelBase model = (IPluginModelBase) fExternalEntries
141:                                .get(i);
142:                        if (model.isEnabled())
143:                            list.add(model);
144:                    }
145:                    return (IPluginModelBase[]) list
146:                            .toArray(new IPluginModelBase[list.size()]);
147:                }
148:                return new IPluginModelBase[0];
149:            }
150:
151:            /**
152:             * Returns the model entry ID
153:             * 
154:             * @return the model entry ID
155:             */
156:            public String getId() {
157:                return fId;
158:            }
159:
160:            /**
161:             * Return the plug-in model associated with the given bundle description or 
162:             * <code>null</code> if none is found.
163:             * 
164:             * @param desc  the given bundle description
165:             * 
166:             * @return the plug-in model associated with the given bundle description if such a
167:             * model exists.
168:             */
169:            public IPluginModelBase getModel(BundleDescription desc) {
170:                if (desc == null)
171:                    return null;
172:
173:                for (int i = 0; i < fWorkspaceEntries.size(); i++) {
174:                    IPluginModelBase model = (IPluginModelBase) fWorkspaceEntries
175:                            .get(i);
176:                    if (desc.equals(model.getBundleDescription()))
177:                        return model;
178:                }
179:                for (int i = 0; i < fExternalEntries.size(); i++) {
180:                    IPluginModelBase model = (IPluginModelBase) fExternalEntries
181:                            .get(i);
182:                    if (desc.equals(model.getBundleDescription()))
183:                        return model;
184:                }
185:                return null;
186:            }
187:
188:            /**
189:             * Returns <code>true</code> if there are workspace plug-ins associated with the ID
190:             * of this model entry; <code>false</code>otherwise.
191:             * 
192:             * @return <code>true</code> if there are workspace plug-ins associated with the ID
193:             * of this model entry; <code>false</code>otherwise.
194:             */
195:            public boolean hasWorkspaceModels() {
196:                return !fWorkspaceEntries.isEmpty();
197:            }
198:
199:            /**
200:             * Returns <code>true</code> if there are target plug-ins associated with the ID
201:             * of this model entry; <code>false</code>otherwise.
202:             * 
203:             * @return <code>true</code> if there are target plug-ins associated with the ID
204:             * of this model entry; <code>false</code>otherwise.
205:             */
206:            public boolean hasExternalModels() {
207:                return !fExternalEntries.isEmpty();
208:            }
209:
210:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.