KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > ui > views > browser > BrowserViewLabelDecorator


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.browser.ui.views.browser;
22
23
24 import org.apache.directory.ldapstudio.browser.core.model.IEntry;
25 import org.apache.directory.ldapstudio.browser.core.model.ISearchResult;
26 import org.apache.directory.ldapstudio.browser.ui.BrowserUIConstants;
27 import org.apache.directory.ldapstudio.browser.ui.BrowserUIPlugin;
28
29 import org.eclipse.jface.viewers.IDecoration;
30 import org.eclipse.jface.viewers.ILightweightLabelDecorator;
31 import org.eclipse.jface.viewers.LabelProvider;
32
33
34 /**
35  * This class implements the label decorator for the browser view. It adds
36  * an overlay image to the main image to mark search results, filtered
37  * entries and inconsistent entries.
38  *
39  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
40  * @version $Rev$, $Date$
41  */

42 public class BrowserViewLabelDecorator extends LabelProvider implements ILightweightLabelDecorator
43 {
44
45     /**
46      * {@inheritDoc}
47      */

48     public void decorate( Object JavaDoc element, IDecoration decoration )
49     {
50         IEntry entry = null;
51
52         if ( element instanceof ISearchResult )
53         {
54             ISearchResult searchResult = ( ISearchResult ) element;
55             entry = searchResult.getEntry();
56             decoration.addOverlay( BrowserUIPlugin.getDefault().getImageDescriptor(
57                 BrowserUIConstants.IMG_OVR_SEARCHRESULT ), IDecoration.BOTTOM_RIGHT );
58         }
59         else if ( element instanceof IEntry )
60         {
61             entry = ( IEntry ) element;
62             if ( entry.getChildrenFilter() != null )
63             {
64                 decoration.addOverlay( BrowserUIPlugin.getDefault().getImageDescriptor(
65                     BrowserUIConstants.IMG_OVR_FILTERED ), IDecoration.BOTTOM_RIGHT );
66             }
67         }
68         else
69         {
70             decoration.addOverlay( null, IDecoration.BOTTOM_RIGHT );
71         }
72
73         if ( entry != null )
74         {
75             if ( !entry.isConsistent() )
76             {
77                 decoration.addOverlay( BrowserUIPlugin.getDefault().getImageDescriptor(
78                     BrowserUIConstants.IMG_OVR_ERROR ), IDecoration.BOTTOM_LEFT );
79             }
80             else if ( !entry.isDirectoryEntry() )
81             {
82                 decoration.addOverlay( BrowserUIPlugin.getDefault().getImageDescriptor(
83                     BrowserUIConstants.IMG_OVR_WARNING ), IDecoration.BOTTOM_LEFT );
84             }
85             else
86             {
87                 decoration.addOverlay( null, IDecoration.BOTTOM_LEFT );
88             }
89         }
90     }
91
92 }
93
Popular Tags