Home | History | Annotate | Download | only in descriptors
      1 /*
      2  * Copyright (C) 2008 The Android Open Source Project
      3  *
      4  * Licensed under the Eclipse Public License, Version 1.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.eclipse.org/org/documents/epl-v10.php
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.ide.eclipse.adt.internal.editors.descriptors;
     18 
     19 import com.android.ide.eclipse.adt.internal.editors.IconFactory;
     20 import com.android.ide.eclipse.adt.internal.editors.uimodel.UiAbstractTextAttributeNode;
     21 
     22 import org.eclipse.jface.viewers.ILabelProvider;
     23 import org.eclipse.jface.viewers.ILabelProviderListener;
     24 import org.eclipse.swt.graphics.Image;
     25 
     26 /**
     27  * Label provider for {@link UiAbstractTextAttributeNode}.
     28  */
     29 public class AttributeDescriptorLabelProvider implements ILabelProvider {
     30 
     31     private final static AttributeDescriptorLabelProvider sThis =
     32         new AttributeDescriptorLabelProvider();
     33 
     34     public static ILabelProvider getProvider() {
     35         return sThis;
     36     }
     37 
     38     @Override
     39     public Image getImage(Object element) {
     40         if (element instanceof UiAbstractTextAttributeNode) {
     41             UiAbstractTextAttributeNode node = (UiAbstractTextAttributeNode) element;
     42             if (node.getDescriptor().isDeprecated()) {
     43                 String v = node.getCurrentValue();
     44                 if (v != null && v.length() > 0) {
     45                     IconFactory factory = IconFactory.getInstance();
     46                     return factory.getIcon("warning"); //$NON-NLS-1$
     47                 }
     48             }
     49         }
     50 
     51         return null;
     52     }
     53 
     54     @Override
     55     public String getText(Object element) {
     56         if (element instanceof UiAbstractTextAttributeNode) {
     57             return ((UiAbstractTextAttributeNode)element).getCurrentValue();
     58         }
     59 
     60         return null;
     61     }
     62 
     63     @Override
     64     public void addListener(ILabelProviderListener listener) {
     65         // TODO Auto-generated method stub
     66 
     67     }
     68 
     69     @Override
     70     public void dispose() {
     71         // TODO Auto-generated method stub
     72 
     73     }
     74 
     75     @Override
     76     public boolean isLabelProperty(Object element, String property) {
     77         // TODO Auto-generated method stub
     78         return false;
     79     }
     80 
     81     @Override
     82     public void removeListener(ILabelProviderListener listener) {
     83         // TODO Auto-generated method stub
     84 
     85     }
     86 
     87 }
     88