KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > schemas > view > views > wrappers > AttributeTypeWrapper


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

20
21 package org.apache.directory.ldapstudio.schemas.view.views.wrappers;
22
23
24 import org.apache.directory.ldapstudio.schemas.Activator;
25 import org.apache.directory.ldapstudio.schemas.PluginConstants;
26 import org.apache.directory.ldapstudio.schemas.model.AttributeType;
27 import org.eclipse.swt.graphics.Image;
28 import org.eclipse.ui.plugin.AbstractUIPlugin;
29
30
31 /**
32  * This class is used to represent an attribute type in a tree viewer.
33  *
34  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
35  * @version $Rev$, $Date$
36  */

37 public class AttributeTypeWrapper extends TreeNode
38 {
39     /** The associated attribute type */
40     private AttributeType myAttributeType;
41     private State state;
42
43     public enum State
44     {
45         resolved, unResolved
46     }
47
48
49     /**
50      * Creates a new instance of AttributeTypeWrapper.
51      *
52      * @param myAttributeType
53      * the associated attribute type
54      * @param parent
55      * the parent element
56      */

57     public AttributeTypeWrapper( AttributeType myAttributeType, ITreeNode parent )
58     {
59         super( parent );
60
61         this.myAttributeType = myAttributeType;
62         this.state = State.resolved;
63     }
64
65
66     /**
67      * Gets the associated attribute type.
68      *
69      * @return
70      * the associated attribute type
71      */

72     public AttributeType getMyAttributeType()
73     {
74         return myAttributeType;
75     }
76
77
78     /* (non-Javadoc)
79      * @see org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.TreeNode#getImage()
80      */

81     public Image getImage()
82     {
83         return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_ATTRIBUTE_TYPE )
84             .createImage();
85     }
86
87
88     /* (non-Javadoc)
89      * @see java.lang.Object#equals(java.lang.Object)
90      */

91     public boolean equals( Object JavaDoc obj )
92     {
93         if ( obj instanceof AttributeTypeWrapper )
94         {
95             AttributeTypeWrapper compared = ( AttributeTypeWrapper ) obj;
96             return compared.getMyAttributeType().getOid().equals( getMyAttributeType().getOid() );
97         }
98
99         return false;
100     }
101
102
103     /* (non-Javadoc)
104      * @see java.lang.Object#toString()
105      */

106     public String JavaDoc toString()
107     {
108         return myAttributeType + " wrapper"; //$NON-NLS-1$
109
}
110
111
112     /**
113      * Gets the state of the object class wrapper.
114      *
115      * @return
116      * the state of the object class wrapper
117      */

118     public State getState()
119     {
120         return state;
121     }
122
123
124     /**
125      * Sets the state of the object class wrapper.
126      *
127      * @param state
128      * the state of the object class wrapper
129      */

130     public void setState( State state )
131     {
132         this.state = state;
133     }
134 }
135
Popular Tags