Skip to content

Commit

Permalink
Merge pull request #4 from moosetechnology/add-possibility-to-hide-tags
Browse files Browse the repository at this point in the history
add-possibility-to-hide-tags
  • Loading branch information
jecisc authored Jul 7, 2020
2 parents f68e8ca + 505d4ba commit 417bd98
Show file tree
Hide file tree
Showing 8 changed files with 220 additions and 40 deletions.
9 changes: 8 additions & 1 deletion src/Famix-Tagging-Code/MooseAbstractGroup.extension.st
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
Extension { #name : #MooseAbstractGroup }

{ #category : #'*Famix-Tagging-Code' }
MooseAbstractGroup >> codeTagAssociations [
MooseAbstractGroup >> allCodeTagAssociations [
"All entity tags placed on this entity"

^ self allWithType: FamixTagCodeAssociation
]

{ #category : #'*Famix-Tagging-Code' }
MooseAbstractGroup >> codeTagAssociations [
"All entity tags placed on this entity"

^ self allCodeTagAssociations reject: #isHidden
]
101 changes: 98 additions & 3 deletions src/Famix-Tagging-Tests/FamixTagMooseModelTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,71 @@ FamixTagMooseModelTest >> testAddANewTagWithCategory [
]

{ #category : #tests }
FamixTagMooseModelTest >> testAllModelTaggedAssociations [
FamixTagMooseModelTest >> testAllModelTags [
self assert: model tags size equals: 2
]

{ #category : #tests }
FamixTagMooseModelTest >> testAllRootTags [
| tag1 tag2 tag3 |
model := FamixTagModel new.
tag1 := model createTagNamed: 'Furry'.
tag2 := model createTagNamed: 'Bronie'.
tag3 := model createTagNamed: 'Scalie'.

tag2 parentTag: tag1.

self assertCollection: model allRootTags hasSameElements: {tag1 . tag3}
]

{ #category : #tests }
FamixTagMooseModelTest >> testAllRootTagsWithHiddenTags [
| tag1 tag2 tag3 |
model := FamixTagModel new.
tag1 := model createTagNamed: 'Furry'.
tag2 := model createTagNamed: 'Bronie'.
tag3 := model createTagNamed: 'Scalie'.

tag2 parentTag: tag1.
tag3 hide.

self assertCollection: model allRootTags hasSameElements: {tag1 . tag3}
]

{ #category : #tests }
FamixTagMooseModelTest >> testAllTagAssociations [
self assert: model allTagAssociations size equals: 2.

model tags first hide.

self assert: model allTagAssociations size equals: 2
]

{ #category : #tests }
FamixTagMooseModelTest >> testAllModelTags [
self assert: model tags size equals: 2
FamixTagMooseModelTest >> testAllTags [
| tag1 tag2 tag3 |
model := FamixTagModel new.
tag1 := model createTagNamed: 'Furry'.
tag2 := model createTagNamed: 'Bronie'.
tag3 := model createTagNamed: 'Scalie'.

tag2 parentTag: tag1.

self assertCollection: model allTags hasSameElements: {tag1 . tag2. tag3}
]

{ #category : #tests }
FamixTagMooseModelTest >> testAllTagsWithHiddenTags [
| tag1 tag2 tag3 |
model := FamixTagModel new.
tag1 := model createTagNamed: 'Furry'.
tag2 := model createTagNamed: 'Bronie'.
tag3 := model createTagNamed: 'Scalie'.

tag2 parentTag: tag1.
tag3 hide.

self assertCollection: model allTags hasSameElements: {tag1 . tag2 . tag3}
]

{ #category : #tests }
Expand Down Expand Up @@ -158,6 +216,29 @@ FamixTagMooseModelTest >> testRetrievalFromModelWithCategories [
self assertEmpty: (model tagCategoryNamed: 'default') markedTags
]

{ #category : #tests }
FamixTagMooseModelTest >> testRootTags [
| tag1 tag2 tag3 |
model := FamixTagModel new.
tag1 := model createTagNamed: 'Furry'.
tag2 := model createTagNamed: 'Bronie'.
tag3 := model createTagNamed: 'Scalie'.

tag2 parentTag: tag1.
tag3 hide.

self assertCollection: model rootTags hasSameElements: {tag1}
]

{ #category : #tests }
FamixTagMooseModelTest >> testTagAssociations [
self assert: model tagAssociations size equals: 2.

model tags first hide.

self assert: model tagAssociations size equals: 1
]

{ #category : #tests }
FamixTagMooseModelTest >> testTagCachesAreResetWhenAddingATag [
self assert: model tags size equals: 2.
Expand Down Expand Up @@ -256,6 +337,20 @@ FamixTagMooseModelTest >> testTagsExportAndImportMSE [
self assert: (importedModel entityNamed: 'Package1::Class1') entityTagAssociations size equals: 1
]

{ #category : #tests }
FamixTagMooseModelTest >> testTagsWithHidden [
| tag1 tag2 tag3 |
model := FamixTagModel new.
tag1 := model createTagNamed: 'Furry'.
tag2 := model createTagNamed: 'Bronie'.
tag3 := model createTagNamed: 'Scalie'.

tag2 parentTag: tag1.
tag3 hide.

self assertCollection: model tags hasSameElements: {tag1 . tag2}
]

{ #category : #tests }
FamixTagMooseModelTest >> testToggleTag [
| entity tag numberOfTag |
Expand Down
5 changes: 5 additions & 0 deletions src/Famix-Tagging-Tests/FamixTagTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ FamixTagTest >> testIsRoot [
self deny: compositeTag isRoot
]

{ #category : #tests }
FamixTagTest >> testIsVisibleByDefault [
self deny: FamixTag new isHidden
]

{ #category : #tests }
FamixTagTest >> testMooseName [
self assert: compositeTag mooseName equals: #parent.
Expand Down
37 changes: 32 additions & 5 deletions src/Famix-Tagging/FamixTag.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ Class {
'serializedColor',
'parentTag',
'categories',
'subTags'
'subTags',
'isHidden'
],
#category : #'Famix-Tagging-Model'
}
Expand Down Expand Up @@ -299,6 +300,11 @@ FamixTag >> hasUniqueMooseNameInModel [
^ true
]

{ #category : #accessing }
FamixTag >> hide [
isHidden := true
]

{ #category : #accessing }
FamixTag >> id [
<FMProperty: #id type: #Number>
Expand All @@ -314,11 +320,12 @@ FamixTag >> id: anObject [
{ #category : #initialization }
FamixTag >> initialize [
super initialize.
subTags := FMNullMultivalueLink on: self opposite: #parentTag: selector: #subTags.
subTags := FMMultivalueLink on: self opposite: #parentTag:.
categories := FMMultiMultivalueLink on: self opposite: #markedTags.

self id: UUIDGenerator default nextRandom16.
self color: MDLColor randomColorAndTint
id := UUIDGenerator default nextRandom16.
self color: MDLColor randomColorAndTint.
isHidden := false
]

{ #category : #accessing }
Expand All @@ -335,6 +342,18 @@ FamixTag >> isComposite [
^ self subTags isNotEmpty
]

{ #category : #accessing }
FamixTag >> isHidden [
<FMProperty: #isHidden type: #Boolean>
<FMComment: 'Flag true for tags that should not appear in the tools.'>
^ isHidden
]

{ #category : #accessing }
FamixTag >> isHidden: anObject [
isHidden := anObject
]

{ #category : #dependencies }
FamixTag >> isInListOfPossibleLinks: aCollection forModel: aMooseModel [
^ aCollection includesAny: (self allTaggedEntitiesInModel: aMooseModel)
Expand Down Expand Up @@ -432,6 +451,7 @@ FamixTag >> parentSeparator [
FamixTag >> parentTag [
<FMProperty: #parentTag type: #FamixTag opposite: #subTags>
<FMComment: 'Parent of the tag'>
<container>
^ parentTag
]

Expand Down Expand Up @@ -554,8 +574,10 @@ FamixTag >> subTagNamed: aString [

{ #category : #accessing }
FamixTag >> subTags [
<FMProperty: #subTags type: #FamixTag opposite: #parentTag> <multivalued>
<FMProperty: #subTags type: #FamixTag opposite: #parentTag>
<multivalued>
<FMComment: 'Sub tags of this composite tag.'>
<derived>
^ subTags
]

Expand Down Expand Up @@ -585,3 +607,8 @@ FamixTag >> taggedEntities [
FamixTag >> taggedEntitiesInModel: aModel [
^ aModel entitiesTaggedWith: self
]

{ #category : #actions }
FamixTag >> toggleVisibility [
isHidden := isHidden not
]
9 changes: 7 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 @@ -121,6 +121,11 @@ FamixTagAssociation >> isEntityTagAssociation [
^ false
]

{ #category : #testing }
FamixTagAssociation >> isHidden [
^ self tag isHidden
]

{ #category : #accessing }
FamixTagAssociation >> mooseModel: aMooseModel [
"We add the association at the beginning of the model entity storage because the user can delete associations but not entities. It is much faster to delete entities at the beginning of the collection. On a big model it can take several second to delete some tags."
Expand Down Expand Up @@ -155,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
2 changes: 1 addition & 1 deletion src/Famix-Tagging/FamixTagSTONWriter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Class {
FamixTagSTONWriter class >> export: aMooseModel with: aTagModel on: aStream [
(self on: aStream)
tagModel: aTagModel;
writeObject: (FamixTagSTONExport tags: aTagModel tags categories: aTagModel allTagCategories associations: aMooseModel allTagAssociations)
writeObject: (FamixTagSTONExport tags: aTagModel allTags categories: aTagModel allTagCategories associations: aMooseModel allTagAssociations)
]

{ #category : #accessing }
Expand Down
38 changes: 30 additions & 8 deletions src/Famix-Tagging/MooseAbstractGroup.extension.st
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
Extension { #name : #MooseAbstractGroup }

{ #category : #'*Famix-Tagging' }
MooseAbstractGroup >> allEntityTagAssociations [
"All entity tags placed on this entity"

^ self allWithType: FamixTagEntityAssociation
]

{ #category : #'*Famix-Tagging' }
MooseAbstractGroup >> allRootTags [
^ self tags select: #isRoot
^ self allTags select: #isRoot
]

{ #category : #'*Famix-Tagging' }
Expand All @@ -17,6 +24,12 @@ MooseAbstractGroup >> allTagCategories [
^ self allWithSubTypesOf: FamixTagCategory
]

{ #category : #'*Famix-Tagging' }
MooseAbstractGroup >> allTags [
<navigation: 'All simple or composite tags known by this model'>
^ self allWithType: FamixTag
]

{ #category : #'*Famix-Tagging' }
MooseAbstractGroup >> associationsForTag: aTag [
| mn |
Expand Down Expand Up @@ -51,7 +64,7 @@ MooseAbstractGroup >> entitiesTaggedWith: aTag [
MooseAbstractGroup >> entityTagAssociations [
"All entity tags placed on this entity"

^ self allWithType: FamixTagEntityAssociation
^ self allEntityTagAssociations reject: #isHidden
]

{ #category : #'*Famix-Tagging' }
Expand All @@ -61,7 +74,7 @@ MooseAbstractGroup >> exportTagsOn: aStream tagModel: aTagModel [

{ #category : #'*Famix-Tagging' }
MooseAbstractGroup >> findEquivalentTagTo: aFamixTag [
^ self tags detect: [ :aTag | aTag equivalentTo: aFamixTag ]
^ self allTags detect: [ :aTag | aTag equivalentTo: aFamixTag ]
]

{ #category : #'*Famix-Tagging' }
Expand All @@ -78,7 +91,7 @@ MooseAbstractGroup >> findTagNamed: aTagMooseName [

{ #category : #'*Famix-Tagging' }
MooseAbstractGroup >> findTagWithId: aTagId [
^ self tags detect: [ :aTag | aTag id = aTagId ]
^ self allTags detect: [ :aTag | aTag id = aTagId ]
]

{ #category : #'*Famix-Tagging' }
Expand All @@ -90,6 +103,17 @@ MooseAbstractGroup >> importTagsFrom: aStream tagModel: aTagModel [
report
]

{ #category : #'*Famix-Tagging' }
MooseAbstractGroup >> rootTags [
^ self allRootTags reject: #isHidden
]

{ #category : #'*Famix-Tagging' }
MooseAbstractGroup >> tagAssociations [
<navigation: 'Visible tag associations stored in this model'>
^ self allTagAssociations reject: #isHidden
]

{ #category : #'*Famix-Tagging' }
MooseAbstractGroup >> tagCategoryNamed: aCategoryMooseName [
^ [ self findTagCategoryNamed: aCategoryMooseName ]
Expand All @@ -106,8 +130,6 @@ MooseAbstractGroup >> tagNamed: aTagMooseName [

{ #category : #'*Famix-Tagging' }
MooseAbstractGroup >> tags [
"to allow tag queries on groups of entities"

<navigation: 'All simple or composite tags known by this model'>
^ self allWithType: FamixTag
<navigation: 'All visible simple or composite tags known by this model'>
^ self allTags reject: #isHidden
]
Loading

0 comments on commit 417bd98

Please sign in to comment.