Class: TECSCDE::HighlightedObjects
- Inherits:
-
Object
- Object
- TECSCDE::HighlightedObjects
show all
- Defined in:
- lib/tecscde/highlighted_objects.rb
Overview
manage highlighted objects
Instance Method Summary
collapse
Constructor Details
54
55
56
|
# File 'lib/tecscde/highlighted_objects.rb', line 54
def initialize
@objects = []
end
|
Instance Method Details
58
59
60
61
62
63
|
# File 'lib/tecscde/highlighted_objects.rb', line 58
def add(obj)
reset_if_ncessary(obj)
@objects << obj
@objects.uniq!
update_attr_tree_view
end
|
#add_del(obj) ⇒ Object
objects#add_del
add if not include, delete if include
67
68
69
70
71
72
73
74
75
|
# File 'lib/tecscde/highlighted_objects.rb', line 67
def add_del(obj)
reset_if_ncessary(obj)
if @objects.include?(obj)
@objects.delete(obj)
else
@objects << obj
end
update_attr_tree_view
end
|
#cell_plugin_dialog ⇒ Object
134
135
136
137
138
139
|
# File 'lib/tecscde/highlighted_objects.rb', line 134
def cell_plugin_dialog
if @objects.length == 1 && @objects[0].is_a?(TECSModel::TmCell)
dialog = CellPluginDialog.new(@objects[0])
dialog.run
end
end
|
#change_cell_name(name) ⇒ Object
127
128
129
130
131
132
|
# File 'lib/tecscde/highlighted_objects.rb', line 127
def change_cell_name(name)
if @objects.length == 1 && @objects[0].is_a?(TECSModel::TmCell)
@objects[0].change_name(name.to_sym)
@objects[0].model.set_undo_point
end
end
|
106
107
108
109
110
|
# File 'lib/tecscde/highlighted_objects.rb', line 106
def each
@objects.each do |obj|
yield obj
end
end
|
#empty? ⇒ Boolean
112
113
114
|
# File 'lib/tecscde/highlighted_objects.rb', line 112
def empty?
@objects.empty?
end
|
#include?(object) ⇒ Boolean
116
117
118
|
# File 'lib/tecscde/highlighted_objects.rb', line 116
def include?(object)
@objects.include?(object)
end
|
#reset(obj = nil) ⇒ Object
77
78
79
80
81
82
83
|
# File 'lib/tecscde/highlighted_objects.rb', line 77
def reset(obj = nil)
@objects = []
if obj
@objects << obj
end
update_attr_tree_view
end
|
#reset_if_ncessary(obj) ⇒ Object
objects#reset_if_ncessary
Port and ( Cell or Bar ) cannot be highlighted simultaneously. Ports belonging to diferent Cell cannot be highlighted simultaneously. obj::TmCell | TmBar | TmPort: new object to be highlighted
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/tecscde/highlighted_objects.rb', line 89
def reset_if_ncessary(obj)
return if @objects.empty?
if @objects[0].is_a?(TECSModel::TmPort)
if obj.is_a?(TECSModel::TmPort)
if obj.owner_cell != @objects[0].owner_cell
reset
end
else
reset
end
else
if obj.is_a?(TECSModel::TmPort)
reset
end
end
end
|
#set_attr_tree_view(tree_view, name_entry, region_entry, frame) ⇒ Object
120
121
122
123
124
125
|
# File 'lib/tecscde/highlighted_objects.rb', line 120
def set_attr_tree_view(tree_view, name_entry, region_entry, frame)
@cell_property_frame = frame
@cell_name_entry = name_entry
@cell_region_entry = region_entry
@attr_tree_view = tree_view
end
|
#update_attr_tree_view ⇒ Object
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
# File 'lib/tecscde/highlighted_objects.rb', line 141
def update_attr_tree_view
cell = nil
n_cell = 0
each do |obj|
if obj.is_a?(TECSModel::TmCell)
cell = obj
n_cell += 1
end
end
if n_cell == 1
@cell_name_entry.text = cell.get_name.to_s
@cell_region_entry.text = cell.get_region.get_namespace_path.to_s
if cell.editable?
@cell_name_entry.modify_fg(Gtk::STATE_NORMAL, Gdk::Color.parse("black"))
@cell_region_entry.modify_fg(Gtk::STATE_NORMAL, Gdk::Color.parse("black"))
@cell_property_frame.set_label("cell property")
else
@cell_name_entry.modify_fg(Gtk::STATE_NORMAL, Gdk::Color.parse("blue"))
@cell_region_entry.modify_fg(Gtk::STATE_NORMAL, Gdk::Color.parse("blue"))
@cell_property_frame.set_label("cell property (read only)")
end
@cell_name_entry.set_editable(cell.editable?)
@cell_region_entry.set_editable(cell.editable?)
@attr_tree_view.set_cell(cell)
else
@cell_name_entry.text = "(unselected)"
@cell_name_entry.set_editable(false)
@cell_name_entry.text = "(unselected)"
@cell_name_entry.set_editable(false)
@cell_property_frame.set_label("cell property (unselected)")
@attr_tree_view.clear
end
end
|