KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 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 org.eclipse.jface.viewers.*;
14 import org.eclipse.pde.internal.core.*;
15 import org.eclipse.swt.widgets.*;
16 import org.eclipse.ui.views.properties.*;
17
18 public class PortabilityChoiceDescriptor extends PropertyDescriptor {
19     private boolean readOnly=false;
20     private Choice [] choices;
21
22 public PortabilityChoiceDescriptor(String JavaDoc name, String JavaDoc displayName, Choice[] choices, boolean readOnly) {
23     super(name, displayName);
24     this.readOnly = readOnly;
25     this.choices = choices;
26 }
27 public CellEditor createPropertyEditor(Composite parent) {
28     if (readOnly) return null;
29     return new PortabilityChoiceCellEditor(parent, choices);
30 }
31 public boolean isCompatibleWith(IPropertyDescriptor anotherProperty) {
32     if (getAlwaysIncompatible())
33         return false;
34     if (anotherProperty instanceof PortabilityChoiceDescriptor) {
35         PortabilityChoiceDescriptor spd = (PortabilityChoiceDescriptor) anotherProperty;
36
37         // Compare Name
38
if (!spd.getId().equals(getId()))
39             return false;
40
41         // Compare DisplayName
42
if (!spd.getDisplayName().equals(getDisplayName()))
43             return false;
44
45         // Compare Category
46
if (getCategory() == null) {
47             if (spd.getCategory() != null)
48                 return false;
49         } else {
50             if (!getCategory().equals(spd.getCategory()))
51                 return false;
52         }
53
54         // Nothing was different.
55
return true;
56     }
57     return false;
58 }
59 }
60
Popular Tags