KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > runtime > registry > PrerequisitePropertySource


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.runtime.registry;
12
13 import java.util.Vector JavaDoc;
14
15 import org.eclipse.core.runtime.IPluginPrerequisite;
16 import org.eclipse.pde.internal.runtime.PDERuntimeMessages;
17 import org.eclipse.ui.views.properties.*;
18
19 public class PrerequisitePropertySource extends RegistryPropertySource {
20     private IPluginPrerequisite prereq;
21     public static final String JavaDoc P_ID = "id"; //$NON-NLS-1$
22
public static final String JavaDoc P_VERSION = "version"; //$NON-NLS-1$
23
public static final String JavaDoc P_EXPORTED = "exported"; //$NON-NLS-1$
24
public static final String JavaDoc P_MATCH = "match"; //$NON-NLS-1$
25
public static final String JavaDoc P_OPTIONAL = "optional"; //$NON-NLS-1$
26
public PrerequisitePropertySource(IPluginPrerequisite prereq) {
27         this.prereq = prereq;
28     }
29     public IPropertyDescriptor[] getPropertyDescriptors() {
30         Vector JavaDoc result = new Vector JavaDoc();
31
32         result.addElement(
33             new PropertyDescriptor(
34                 P_EXPORTED,
35                 PDERuntimeMessages.RegistryView_prerequisitePR_exported));
36         result.addElement(
37             new PropertyDescriptor(
38                 P_ID,
39                 PDERuntimeMessages.RegistryView_prerequisitePR_id));
40         result.addElement(
41             new PropertyDescriptor(
42                 P_VERSION,
43                 PDERuntimeMessages.RegistryView_prerequisitePR_version));
44         result.addElement(
45             new PropertyDescriptor(
46                 P_MATCH,
47                 PDERuntimeMessages.RegistryView_prerequisitePR_match));
48         result.addElement(
49             new PropertyDescriptor(
50                 P_OPTIONAL,
51                 PDERuntimeMessages.RegistryView_prerequisitePR_optional));
52         return toDescriptorArray(result);
53         
54     }
55
56     public Object JavaDoc getPropertyValue(Object JavaDoc name) {
57         if (name.equals(P_ID))
58             return prereq.getUniqueIdentifier();
59
60         if (name.equals(P_EXPORTED))
61             return prereq.isExported() ? "true" : "false"; //$NON-NLS-1$ //$NON-NLS-2$
62

63         if (name.equals(P_VERSION)) {
64             Object JavaDoc version = prereq.getVersionIdentifier();
65             return version != null ? version.toString() : ""; //$NON-NLS-1$
66
}
67
68         if (name.equals(P_OPTIONAL))
69             return prereq.isOptional() ? "true" : "false"; //$NON-NLS-1$ //$NON-NLS-2$
70

71         if (name.equals(P_MATCH)) {
72             if (prereq.isMatchedAsCompatible())
73                 return PDERuntimeMessages.RegistryView_prerequisitePR_matchedCompatible;
74             if (prereq.isMatchedAsEquivalent())
75                 return PDERuntimeMessages.RegistryView_prerequisitePR_matchedEquivalent;
76             if (prereq.isMatchedAsExact())
77                 return PDERuntimeMessages.RegistryView_prerequisitePR_matchedExact;
78             if (prereq.isMatchedAsGreaterOrEqual())
79                 return PDERuntimeMessages.RegistryView_prerequisitePR_matchedGreaterOrEqual;
80             if (prereq.isMatchedAsPerfect())
81                 return PDERuntimeMessages.RegistryView_prerequisitePR_matchedPerfect;
82         }
83         return ""; //$NON-NLS-1$
84
}
85 }
86
Popular Tags