Module: Java::OrgEclipseEmfEcore::EObject::NavigationMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.only_of_class(collection, eclass) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/emf/emf_nav.rb', line 46

def self.only_of_class(collection,eclass)
	selected = collection.select {|o| o.eClass.isSuperTypeOf eclass}
	case selected.count
	when 0
		raise EMF::LessThanExpectedFound.new
	when 1
		return selected.first
	else
		raise EMF::MoreThanExpectedFound.new
	end
end

Instance Method Details

#contentsObject



11
12
13
14
15
16
17
18
# File 'lib/emf/emf_nav.rb', line 11

def contents
	method = nil
	method = :eContents if respond_to?(:eContents)
	method = :old_contents if respond_to?(:old_contents)	
	method = :getContents if respond_to?(:getContents)
	raise "No method for getting contents, class: #{self.class}" unless method!=nil
	send method
end

#contents_deepObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/emf/emf_nav.rb', line 22

def contents_deep
	l = []
	contents.each do |c|
		l << c
		begin
			grand_children = c.contents_deep
		rescue Exception => e
			raise "Problem getting children of #{c} (#{c.class}): #{e}"
		end
		grand_children.each do |sc|
			l << sc
		end
	end   
	l
end

#only_content_deep_of_eclass(eclass) ⇒ Object



42
43
44
# File 'lib/emf/emf_nav.rb', line 42

def only_content_deep_of_eclass(eclass)
	Java::OrgEclipseEmfEcore::EObject::NavigationMethods.only_of_class(contents_deep,eclass)
end

#only_content_of_eclass(eclass) ⇒ Object



38
39
40
# File 'lib/emf/emf_nav.rb', line 38

def only_content_of_eclass(eclass)
	Java::OrgEclipseEmfEcore::EObject::NavigationMethods.only_of_class(contents,eclass)
end