@Override
    protected void doDrawCellContent(
        GC gc, org.eclipse.swt.graphics.Rectangle rect, int row, int col) {

      PropertyRow propertyRow = (PropertyRow) contentProvider.getRowContent(row);
      if (!(propertyRow instanceof Descriptor)) return;

      IItemPropertyDescriptor propertyDescriptor =
          ((Descriptor) propertyRow).getItemPropertyDescriptor();
      Object propertyValue = propertyDescriptor.getPropertyValue(contentProvider.getElement());
      IItemLabelProvider labelProvider = propertyDescriptor.getLabelProvider(propertyValue);
      Image image =
          ExtendedImageRegistry.getInstance().getImage(labelProvider.getImage(propertyValue));

      drawTextImage(
          gc,
          " " + propertyRow.toString(),
          alignment,
          image,
          alignment,
          rect.x + 2,
          rect.y + 1,
          rect.width - 1,
          rect.height - 1);
    }
 /**
  * Returns the image for the element
  *
  * @param editPart the edit part that displays the element
  * @return the image
  */
 public Image getImage(GraphicalEditPart editPart) {
   Element element = getUMLElement(editPart);
   String key = "";
   if (element instanceof NamedElement) {
     key = ((NamedElement) element).getName() + "::" + ((NamedElement) element).getVisibility();
   } else if (element != null) {
     key = element.getClass().getName();
   } else {
     return null;
   }
   ImageRegistry imageRegistry = Activator.getDefault().getImageRegistry();
   Image image = imageRegistry.get(key);
   ImageDescriptor descriptor = null;
   if (image == null) {
     AdapterFactory factory = Activator.getDefault().getItemProvidersAdapterFactory();
     IItemLabelProvider labelProvider =
         (IItemLabelProvider) factory.adapt(getUMLElement(editPart), IItemLabelProvider.class);
     if (labelProvider != null) {
       descriptor =
           ExtendedImageRegistry.getInstance()
               .getImageDescriptor(labelProvider.getImage(getUMLElement(editPart)));
     }
     if (descriptor == null) {
       descriptor = ImageDescriptor.getMissingImageDescriptor();
     }
     imageRegistry.put(key, descriptor);
     image = imageRegistry.get(key);
   }
   return image;
 }
 /** @generated */
 public ImageDescriptor getItemImageDescriptor(Object item) {
   IItemLabelProvider labelProvider =
       (IItemLabelProvider) adapterFactory.adapt(item, IItemLabelProvider.class);
   if (labelProvider != null) {
     return ExtendedImageRegistry.getInstance().getImageDescriptor(labelProvider.getImage(item));
   }
   return null;
 }
  /**
   * Get the image for given object based on generated item provider.
   *
   * @param object_p
   * @return<code>null</code> if one of parameters is <code>null</code> or if no image is found.
   */
  public static Image getImage(EObject object_p) {
    Object image = null;

    IItemLabelProvider provider = getItemLabelProvider(object_p);
    if (null != provider) {
      image = provider.getImage(object_p);
    }
    return (null != image) ? getImageFromObject(image) : null;
  }
  /**
   * Get the label for given object based on generated item provider.
   *
   * @param object_p
   * @return<code>null</code> if one of parameters is <code>null</code> or if no label is found.
   */
  public static String getText(EObject object_p) {
    String label = ICommonConstants.EMPTY_STRING;

    IItemLabelProvider provider = getItemLabelProvider(object_p);
    if (null != provider) {
      label = provider.getText(object_p);
    }
    return label;
  }
예제 #6
0
 /**
  * Select the object <code>next</code> as a subnode of the <code>currentNode</code>.
  *
  * @param currentNode the currentNode
  * @param next the subnode to select
  * @return the selected node
  */
 private SWTBotTreeItem selectSubNode(SWTBotTreeItem currentNode, Object next) {
   final AdapterFactory adapterFactory = EEFRuntimePlugin.getDefault().getAdapterFactory();
   final IItemLabelProvider labelProvider =
       (IItemLabelProvider) adapterFactory.adapt(next, IItemLabelProvider.class);
   final String text = labelProvider.getText(next);
   final SWTBotTreeItem node2 = currentNode.getNode(text);
   node2.select();
   return node2;
 }
 private String getLabel(EObject eObject) {
   AdapterFactory adapterFactory = getAdapterFactory(eObject);
   if (adapterFactory == null) {
     return "";
   }
   IItemLabelProvider itemLabelProvider =
       (IItemLabelProvider) adapterFactory.adapt(eObject, IItemLabelProvider.class);
   return itemLabelProvider != null
       ? itemLabelProvider.getText(eObject)
       : eObject == null ? "" : eObject.toString();
 }
 @Override
 public String getCategory(Object object) {
   String category = super.getCategory(object);
   if (category == null) {
     IItemLabelProvider labeler = EMFUtils.adapt(object, IItemLabelProvider.class);
     if (labeler != null) {
       return labeler.getText(object);
     }
   }
   return category;
 }
 /**
  * This returns the label text for the adapted class.
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  *
  * @generated NOT
  */
 @Override
 public String getText(Object object) {
   Utilisateur utilisateur = (Utilisateur) object;
   Employe employe = utilisateur.getEmploye();
   String login = utilisateur.getLogin();
   String label = login == null || login.trim().isEmpty() ? "!!!login non renseigné!!!" : login;
   if (null != employe) {
     IItemLabelProvider employeLabelProvider =
         (IItemLabelProvider) getAdapterFactory().adapt(employe, IItemLabelProvider.class);
     label += " - " + employeLabelProvider.getText(employe);
   }
   return label;
 }
예제 #10
0
 /**
  * This will try and get the IItemLabelProvider associated to the given EObject if its
  * ItemProviderFactory is registered, then return the text it provides.
  *
  * @param eObj EObject we need the text of.
  * @return The text provided by the IItemLabelProvider associated with <tt>eObj</tt>, <code>null
  *     </code> if it cannot be found.
  * @see IItemLabelProvider#getText(Object)
  * @since 0.8
  */
 public static String getItemProviderText(EObject eObj) {
   final String text;
   if (eObj == null) {
     text = "null"; // $NON-NLS-1$
   } else {
     final IItemLabelProvider labelProvider = adapt(eObj, IItemLabelProvider.class);
     if (labelProvider != null) {
       text = labelProvider.getText(eObj);
     } else {
       text = ""; // $NON-NLS-1$
     }
   }
   return text;
 }
  /**
   * This returns NonPlayerCharacter.gif.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated not
   */
  @Override
  public Object getImage(Object object) {
    ManagedCharacter pc = (ManagedCharacter) object;

    ComposeableAdapterFactory factory =
        ((Shr5managementItemProviderAdapterFactory) this.adapterFactory).getRootAdapterFactory();
    if (factory != null && pc.getPersona() != null) {
      IItemLabelProvider labelprovider =
          (IItemLabelProvider) factory.adapt(pc.getPersona(), IItemLabelProvider.class);
      if (labelprovider != null) return labelprovider.getImage(pc.getPersona());
    }

    return overlayImage(object, getResourceLocator().getImage("full/obj16/NonPlayerCharacter"));
  }
  /**
   * This returns the label text for the adapted class.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated not
   */
  @Override
  public String getText(Object object) {
    ManagedCharacter pc = (ManagedCharacter) object;
    if (pc.getPersona() != null) {
      ComposeableAdapterFactory factory =
          ((Shr5managementItemProviderAdapterFactory) this.adapterFactory).getRootAdapterFactory();
      IItemLabelProvider labelprovider =
          (IItemLabelProvider) factory.adapt(pc.getPersona(), IItemLabelProvider.class);

      if (labelprovider != null)
        return getString("_UI_NonPlayerCharacter_type")
            + " "
            + labelprovider.getText(pc.getPersona());
    }

    return getString("_UI_NonPlayerCharacter_type");
  }
 private String toDisplayName(EObject eObject) {
   IItemLabelProvider labelAdapter =
       (IItemLabelProvider)
           EcoreUtil.getRegisteredAdapter(
               EcorePackage.eINSTANCE.getEAnnotation(), IItemLabelProvider.class);
   if (labelAdapter == null) {
     labelAdapter =
         (IItemLabelProvider) ecoreLabelProviderFactory.adapt(eObject, IItemLabelProvider.class);
   }
   String label = null;
   try {
     label = labelAdapter.getText(eObject);
   } catch (RuntimeException e) {
     // Ensure fault isolation of the item provider
     label = EcoreUtil.getIdentification(eObject);
   }
   return label;
 }
예제 #14
0
  public String evaluate(
      NamedElement source, IParameterValueList2 parameterValues, IFacetManager facetManager)
      throws DerivedTypedElementException {
    ParameterValue parameterValue =
        parameterValues.getParameterValueByName("eObject"); // $NON-NLS-1$
    if (parameterValue.getValue() instanceof EStructuralFeature) {
      return ((EStructuralFeature) parameterValue.getValue()).getName();
    }

    // Delegate to UML2 Edit providers to get localized and inferred names where applicable
    return labelProvider.getText(source);
  }
  private static ImageDescriptor findImageDescriptor(TreeItemCreationTool createTool) {

    ImageDescriptor descriptor =
        DTreeViewerManager.getImageRegistry()
            .getDescriptor(DTreeViewerManager.CREATE_TREE_ITEM_IMG);
    EObject created = null;

    Iterator<CreateInstance> createInstances =
        Iterators.filter(createTool.eAllContents(), CreateInstance.class);
    while (created == null && createInstances.hasNext()) {
      CreateInstance map = createInstances.next();
      created = CreateToolItemAction.tryToInstanciateType(createTool, created, map.getTypeName());
    }

    Iterator<TreeItemMapping> it = createTool.getMapping().iterator();
    while (created == null && it.hasNext()) {
      TreeItemMapping map = it.next();
      created =
          CreateToolItemAction.tryToInstanciateType(createTool, created, map.getDomainClass());
    }

    if (created != null) {
      final IItemLabelProvider labelProvider =
          (IItemLabelProvider)
              TreeUIPlugin.getPlugin()
                  .getItemProvidersAdapterFactory()
                  .adapt(created, IItemLabelProvider.class);
      if (labelProvider != null) {
        ImageDescriptor semanticDescriptor =
            ExtendedImageRegistry.getInstance().getImageDescriptor(labelProvider.getImage(created));
        if (semanticDescriptor != null) {
          descriptor = semanticDescriptor;
        }
      }
    }

    return descriptor;
  }
예제 #16
0
 /**
  * This will try and get the IItemLabelProvider associated to the given EObject if its
  * ItemProviderFactory is registered, then return the image it provides.
  *
  * @param eObj EObject we need an image for.
  * @return The Image provided by the IItemLabelProvider associated with <tt>eObj</tt>, <code>null
  *     </code> if it cannot be found.
  * @see IItemLabelProvider#getImage(Object)
  * @since 0.8
  */
 public static Object getItemProviderImage(EObject eObj) {
   final IItemLabelProvider labelProvider = adapt(eObj, IItemLabelProvider.class);
   if (labelProvider != null) return labelProvider.getImage(eObj);
   return null;
 }
 @Override
 public Image getImage() {
   IItemLabelProvider itemLabelProvider = itemPropertyDescriptor.getLabelProvider(object);
   return ExtendedImageRegistry.getInstance().getImage(itemLabelProvider.getImage(object));
 }