Java Code Examples for org.eclipse.emf.ecore.EObject#toString()

The following examples show how to use org.eclipse.emf.ecore.EObject#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnnotationArgumentImpl.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public String getValueAsString() {
	final EObject value = this.value();
	if ((value == null)) {
		return null;
	}
	String _switchResult = null;
	boolean _matched = false;
	if (value instanceof Literal) {
		_matched=true;
		_switchResult = ((Literal)value).getValueAsString();
	}
	if (!_matched) {
		if (value instanceof TypeRef) {
			_matched=true;
			_switchResult = ((TypeRef)value).getTypeRefAsString();
		}
	}
	if (!_matched) {
		_switchResult = value.toString();
	}
	return _switchResult;
}
 
Example 2
Source File: ModelDefinitionItemProvider.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This returns the label text for the adapted class. <!-- begin-user-doc
 * --> <!-- end-user-doc -->
 * 
 * @generated-not
 */
@Override
public String getText(Object object) {
    String label = ((ModelDefinition) object).getKey();
    EObject value = ((ModelDefinition) object).getValue();
    if (value != null) {
        label += ": " + value.toString();
    }
    return label == null ? "" : label;
}
 
Example 3
Source File: VariableValueCellLabelProvider.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void update(ViewerCell cell) {
    final Definition definition = (Definition) cell.getElement();
    if (definition instanceof StringDefinition) {
        cell.setText(((StringDefinition) definition).getValue());
    } else if (definition instanceof IntegerDefinition) {
        cell.setText(String.valueOf(((IntegerDefinition) definition).getValue()));
    } else if (definition instanceof RealDefinition) {
        cell.setText(String.valueOf(((RealDefinition) definition).getValue()));
    } else if (definition instanceof BooleanDefinition) {
        cell.setText(String.valueOf(((BooleanDefinition) definition).isValue()));
    } else if (definition instanceof ModelDefinition) {
        final String text;
        final EObject eObj = ((ModelDefinition) definition).getValue();
        if (eObj != null) {
            final IItemLabelProvider itemProvider = (IItemLabelProvider) adapterFactory.adapt(eObj,
                    IItemLabelProvider.class);

            if (itemProvider == null) {
                text = eObj.toString();
            } else {
                text = itemProvider.getText(eObj);
            }
            cell.setText(text);
        } else {
            cell.setText("");
        }
    } else {
        cell.setText(DON_T_KNOW_WHAT_TO_DO_WITH + definition.getClass().getCanonicalName());
    }
}
 
Example 4
Source File: TextRegionAccessToString.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
protected String toString(EObject ele) {
	if (ele instanceof AbstractElement)
		return grammarToString.apply((AbstractElement) ele);
	if (ele instanceof AbstractRule)
		return ele.eClass().getName() + "'" + ((AbstractRule) ele).getName() + "'";
	return ele.toString();
}
 
Example 5
Source File: AbstractGeneratorEntryExecutor.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected void logStart(GeneratorEntry entry) {
	EObject elementRef = entry.getElementRef();
	String elementName = elementRef instanceof NamedElement
			? ((NamedElement) elementRef).getName()
			: elementRef.toString();
	String targetProject = helper.getTargetProjectValue(entry).getStringValue();
	logger.log(String.format("Generating '%s' to target project '%s' ...", elementName, targetProject));
}
 
Example 6
Source File: EGaml.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Save an eObject into a string
 *
 * @param expr
 *            the expr
 * @return the string
 */

@Override
public String toString(final EObject expr) {
	if (expr == null) { return null; }
	if (expr instanceof Statement) {
		return getNameOf(expr);
	} else if (expr instanceof Facet) { return ((Facet) expr).getName(); }

	if (!(expr instanceof Expression)) { return expr.toString(); }
	final StringBuilder serializer = new StringBuilder(100);
	serializer.setLength(0);
	serialize(serializer, (Expression) expr);
	return serializer.toString();
}
 
Example 7
Source File: CustomLaneEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void logWrongParent() {
    final EObject resolvedSemanticElement = resolveSemanticElement();
    final String currentLaneName = resolvedSemanticElement instanceof Element ? ((Element) resolvedSemanticElement).getName() : resolvedSemanticElement
            .toString();
    final EObject parentResolvedSemanticElement = ((GraphicalEditPart) getParent()).resolveSemanticElement();
    final String containerName = parentResolvedSemanticElement instanceof Element ? ((Element) parentResolvedSemanticElement).getName()
            : parentResolvedSemanticElement.toString();
    BonitaStudioLog.warning("Warning: the lane" + currentLaneName + " is contained in another thing than a PoolCompartment. It is contained in: "
            + containerName, Activator.PLUGIN_ID);
}
 
Example 8
Source File: GrammarAccessExtensions.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
protected String _grammarElementIdentifier(final EObject it) {
  String _string = it.toString();
  return ("Unsupported : grammarElementIdentifier for: " + _string);
}
 
Example 9
Source File: GrammarAccessExtensions.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
protected String _grammarElementAccess(final EObject it) {
  String _string = it.toString();
  return ("Unsupported : grammarElementAccess for: " + _string);
}