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

make 2 different selection-tools coexist in pyside
Swapping text selections in Sublime Text 2
Selecting text with Sublime Text 2
Stata: Lag length criteria: How can I explain the results?
jquery-autocomplete default selection
Zend Studio selecting full Block
Genetic Algorithm - producing a new generation
UICollectionView shouldSelectItemAtIndexPath=NO does not avoid deselecting old selection?
UICollectionView Tap Selects More Than One Cell
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

Categories

HOME
webview
events
yahoo-weather-api
opencv-python
applescript
selenium-builder
writefile
loopbackjs
plpgsql
dronekit-python
tcp
gallery
position
wagtail
tfs2010
sharepoint-online
bellman-ford
match
bundler
jodatime
distributed-computing
pywinauto
android-contacts
cmake-gui
spring-shell
jest
spring-ldap
tableview
android-permissions
dashdb
stackexchange.redis
quantitative-finance
chronicle-queue
cellular-network
spreadsheetgear
cube
splunk-query
xenapp
john-the-ripper
quickcheck
cloveretl
transform
numerics
assertions
ftp-server
jade4j
code-rally
classnotfoundexception
viewcontroller
autorelease
webalizer
return-type
xcglogger
photoswipe
sonatype
palindrome
gmaps.js
gapi
multi-touch
bigdecimal
mathjs
system.web.optimization
fdt
teamviewer
android-expansion-files
enunciate
dsa
ambiguity
apple
alwayson
kefir.js
wicked-gem
webproject
sablecc
hp-idol-ondemand
zend-mail
windows-rt
quantify
loginview
osascript
aho-corasick
redpitaya
cpu-time
ggts
frontbase
tnt4j
ember-table
notin
html-frames
oscilloscope
session-0-isolation
wndproc
flymake
dropshadow
fbml
infopath-2007
firefly-mv
rtd
fragment-identifier
channelfactory
eaccelerator
mongrel
3-tier
asdoc
jquery-effects
gtktextview
motif
stretchblt
server-load
levels
error-detection
webclient.uploaddata

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App