Skip to content

Commit

Permalink
Change tagging buttons in toolbar.
Browse files Browse the repository at this point in the history
One command to select a tag, one to tag entities
  • Loading branch information
ClotildeToullec committed Sep 27, 2024
1 parent 01969a1 commit 80fa6d1
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 110 deletions.
14 changes: 7 additions & 7 deletions src/MooseIDE-Core/MiAbstractBrowser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -604,16 +604,17 @@ MiAbstractBrowser >> restore [

{ #category : #accessing }
MiAbstractBrowser >> selectedTag [
^self model
ifNil: [ nil ]
ifNotNil: [ :model | model selectedTag]

^ self model ifNil: [ nil ] ifNotNil: [ :model | model selectedTag ]
]

{ #category : #accessing }
MiAbstractBrowser >> selectedTag: aTag [
^self model

self model
ifNil: [ nil ]
ifNotNil: [ :model | model selectedTag: aTag]
ifNotNil: [ :model | model selectedTag: aTag ].
self updateToolbar
]

{ #category : #initialization }
Expand Down Expand Up @@ -660,8 +661,7 @@ MiAbstractBrowser >> tagName [
{ #category : #actions }
MiAbstractBrowser >> tagSelectedEntities [

^self model
ifNotNil: [ :model | model tagSelectedEntities ]
self model ifNotNil: [ :model | model tagSelectedEntities ]
]

{ #category : #buses }
Expand Down
7 changes: 4 additions & 3 deletions src/MooseIDE-Core/MiAbstractModel.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Class {
#superclass : #Object,
#instVars : [
'browser',
'lastTagSelected'
'lastTagSelected',
'selectedTag'
],
#category : #'MooseIDE-Core-Browser'
}
Expand Down Expand Up @@ -59,13 +60,13 @@ MiAbstractModel >> miSelectedItem [
{ #category : #tagging }
MiAbstractModel >> selectedTag [

^self currentApplication tagSelectedInMooseModel: self currentMooseModel
^ selectedTag
]

{ #category : #tagging }
MiAbstractModel >> selectedTag: aTag [

self currentApplication selectedTag: aTag
selectedTag := aTag
]

{ #category : #accessing }
Expand Down
56 changes: 56 additions & 0 deletions src/MooseIDE-Core/MiSelectTagCommand.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Class {
#name : #MiSelectTagCommand,
#superclass : #MiCommand,
#category : #'MooseIDE-Core-Command'
}

{ #category : #default }
MiSelectTagCommand class >> defaultDescription [

^ 'Select the tag that will be used to tag the current entities in this browser'
]

{ #category : #default }
MiSelectTagCommand class >> defaultName [

^ 'Select Tag'
]

{ #category : #testing }
MiSelectTagCommand >> canBeExecuted [

^ self context canTagEntities
]

{ #category : #executing }
MiSelectTagCommand >> execute [

self newMenu openWithSpecAtPointer
]

{ #category : #'instance creation' }
MiSelectTagCommand >> newMenu [

^ SpMenuPresenter new
addGroup: [ :group |
self tagsList do: [ :tag |
group addItem: [ :item |
item
name: tag name;
icon: (self application iconForTag: tag);
action: [ self selectedTag: tag ];
yourself ] ] ];
yourself
]

{ #category : #accessing }
MiSelectTagCommand >> selectedTag: aTag [

context selectedTag: aTag
]

{ #category : #accessing }
MiSelectTagCommand >> tagsList [

^ self context tagList
]
97 changes: 10 additions & 87 deletions src/MooseIDE-Core/MiTagCommand.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,107 +17,30 @@ MiTagCommand class >> defaultDescription [
]

{ #category : #'accessing - defaults' }
MiTagCommand class >> defaultName [
^ 'Tag entities'
]

{ #category : #converting }
MiTagCommand >> asSpecCommand [

^super asSpecCommand
buildPresenterBlock: [ :cmd | self buildToolbarButton: cmd ] ;
yourself
]

{ #category : #building }
MiTagCommand >> buildTagMenu [

^ [
SpMenuPresenter new
addGroup: [ :group |
self tagsList do: [ :tag |
group addItem: [ :item |
item
name: tag name;
icon: (self application iconForTag: tag);
action: [ self selectedTag: tag ];
yourself ] ] ];
yourself ]
]
MiTagCommand class >> defaultIconName [

{ #category : #building }
MiTagCommand >> buildToolbarButton: specCommand [

tagButton := SpToolbarMenuButtonPresenter new.

self canBeExecuted
ifFalse: [ self disableTagButton ]
ifTrue: [
tagButton
help: self buttonHelp ;
action: [ self execute ] ;
menu: self buildTagMenu.

self updateButton
].

^tagButton
^ #famixTagLabel
]

{ #category : #accessing }
MiTagCommand >> buttonHelp [
self canBeExecuted ifFalse: [ ^'no tagging' ].

^'left click to tag
right click to change tag'
]

{ #category : #accessing }
MiTagCommand >> buttonIcon [

^ self application iconForTag: context selectedTag
]

{ #category : #accessing }
MiTagCommand >> buttonLabel [
^context tagName
{ #category : #'accessing - defaults' }
MiTagCommand class >> defaultName [
^ 'Tag entities'
]

{ #category : #testing }
MiTagCommand >> canBeExecuted [

^ self context canTagEntities
^ self context canTagEntities and: [ context selectedTag isNotNil ]
]

{ #category : #building }
MiTagCommand >> disableTagButton [
tagButton
help: 'No tagging' ;
label: '--' ;
action: [ ] ;
disable
{ #category : #accessing }
MiTagCommand >> dynamicName [

^ context tagName
]

{ #category : #executing }
MiTagCommand >> execute [

context tagSelectedEntities
]

{ #category : #execution }
MiTagCommand >> selectedTag: aTag [
context selectedTag: aTag.
self updateButton
]

{ #category : #accessing }
MiTagCommand >> tagsList [
^context tagList.

]

{ #category : #building }
MiTagCommand >> updateButton [
tagButton label: self buttonLabel.
tagButton icon: self buttonIcon.
]
58 changes: 45 additions & 13 deletions src/MooseIDE-Core/MiWindowPresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,30 @@ MiWindowPresenter class >> buildCommandsGroupWith: aPresenter forRoot: rootComma

rootCommandGroup
register:
(MiReceivingModeCommand asCommandGroupForSpecContext: aPresenter) ;
register: (MiEditBusCommand forSpecContext: aPresenter) ;
register: (MiTagCommand forSpecContext: aPresenter) ;
(MiReceivingModeCommand asCommandGroupForSpecContext: aPresenter);
register: (MiEditBusCommand forSpecContext: aPresenter);
register: (self taggingCommandGroupFor: aPresenter);
register:
(MiHelpCommand forSpecContext: aPresenter) beDisplayedOnRightSide ;
(MiHelpCommand forSpecContext: aPresenter) beDisplayedOnRightSide;
register: (self actionsCommandGroupFor: aPresenter).

aPresenter hasSettings ifTrue: [
aPresenter hasSettings ifTrue: [
rootCommandGroup register:
(MiSettingsCommand forSpecContext: aPresenter)
beDisplayedOnRightSide ].
aPresenter hasVisualization ifTrue: [
rootCommandGroup register:
aPresenter hasVisualization ifTrue: [
rootCommandGroup register:
(MiExportVisualizationCommand forSpecContext: aPresenter)
beDisplayedOnRightSide
]
beDisplayedOnRightSide ]
]

{ #category : #commands }
MiWindowPresenter class >> taggingCommandGroupFor: aPresenter [

^ CmCommandGroup forSpec
name: 'Tagging';
register: (MiTagCommand forSpecContext: aPresenter);
register: (MiSelectTagCommand forSpecContext: aPresenter)
]

{ #category : #toolbar }
Expand Down Expand Up @@ -100,14 +108,38 @@ MiWindowPresenter >> updateReceivingModeButtons [
]

{ #category : #toolbar }
MiWindowPresenter >> updateToolbar [

self toolbarCommandGroup allCommands do: [ :cmd |
cmd updateEnableStatus ].
MiWindowPresenter >> updateReceivingModelToolbarButtons [

(self toolbarCommandGroup
commandOrGroupNamed: 'Receiving Mode'
ifNone: [ ^ self ]) commands do: [ :cmd |
cmd canBeExecuted ifFalse: [
cmd presenter icon: (cmd icon lighter: 0.4) ] ]
]

{ #category : #toolbar }
MiWindowPresenter >> updateTaggingToolbarButton [

| tagCommand |
tagCommand := (self toolbarCommandGroup
commandOrGroupNamed: 'Tagging'
ifNone: [ ^ self ])
commandOrGroupNamed: 'Tag entities'
ifNone: [ ^ self ].

tagCommand canBeExecuted ifTrue: [
tagCommand presenter
icon: (self application iconForTag: self presenter selectedTag);
label: self presenter selectedTag name ]
]

{ #category : #toolbar }
MiWindowPresenter >> updateToolbar [

self toolbarCommandGroup allCommands do: [ :cmd |
cmd updateEnableStatus ].

self updateReceivingModelToolbarButtons.

self updateTaggingToolbarButton
]

0 comments on commit 80fa6d1

Please sign in to comment.