selection


Getting the Root-Element of an EObject which is being listened in a Tree-/Tableviewer


What might be the best way to ask for the root-element of an Ecore-Object? I am listening to certain editors and get the IStructuredSelection from it. But I need to filter the TreeViewers further, since not all of them I am listening to contain the same elements. As far as I can see there is no direct method, which is generated by the EMF itself, that asks for the root-elements. Could you please point me in the right direction? Thanks in regard.
If you have an EObject, you may get the desired result just by recursively checking the eContainer(). Such as:
public static EObject getRoot(EObject eo) {
EObject parent = eo.eContainer();
if (parent != null) {
return getRoot(parent);
}
return eo;
}
For any EObject this should return the top-level EObject that contains it.
But instead of rolling your own like that, you may want to rely on getRootContainer() in the EcoreUtil class. Don't overlook EcoreUtil when working with EMF, it has helper methods at least some of which are bound to be useful in an EMF application.

Related Links

Should this be selection or projection
Deselecting cells programmatically in NSMatrix does not work
Sublime Text 2 multiple selection at boundaries of selection (Mac OS X)
How should Stochastic Universal Sampling be combined with Elitism in Genetic Programming?
Sencha Chart 2.0 - Multiple Selection
Why Rangy library doesn't work with contenteditable in Opera?
Function inside selection condition in relational algebra
What is the fastest way of selecting an photoshop object (layer)?
tournament selection
SpreadsheetApp.getActiveSheet().getActiveSelection() broken
CSS multiple class selection
Retrieve point of selection in Eclipse GEF
Strange behavior of Property.valueChangeListener of Select UI / Vaadin 6.7.3
(ABAP) How to know whether initial screen (selection-screen) is filled or not
Aptana Studio 3.0.6 block mode select broken
dynamically load rangy library

Categories

HOME
seedstack
enums
dafny
autocomplete
implicit-conversion
visualforce
impala
ag-grid
siesta
solution
match
slide
lapack
webstore
fresco
pygobject
android-5.1.1-lollipop
uima
yii2-basic-app
neo4j.rb
fido-u2f
intel
quantitative-finance
pyopencl
plyr
history.js
sendmessage
source-insight
adminer
busboy
wdk
subclassing
code-rally
identify
recovery
spring-restcontroller
stat
icepdf
opal-framework
robust
minikube
sony-future-lab-n
algebra
mobile-angular-ui
multi-touch
xmlbeans
mathml
oci
ajaxmin
urbit
textblock
accessibilityservice
gwt-syncproxy
psd
diawi
helm
textpattern
ora-04091
swagger-maven-plugin
org-babel
erlog
fuseesb
text-align
mathematical-expressions
debug-symbols
windows-rt
lmax
libgcc
aho-corasick
forceclose
fileshare
sql-function
nodeload
accountmanager
jomsocial
code39
eclim
yii-booster
insertonsubmit
blobstorage
eager-loading
2d-vector
session-0-isolation
simplecov
cgrectmake
xcode4.5
groovy-console
datacontracts
printqueue
cassini
outlook-2007-addin
aspbutton
oracle-pro-c
firephp

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App