KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > feature > FeaturePropertySource


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 Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.editor.feature;
12
13 import java.util.*;
14
15 import org.eclipse.jface.viewers.*;
16 import org.eclipse.pde.internal.core.ifeature.*;
17 import org.eclipse.pde.internal.ui.editor.*;
18 import org.eclipse.ui.views.properties.*;
19
20 public abstract class FeaturePropertySource implements IPropertySource {
21     protected IFeatureObject object;
22
23     public FeaturePropertySource(IFeatureObject object) {
24         this.object = object;
25     }
26     protected PropertyDescriptor createTextPropertyDescriptor(
27         String JavaDoc name,
28         String JavaDoc displayName) {
29         if (isEditable())
30             return new ModifiedTextPropertyDescriptor(name, displayName);
31         else
32             return new PropertyDescriptor(name, displayName);
33     }
34
35     protected PropertyDescriptor createChoicePropertyDescriptor(
36         String JavaDoc name,
37         String JavaDoc displayName,
38         final String JavaDoc[] choices) {
39         if (isEditable()) {
40             PropertyDescriptor desc = new ComboBoxPropertyDescriptor(name, displayName, choices);
41             desc.setLabelProvider(new LabelProvider() {
42                 public String JavaDoc getText(Object JavaDoc obj) {
43                     Integer JavaDoc index = (Integer JavaDoc)obj;
44                     return choices[index.intValue()];
45                 }
46             });
47             return desc;
48         } else
49             return new PropertyDescriptor(name, displayName);
50     }
51     public Object JavaDoc getEditableValue() {
52         return null;
53     }
54     public boolean isEditable() {
55         return object.getModel().isEditable();
56     }
57     public boolean isPropertySet(Object JavaDoc property) {
58         return false;
59     }
60     public void resetPropertyValue(Object JavaDoc property) {
61     }
62     protected IPropertyDescriptor[] toDescriptorArray(Vector result) {
63         IPropertyDescriptor[] array = new IPropertyDescriptor[result.size()];
64         result.copyInto(array);
65         return array;
66     }
67 }
68
Popular Tags