KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > schema > TypeRestrictionDescriptor


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