Exemplo n.º 1
0
  @Override
  public Image getImage(Object element) {
    if (element == null) {
      return null;
    }

    Image image = null;

    // This first, since EClass is an EObject
    if (element instanceof EClass) {
      image = getEClassImage((EClass) element);
    } else if (element instanceof EObject) {
      image = getObjectImage(((EObject) element));
    }

    // Try registered extensions
    if (image == null) {
      image = LabelProviderExtensionHandler.INSTANCE.getImage(element);
    }

    return image;
  }
Exemplo n.º 2
0
  /**
   * @return A default name for an element.<br>
   *     This will be the element's name if of type INameable or the default Zenta name if an Zenta
   *     EObject, or a default name if blank.
   */
  @Override
  public String getLabel(Object element) {
    if (element == null) {
      return ""; //$NON-NLS-1$
    }

    String name = null;

    // Get Name
    if (element instanceof INameable) {
      name = ((INameable) element).getName();
    }

    // It's blank. Can we get a default name from its class?
    if (!StringUtils.isSet(name) && element instanceof EObject) {
      name = getDefaultName(((EObject) element).eClass());
    }

    // Yes
    if (StringUtils.isSet(name)) {
      return name;
    }

    // Defaults for empty strings
    if (element instanceof IZentaDiagramModel) {
      return Messages.ZentaLabelProvider_0;
    } else if (element instanceof ISketchModel) {
      return Messages.ZentaLabelProvider_1;
    } else if (element instanceof IDiagramModelImage) {
      return Messages.ZentaLabelProvider_2;
    }

    // If it's blank try registered extensions
    if (!StringUtils.isSet(name)) {
      name = LabelProviderExtensionHandler.INSTANCE.getLabel(element);
    }

    return StringUtils.safeString(name);
  }