From 22a9b32b0a6bb26f95eada1ae25c93764182e968 Mon Sep 17 00:00:00 2001 From: MeghaSudheendran Date: Fri, 25 Sep 2026 15:16:16 +0200 Subject: [PATCH 1/5] refactor: Created abstract super class MiTagAbstractForm --- .../MiTagCreationFormTest.class.st | 2 +- .../MiTagAbstractForm.class.st | 313 +++++++++++++++ .../MiTagCreationForm.class.st | 366 +----------------- .../MiTagEditionForm.class.st | 17 +- 4 files changed, 329 insertions(+), 369 deletions(-) create mode 100644 src/MooseIDE-Tagging/MiTagAbstractForm.class.st diff --git a/src/MooseIDE-Tagging-Tests/MiTagCreationFormTest.class.st b/src/MooseIDE-Tagging-Tests/MiTagCreationFormTest.class.st index 27333fc25..866d1d7aa 100644 --- a/src/MooseIDE-Tagging-Tests/MiTagCreationFormTest.class.st +++ b/src/MooseIDE-Tagging-Tests/MiTagCreationFormTest.class.st @@ -11,7 +11,7 @@ Class { { #category : 'helpers' } MiTagCreationFormTest >> presenterClass [ - ^ MiTagCreationForm + ^ MiTagCreationForm ] { #category : 'helpers' } diff --git a/src/MooseIDE-Tagging/MiTagAbstractForm.class.st b/src/MooseIDE-Tagging/MiTagAbstractForm.class.st new file mode 100644 index 000000000..cee969679 --- /dev/null +++ b/src/MooseIDE-Tagging/MiTagAbstractForm.class.st @@ -0,0 +1,313 @@ +" +the page that allows to enter information about the tag (like its name and category) +This is the right part of the tag browser +" +Class { + #name : 'MiTagAbstractForm', + #superclass : 'SpPresenter', + #instVars : [ + 'colorPicker', + 'cancelButton', + 'submitButton', + 'nameField', + 'descriptionField', + 'categorySelection', + 'intentButton', + 'extentButton', + 'isIntent', + 'queryList', + 'queryListLabeled', + 'tagBrowser' + ], + #category : 'MooseIDE-Tagging-Browser', + #package : 'MooseIDE-Tagging', + #tag : 'Browser' +} + +{ #category : 'accessing' } +MiTagAbstractForm >> cancelButton [ + + ^ cancelButton +] + +{ #category : 'accessing' } +MiTagAbstractForm >> categorySelection [ + + ^ categorySelection +] + +{ #category : 'initialization' } +MiTagAbstractForm >> checkFormInputs [ + + nameField text ifEmpty: [ ^ false ]. + ^ true +] + +{ #category : 'initialization' } +MiTagAbstractForm >> close [ + + owner close +] + +{ #category : 'private' } +MiTagAbstractForm >> connectPresenters [ + + extentButton action: [ self setExtentForm ]. + intentButton action: [ self setIntentForm ]. +] + +{ #category : 'brokerage' } +MiTagAbstractForm >> consume: aQuery [ + + self updateQueryList +] + +{ #category : 'accessing' } +MiTagAbstractForm >> extentButton [ + + ^ extentButton +] + +{ #category : 'initialization' } +MiTagAbstractForm >> fetchQueries [ + + ^ (tagBrowser application itemsFor: FQAbstractQuery) asOrderedCollection +] + +{ #category : 'initialization' } +MiTagAbstractForm >> formLayout [ + + ^ SpBoxLayout newTopToBottom + spacing: 10; + add: (SpBoxLayout newLeftToRight + spacing: 5; + add: (SpBoxLayout newTopToBottom + add: 'Name' asPresenter expand: false; + add: nameField expand: false; + yourself); + add: (SpBoxLayout newTopToBottom + add: 'Category (optional)'; + add: categorySelection; + yourself) + width: 200; + yourself) + expand: false; + add: (SpBoxLayout newTopToBottom + add: 'Description (optional)' asPresenter expand: false; + add: descriptionField expand: true; + yourself) + expand: true. +] + +{ #category : 'initialization' } +MiTagAbstractForm >> initialize [ + + super initialize. + isIntent := false. + +] + +{ #category : 'initialization' } +MiTagAbstractForm >> initializeDialogButtonsLayout [ + + ^SpBoxLayout newLeftToRight + hAlignEnd ; + add: cancelButton expand: false ; + add: submitButton expand: false ; + yourself +] + +{ #category : 'initialization' } +MiTagAbstractForm >> initializePresenters [ + + submitButton := self newButton + label: 'Add' ; + action: [ self submit ]. + cancelButton := self newButton + label: 'Cancel' ; + action: [ self close ]. + + colorPicker := self newColorPicker + setColor: Color random. + extentButton := self newToggleButton + state: true; + label: 'Static'. + intentButton := self newToggleButton + state: false; + label: 'Dynamic'. + + self initializeTagDescriptionPresenters. + + self initializeLayout +] + +{ #category : 'initialization' } +MiTagAbstractForm >> initializeTagDescriptionPresenters [ + + nameField := self newTextInput. + descriptionField := self newText. + categorySelection := self newDropList + sortingBlock: [ :item | + item model + ifNil: [ '' ] + ifNotNil: [ :category | category name ] ] + ascending; + display: [ :cat | cat ifNil: [ '' ] ifNotNil: [ cat name ] ]. + queryList := self newDropList + startWithoutSelection; + display: [ :query | self stringForQuery: query ]. + queryListLabeled := MiPresenter new + layout: (SpBoxLayout newTopToBottom + add: 'Query' asPresenter expand: false; + add: queryList expand: false; + yourself); + hide. + +] + +{ #category : 'accessing' } +MiTagAbstractForm >> intentButton [ + + ^ intentButton +] + +{ #category : 'accessing' } +MiTagAbstractForm >> nameField [ + + ^ nameField +] + +{ #category : 'accessing' } +MiTagAbstractForm >> queryList [ + + ^ queryList +] + +{ #category : 'accessing' } +MiTagAbstractForm >> queryListLabeled [ + + ^ queryListLabeled +] + +{ #category : 'brokerage' } +MiTagAbstractForm >> remove: aQuery [ + + self updateQueryList +] + +{ #category : 'initialization' } +MiTagAbstractForm >> reset [ + + colorPicker setColor: Color random. + nameField text: ''. + descriptionField text: ''. + categorySelection resetSelection. + queryList resetSelection. + self updateQueryList +] + +{ #category : 'private' } +MiTagAbstractForm >> setExtentForm [ + + isIntent ifFalse: [ + extentButton state: true. + ^ self ]. + isIntent := false. + intentButton state: false. + queryListLabeled hide. + self update +] + +{ #category : 'private' } +MiTagAbstractForm >> setIntentForm [ + + isIntent ifTrue: [ + intentButton state: true. + ^ self ]. + isIntent := true. + extentButton state: false. + queryListLabeled show. + self update +] + +{ #category : 'accessing' } +MiTagAbstractForm >> specModel [ + + ^tagBrowser specModel +] + +{ #category : 'initialization' } +MiTagAbstractForm >> stringForQuery: aQuery [ + + | queryText contractor | + queryText := aQuery ifNil: [ '' ] ifNotNil: [ + String streamContents: [ :aStream | + aQuery storeWithParentsOn: aStream ] ]. + contractor := LbCContractor new addStrategy: + (LbCEllipsisStrategy new + separator: '...'; + upTo: 50; + yourself). + ^ contractor reduce: queryText +] + +{ #category : 'initialization' } +MiTagAbstractForm >> submit [ + + | tag | + self checkFormInputs ifFalse: [ ^ self ]. + + tag := isIntent + ifTrue: [ + self specModel + createDynamicTag: nameField text + description: descriptionField text + color: colorPicker color + category: categorySelection selectedItem + query: queryList selectedItem ] + ifFalse: [ + self specModel + createTag: nameField text + description: descriptionField text + color: colorPicker color + category: categorySelection selectedItem ]. + + tag + ifNil: [ self alert: 'This tag name is already in use. Please choose a different one.' ]. + + tagBrowser refreshTagList. + self close +] + +{ #category : 'accessing' } +MiTagAbstractForm >> submitButton [ + + ^ submitButton +] + +{ #category : 'accessing' } +MiTagAbstractForm >> tagBrowser: aTagBrowser [ + + tagBrowser := aTagBrowser. + self updateQueryList. + self updateCategories +] + +{ #category : 'private' } +MiTagAbstractForm >> updateCategories [ + "allow to have no category, hence the first nil element" + + categorySelection items: { nil }, (self specModel allCategories) +] + +{ #category : 'accessing' } +MiTagAbstractForm >> updateQueryList [ + + queryList items: self fetchQueries +] + +{ #category : 'accessing - deprecated' } +MiTagAbstractForm >> windowTitle [ + + ^'Create tag' +] diff --git a/src/MooseIDE-Tagging/MiTagCreationForm.class.st b/src/MooseIDE-Tagging/MiTagCreationForm.class.st index 01e593f5f..878824e7e 100644 --- a/src/MooseIDE-Tagging/MiTagCreationForm.class.st +++ b/src/MooseIDE-Tagging/MiTagCreationForm.class.st @@ -1,366 +1,22 @@ -" -the page that allows to enter information about the tag (like its name and category) -This is the right part of the tag browser -" Class { #name : 'MiTagCreationForm', - #superclass : 'SpPresenter', - #instVars : [ - 'colorPicker', - 'cancelButton', - 'submitButton', - 'nameField', - 'descriptionField', - 'categorySelection', - 'intentButton', - 'extentButton', - 'isIntent', - 'queryList', - 'queryListLabeled', - 'tagBrowser' - ], + #superclass : 'MiTagAbstractForm', #category : 'MooseIDE-Tagging-Browser', #package : 'MooseIDE-Tagging', #tag : 'Browser' } -{ #category : 'accessing' } -MiTagCreationForm >> cancelButton [ - - ^ cancelButton -] - -{ #category : 'accessing' } -MiTagCreationForm >> categorySelection [ - - ^ categorySelection -] - -{ #category : 'initialization' } -MiTagCreationForm >> checkFormInputs [ - - nameField text ifEmpty: [ ^ false ]. - ^ true -] - -{ #category : 'initialization' } -MiTagCreationForm >> close [ - - owner close -] - -{ #category : 'private' } -MiTagCreationForm >> connectPresenters [ - - extentButton action: [ self setExtentForm ]. - intentButton action: [ self setIntentForm ]. -] - -{ #category : 'brokerage' } -MiTagCreationForm >> consume: aQuery [ - - self updateQueryList -] - -{ #category : 'accessing' } -MiTagCreationForm >> extentButton [ - - ^ extentButton -] - -{ #category : 'initialization' } -MiTagCreationForm >> fetchQueries [ - - ^ (tagBrowser application itemsFor: FQAbstractQuery) asOrderedCollection -] - -{ #category : 'initialization' } -MiTagCreationForm >> initialize [ - - super initialize. - isIntent := false. - -] - -{ #category : 'initialization' } -MiTagCreationForm >> initializeDialogButtonsLayout [ - - ^SpBoxLayout newLeftToRight - hAlignEnd ; - add: cancelButton expand: false ; - add: submitButton expand: false ; - yourself -] - { #category : 'initialization' } MiTagCreationForm >> initializeFormLayout [ - ^SpBoxLayout newTopToBottom - spacing: 5; - - add: (SpBoxLayout newLeftToRight - add: extentButton; - add: intentButton; - yourself) - expand: false; - - add: (SpBoxLayout newLeftToRight - spacing: 5; - - add: (SpBoxLayout newTopToBottom - add: 'Name' asPresenter expand: false; - add: nameField expand: false; - yourself); - - add: (SpBoxLayout newTopToBottom - add: 'Category (optional)'; - add: categorySelection; - yourself) - width: 200; - - yourself) - expand: false; - - add: (SpBoxLayout newTopToBottom - add: 'Description (optional)' asPresenter - expand: false; - add: descriptionField; - yourself) - expand: true; - add: queryListLabeled expand: false; - yourself. -] - -{ #category : 'initialization' } -MiTagCreationForm >> initializeLayout [ - - | sep colorPickerWidth colorPickerLayout | - self layout: (SpBoxLayout newTopToBottom spacing: 5). - - colorPickerWidth := 240. - - (sep := SpRoassalPresenter new) canvas color: (Color - r: 40 - g: 40 - b: 40 - range: 255) translucent. - - colorPickerLayout := SpBoxLayout newTopToBottom - add: (SpBoxLayout newLeftToRight - add: 'Tag Color' asPresenter; - hAlignCenter; - yourself) - width: colorPickerWidth; - add: colorPicker ; - yourself. - - self initializeFormLayout. - - self layout - add: (SpBoxLayout newLeftToRight - spacing: 10; - add: colorPickerLayout width: colorPickerWidth ; - add: sep width: 2; - add: (SpBoxLayout newTopToBottom - spacing: 5; - add: (self initializeFormLayout) expand: true fill: true; - add: self initializeDialogButtonsLayout expand: false ; - yourself); - yourself) - -] - -{ #category : 'initialization' } -MiTagCreationForm >> initializePresenters [ - - submitButton := self newButton - label: 'Add' ; - action: [ self submit ]. - cancelButton := self newButton - label: 'Cancel' ; - action: [ self close ]. - - colorPicker := self newColorPicker - setColor: Color random. - extentButton := self newToggleButton - state: true; - label: 'Static'. - intentButton := self newToggleButton - state: false; - label: 'Dynamic'. - - self initializeTagDescriptionPresenters. - - self initializeLayout -] - -{ #category : 'initialization' } -MiTagCreationForm >> initializeTagDescriptionPresenters [ - - nameField := self newTextInput. - descriptionField := self newText. - categorySelection := self newDropList - sortingBlock: [ :item | - item model - ifNil: [ '' ] - ifNotNil: [ :category | category name ] ] - ascending; - display: [ :cat | cat ifNil: [ '' ] ifNotNil: [ cat name ] ]. - queryList := self newDropList - startWithoutSelection; - display: [ :query | self stringForQuery: query ]. - queryListLabeled := MiPresenter new - layout: (SpBoxLayout newTopToBottom - add: 'Query' asPresenter expand: false; - add: queryList expand: false; - yourself); - hide. - -] - -{ #category : 'accessing' } -MiTagCreationForm >> intentButton [ - - ^ intentButton -] - -{ #category : 'accessing' } -MiTagCreationForm >> nameField [ - - ^ nameField -] - -{ #category : 'accessing' } -MiTagCreationForm >> queryList [ - - ^ queryList -] - -{ #category : 'accessing' } -MiTagCreationForm >> queryListLabeled [ - - ^ queryListLabeled -] - -{ #category : 'brokerage' } -MiTagCreationForm >> remove: aQuery [ - - self updateQueryList -] - -{ #category : 'initialization' } -MiTagCreationForm >> reset [ - - colorPicker setColor: Color random. - nameField text: ''. - descriptionField text: ''. - categorySelection resetSelection. - queryList resetSelection. - self updateQueryList -] - -{ #category : 'private' } -MiTagCreationForm >> setExtentForm [ - - isIntent ifFalse: [ - extentButton state: true. - ^ self ]. - isIntent := false. - intentButton state: false. - queryListLabeled hide. - self update -] - -{ #category : 'private' } -MiTagCreationForm >> setIntentForm [ - - isIntent ifTrue: [ - intentButton state: true. - ^ self ]. - isIntent := true. - extentButton state: false. - queryListLabeled show. - self update -] - -{ #category : 'accessing' } -MiTagCreationForm >> specModel [ - - ^tagBrowser specModel -] - -{ #category : 'initialization' } -MiTagCreationForm >> stringForQuery: aQuery [ - - | queryText contractor | - queryText := aQuery ifNil: [ '' ] ifNotNil: [ - String streamContents: [ :aStream | - aQuery storeWithParentsOn: aStream ] ]. - contractor := LbCContractor new addStrategy: - (LbCEllipsisStrategy new - separator: '...'; - upTo: 50; - yourself). - ^ contractor reduce: queryText -] - -{ #category : 'initialization' } -MiTagCreationForm >> submit [ - - | tag | - self checkFormInputs ifFalse: [ ^ self ]. - - tag := isIntent - ifTrue: [ - self specModel - createDynamicTag: nameField text - description: descriptionField text - color: colorPicker color - category: categorySelection selectedItem - query: queryList selectedItem ] - ifFalse: [ - self specModel - createTag: nameField text - description: descriptionField text - color: colorPicker color - category: categorySelection selectedItem ]. - - tag - ifNil: [ self alert: 'This tag name is already in use. Please choose a different one.' ]. - - tagBrowser refreshTagList. - self close -] - -{ #category : 'accessing' } -MiTagCreationForm >> submitButton [ - - ^ submitButton -] - -{ #category : 'accessing' } -MiTagCreationForm >> tagBrowser: aTagBrowser [ - - tagBrowser := aTagBrowser. - self updateQueryList. - self updateCategories -] - -{ #category : 'private' } -MiTagCreationForm >> updateCategories [ - "allow to have no category, hence the first nil element" - - categorySelection items: { nil }, (self specModel allCategories) -] - -{ #category : 'accessing' } -MiTagCreationForm >> updateQueryList [ - - queryList items: self fetchQueries -] - -{ #category : 'accessing - deprecated' } -MiTagCreationForm >> windowTitle [ - - ^'Create tag' + ^ SpBoxLayout newTopToBottom + spacing: 5; + add: (SpBoxLayout newLeftToRight + add: extentButton; + add: intentButton; + yourself) + expand: false; + add: self formLayout expand: true; + add: queryListLabeled expand: false; + yourself ] diff --git a/src/MooseIDE-Tagging/MiTagEditionForm.class.st b/src/MooseIDE-Tagging/MiTagEditionForm.class.st index 417dab4df..c403f8aa3 100644 --- a/src/MooseIDE-Tagging/MiTagEditionForm.class.st +++ b/src/MooseIDE-Tagging/MiTagEditionForm.class.st @@ -1,6 +1,6 @@ Class { #name : 'MiTagEditionForm', - #superclass : 'MiTagCreationForm', + #superclass : 'MiTagAbstractForm', #category : 'MooseIDE-Tagging-Browser', #package : 'MooseIDE-Tagging', #tag : 'Browser' @@ -9,7 +9,7 @@ Class { { #category : 'initialization' } MiTagEditionForm >> checkFormInputs [ - nameField text ifEmpty: [ ^ false ]. + self specModel currentTag isIntent ifFalse: [ (self specModel getTagNamed: nameField text) ifNotNil: [ :tag | self specModel currentTag = tag ifFalse: [ @@ -27,18 +27,9 @@ MiTagEditionForm >> checkFormInputs [ yourself); popup. ^ false ] ] ]. + - - ^ true -] - -{ #category : 'initialization' } -MiTagEditionForm >> connectPresenters [ - - "cancelButton action: [ - self reset. - self owner closeTagEditionForm ]. - submitButton action: [ self submit ]" + ^ super checkFormInputs ] { #category : 'accessing' } From 964df038e5c767010783ca7632fb3d1b3b10acb7 Mon Sep 17 00:00:00 2001 From: MeghaSudheendran Date: Fri, 25 Sep 2026 15:16:59 +0200 Subject: [PATCH 2/5] refactor: same as previous commit. --- .../MiTagAbstractForm.class.st | 12 +++++++ .../MiTagEditionForm.class.st | 36 +++---------------- 2 files changed, 17 insertions(+), 31 deletions(-) diff --git a/src/MooseIDE-Tagging/MiTagAbstractForm.class.st b/src/MooseIDE-Tagging/MiTagAbstractForm.class.st index cee969679..4e0800168 100644 --- a/src/MooseIDE-Tagging/MiTagAbstractForm.class.st +++ b/src/MooseIDE-Tagging/MiTagAbstractForm.class.st @@ -117,6 +117,18 @@ MiTagAbstractForm >> initializeDialogButtonsLayout [ yourself ] +{ #category : 'initialization' } +MiTagAbstractForm >> initializeFormLayout [ + + self subclassResponsibility +] + +{ #category : 'initialization' } +MiTagAbstractForm >> initializeLayout [ + self initializeFormLayout + +] + { #category : 'initialization' } MiTagAbstractForm >> initializePresenters [ diff --git a/src/MooseIDE-Tagging/MiTagEditionForm.class.st b/src/MooseIDE-Tagging/MiTagEditionForm.class.st index c403f8aa3..ea2f9040b 100644 --- a/src/MooseIDE-Tagging/MiTagEditionForm.class.st +++ b/src/MooseIDE-Tagging/MiTagEditionForm.class.st @@ -49,41 +49,15 @@ MiTagEditionForm >> fillWithCurrentTag [ ] { #category : 'initialization' } -MiTagEditionForm >> formLayout [ - - ^ SpBoxLayout newTopToBottom - spacing: 10; - add: (SpBoxLayout newLeftToRight - spacing: 5; - add: (SpBoxLayout newTopToBottom - add: 'Name' asPresenter expand: false; - add: nameField expand: false; - yourself); - add: (SpBoxLayout newTopToBottom - add: 'Category (optional)'; - add: categorySelection; - yourself) - width: 200; - yourself) - expand: false; - add: (SpBoxLayout newTopToBottom - add: 'Description (optional)' asPresenter expand: false; - add: descriptionField height: 150; - yourself) - expand: false; - add: (SpBoxLayout newLeftToRight - vAlignEnd; - spacing: 10; - add: cancelButton; - add: submitButton; - yourself); - yourself +MiTagEditionForm >> formTitle [ + + ^ 'Edit tag' ] { #category : 'initialization' } -MiTagEditionForm >> formTitle [ +MiTagEditionForm >> initializeFormLayout [ - ^ 'Edit tag' + ^ self formLayout ] { #category : 'initialization' } From 116ef6b9a7410b8380f1653d8069cc29ea8fd951 Mon Sep 17 00:00:00 2001 From: MeghaSudheendran Date: Fri, 25 Sep 2026 15:28:29 +0200 Subject: [PATCH 3/5] fix: Corrected bug in opening the window --- .../MiTagAbstractForm.class.st | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/src/MooseIDE-Tagging/MiTagAbstractForm.class.st b/src/MooseIDE-Tagging/MiTagAbstractForm.class.st index 4e0800168..1a209c1ef 100644 --- a/src/MooseIDE-Tagging/MiTagAbstractForm.class.st +++ b/src/MooseIDE-Tagging/MiTagAbstractForm.class.st @@ -96,7 +96,8 @@ MiTagAbstractForm >> formLayout [ add: 'Description (optional)' asPresenter expand: false; add: descriptionField expand: true; yourself) - expand: true. + expand: true ; + yourself ] { #category : 'initialization' } @@ -125,7 +126,40 @@ MiTagAbstractForm >> initializeFormLayout [ { #category : 'initialization' } MiTagAbstractForm >> initializeLayout [ - self initializeFormLayout + + | sep colorPickerWidth colorPickerLayout | + self layout: (SpBoxLayout newTopToBottom spacing: 5). + + colorPickerWidth := 240. + + (sep := SpRoassalPresenter new) canvas color: (Color + r: 40 + g: 40 + b: 40 + range: 255) translucent. + + colorPickerLayout := SpBoxLayout newTopToBottom + add: (SpBoxLayout newLeftToRight + add: 'Tag Color' asPresenter; + hAlignCenter; + yourself) + width: colorPickerWidth; + add: colorPicker ; + yourself. + + self initializeFormLayout. + + self layout + add: (SpBoxLayout newLeftToRight + spacing: 10; + add: colorPickerLayout width: colorPickerWidth ; + add: sep width: 2; + add: (SpBoxLayout newTopToBottom + spacing: 5; + add: (self initializeFormLayout) expand: true fill: true; + add: self initializeDialogButtonsLayout expand: false ; + yourself); + yourself) ] From bbc2c0e15eeb0c309b3b7a3c13aa3b36576c5d05 Mon Sep 17 00:00:00 2001 From: MeghaSudheendran Date: Fri, 25 Sep 2026 16:21:54 +0200 Subject: [PATCH 4/5] refactor: moved 2 instance variables down (MiTagCreationForm) --- .../MiTagCreationFormTest.class.st | 17 +++- .../MiTagAbstractForm.class.st | 65 ++++----------- .../MiTagCreationForm.class.st | 80 +++++++++++++++++++ .../MiTagEditionForm.class.st | 36 ++++++--- 4 files changed, 133 insertions(+), 65 deletions(-) diff --git a/src/MooseIDE-Tagging-Tests/MiTagCreationFormTest.class.st b/src/MooseIDE-Tagging-Tests/MiTagCreationFormTest.class.st index 866d1d7aa..f20090ae0 100644 --- a/src/MooseIDE-Tagging-Tests/MiTagCreationFormTest.class.st +++ b/src/MooseIDE-Tagging-Tests/MiTagCreationFormTest.class.st @@ -93,14 +93,25 @@ MiTagCreationFormTest >> testQueryDropListFetchQueriesFromQueriesProducer [ ] { #category : 'tests' } -MiTagCreationFormTest >> testSetIntentTag [ +MiTagCreationFormTest >> testSetExtentTag [ self deny: creationForm intentButton state. - self flag: 'fix weird behavior'. + creationForm extentButton click. + creationForm extentButton action value. "this should be triggered by clicking on the button but it does seem to work :-(" + + self deny: creationForm intentButton state. + self assert: creationForm extentButton state. + self deny: creationForm queryListLabeled isVisible +] + +{ #category : 'tests' } +MiTagCreationFormTest >> testSetIntentTag [ + + self deny: creationForm intentButton state. creationForm intentButton click. - creationForm intentButton action value. + creationForm intentButton action value. "this should be triggered by clicking on the button but it does seem to work :-(" self assert: creationForm intentButton state. self deny: creationForm extentButton state. diff --git a/src/MooseIDE-Tagging/MiTagAbstractForm.class.st b/src/MooseIDE-Tagging/MiTagAbstractForm.class.st index 1a209c1ef..f208670d4 100644 --- a/src/MooseIDE-Tagging/MiTagAbstractForm.class.st +++ b/src/MooseIDE-Tagging/MiTagAbstractForm.class.st @@ -12,8 +12,6 @@ Class { 'nameField', 'descriptionField', 'categorySelection', - 'intentButton', - 'extentButton', 'isIntent', 'queryList', 'queryListLabeled', @@ -49,25 +47,12 @@ MiTagAbstractForm >> close [ owner close ] -{ #category : 'private' } -MiTagAbstractForm >> connectPresenters [ - - extentButton action: [ self setExtentForm ]. - intentButton action: [ self setIntentForm ]. -] - { #category : 'brokerage' } MiTagAbstractForm >> consume: aQuery [ self updateQueryList ] -{ #category : 'accessing' } -MiTagAbstractForm >> extentButton [ - - ^ extentButton -] - { #category : 'initialization' } MiTagAbstractForm >> fetchQueries [ @@ -175,13 +160,7 @@ MiTagAbstractForm >> initializePresenters [ colorPicker := self newColorPicker setColor: Color random. - extentButton := self newToggleButton - state: true; - label: 'Static'. - intentButton := self newToggleButton - state: false; - label: 'Dynamic'. - + self initializeTagDescriptionPresenters. self initializeLayout @@ -211,10 +190,10 @@ MiTagAbstractForm >> initializeTagDescriptionPresenters [ ] -{ #category : 'accessing' } -MiTagAbstractForm >> intentButton [ +{ #category : 'testing' } +MiTagAbstractForm >> isIntentSubmit [ - ^ intentButton + self subclassResponsibility ] { #category : 'accessing' } @@ -223,6 +202,12 @@ MiTagAbstractForm >> nameField [ ^ nameField ] +{ #category : 'testing' } +MiTagAbstractForm >> notIntentSubmit [ + + self subclassResponsibility +] + { #category : 'accessing' } MiTagAbstractForm >> queryList [ @@ -255,11 +240,7 @@ MiTagAbstractForm >> reset [ { #category : 'private' } MiTagAbstractForm >> setExtentForm [ - isIntent ifFalse: [ - extentButton state: true. - ^ self ]. isIntent := false. - intentButton state: false. queryListLabeled hide. self update ] @@ -267,11 +248,7 @@ MiTagAbstractForm >> setExtentForm [ { #category : 'private' } MiTagAbstractForm >> setIntentForm [ - isIntent ifTrue: [ - intentButton state: true. - ^ self ]. isIntent := true. - extentButton state: false. queryListLabeled show. self update ] @@ -304,22 +281,12 @@ MiTagAbstractForm >> submit [ self checkFormInputs ifFalse: [ ^ self ]. tag := isIntent - ifTrue: [ - self specModel - createDynamicTag: nameField text - description: descriptionField text - color: colorPicker color - category: categorySelection selectedItem - query: queryList selectedItem ] - ifFalse: [ - self specModel - createTag: nameField text - description: descriptionField text - color: colorPicker color - category: categorySelection selectedItem ]. - - tag - ifNil: [ self alert: 'This tag name is already in use. Please choose a different one.' ]. + ifTrue: [ self isIntentSubmit ] + ifFalse: [ self notIntentSubmit ]. + + tag ifNil: [ + self alert: + 'This tag name is already in use. Please choose a different one.' ]. tagBrowser refreshTagList. self close diff --git a/src/MooseIDE-Tagging/MiTagCreationForm.class.st b/src/MooseIDE-Tagging/MiTagCreationForm.class.st index 878824e7e..dbfb5f5c1 100644 --- a/src/MooseIDE-Tagging/MiTagCreationForm.class.st +++ b/src/MooseIDE-Tagging/MiTagCreationForm.class.st @@ -1,11 +1,28 @@ Class { #name : 'MiTagCreationForm', #superclass : 'MiTagAbstractForm', + #instVars : [ + 'intentButton', + 'extentButton' + ], #category : 'MooseIDE-Tagging-Browser', #package : 'MooseIDE-Tagging', #tag : 'Browser' } +{ #category : 'private' } +MiTagCreationForm >> connectPresenters [ + + extentButton action: [ self setExtentForm ]. + intentButton action: [ self setIntentForm ]. +] + +{ #category : 'accessing' } +MiTagCreationForm >> extentButton [ + + ^ extentButton +] + { #category : 'initialization' } MiTagCreationForm >> initializeFormLayout [ @@ -20,3 +37,66 @@ MiTagCreationForm >> initializeFormLayout [ add: queryListLabeled expand: false; yourself ] + +{ #category : 'initialization' } +MiTagCreationForm >> initializePresenters [ + + extentButton := self newToggleButton + state: true; + label: 'Static'. + intentButton := self newToggleButton + state: false; + label: 'Dynamic'. + super initializePresenters +] + +{ #category : 'accessing' } +MiTagCreationForm >> intentButton [ + + ^ intentButton +] + +{ #category : 'testing' } +MiTagCreationForm >> isIntentSubmit [ + + self specModel + createDynamicTag: nameField text + description: descriptionField text + color: colorPicker color + category: categorySelection selectedItem + query: queryList selectedItem +] + +{ #category : 'testing' } +MiTagCreationForm >> notIntentSubmit [ + + self specModel + createTag: nameField text + description: descriptionField text + color: colorPicker color + category: categorySelection selectedItem +] + +{ #category : 'private' } +MiTagCreationForm >> setExtentForm [ + + isIntent ifFalse: [ + extentButton state: true. + ^ self ]. + + intentButton state: false. + + super setExtentForm +] + +{ #category : 'private' } +MiTagCreationForm >> setIntentForm [ + + isIntent ifTrue: [ + intentButton state: true. + ^ self ]. + + extentButton state: false. + + super setIntentForm +] diff --git a/src/MooseIDE-Tagging/MiTagEditionForm.class.st b/src/MooseIDE-Tagging/MiTagEditionForm.class.st index ea2f9040b..88d88df83 100644 --- a/src/MooseIDE-Tagging/MiTagEditionForm.class.st +++ b/src/MooseIDE-Tagging/MiTagEditionForm.class.st @@ -70,6 +70,27 @@ MiTagEditionForm >> initializePresenters [ intentButton hide. ] +{ #category : 'initialization' } +MiTagEditionForm >> isIntentSubmit [ + + self specModel + editCurrentDynamicTag: nameField text + description: descriptionField text + color: colorPicker color + category: categorySelection selectedItem + query: queryList selectedItem +] + +{ #category : 'initialization' } +MiTagEditionForm >> notIntentSubmit [ + + self specModel + editCurrentTag: nameField text + description: descriptionField text + color: colorPicker color + category: categorySelection selectedItem +] + { #category : 'accessing' } MiTagEditionForm >> setDynamicTag: aTag [ @@ -102,19 +123,8 @@ MiTagEditionForm >> submit [ self checkFormInputs ifFalse: [ ^ self ]. self specModel currentTag isIntent - ifTrue: [ - self specModel - editCurrentDynamicTag: nameField text - description: descriptionField text - color: colorPicker color - category: categorySelection selectedItem - query: queryList selectedItem ] - ifFalse: [ - self specModel - editCurrentTag: nameField text - description: descriptionField text - color: colorPicker color - category: categorySelection selectedItem ]. + ifTrue: [ self isIntentSubmit ] + ifFalse: [ self notIntentSubmit ]. tagBrowser refreshTagList. self close From 3f59770ee0ec010f73e15d5d82917de785e346a8 Mon Sep 17 00:00:00 2001 From: MeghaSudheendran Date: Fri, 25 Sep 2026 16:35:18 +0200 Subject: [PATCH 5/5] refactor: push down another instance variable to MiTagCreationForm --- .../MiTagAbstractForm.class.st | 16 +----------- .../MiTagCreationForm.class.st | 26 ++++++++++++++++--- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/MooseIDE-Tagging/MiTagAbstractForm.class.st b/src/MooseIDE-Tagging/MiTagAbstractForm.class.st index f208670d4..b0c90d96e 100644 --- a/src/MooseIDE-Tagging/MiTagAbstractForm.class.st +++ b/src/MooseIDE-Tagging/MiTagAbstractForm.class.st @@ -14,7 +14,6 @@ Class { 'categorySelection', 'isIntent', 'queryList', - 'queryListLabeled', 'tagBrowser' ], #category : 'MooseIDE-Tagging-Browser', @@ -181,12 +180,6 @@ MiTagAbstractForm >> initializeTagDescriptionPresenters [ queryList := self newDropList startWithoutSelection; display: [ :query | self stringForQuery: query ]. - queryListLabeled := MiPresenter new - layout: (SpBoxLayout newTopToBottom - add: 'Query' asPresenter expand: false; - add: queryList expand: false; - yourself); - hide. ] @@ -214,12 +207,6 @@ MiTagAbstractForm >> queryList [ ^ queryList ] -{ #category : 'accessing' } -MiTagAbstractForm >> queryListLabeled [ - - ^ queryListLabeled -] - { #category : 'brokerage' } MiTagAbstractForm >> remove: aQuery [ @@ -241,7 +228,6 @@ MiTagAbstractForm >> reset [ MiTagAbstractForm >> setExtentForm [ isIntent := false. - queryListLabeled hide. self update ] @@ -249,7 +235,7 @@ MiTagAbstractForm >> setExtentForm [ MiTagAbstractForm >> setIntentForm [ isIntent := true. - queryListLabeled show. + self update ] diff --git a/src/MooseIDE-Tagging/MiTagCreationForm.class.st b/src/MooseIDE-Tagging/MiTagCreationForm.class.st index dbfb5f5c1..a448cd009 100644 --- a/src/MooseIDE-Tagging/MiTagCreationForm.class.st +++ b/src/MooseIDE-Tagging/MiTagCreationForm.class.st @@ -3,7 +3,8 @@ Class { #superclass : 'MiTagAbstractForm', #instVars : [ 'intentButton', - 'extentButton' + 'extentButton', + 'queryListLabeled' ], #category : 'MooseIDE-Tagging-Browser', #package : 'MooseIDE-Tagging', @@ -50,6 +51,19 @@ MiTagCreationForm >> initializePresenters [ super initializePresenters ] +{ #category : 'initialization' } +MiTagCreationForm >> initializeTagDescriptionPresenters [ + + super initializeTagDescriptionPresenters. + queryListLabeled := MiPresenter new + layout: (SpBoxLayout newTopToBottom + add: 'Query' asPresenter expand: false; + add: queryList expand: false; + yourself); + hide. + +] + { #category : 'accessing' } MiTagCreationForm >> intentButton [ @@ -77,6 +91,12 @@ MiTagCreationForm >> notIntentSubmit [ category: categorySelection selectedItem ] +{ #category : 'accessing' } +MiTagCreationForm >> queryListLabeled [ + + ^ queryListLabeled +] + { #category : 'private' } MiTagCreationForm >> setExtentForm [ @@ -85,7 +105,7 @@ MiTagCreationForm >> setExtentForm [ ^ self ]. intentButton state: false. - + queryListLabeled hide. super setExtentForm ] @@ -97,6 +117,6 @@ MiTagCreationForm >> setIntentForm [ ^ self ]. extentButton state: false. - + queryListLabeled show. super setIntentForm ]