Package es.iiia.sgi.providers

Source Code of es.iiia.sgi.providers.RuleLabelProvider

package es.iiia.sgi.providers;

import java.net.URL;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;

import es.iiia.sgi.Activator;
import es.iiia.shapegrammar.enums.ShapeGrammarRuleType;
import es.iiia.shapegrammar.model.NodeModel;
import es.iiia.shapegrammar.rule.RuleModel;

public class RuleLabelProvider implements ILabelProvider {

  public Image getImage(Object element) {
    ShapeGrammarRuleType type = (((RuleModel) element).getRuleType());
   
    if (type.equals(ShapeGrammarRuleType.Addition)) {
      return this.getImage("icons/rule_addition.png");
    } else if (type.equals(ShapeGrammarRuleType.Modification)) {
      return this.getImage("icons/rule_modification.png");
    }
    return this.getImage("icons/rule_substitution.png");
   
    //return PlatformUI.getWorkbench()..getSharedImages().getImage(
    //    ISharedImages.IMG_OBJ_ELEMENT);
  }

  public String getText(Object element) {
    return ((NodeModel) element).getName();
  }

  public void addListener(ILabelProviderListener listener) {
    // TODO Auto-generated method stub
   
  }

  public void dispose() {
    // TODO Auto-generated method stub
   
  }

  public boolean isLabelProperty(Object element, String property) {
    // TODO Auto-generated method stub
    return false;
  }

  public void removeListener(ILabelProviderListener listener) {
    // TODO Auto-generated method stub
   
  }
 

   protected Image getImage(String relativeURL) {
    ImageDescriptor image =  Activator.getImageDescriptor(relativeURL);
    if (image != null) {
      return image.createImage();
    }
    return null;
  }
}
TOP

Related Classes of es.iiia.sgi.providers.RuleLabelProvider

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.