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


0001:        /*******************************************************************************
0002:         * Copyright (c) 2000, 2007 IBM Corporation and others.
0003:         * All rights reserved. This program and the accompanying materials
0004:         * are made available under the terms of the Eclipse Public License v1.0
0005:         * which accompanies this distribution, and is available at
0006:         * http://www.eclipse.org/legal/epl-v10.html
0007:         *
0008:         * Contributors:
0009:         *     IBM Corporation - initial API and implementation
0010:         *******************************************************************************/package org.eclipse.pde.internal.ui;
0011:
0012:        import java.util.Locale;
0013:
0014:        import org.eclipse.core.resources.IProject;
0015:        import org.eclipse.core.resources.IResource;
0016:        import org.eclipse.core.runtime.CoreException;
0017:        import org.eclipse.jdt.ui.ISharedImages;
0018:        import org.eclipse.jdt.ui.JavaUI;
0019:        import org.eclipse.jface.resource.ImageDescriptor;
0020:        import org.eclipse.osgi.service.resolver.BundleDescription;
0021:        import org.eclipse.osgi.service.resolver.ResolverError;
0022:        import org.eclipse.pde.core.build.IBuildEntry;
0023:        import org.eclipse.pde.core.plugin.IFragment;
0024:        import org.eclipse.pde.core.plugin.IFragmentModel;
0025:        import org.eclipse.pde.core.plugin.IPlugin;
0026:        import org.eclipse.pde.core.plugin.IPluginBase;
0027:        import org.eclipse.pde.core.plugin.IPluginExtension;
0028:        import org.eclipse.pde.core.plugin.IPluginExtensionPoint;
0029:        import org.eclipse.pde.core.plugin.IPluginImport;
0030:        import org.eclipse.pde.core.plugin.IPluginLibrary;
0031:        import org.eclipse.pde.core.plugin.IPluginModel;
0032:        import org.eclipse.pde.core.plugin.IPluginModelBase;
0033:        import org.eclipse.pde.core.plugin.PluginRegistry;
0034:        import org.eclipse.pde.internal.core.PDECore;
0035:        import org.eclipse.pde.internal.core.TargetPlatformHelper;
0036:        import org.eclipse.pde.internal.core.WorkspaceModelManager;
0037:        import org.eclipse.pde.internal.core.builders.CompilerFlags;
0038:        import org.eclipse.pde.internal.core.feature.FeatureChild;
0039:        import org.eclipse.pde.internal.core.feature.FeatureImport;
0040:        import org.eclipse.pde.internal.core.feature.FeaturePlugin;
0041:        import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSConstants;
0042:        import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSObject;
0043:        import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSConstants;
0044:        import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSObject;
0045:        import org.eclipse.pde.internal.core.ifeature.IFeature;
0046:        import org.eclipse.pde.internal.core.ifeature.IFeatureChild;
0047:        import org.eclipse.pde.internal.core.ifeature.IFeatureData;
0048:        import org.eclipse.pde.internal.core.ifeature.IFeatureImport;
0049:        import org.eclipse.pde.internal.core.ifeature.IFeatureInfo;
0050:        import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
0051:        import org.eclipse.pde.internal.core.ifeature.IFeaturePlugin;
0052:        import org.eclipse.pde.internal.core.ifeature.IFeatureURLElement;
0053:        import org.eclipse.pde.internal.core.iproduct.IProductFeature;
0054:        import org.eclipse.pde.internal.core.iproduct.IProductPlugin;
0055:        import org.eclipse.pde.internal.core.ischema.IDocumentSection;
0056:        import org.eclipse.pde.internal.core.ischema.IMetaAttribute;
0057:        import org.eclipse.pde.internal.core.ischema.ISchema;
0058:        import org.eclipse.pde.internal.core.ischema.ISchemaAttribute;
0059:        import org.eclipse.pde.internal.core.ischema.ISchemaCompositor;
0060:        import org.eclipse.pde.internal.core.ischema.ISchemaElement;
0061:        import org.eclipse.pde.internal.core.ischema.ISchemaInclude;
0062:        import org.eclipse.pde.internal.core.ischema.ISchemaObject;
0063:        import org.eclipse.pde.internal.core.ischema.ISchemaObjectReference;
0064:        import org.eclipse.pde.internal.core.ischema.ISchemaRepeatable;
0065:        import org.eclipse.pde.internal.core.isite.ISiteArchive;
0066:        import org.eclipse.pde.internal.core.isite.ISiteCategory;
0067:        import org.eclipse.pde.internal.core.isite.ISiteCategoryDefinition;
0068:        import org.eclipse.pde.internal.core.isite.ISiteFeature;
0069:        import org.eclipse.pde.internal.core.itarget.IAdditionalLocation;
0070:        import org.eclipse.pde.internal.core.itarget.ITargetFeature;
0071:        import org.eclipse.pde.internal.core.itarget.ITargetPlugin;
0072:        import org.eclipse.pde.internal.core.itoc.ITocConstants;
0073:        import org.eclipse.pde.internal.core.plugin.ImportObject;
0074:        import org.eclipse.pde.internal.core.text.bundle.ExecutionEnvironment;
0075:        import org.eclipse.pde.internal.core.text.bundle.PackageObject;
0076:        import org.eclipse.pde.internal.core.text.toc.TocObject;
0077:        import org.eclipse.pde.internal.core.util.PDETextHelper;
0078:        import org.eclipse.pde.internal.ui.elements.NamedElement;
0079:        import org.eclipse.pde.internal.ui.util.SharedLabelProvider;
0080:        import org.eclipse.swt.graphics.Image;
0081:        import org.eclipse.swt.internal.BidiUtil;
0082:        import org.eclipse.ui.PlatformUI;
0083:        import org.osgi.framework.Version;
0084:
0085:        public class PDELabelProvider extends SharedLabelProvider {
0086:            public PDELabelProvider() {
0087:            }
0088:
0089:            public String getText(Object obj) {
0090:                if (obj instanceof  IPluginModelBase) {
0091:                    return getObjectText(((IPluginModelBase) obj)
0092:                            .getPluginBase());
0093:                }
0094:                if (obj instanceof  IPluginBase) {
0095:                    return getObjectText((IPluginBase) obj);
0096:                }
0097:                if (obj instanceof  ImportObject) {
0098:                    return getObjectText((ImportObject) obj);
0099:                }
0100:                if (obj instanceof  IProductPlugin) {
0101:                    return getObjectText((IProductPlugin) obj);
0102:                }
0103:                if (obj instanceof  BundleDescription) {
0104:                    return getObjectText((BundleDescription) obj);
0105:                }
0106:                if (obj instanceof  IPluginImport) {
0107:                    return getObjectText((IPluginImport) obj);
0108:                }
0109:                if (obj instanceof  IPluginLibrary) {
0110:                    return getObjectText((IPluginLibrary) obj);
0111:                }
0112:                if (obj instanceof  IPluginExtension) {
0113:                    return getObjectText((IPluginExtension) obj);
0114:                }
0115:                if (obj instanceof  IPluginExtensionPoint) {
0116:                    return getObjectText((IPluginExtensionPoint) obj);
0117:                }
0118:                if (obj instanceof  NamedElement) {
0119:                    return ((NamedElement) obj).getLabel();
0120:                }
0121:                if (obj instanceof  ISchemaObject) {
0122:                    return getObjectText((ISchemaObject) obj);
0123:                }
0124:                if (obj instanceof  ISimpleCSObject) {
0125:                    return getObjectText((ISimpleCSObject) obj);
0126:                }
0127:                if (obj instanceof  ICompCSObject) {
0128:                    return getObjectText((ICompCSObject) obj);
0129:                }
0130:                if (obj instanceof  TocObject) {
0131:                    return getObjectText((TocObject) obj);
0132:                }
0133:                if (obj instanceof  FeaturePlugin) {
0134:                    return getObjectText((FeaturePlugin) obj);
0135:                }
0136:                if (obj instanceof  FeatureImport) {
0137:                    return getObjectText((FeatureImport) obj);
0138:                }
0139:                if (obj instanceof  IFeatureModel) {
0140:                    return getObjectText((IFeatureModel) obj);
0141:                }
0142:                if (obj instanceof  FeatureChild) {
0143:                    return getObjectText((FeatureChild) obj);
0144:                }
0145:                if (obj instanceof  IProductFeature) {
0146:                    return getObjectText((IProductFeature) obj);
0147:                }
0148:                if (obj instanceof  ISiteFeature) {
0149:                    return getObjectText((ISiteFeature) obj);
0150:                }
0151:                if (obj instanceof  ISiteArchive) {
0152:                    return getObjectText((ISiteArchive) obj);
0153:                }
0154:                if (obj instanceof  ISiteCategoryDefinition) {
0155:                    return getObjectText((ISiteCategoryDefinition) obj);
0156:                }
0157:                if (obj instanceof  ISiteCategory) {
0158:                    return getObjectText((ISiteCategory) obj);
0159:                }
0160:                if (obj instanceof  IBuildEntry) {
0161:                    return getObjectText((IBuildEntry) obj);
0162:                }
0163:                if (obj instanceof  PackageObject) {
0164:                    return getObjectText((PackageObject) obj);
0165:                }
0166:                if (obj instanceof  ITargetPlugin) {
0167:                    return getObjectText((ITargetPlugin) obj);
0168:                }
0169:                if (obj instanceof  ITargetFeature) {
0170:                    return getObjectText((ITargetFeature) obj);
0171:                }
0172:                if (obj instanceof  IAdditionalLocation) {
0173:                    return getObjectText((IAdditionalLocation) obj);
0174:                }
0175:                if (obj instanceof  ExecutionEnvironment) {
0176:                    return getObjectText((ExecutionEnvironment) obj);
0177:                }
0178:                return super .getText(obj);
0179:            }
0180:
0181:            private String getObjectText(ExecutionEnvironment environment) {
0182:                return preventNull(environment.getName());
0183:            }
0184:
0185:            public String getObjectText(IPluginBase pluginBase) {
0186:                String name = isFullNameModeEnabled() ? pluginBase
0187:                        .getTranslatedName() : pluginBase.getId();
0188:                name = preventNull(name);
0189:                String version = pluginBase.getVersion();
0190:
0191:                String text;
0192:
0193:                if (version != null && version.length() > 0)
0194:                    text = name + ' ' + formatVersion(pluginBase.getVersion());
0195:                else
0196:                    text = name;
0197:                if (pluginBase.getModel() != null
0198:                        && !pluginBase.getModel().isInSync())
0199:                    text += " " + PDEUIMessages.PluginModelManager_outOfSync; //$NON-NLS-1$
0200:                return text;
0201:            }
0202:
0203:            private String preventNull(String text) {
0204:                return text != null ? text : ""; //$NON-NLS-1$
0205:            }
0206:
0207:            public String getObjectText(IPluginExtension extension) {
0208:                return preventNull(isFullNameModeEnabled() ? extension
0209:                        .getTranslatedName() : extension.getPoint());
0210:            }
0211:
0212:            public String getObjectText(IPluginExtensionPoint point) {
0213:                return preventNull(isFullNameModeEnabled() ? point
0214:                        .getTranslatedName() : point.getId());
0215:            }
0216:
0217:            public String getObjectText(ImportObject obj) {
0218:                String version = obj.getImport().getVersion();
0219:                if (version != null && version.length() > 0)
0220:                    version = formatVersion(version);
0221:
0222:                String text = isFullNameModeEnabled() ? obj.toString()
0223:                        : preventNull(obj.getId());
0224:                return version == null || version.length() == 0 ? text : text
0225:                        + " " + version; //$NON-NLS-1$
0226:            }
0227:
0228:            public String getObjectText(IProductPlugin obj) {
0229:                if (isFullNameModeEnabled()) {
0230:                    String id = obj.getId();
0231:                    IPluginModelBase model = PluginRegistry.findModel(obj
0232:                            .getId());
0233:                    if (model != null) {
0234:                        return model.getPluginBase().getTranslatedName();
0235:                    }
0236:                    return id != null ? id : "?"; //$NON-NLS-1$
0237:                }
0238:                return preventNull(obj.getId());
0239:            }
0240:
0241:            public String getObjectText(BundleDescription bundle) {
0242:                String id = bundle.getSymbolicName();
0243:                if (isFullNameModeEnabled()) {
0244:                    IPluginModelBase model = PluginRegistry.findModel(bundle);
0245:                    if (model != null) {
0246:                        return model.getPluginBase().getTranslatedName();
0247:                    }
0248:                    return id != null ? id : "?"; //$NON-NLS-1$
0249:                }
0250:                return preventNull(id);
0251:            }
0252:
0253:            public String getObjectText(IPluginImport obj) {
0254:                if (isFullNameModeEnabled()) {
0255:                    String id = obj.getId();
0256:                    IPluginModelBase model = PluginRegistry.findModel(obj
0257:                            .getId());
0258:                    if (model != null) {
0259:                        return model.getPluginBase().getTranslatedName();
0260:                    }
0261:                    return id != null ? id : "?"; //$NON-NLS-1$
0262:                }
0263:                return preventNull(obj.getId());
0264:            }
0265:
0266:            public String getObjectText(IBuildEntry obj) {
0267:                return obj.getName();
0268:            }
0269:
0270:            public String getObjectText(IPluginLibrary obj) {
0271:                return preventNull(obj.getName());
0272:            }
0273:
0274:            public String getObjectText(ISchemaObject obj) {
0275:                StringBuffer text = new StringBuffer(obj.getName());
0276:                if (obj instanceof  ISchemaRepeatable) {
0277:                    ISchemaRepeatable rso = (ISchemaRepeatable) obj;
0278:                    boolean unbounded = rso.getMaxOccurs() == Integer.MAX_VALUE;
0279:                    int maxOccurs = rso.getMaxOccurs();
0280:                    int minOccurs = rso.getMinOccurs();
0281:                    if (maxOccurs != 1 || minOccurs != 1) {
0282:                        if (isRTL() && BidiUtil.isBidiPlatform())
0283:                            text.append('\u200f');
0284:                        text.append(" ("); //$NON-NLS-1$
0285:                        text.append(minOccurs);
0286:                        text.append(" - "); //$NON-NLS-1$ //$NON-NLS-2$
0287:                        if (unbounded)
0288:                            text.append('*');
0289:                        else
0290:                            text.append(maxOccurs);
0291:                        text.append(')');
0292:                    }
0293:                }
0294:
0295:                return text.toString();
0296:            }
0297:
0298:            /**
0299:             * @param obj
0300:             * @return
0301:             */
0302:            public String getObjectText(ISimpleCSObject obj) {
0303:                int limit = 50;
0304:
0305:                if (obj.getType() == ISimpleCSConstants.TYPE_CHEAT_SHEET) {
0306:                    limit = 40;
0307:                } else if (obj.getType() == ISimpleCSConstants.TYPE_ITEM) {
0308:                    limit = 36;
0309:                } else if (obj.getType() == ISimpleCSConstants.TYPE_INTRO) {
0310:                    limit = 36;
0311:                } else if (obj.getType() == ISimpleCSConstants.TYPE_SUBITEM) {
0312:                    limit = 32;
0313:                }
0314:                return PDETextHelper.truncateAndTrailOffText(PDETextHelper
0315:                        .translateReadText(obj.getName()), limit);
0316:            }
0317:
0318:            /**
0319:             * @param obj
0320:             * @return
0321:             */
0322:            public String getObjectText(ICompCSObject obj) {
0323:                int limit = 40;
0324:                ICompCSObject parent = obj.getParent();
0325:                while (parent != null) {
0326:                    limit = limit - 4;
0327:                    parent = parent.getParent();
0328:                }
0329:                return PDETextHelper.truncateAndTrailOffText(PDETextHelper
0330:                        .translateReadText(obj.getName()), limit);
0331:            }
0332:
0333:            /**
0334:             * @param obj
0335:             * @return
0336:             */
0337:            public String getObjectText(TocObject obj) {
0338:                return PDETextHelper.translateReadText(obj.getName());
0339:            }
0340:
0341:            public String getObjectText(FeaturePlugin obj) {
0342:                String name = isFullNameModeEnabled() ? obj.getLabel() : obj
0343:                        .getId();
0344:                String version = obj.getVersion();
0345:
0346:                String text;
0347:
0348:                if (version != null && version.length() > 0)
0349:                    text = name + ' ' + formatVersion(version);
0350:                else
0351:                    text = name;
0352:                return preventNull(text);
0353:            }
0354:
0355:            public String getObjectText(FeatureImport obj) {
0356:                int type = obj.getType();
0357:                if (type == IFeatureImport.PLUGIN) {
0358:                    IPlugin plugin = obj.getPlugin();
0359:                    if (plugin != null && isFullNameModeEnabled()) {
0360:                        return preventNull(plugin.getTranslatedName());
0361:                    }
0362:                } else if (type == IFeatureImport.FEATURE) {
0363:                    IFeature feature = obj.getFeature();
0364:                    if (feature != null && isFullNameModeEnabled()) {
0365:                        return preventNull(feature.getTranslatableLabel());
0366:                    }
0367:                }
0368:                return preventNull(obj.getId());
0369:            }
0370:
0371:            public String getObjectText(IFeatureModel obj, boolean showVersion) {
0372:                IFeature feature = obj.getFeature();
0373:                String name = (isFullNameModeEnabled()) ? feature
0374:                        .getTranslatableLabel() : feature.getId();
0375:                if (!showVersion)
0376:                    return preventNull(name);
0377:                return preventNull(name) + ' '
0378:                        + formatVersion(feature.getVersion());
0379:
0380:            }
0381:
0382:            public String getObjectText(IFeatureModel obj) {
0383:                return getObjectText(obj, true);
0384:            }
0385:
0386:            public String getObjectText(FeatureChild obj) {
0387:                return preventNull(obj.getId()) + ' '
0388:                        + formatVersion(obj.getVersion());
0389:            }
0390:
0391:            public String getObjectText(IProductFeature obj) {
0392:                IFeatureModel model = PDECore.getDefault()
0393:                        .getFeatureModelManager().findFeatureModel(obj.getId());
0394:                return (model != null) ? getObjectText(model, false)
0395:                        : preventNull(obj.getId());
0396:            }
0397:
0398:            public String getObjectText(ISiteFeature obj) {
0399:                IFeatureModel model = PDECore.getDefault()
0400:                        .getFeatureModelManager().findFeatureModel(
0401:                                obj.getId(),
0402:                                obj.getVersion() != null ? obj.getVersion()
0403:                                        : "0.0.0"); //$NON-NLS-1$
0404:                if (model != null)
0405:                    return getObjectText(model);
0406:                return preventNull(obj.getURL());
0407:            }
0408:
0409:            public String getObjectText(ISiteArchive obj) {
0410:                return preventNull(obj.getPath());
0411:            }
0412:
0413:            public String getObjectText(ISiteCategoryDefinition obj) {
0414:                return preventNull(obj.getLabel());
0415:            }
0416:
0417:            public String getObjectText(PackageObject obj) {
0418:                StringBuffer buffer = new StringBuffer(obj.getName());
0419:                String version = obj.getVersion();
0420:                if (version != null
0421:                        && !version.equals(Version.emptyVersion.toString())) {
0422:                    // Format version range for ImportPackageObject.  ExportPackageObject is handled correctly in this function
0423:                    version = formatVersion(version);
0424:                    buffer.append(' ').append(version);
0425:                }
0426:                return buffer.toString();
0427:            }
0428:
0429:            public String getObjectText(ISiteCategory obj) {
0430:                ISiteCategoryDefinition def = obj.getDefinition();
0431:                if (def != null)
0432:                    return preventNull(def.getLabel());
0433:                return preventNull(obj.getName());
0434:            }
0435:
0436:            public String getObjectText(ITargetPlugin obj) {
0437:                if (isFullNameModeEnabled()) {
0438:                    String id = obj.getId();
0439:                    IPluginModelBase model = PluginRegistry.findModel(obj
0440:                            .getId());
0441:                    if (model != null) {
0442:                        return model.getPluginBase().getTranslatedName();
0443:                    }
0444:                    return id != null ? id : "?"; //$NON-NLS-1$
0445:                }
0446:                return preventNull(obj.getId());
0447:            }
0448:
0449:            public String getObjectText(ITargetFeature obj) {
0450:                IFeatureModel model = PDECore.getDefault()
0451:                        .getFeatureModelManager().findFeatureModel(obj.getId());
0452:                return (model != null) ? getObjectText(model, false)
0453:                        : preventNull(obj.getId());
0454:            }
0455:
0456:            public String getObjectText(IAdditionalLocation obj) {
0457:                return preventNull(obj.getPath());
0458:            }
0459:
0460:            public Image getImage(Object obj) {
0461:                if (obj instanceof  IPlugin) {
0462:                    return getObjectImage((IPlugin) obj);
0463:                }
0464:                if (obj instanceof  IFragment) {
0465:                    return getObjectImage((IFragment) obj);
0466:                }
0467:                if (obj instanceof  IPluginModel) {
0468:                    return getObjectImage(((IPluginModel) obj).getPlugin());
0469:                }
0470:                if (obj instanceof  IFragmentModel) {
0471:                    return getObjectImage(((IFragmentModel) obj).getFragment());
0472:                }
0473:                if (obj instanceof  ImportObject) {
0474:                    return getObjectImage((ImportObject) obj);
0475:                }
0476:                if (obj instanceof  IPluginImport) {
0477:                    return getObjectImage((IPluginImport) obj);
0478:                }
0479:                if (obj instanceof  IProductPlugin) {
0480:                    return getObjectImage((IProductPlugin) obj);
0481:                }
0482:                if (obj instanceof  BundleDescription) {
0483:                    return getObjectImage((BundleDescription) obj);
0484:                }
0485:
0486:                if (obj instanceof  IPluginLibrary) {
0487:                    return getObjectImage((IPluginLibrary) obj);
0488:                }
0489:                if (obj instanceof  IPluginExtension) {
0490:                    return getObjectImage((IPluginExtension) obj);
0491:                }
0492:                if (obj instanceof  IPluginExtensionPoint) {
0493:                    return getObjectImage((IPluginExtensionPoint) obj);
0494:                }
0495:                if (obj instanceof  NamedElement) {
0496:                    return ((NamedElement) obj).getImage();
0497:                }
0498:                if (obj instanceof  ISchemaElement) {
0499:                    return getObjectImage((ISchemaElement) obj);
0500:                }
0501:                if (obj instanceof  ISimpleCSObject) {
0502:                    return getObjectImage((ISimpleCSObject) obj);
0503:                }
0504:                if (obj instanceof  ICompCSObject) {
0505:                    return getObjectImage((ICompCSObject) obj);
0506:                }
0507:                if (obj instanceof  TocObject) {
0508:                    return getObjectImage((TocObject) obj);
0509:                }
0510:                if (obj instanceof  ISchemaAttribute) {
0511:                    return getObjectImage((ISchemaAttribute) obj);
0512:                }
0513:                if (obj instanceof  ISchemaInclude) {
0514:                    ISchema schema = ((ISchemaInclude) obj).getIncludedSchema();
0515:                    return get(PDEPluginImages.DESC_PAGE_OBJ, schema == null
0516:                            || !schema.isValid() ? F_ERROR : 0);
0517:                }
0518:                if (obj instanceof  IDocumentSection || obj instanceof  ISchema) {
0519:                    return get(PDEPluginImages.DESC_DOC_SECTION_OBJ);
0520:                }
0521:                if (obj instanceof  ISchemaCompositor) {
0522:                    return getObjectImage((ISchemaCompositor) obj);
0523:                }
0524:                if (obj instanceof  IFeatureURLElement) {
0525:                    return getObjectImage((IFeatureURLElement) obj);
0526:                }
0527:                if (obj instanceof  IFeatureModel) {
0528:                    int flags = 0;
0529:                    if (((IFeatureModel) obj).getUnderlyingResource() == null)
0530:                        flags |= F_EXTERNAL;
0531:                    return get(PDEPluginImages.DESC_FEATURE_OBJ, flags);
0532:                }
0533:                if (obj instanceof  IFeatureChild) {
0534:                    return getObjectImage((IFeatureChild) obj);
0535:                }
0536:                if (obj instanceof  IProductFeature) {
0537:                    return getObjectImage((IProductFeature) obj);
0538:                }
0539:                if (obj instanceof  IFeaturePlugin) {
0540:                    return getObjectImage((IFeaturePlugin) obj);
0541:                }
0542:                if (obj instanceof  IFeatureData) {
0543:                    return getObjectImage((IFeatureData) obj);
0544:                }
0545:                if (obj instanceof  IFeatureImport) {
0546:                    return getObjectImage((IFeatureImport) obj);
0547:                }
0548:                if (obj instanceof  IFeatureInfo) {
0549:                    return getObjectImage((IFeatureInfo) obj);
0550:                }
0551:                if (obj instanceof  IBuildEntry) {
0552:                    return get(PDEPluginImages.DESC_BUILD_VAR_OBJ);
0553:                }
0554:                if (obj instanceof  ISiteFeature) {
0555:                    return getObjectImage((ISiteFeature) obj);
0556:                }
0557:                if (obj instanceof  ISiteArchive) {
0558:                    return getObjectImage((ISiteArchive) obj);
0559:                }
0560:                if (obj instanceof  ISiteCategoryDefinition) {
0561:                    return getObjectImage((ISiteCategoryDefinition) obj);
0562:                }
0563:                if (obj instanceof  ISiteCategory) {
0564:                    return getObjectImage((ISiteCategory) obj);
0565:                }
0566:                if (obj instanceof  PackageObject) {
0567:                    return getObjectImage((PackageObject) obj);
0568:                }
0569:                if (obj instanceof  ITargetPlugin) {
0570:                    return getObjectImage((ITargetPlugin) obj);
0571:                }
0572:                if (obj instanceof  ITargetFeature) {
0573:                    return getObjectImage((ITargetFeature) obj);
0574:                }
0575:                if (obj instanceof  IAdditionalLocation) {
0576:                    return getObjectImage((IAdditionalLocation) obj);
0577:                }
0578:                if (obj instanceof  ExecutionEnvironment) {
0579:                    return getObjectImage((ExecutionEnvironment) obj);
0580:                }
0581:                if (obj instanceof  ResolverError) {
0582:                    return getObjectImage((ResolverError) obj);
0583:                }
0584:                return super .getImage(obj);
0585:            }
0586:
0587:            private Image getObjectImage(ResolverError obj) {
0588:                int type = obj.getType();
0589:                switch (type) {
0590:                case ResolverError.MISSING_IMPORT_PACKAGE:
0591:                case ResolverError.EXPORT_PACKAGE_PERMISSION:
0592:                case ResolverError.IMPORT_PACKAGE_PERMISSION:
0593:                case ResolverError.IMPORT_PACKAGE_USES_CONFLICT:
0594:                    return JavaUI.getSharedImages().getImage(
0595:                            ISharedImages.IMG_OBJS_PACKAGE);
0596:                case ResolverError.MISSING_EXECUTION_ENVIRONMENT:
0597:                    return get(PDEPluginImages.DESC_JAVA_LIB_OBJ);
0598:                case ResolverError.MISSING_FRAGMENT_HOST:
0599:                case ResolverError.MISSING_REQUIRE_BUNDLE:
0600:                case ResolverError.PROVIDE_BUNDLE_PERMISSION:
0601:                case ResolverError.REQUIRE_BUNDLE_PERMISSION:
0602:                case ResolverError.REQUIRE_BUNDLE_USES_CONFLICT:
0603:                case ResolverError.HOST_BUNDLE_PERMISSION:
0604:                    return get(PDEPluginImages.DESC_PLUGIN_OBJ);
0605:                }
0606:                return null;
0607:            }
0608:
0609:            private Image getObjectImage(ExecutionEnvironment environment) {
0610:                return get(PDEPluginImages.DESC_JAVA_LIB_OBJ);
0611:            }
0612:
0613:            private Image getObjectImage(IPlugin plugin) {
0614:                return getObjectImage(plugin, false, false);
0615:            }
0616:
0617:            private Image getObjectImage(BundleDescription bundle) {
0618:                return bundle.getHost() == null ? get(PDEPluginImages.DESC_PLUGIN_OBJ)
0619:                        : get(PDEPluginImages.DESC_FRAGMENT_OBJ);
0620:            }
0621:
0622:            public Image getObjectImage(IPlugin plugin, boolean checkEnabled,
0623:                    boolean javaSearch) {
0624:                IPluginModelBase model = plugin.getPluginModel();
0625:                int flags = getModelFlags(model);
0626:
0627:                if (javaSearch)
0628:                    flags |= F_JAVA;
0629:                ImageDescriptor desc = PDEPluginImages.DESC_PLUGIN_OBJ;
0630:                if (checkEnabled && model.isEnabled() == false)
0631:                    desc = PDEPluginImages.DESC_EXT_PLUGIN_OBJ;
0632:                return get(desc, flags);
0633:            }
0634:
0635:            private int getModelFlags(IPluginModelBase model) {
0636:                int flags = 0;
0637:                if (!(model.isLoaded() && model.isInSync()))
0638:                    flags = F_ERROR;
0639:                IResource resource = model.getUnderlyingResource();
0640:                if (resource == null) {
0641:                    flags |= F_EXTERNAL;
0642:                } else {
0643:                    IProject project = resource.getProject();
0644:                    try {
0645:                        if (WorkspaceModelManager.isBinaryProject(project)) {
0646:                            String property = project
0647:                                    .getPersistentProperty(PDECore.EXTERNAL_PROJECT_PROPERTY);
0648:                            if (property != null) {
0649:                                /*
0650:                                if (property.equals(PDECore.EXTERNAL_PROJECT_VALUE))
0651:                                	flags |= F_EXTERNAL;
0652:                                else if (property.equals(PDECore.BINARY_PROJECT_VALUE))
0653:                                 */
0654:                                flags |= F_BINARY;
0655:                            }
0656:                        }
0657:                    } catch (CoreException e) {
0658:                    }
0659:                }
0660:                return flags;
0661:            }
0662:
0663:            private Image getObjectImage(IFragment fragment) {
0664:                return getObjectImage(fragment, false, false);
0665:            }
0666:
0667:            public Image getObjectImage(IFragment fragment,
0668:                    boolean checkEnabled, boolean javaSearch) {
0669:                IPluginModelBase model = fragment.getPluginModel();
0670:                int flags = getModelFlags(model);
0671:                if (javaSearch)
0672:                    flags |= F_JAVA;
0673:                ImageDescriptor desc = PDEPluginImages.DESC_FRAGMENT_OBJ;
0674:                if (checkEnabled && !model.isEnabled())
0675:                    desc = PDEPluginImages.DESC_EXT_FRAGMENT_OBJ;
0676:                return get(desc, flags);
0677:            }
0678:
0679:            private Image getObjectImage(ImportObject iobj) {
0680:                int flags = 0;
0681:                IPluginImport iimport = iobj.getImport();
0682:                if (!iobj.isResolved())
0683:                    flags = iimport.isOptional() ? F_WARNING : F_ERROR;
0684:                else if (iimport.isReexported())
0685:                    flags = F_EXPORT;
0686:                IPlugin plugin = iobj.getPlugin();
0687:                if (plugin != null) {
0688:                    IPluginModelBase model = plugin.getPluginModel();
0689:                    flags |= getModelFlags(model);
0690:                }
0691:                return get(getRequiredPluginImageDescriptor(iimport), flags);
0692:            }
0693:
0694:            protected ImageDescriptor getRequiredPluginImageDescriptor(
0695:                    IPluginImport iobj) {
0696:                return PDEPluginImages.DESC_REQ_PLUGIN_OBJ;
0697:            }
0698:
0699:            private Image getObjectImage(IPluginImport obj) {
0700:                int flags = 0;
0701:                if (obj.isReexported())
0702:                    flags = F_EXPORT;
0703:                return get(getRequiredPluginImageDescriptor(obj), flags);
0704:            }
0705:
0706:            private Image getObjectImage(IProductPlugin obj) {
0707:                BundleDescription desc = TargetPlatformHelper.getState()
0708:                        .getBundle(obj.getId(), null);
0709:                if (desc != null) {
0710:                    return desc.getHost() == null ? get(PDEPluginImages.DESC_PLUGIN_OBJ)
0711:                            : get(PDEPluginImages.DESC_FRAGMENT_OBJ);
0712:                }
0713:                return get(PDEPluginImages.DESC_PLUGIN_OBJ, F_ERROR);
0714:            }
0715:
0716:            private Image getObjectImage(IPluginLibrary library) {
0717:                return get(PDEPluginImages.DESC_JAVA_LIB_OBJ);
0718:            }
0719:
0720:            private Image getObjectImage(IPluginExtension point) {
0721:                return get(PDEPluginImages.DESC_EXTENSION_OBJ);
0722:            }
0723:
0724:            private Image getObjectImage(IPluginExtensionPoint point) {
0725:                return get(PDEPluginImages.DESC_EXT_POINT_OBJ);
0726:            }
0727:
0728:            private Image getObjectImage(ISimpleCSObject object) {
0729:
0730:                if (object.getType() == ISimpleCSConstants.TYPE_ITEM) {
0731:                    return get(PDEPluginImages.DESC_CSITEM_OBJ);
0732:                } else if (object.getType() == ISimpleCSConstants.TYPE_SUBITEM) {
0733:                    return get(PDEPluginImages.DESC_CSSUBITEM_OBJ);
0734:                } else if (object.getType() == ISimpleCSConstants.TYPE_REPEATED_SUBITEM) {
0735:                    return get(PDEPluginImages.DESC_CSUNSUPPORTED_OBJ);
0736:                } else if (object.getType() == ISimpleCSConstants.TYPE_CONDITIONAL_SUBITEM) {
0737:                    return get(PDEPluginImages.DESC_CSUNSUPPORTED_OBJ);
0738:                } else if (object.getType() == ISimpleCSConstants.TYPE_CHEAT_SHEET) {
0739:                    return get(PDEPluginImages.DESC_SIMPLECS_OBJ);
0740:                } else if (object.getType() == ISimpleCSConstants.TYPE_INTRO) {
0741:                    return get(PDEPluginImages.DESC_CSINTRO_OBJ);
0742:                } else if (object.getType() == ISimpleCSConstants.TYPE_PERFORM_WHEN) {
0743:                    return get(PDEPluginImages.DESC_CSUNSUPPORTED_OBJ);
0744:                }
0745:                return get(PDEPluginImages.DESC_SIMPLECS_OBJ, F_ERROR);
0746:            }
0747:
0748:            /**
0749:             * @param object
0750:             * @return
0751:             */
0752:            private Image getObjectImage(ICompCSObject object) {
0753:
0754:                if (object.getType() == ICompCSConstants.TYPE_TASK) {
0755:                    return get(PDEPluginImages.DESC_SIMPLECS_OBJ);
0756:                } else if (object.getType() == ICompCSConstants.TYPE_TASKGROUP) {
0757:                    return get(PDEPluginImages.DESC_CSTASKGROUP_OBJ);
0758:                } else if (object.getType() == ICompCSConstants.TYPE_COMPOSITE_CHEATSHEET) {
0759:                    return get(PDEPluginImages.DESC_COMPCS_OBJ);
0760:                }
0761:                return get(PDEPluginImages.DESC_SIMPLECS_OBJ, F_ERROR);
0762:            }
0763:
0764:            /**
0765:             * @param object
0766:             * @return
0767:             */
0768:            private Image getObjectImage(TocObject object) {
0769:                switch (object.getType()) {
0770:                case ITocConstants.TYPE_TOC: {
0771:                    return get(PDEPluginImages.DESC_TOC_OBJ);
0772:                }
0773:                case ITocConstants.TYPE_TOPIC: { //Return the leaf topic icon for a topic with no children
0774:                    if (object.getChildren().isEmpty()) {
0775:                        return get(PDEPluginImages.DESC_TOC_LEAFTOPIC_OBJ);
0776:                    }
0777:                    //Return the regular topic icon for a topic with children
0778:                    return get(PDEPluginImages.DESC_TOC_TOPIC_OBJ);
0779:                }
0780:                case ITocConstants.TYPE_LINK: {
0781:                    return get(PDEPluginImages.DESC_TOC_LINK_OBJ);
0782:                }
0783:                case ITocConstants.TYPE_ANCHOR: {
0784:                    return get(PDEPluginImages.DESC_TOC_ANCHOR_OBJ);
0785:                }
0786:                default:
0787:                    return get(PDEPluginImages.DESC_SIMPLECS_OBJ, F_ERROR);
0788:                }
0789:            }
0790:
0791:            private Image getObjectImage(ISchemaElement element) {
0792:                int flags = 0;
0793:                if (element instanceof  ISchemaObjectReference
0794:                        && ((ISchemaObjectReference) element)
0795:                                .getReferencedObject() == null)
0796:                    flags |= F_ERROR;
0797:                ImageDescriptor desc = element instanceof  ISchemaObjectReference ? PDEPluginImages.DESC_XML_ELEMENT_REF_OBJ
0798:                        : PDEPluginImages.DESC_GEL_SC_OBJ;
0799:                return get(desc, flags);
0800:            }
0801:
0802:            private Image getObjectImage(ISchemaAttribute att) {
0803:                if (att.getKind() == IMetaAttribute.JAVA)
0804:                    return get(PDEPluginImages.DESC_ATT_CLASS_OBJ);
0805:                if (att.getKind() == IMetaAttribute.RESOURCE)
0806:                    return get(PDEPluginImages.DESC_ATT_FILE_OBJ);
0807:                if (att.getUse() == ISchemaAttribute.REQUIRED)
0808:                    return get(PDEPluginImages.DESC_ATT_REQ_OBJ);
0809:                return get(PDEPluginImages.DESC_ATT_IMPL_OBJ);
0810:            }
0811:
0812:            private Image getObjectImage(ISchemaCompositor compositor) {
0813:                switch (compositor.getKind()) {
0814:                case ISchemaCompositor.ALL:
0815:                    return get(PDEPluginImages.DESC_ALL_SC_OBJ);
0816:                case ISchemaCompositor.CHOICE:
0817:                    return get(PDEPluginImages.DESC_CHOICE_SC_OBJ);
0818:                case ISchemaCompositor.SEQUENCE:
0819:                    return get(PDEPluginImages.DESC_SEQ_SC_OBJ);
0820:                case ISchemaCompositor.GROUP:
0821:                    return get(PDEPluginImages.DESC_GROUP_SC_OBJ);
0822:                }
0823:                return null;
0824:            }
0825:
0826:            private Image getObjectImage(IFeatureURLElement url) {
0827:                return get(PDEPluginImages.DESC_LINK_OBJ);
0828:            }
0829:
0830:            private Image getObjectImage(IFeaturePlugin plugin) {
0831:                int flags = 0;
0832:                if (((FeaturePlugin) plugin).getPluginBase() == null) {
0833:                    int cflag = CompilerFlags.getFlag(null,
0834:                            CompilerFlags.F_UNRESOLVED_PLUGINS);
0835:                    if (cflag == CompilerFlags.ERROR)
0836:                        flags = F_ERROR;
0837:                    else if (cflag == CompilerFlags.WARNING)
0838:                        flags = F_WARNING;
0839:                }
0840:                if (plugin.isFragment())
0841:                    return get(PDEPluginImages.DESC_FRAGMENT_OBJ, flags);
0842:                return get(PDEPluginImages.DESC_PLUGIN_OBJ, flags);
0843:            }
0844:
0845:            private Image getObjectImage(IFeatureChild feature) {
0846:                int flags = 0;
0847:                if (((FeatureChild) feature).getReferencedFeature() == null) {
0848:                    int cflag = CompilerFlags.getFlag(null,
0849:                            CompilerFlags.F_UNRESOLVED_FEATURES);
0850:                    if (cflag == CompilerFlags.ERROR)
0851:                        flags = F_ERROR;
0852:                    else if (cflag == CompilerFlags.WARNING)
0853:                        flags = F_WARNING;
0854:                }
0855:                return get(PDEPluginImages.DESC_FEATURE_OBJ, flags);
0856:            }
0857:
0858:            private Image getObjectImage(IProductFeature feature) {
0859:                return get(PDEPluginImages.DESC_FEATURE_OBJ, 0);
0860:            }
0861:
0862:            private Image getObjectImage(IFeatureData data) {
0863:                int flags = 0;
0864:                if (!data.exists())
0865:                    flags = F_ERROR;
0866:                ImageDescriptor desc = PlatformUI.getWorkbench()
0867:                        .getEditorRegistry().getImageDescriptor(data.getId());
0868:                return get(desc, flags);
0869:            }
0870:
0871:            private Image getObjectImage(IFeatureImport obj) {
0872:                FeatureImport iimport = (FeatureImport) obj;
0873:                int type = iimport.getType();
0874:                ImageDescriptor base;
0875:                int flags = 0;
0876:
0877:                if (type == IFeatureImport.FEATURE) {
0878:                    base = PDEPluginImages.DESC_FEATURE_OBJ;
0879:                    IFeature feature = iimport.getFeature();
0880:                    if (feature == null)
0881:                        flags = F_ERROR;
0882:                } else {
0883:                    base = PDEPluginImages.DESC_REQ_PLUGIN_OBJ;
0884:                    IPlugin plugin = iimport.getPlugin();
0885:                    if (plugin == null)
0886:                        flags = F_ERROR;
0887:                }
0888:
0889:                return get(base, flags);
0890:            }
0891:
0892:            private Image getObjectImage(IFeatureInfo info) {
0893:                int flags = 0;
0894:                String text = info.getDescription();
0895:                if (text != null)
0896:                    text = text.trim();
0897:                if (text != null && text.length() > 0) {
0898:                    // complete
0899:                    flags = F_EDIT;
0900:                }
0901:                return get(PDEPluginImages.DESC_DOC_SECTION_OBJ, flags);
0902:            }
0903:
0904:            public Image getObjectImage(ISiteFeature obj) {
0905:                int flags = 0;
0906:                if (obj.getArchiveFile() != null) {
0907:                    flags = F_BINARY;
0908:                }
0909:                return get(PDEPluginImages.DESC_JAVA_LIB_OBJ, flags);
0910:            }
0911:
0912:            public Image getObjectImage(ISiteArchive obj) {
0913:                return get(PDEPluginImages.DESC_JAVA_LIB_OBJ, 0);
0914:            }
0915:
0916:            public Image getObjectImage(ISiteCategoryDefinition obj) {
0917:                return get(PDEPluginImages.DESC_CATEGORY_OBJ);
0918:            }
0919:
0920:            public Image getObjectImage(ISiteCategory obj) {
0921:                int flags = obj.getDefinition() == null ? F_ERROR : 0;
0922:                return get(PDEPluginImages.DESC_CATEGORY_OBJ, flags);
0923:            }
0924:
0925:            public Image getObjectImage(PackageObject obj) {
0926:                return JavaUI.getSharedImages().getImage(
0927:                        ISharedImages.IMG_OBJS_PACKAGE);
0928:            }
0929:
0930:            public Image getObjectImage(ITargetPlugin obj) {
0931:                BundleDescription desc = TargetPlatformHelper.getState()
0932:                        .getBundle(obj.getId(), null);
0933:                if (desc != null) {
0934:                    return desc.getHost() == null ? get(PDEPluginImages.DESC_PLUGIN_OBJ)
0935:                            : get(PDEPluginImages.DESC_FRAGMENT_OBJ);
0936:                }
0937:                return get(PDEPluginImages.DESC_PLUGIN_OBJ, 0);
0938:            }
0939:
0940:            public Image getObjectImage(ITargetFeature obj) {
0941:                return get(PDEPluginImages.DESC_FEATURE_OBJ, 0);
0942:            }
0943:
0944:            public Image getObjectImage(IAdditionalLocation obj) {
0945:                return get(PDEPluginImages.DESC_SITE_OBJ);
0946:            }
0947:
0948:            public boolean isFullNameModeEnabled() {
0949:                return PDEPlugin.isFullNameModeEnabled();
0950:            }
0951:
0952:            /*
0953:             * BIDI support (bug 183417)
0954:             * Any time we display a bracketed version, we should preface it with /u200f (zero width arabic character).
0955:             * Then inside the bracket, we should include /u200e (zero width latin character).  Since the leading separator
0956:             * will be resolved based on its surrounding text, when it is surrounded by a arabic character and a latin character
0957:             * the bracket will take the proper shape based on the underlying embedded direction.  The latin character must
0958:             * come after the bracket since versions are represented with latin numbers.  This ensure proper number format.
0959:             */
0960:
0961:            /*
0962:             * returns true if instance has either arabic of hebrew locale (text displayed RTL)
0963:             */
0964:            private static boolean isRTL() {
0965:                Locale locale = Locale.getDefault();
0966:                String localeString = locale.toString();
0967:                return (localeString.startsWith("ar") || //$NON-NLS-1$
0968:                localeString.startsWith("he")); //$NON-NLS-1$
0969:            }
0970:
0971:            /*
0972:             * Returns a String containing the unicode to properly display the version ranging when running bidi. 
0973:             */
0974:            public static String formatVersion(String versionRange) {
0975:                boolean isBasicVersion = versionRange == null
0976:                        || versionRange.length() == 0
0977:                        || Character.isDigit(versionRange.charAt(0));
0978:                if (isBasicVersion) {
0979:                    if (BidiUtil.isBidiPlatform())
0980:                        // The versionRange is a single version.  Since parenthesis is neutral, it direction is determined by leading and following character.
0981:                        // Since leading character is arabic and following character is latin, the parenthesis will take default (proper) direction.  
0982:                        // Must have the following character be the latin character to ensure version is formatted as latin (LTR)
0983:                        return "\u200f(\u200e" + versionRange + ")"; //$NON-NLS-1$ //$NON-NLS-2$
0984:                    return "(" + versionRange + ')'; //$NON-NLS-1$
0985:                } else if (isRTL() && BidiUtil.isBidiPlatform()) {
0986:                    // when running RTL and formatting a versionRange, we need to break up the String to make sure it is properly formatted.
0987:                    // A version should always be formatted LTR (start with \u202d, ends with \u202c) since it is composed of latin characaters.  
0988:                    // With specifying this format, if the qualifier has a latin character, it will not be formatted correctly.
0989:                    int index = versionRange.indexOf(',');
0990:                    if (index > 0) {
0991:                        // begin with zero length arabic character so version appears on left (correct) side of id.  
0992:                        // Then add RTL strong encoding so parentheses and comma have RTL formatting. 
0993:                        StringBuffer buffer = new StringBuffer("\u200f\u202e"); //$NON-NLS-1$
0994:                        // begin with leading separator (either parenthesis or bracket)
0995:                        buffer.append(versionRange.charAt(0));
0996:                        // start LTR encoding for min version
0997:                        buffer.append('\u202d');
0998:                        // min version
0999:                        buffer.append(versionRange.substring(1, index));
1000:                        // end LTR encoding, add ',' (which will be RTL due to first RTL strong encoding), and start LTR encoding for max version
1001:                        // We require a space between the two numbers otherwise it is considered 1 number in arabic (comma is digit grouping system).
1002:                        buffer.append("\u202c, \u202d"); //$NON-NLS-1$
1003:                        // max version
1004:                        buffer.append(versionRange.substring(index + 1,
1005:                                versionRange.length() - 1));
1006:                        // end LTR encoding
1007:                        buffer.append('\u202c');
1008:                        // add trailing separator
1009:                        buffer.append(versionRange
1010:                                .charAt(versionRange.length() - 1));
1011:                        return buffer.toString();
1012:                    }
1013:                    //			} else {
1014:                    //			    since the version is LTR and we are running LTR, do nothing.  This is the case for version ranges when run in LTR
1015:                }
1016:                return versionRange;
1017:            }
1018:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.