KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > view > ModelEntryPropertySource


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.ui.view;
12
13 import org.eclipse.core.resources.IResource;
14 import org.eclipse.pde.core.plugin.IPluginModelBase;
15 import org.eclipse.pde.internal.core.ModelEntry;
16 import org.eclipse.ui.views.properties.IPropertyDescriptor;
17 import org.eclipse.ui.views.properties.IPropertySource;
18 import org.eclipse.ui.views.properties.PropertyDescriptor;
19
20 public class ModelEntryPropertySource implements IPropertySource {
21     private IPropertyDescriptor [] descriptors;
22     private ModelEntry entry;
23
24     /**
25      * Constructor for FileAdapterPropertySource.
26      */

27     public ModelEntryPropertySource() {
28         super();
29     }
30     
31     public void setEntry(ModelEntry entry) {
32         this.entry = entry;
33     }
34
35     /**
36      * @see IPropertySource#getEditableValue()
37      */

38     public Object JavaDoc getEditableValue() {
39         return null;
40     }
41
42     /**
43      * @see IPropertySource#getPropertyDescriptors()
44      */

45     public IPropertyDescriptor[] getPropertyDescriptors() {
46         if (descriptors==null) {
47             descriptors = new IPropertyDescriptor[8];
48             descriptors[0] = new PropertyDescriptor("kind", "kind"); //$NON-NLS-1$ //$NON-NLS-2$
49
descriptors[1] = new PropertyDescriptor("name", "name"); //$NON-NLS-1$ //$NON-NLS-2$
50
descriptors[2] = new PropertyDescriptor("fragment", "fragment"); //$NON-NLS-1$ //$NON-NLS-2$
51
descriptors[3] = new PropertyDescriptor("path", "path"); //$NON-NLS-1$ //$NON-NLS-2$
52
descriptors[4] = new PropertyDescriptor("id", "id"); //$NON-NLS-1$ //$NON-NLS-2$
53
descriptors[5] = new PropertyDescriptor("version", "version"); //$NON-NLS-1$ //$NON-NLS-2$
54
descriptors[6] = new PropertyDescriptor("provider", "provider"); //$NON-NLS-1$ //$NON-NLS-2$
55
descriptors[7] = new PropertyDescriptor("enabled", "enabled"); //$NON-NLS-1$ //$NON-NLS-2$
56
}
57         return descriptors;
58     }
59
60     /**
61      * @see IPropertySource#getPropertyValue(Object)
62      */

63     public Object JavaDoc getPropertyValue(Object JavaDoc id) {
64         String JavaDoc key = id.toString();
65         IPluginModelBase model = entry.getActiveModel();
66         IResource resource = model.getUnderlyingResource();
67         if (key.equals("enabled")) //$NON-NLS-1$
68
return model.isEnabled()?"true":"false"; //$NON-NLS-1$ //$NON-NLS-2$
69
if (key.equals("kind")) //$NON-NLS-1$
70
return resource!=null?"workspace":"external"; //$NON-NLS-1$ //$NON-NLS-2$
71
if (key.equals("fragment")) //$NON-NLS-1$
72
return model.isFragmentModel()?"yes":"no"; //$NON-NLS-1$ //$NON-NLS-2$
73
if (key.equals("name")) //$NON-NLS-1$
74
return model.getPluginBase().getTranslatedName();
75         if (key.equals("path")) { //$NON-NLS-1$
76
if (resource!=null)
77                 return resource.getLocation().toOSString();
78             return model.getInstallLocation();
79         }
80         if (key.equals("id")) //$NON-NLS-1$
81
return model.getPluginBase().getId();
82         if (key.equals("version")) //$NON-NLS-1$
83
return model.getPluginBase().getVersion();
84         if (key.equals("provider")) //$NON-NLS-1$
85
return model.getPluginBase().getProviderName();
86         return null;
87     }
88
89     /**
90      * @see IPropertySource#isPropertySet(Object)
91      */

92     public boolean isPropertySet(Object JavaDoc id) {
93         return false;
94     }
95
96     /**
97      * @see IPropertySource#resetPropertyValue(Object)
98      */

99     public void resetPropertyValue(Object JavaDoc id) {
100     }
101
102     /**
103      * @see IPropertySource#setPropertyValue(Object, Object)
104      */

105     public void setPropertyValue(Object JavaDoc id, Object JavaDoc value) {
106     }
107
108 }
109
Popular Tags