Skip to content

Commit

Permalink
Manage visibility on entities.
Browse files Browse the repository at this point in the history
  • Loading branch information
jecisc committed Jul 7, 2020
1 parent 687c99a commit 505d4ba
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/Famix-Tagging/FamixTagAssociation.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ FamixTagAssociation >> checkingDoubleTagging [

{ #category : #accessing }
FamixTagAssociation >> entity [
<FMProperty: #entity type: #MooseEntity>
<FMProperty: #entity type: #MooseEntity opposite: #allTagAssociations>
<FMComment: 'Tagged entity'>
^ entity
]
Expand Down Expand Up @@ -160,7 +160,7 @@ FamixTagAssociation >> setEntityTo: anEntity [
anEntity ifNotNil: [ anEntity mooseModel ifNotNil: [ :model | self mooseModel: model ] ].
entity := FMMultivalueLink
on: self
update: #tagAssociations
update: #allTagAssociations
from: self entity
to: anEntity
]
Expand Down
59 changes: 39 additions & 20 deletions src/Famix-Tagging/MooseEntity.extension.st
Original file line number Diff line number Diff line change
@@ -1,12 +1,45 @@
Extension { #name : #MooseEntity }

{ #category : #'*Famix-Tagging' }
MooseEntity >> entityTagAssociations [
MooseEntity >> allEntityTagAssociations [
"All entity tag associations placed on this entity"

^ self tagAssociations select: #isEntityTagAssociation
]

{ #category : #'*Famix-Tagging' }
MooseEntity >> allTagAssociations [
<FMProperty: #allTagAssociations type: #FamixTagAssociation opposite: #entity>
<multivalued>
<FMComment: 'All the tag associations linking this entity to a Tag'>
^ self propertyNamed: #allTagAssociations ifAbsentPut: [ FMMultivalueLink on: self opposite: #entity: ]
]

{ #category : #'*Famix-Tagging' }
MooseEntity >> allTagAssociations: aCollection [
self allTagAssociations value: aCollection
]

{ #category : #'*Famix-Tagging' }
MooseEntity >> allTags [
"all tags on me"

"
self removeTags
"

^ (self allTagAssociations collectAsSet: #tag) asArray
]

{ #category : #'*Famix-Tagging' }
MooseEntity >> entityTagAssociations [
"All entity tag associations placed on this entity"

^ self allEntityTagAssociations reject: #isHidden
]

{ #category : #'*Famix-Tagging' }
MooseEntity >> isTagged [
<FMProperty: #isTagged type: #Boolean>
Expand Down Expand Up @@ -34,25 +67,17 @@ MooseEntity >> numberOfTags [
MooseEntity >> removeTag: aTag [
"remove a tag from this moose entity"

self tagAssociations detect: [ :assoc | assoc tag = aTag ] ifFound: #remove
self allTagAssociations detect: [ :assoc | assoc tag = aTag ] ifFound: #remove
]

{ #category : #'*Famix-Tagging' }
MooseEntity >> removeTags [
self tagAssociations asOrderedCollection do: #remove
self allTagAssociations asOrderedCollection do: #remove
]

{ #category : #'*Famix-Tagging' }
MooseEntity >> tagAssociations [
<FMProperty: #tagAssociations type: #FamixTagAssociation opposite: #entity>
<multivalued>
<FMComment: 'All the tag associations linking this entity to a Tag'>
^ self propertyNamed: #tagAssociations ifAbsentPut: [ FMMultivalueLink on: self opposite: #entity: ]
]

{ #category : #'*Famix-Tagging' }
MooseEntity >> tagAssociations: aCollection [
self tagAssociations value: aCollection
^ self allTagAssociations reject: #isHidden
]

{ #category : #'*Famix-Tagging' }
Expand All @@ -74,13 +99,7 @@ MooseEntity >> tagWithName: aTagName tagModel: aTagModel [

{ #category : #'*Famix-Tagging' }
MooseEntity >> tags [
"all tags on me"
"
self removeTags
"
^ (self tagAssociations collectAsSet: #tag) asArray
^ self allTags reject: #isHidden
]

{ #category : #'*Famix-Tagging' }
Expand All @@ -92,7 +111,7 @@ MooseEntity >> tagsInModel: aTagModel [
MooseEntity >> toggleTag: aTag [
"If the entity as already tagged with this tag, remove it. Else, tag the entity."

self tags
self allTags
detect: [ :tag | tag = aTag ]
ifFound: [ :tag | self removeTag: tag ]
ifNone: [ aTag tagEntity: self ]
Expand Down

0 comments on commit 505d4ba

Please sign in to comment.