Package de.innovationgate.eclipse.wgadesigner.decorators

Source Code of de.innovationgate.eclipse.wgadesigner.decorators.NatureDecorator

/*******************************************************************************
* Copyright (c) 2009, 2010 Innovation Gate GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*     Innovation Gate GmbH - initial API and implementation
******************************************************************************/
package de.innovationgate.eclipse.wgadesigner.decorators;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.ILabelDecorator;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.eclipse.team.ui.synchronize.ISynchronizeModelElement;

import de.innovationgate.eclipse.wgadesigner.WGADesignerPlugin;

public class NatureDecorator extends LabelProvider implements ILabelDecorator {

  public Image decorateImage(Image image, Object element) {
    if(element instanceof ISynchronizeModelElement) {
          ISynchronizeModelElement node = (ISynchronizeModelElement)element;
          element = node.getResource();
    }
   
    if (element instanceof IProject) {
      try {
        if (((IProject) element).hasNature(WGADesignerPlugin.NATURE_WGA_RUNTIME)) {
          return WGADesignerPlugin.getDefault().getImageRegistry().get(WGADesignerPlugin.IMAGE_WGA_RUNTIME);
        }
      } catch (CoreException e) {
        // do not decorate
      }
    }
    return image;

  }

  public String decorateText(String text, Object element) {
    return text;
  }


}
TOP

Related Classes of de.innovationgate.eclipse.wgadesigner.decorators.NatureDecorator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.