KickJava   Java API By Example, From Geeks To Geeks.

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


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;
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.apache.directory.ldapstudio.schemas.model.ObjectClass;
28 import org.apache.directory.ldapstudio.schemas.model.SchemaElement;
29 import org.eclipse.jface.viewers.ITableLabelProvider;
30 import org.eclipse.jface.viewers.LabelProvider;
31 import org.eclipse.swt.graphics.Image;
32 import org.eclipse.ui.plugin.AbstractUIPlugin;
33
34
35 /**
36  * Label provider for the search view
37  *
38  */

39 public class SearchViewLabelProvider extends LabelProvider implements ITableLabelProvider
40 {
41
42     /* (non-Javadoc)
43      * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
44      */

45     public Image getColumnImage( Object JavaDoc element, int columnIndex )
46     {
47         if ( columnIndex == 0 )
48         {
49             if ( element instanceof ObjectClass )
50             {
51                 return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
52                     PluginConstants.IMG_OBJECT_CLASS ).createImage();
53             }
54
55             if ( element instanceof AttributeType )
56             {
57                 return AbstractUIPlugin.imageDescriptorFromPlugin( Activator.PLUGIN_ID,
58                     PluginConstants.IMG_ATTRIBUTE_TYPE ).createImage();
59             }
60         }
61
62         return null;
63     }
64
65
66     /* (non-Javadoc)
67      * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
68      */

69     public String JavaDoc getColumnText( Object JavaDoc element, int columnIndex )
70     {
71         String JavaDoc result = ""; //$NON-NLS-1$
72
if ( element instanceof SchemaElement )
73         {
74             SchemaElement schemaElement = ( SchemaElement ) element;
75             switch ( columnIndex )
76             {
77                 case 0: // COMPLETED_COLUMN
78
break;
79                 case 1:
80                     result = schemaElement.getNames()[0];
81                     break;
82                 case 2:
83                     result = schemaElement.getOriginatingSchema().getName();
84                     break;
85                 default:
86                     break;
87             }
88         }
89         return result;
90     }
91
92 }
93
Popular Tags