sysmodelmgr/com.symbian.smt.gui/src/com/symbian/smt/gui/OutOfSyncDecorator.java
changeset 0 522a326673b6
equal deleted inserted replaced
-1:000000000000 0:522a326673b6
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 package com.symbian.smt.gui;
       
    17 
       
    18 import org.eclipse.core.resources.IFile;
       
    19 import org.eclipse.core.resources.IProject;
       
    20 import org.eclipse.core.resources.IResource;
       
    21 import org.eclipse.core.runtime.FileLocator;
       
    22 import org.eclipse.core.runtime.Path;
       
    23 import org.eclipse.core.runtime.Platform;
       
    24 import org.eclipse.jface.resource.ImageDescriptor;
       
    25 import org.eclipse.jface.viewers.IDecoration;
       
    26 import org.eclipse.jface.viewers.ILabelProviderListener;
       
    27 import org.eclipse.jface.viewers.ILightweightLabelDecorator;
       
    28 import org.osgi.framework.Bundle;
       
    29 
       
    30 public class OutOfSyncDecorator implements ILightweightLabelDecorator {
       
    31 	private static final Bundle bundle = Platform
       
    32 			.getBundle("com.symbian.smt.gui");
       
    33 	private static final Path path = new Path("icons/SITK_Decorator_error.gif");
       
    34 	private SmmPartListener temp = new SmmPartListener();
       
    35 
       
    36 	/*
       
    37 	 * (non-Javadoc)
       
    38 	 * 
       
    39 	 * @see
       
    40 	 * org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.
       
    41 	 * jface.viewers.ILabelProviderListener)
       
    42 	 */
       
    43 	public void addListener(ILabelProviderListener listener) {
       
    44 	}
       
    45 
       
    46 	/*
       
    47 	 * (non-Javadoc)
       
    48 	 * 
       
    49 	 * @see
       
    50 	 * org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang
       
    51 	 * .Object, org.eclipse.jface.viewers.IDecoration)
       
    52 	 */
       
    53 	public void decorate(Object element, IDecoration decoration) {
       
    54 
       
    55 		String projectName = null;
       
    56 
       
    57 		if (element instanceof IFile || element instanceof IProject) {
       
    58 			IResource aResource = (IResource) element;
       
    59 			projectName = aResource.getProject().getName();
       
    60 
       
    61 			if (aResource.isDerived() || aResource instanceof IProject) {
       
    62 				decorateProject(projectName, decoration);
       
    63 			}
       
    64 		}
       
    65 	}
       
    66 
       
    67 	public void decorateProject(String projectName, IDecoration decoration) {
       
    68 		if (!temp.isInSync(projectName)) {
       
    69 			decoration.addOverlay(ImageDescriptor.createFromURL(FileLocator
       
    70 					.find(bundle, path, null)));
       
    71 		} else {
       
    72 			decoration.addOverlay(null);
       
    73 		}
       
    74 	}
       
    75 
       
    76 	/*
       
    77 	 * (non-Javadoc)
       
    78 	 * 
       
    79 	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
       
    80 	 */
       
    81 	public void dispose() {
       
    82 	}
       
    83 
       
    84 	/*
       
    85 	 * (non-Javadoc)
       
    86 	 * 
       
    87 	 * @see
       
    88 	 * org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang
       
    89 	 * .Object, java.lang.String)
       
    90 	 */
       
    91 	public boolean isLabelProperty(Object element, String property) {
       
    92 		return false;
       
    93 	}
       
    94 
       
    95 	/*
       
    96 	 * (non-Javadoc)
       
    97 	 * 
       
    98 	 * @see
       
    99 	 * org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse
       
   100 	 * .jface.viewers.ILabelProviderListener)
       
   101 	 */
       
   102 	public void removeListener(ILabelProviderListener listener) {
       
   103 	}
       
   104 }