/**
   * 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;
  }
Example #2
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;
 }
Example #5
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);
  }
 /**
  * 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;
 }
Example #7
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 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;
 }