KickJava   Java API By Example, From Geeks To Geeks.

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


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.Schema;
27 import org.eclipse.swt.graphics.Image;
28 import org.eclipse.ui.plugin.AbstractUIPlugin;
29
30
31 /**
32  * Nasty trick to display object-classes attributes in the tree-viewer
33  */

34 public class SchemaWrapper extends TreeNode
35 {
36     /** The associated schema */
37     private Schema mySchema;
38
39
40     /**
41      * Default constructor
42      * @param mySchema
43      * @param parent
44      */

45     public SchemaWrapper( Schema mySchema, ITreeNode parent )
46     {
47         super( parent );
48         this.mySchema = mySchema;
49     }
50
51
52     /**
53      * @return the wrapped schema
54      */

55     public Schema getMySchema()
56     {
57         return mySchema;
58     }
59
60
61     /* (non-Javadoc)
62      * @see org.apache.directory.ldapstudio.schemas.view.viewers.wrappers.TreeNode#getImage()
63      */

64     public Image getImage()
65     {
66         if ( this.mySchema.type.equals( Schema.SchemaType.coreSchema ) )
67         {
68             return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_SCHEMA_CORE )
69                 .createImage();
70         }
71         else
72         {
73             return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID, PluginConstants.IMG_SCHEMA )
74                 .createImage();
75         }
76     }
77
78
79     /**
80      * Gets the name of the schema.
81      *
82      * @return
83      * the name of the schema
84      */

85     public String JavaDoc getName()
86     {
87         String JavaDoc res = ""; //$NON-NLS-1$
88
if ( mySchema.hasBeenModified() )
89             res += "*"; //$NON-NLS-1$
90
return res + mySchema.getName();
91     }
92
93
94     /* (non-Javadoc)
95      * @see java.lang.Object#equals(java.lang.Object)
96      */

97     public boolean equals( Object JavaDoc obj )
98     {
99         if ( obj instanceof SchemaWrapper )
100         {
101             SchemaWrapper compared = ( SchemaWrapper ) obj;
102             return compared.getName().equals( this.getName() );
103         }
104         return false;
105     }
106
107
108     /* (non-Javadoc)
109      * @see java.lang.Object#toString()
110      */

111     public String JavaDoc toString()
112     {
113         return mySchema.getName() + " wrapper"; //$NON-NLS-1$
114
}
115 }
116
Popular Tags