How to access an attribute of a node? [message #75489] |
Tue, 07 November 2006 16:48 |
Eclipse User |
|
|
|
Originally posted by: christian.daenekas.informatik.uni-oldenburg.de
Hello,
I´m working on an graphical editor and have to define constraints using
Java. I´ve defined a Link Constraint (target end constraint) named
operandConnectionConstraint. The generated code looks like this:
private static class JavaConstraints {
/**
* @generated
*/
private static Boolean operandConnectionConstraint(
operatornode self, operandnode oppositeEnd) {
// TODO: implement this method
// Ensure that you remove @generated or mark it @generated NOT
throw new MetricsAbstractExpression.NoImplException(
"No user java implementation provided in
'operandConnectionConstraint' operation"); //$NON-NLS-1$
}
} // JavaConstraints
Now I need to get the value of an attribute of the self node,which has
the name "class" in the ecore model (value type is String). Now, how can
I accomplish this? I think the method to use is eGet(), which requires a
EStructuralFeature as parameter. So I think of something like
"self.eGet(feature)" to get the disired value. I just don´t know where
to get the EStructuralFeature for my "class" attribute. Or do i have to
create one? I´m a little confused about this and have not found any
documentation on this.
Greetings,
Christian
|
|
|
Re: How to access an attribute of a node? [message #75507 is a reply to message #75489] |
Tue, 07 November 2006 17:03 |
Eclipse User |
|
|
|
Originally posted by: vcciubot.uwaterloo.ca
This for instance, gives you
Bluenose2Package.eINSTANCE.getAbstractBlock_ConcreteBlocks()
the concreteBlocks feature of the AbstractBlock eclass in the
Bluenose2Package.
But you can also access this directly as abstractBlock.getConcreteBlocks()
if abstractBlock is of type AbstractBlock.
For reading access to the model you must use smth like this:
enabled = (Boolean) host.getEditingDomain().runExclusive(
new RunnableWithResult.Impl() {
public void run() {
Style style = (Style) view
.getStyle(eclass);
setResult(readStyleValue(style));
}
});
} catch (InterruptedException e) {
e.printStackTrace();
}
|
|
|
Powered by
FUDForum. Page generated in 0.03618 seconds