Changeset 757
- Timestamp:
- 02/06/06 00:52:49 (3 years ago)
- Files:
-
- trunk/gaphor/ChangeLog (modified) (1 diff)
- trunk/gaphor/NEWS (modified) (1 diff)
- trunk/gaphor/gaphor/UML/uml2.override (modified) (2 diffs)
- trunk/gaphor/gaphor/UML/util.py (added)
- trunk/gaphor/gaphor/diagram/dependency.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/gaphor/ChangeLog
r750 r757 1 2006-02-06 wrobell <wrobell@pld-linux.org> 2 * gaphor/UML/uml2.override: provided and required interfaces of 3 component realizing classifiers are visible in Component.{provided,required} 4 derived associations 5 * gaphor/UML/util.py: added utility functions for getting provided and 6 required interfaces of classifier/component 7 * gaphor/diagram/dependency.py: support for automatic realization 8 dependencies between components and interfaces 9 1 10 2006-01-16 wrobell <wrobell@pld-linux.org> 2 11 * gaphor/diagram/commentline.py: allow_connect_handle does not throw an trunk/gaphor/NEWS
r755 r757 1 1 0.8.1 2 2 ----- 3 - small bug fixes 3 - support for automatic realization dependencies between components and 4 interfaces 5 - provided and required interfaces of component realizing classifiers are 6 visible in Component.{provided,required} derived associations 7 - missing icons added 4 8 5 9 0.8.0 trunk/gaphor/gaphor/UML/uml2.override
r728 r757 181 181 override Component.provided 182 182 def component_provided(self): 183 interfaces = [ impl.contract[0] for impl in self.implementation \ 184 if impl.isKindOf(Implementation) ] # should we process with this condition? 185 return interfaces 183 from gaphor.UML.util import pr_interface_deps, pr_rc_interface_deps 184 import itertools 185 186 implementations = (impl.contract[0] for impl in self.implementation if impl.isKindOf(Implementation)) 187 realizations = pr_interface_deps(self, Realization) 188 189 # realizing classifiers realizations 190 # this generator of generators, so flatten it later 191 rc_realizations = pr_rc_interface_deps(self, Realization) 192 193 return tuple(set(itertools.chain(implementations, realizations, *rc_realizations))) 186 194 187 195 Component.provided = property(component_provided, doc = \ … … 193 201 override Component.required 194 202 def component_required(self): 195 interfaces = [ dep.supplier[0] for dep in self.clientDependency \ 196 if dep.isKindOf(Usage) and dep.supplier[0].isKindOf(Interface) ] 197 return interfaces 203 from gaphor.UML.util import pr_interface_deps, pr_rc_interface_deps 204 import itertools 205 206 usages = pr_interface_deps(self, Usage) 207 208 # realizing classifiers usages 209 # this generator of generators, so flatten it later 210 rc_usages = pr_rc_interface_deps(self, Usage) 211 212 return tuple(set(itertools.chain(usages, *rc_usages))) 198 213 199 214 Component.required = property(component_required, doc = \ trunk/gaphor/gaphor/diagram/dependency.py
r744 r757 35 35 dependencies to an interface, it will probably not be very explaining 36 36 (esp. Usage dependencies). 37 38 Function get_dependency_type should be used to determine automatically 39 type of a dependency. 37 40 38 41 TODO (see also InterfaceItem): When a Usage dependency is drawn and is … … 150 153 """See RelationshipItem.find_relationship(). 151 154 """ 152 return self._find_relationship(head_subject, tail_subject, 153 ('supplier', 'supplierDependency'), 154 ('client', 'clientDependency')) 155 if get_dependency_type(head_subject, tail_subject) == UML.Realization: 156 args = (('realizingClassifier', None), ('abstraction', 'realization')) 157 else: 158 args = (('supplier', 'supplierDependency'), ('client', 'clientDependency')) 159 return self._find_relationship(head_subject, tail_subject, *args) 160 155 161 156 162 def allow_connect_handle(self, handle, connecting_to): … … 177 183 178 184 if self.auto_dependency: 179 # Determine the dependency_type if only one handle is connected 180 if c1 and isinstance(c1.subject, UML.Interface): 181 self.set_dependency_type(UML.Usage) 182 else: 183 self.set_dependency_type(UML.Dependency) 185 # determining the dependency type can be performed when only 186 # one handle is connected 187 s1 = s2 = None 188 if c1: 189 s1 = c1.subject 190 if c2: 191 s2 = c2.subject 192 self.set_dependency_type(get_dependency_type(s1, s2)) 184 193 185 194 if c1 and c2: … … 189 198 if not relation: 190 199 relation = resource(UML.ElementFactory).create(self.dependency_type) 191 relation.supplier = s1 192 relation.client = s2 200 if get_dependency_type(s1, s2) == UML.Realization: 201 relation.realizingClassifier = s1 202 relation.abstraction = s2 203 else: 204 relation.supplier = s1 205 relation.client = s2 193 206 self.subject = relation 194 207 … … 200 213 self.set_subject(None) 201 214 215 216 217 def is_usage(s): 218 """ 219 Return true if dependency should be usage dependency. 220 """ 221 return isinstance(s, UML.Interface) 222 223 224 def is_component_realization(ts, hs): 225 """ 226 Return true if dependency should be realization dependency. 227 """ 228 return isinstance(ts, UML.Classifier) and isinstance(hs, UML.Component) 229 230 231 def get_dependency_type(ts, hs): 232 """ 233 Determine dependency type: 234 - check if it is usage 235 - check if it is realization 236 - if none of above, then it is normal dependency 237 238 The checks should be performed in above order. For example if ts and hs 239 are Interface and Component, then we have two choices: 240 - claim it is an usage (as ts is an Interface) 241 - or claim it is a realization (as Interface is Classifier, too) 242 In this case we want usage to win over realization. 243 """ 244 dt = UML.Dependency 245 if is_usage(ts): 246 dt = UML.Usage 247 elif is_component_realization(ts, hs): 248 dt = UML.Realization 249 return dt 250 251 202 252 initialize_item(DependencyItem, UML.Dependency)
