diff --git a/repository/OpenPonk-ClassEditor/OPDiagramElement.extension.st b/repository/OpenPonk-ClassEditor/OPDiagramElement.extension.st index 428f4029..6df0c577 100644 --- a/repository/OpenPonk-ClassEditor/OPDiagramElement.extension.st +++ b/repository/OpenPonk-ClassEditor/OPDiagramElement.extension.st @@ -3,15 +3,27 @@ Extension { #name : 'OPDiagramElement' } { #category : '*OpenPonk-ClassEditor' } OPDiagramElement >> showAssociationEndLabels [ - ^ self - stylePropertyNamed: #showAssociationEndLabels - ifAbsent: [ true ] + ^ self stylePropertyNamed: self showAssociationEndLabelsKey ifAbsent: [ + OPUmlDiagramHideSameAsClassEndLabelsFigureCommand + resultingShowState ] ] { #category : '*OpenPonk-ClassEditor' } -OPDiagramElement >> showAssociationEndLabels: aBoolean [ +OPDiagramElement >> showAssociationEndLabels: aSymbol [ - self stylePropertyNamed: #showAssociationEndLabels put: aBoolean + self stylePropertyNamed: self showAssociationEndLabelsKey put: aSymbol +] + +{ #category : '*OpenPonk-ClassEditor' } +OPDiagramElement class >> showAssociationEndLabelsKey [ + + ^ #showAssociationEndLabels +] + +{ #category : '*OpenPonk-ClassEditor' } +OPDiagramElement >> showAssociationEndLabelsKey [ + + ^ self class showAssociationEndLabelsKey ] { #category : '*OpenPonk-ClassEditor' } @@ -19,3 +31,9 @@ OPDiagramElement >> supportsHidingLabelEnds [ ^ false ] + +{ #category : '*OpenPonk-ClassEditor' } +OPDiagramElement >> unsetAssociationEndLabels [ + + self removeLocalStylePropertyNamed: self showAssociationEndLabelsKey +] diff --git a/repository/OpenPonk-ClassEditor/OPUmlAssociationEndLabel.class.st b/repository/OpenPonk-ClassEditor/OPUmlAssociationEndLabel.class.st index 4604d20c..b5742df9 100644 --- a/repository/OpenPonk-ClassEditor/OPUmlAssociationEndLabel.class.st +++ b/repository/OpenPonk-ClassEditor/OPUmlAssociationEndLabel.class.st @@ -41,8 +41,13 @@ OPUmlAssociationEndLabel >> defaultMinDistance [ OPUmlAssociationEndLabel >> defaultText [ | type typeName defaultText | + self showAssociationEndLabels + = OPUmlDiagramHideEndLabelsFigureCommand resultingShowState ifTrue: [ + ^ '' ]. defaultText := self modelElement notationStringAsRoleName. - self showAssociationEndLabels ifTrue: [ ^ defaultText ]. + self showAssociationEndLabels + = OPUmlDiagramShowEndLabelsFigureCommand resultingShowState ifTrue: [ + ^ defaultText ]. type := self modelElement type. type ifNil: [ ^ defaultText ]. typeName := type name. @@ -50,8 +55,8 @@ OPUmlAssociationEndLabel >> defaultText [ typeName ifEmpty: [ ^ defaultText ]. (typeName reject: [ :each | each isSeparator ]) asLowercase = (defaultText reject: [ :each | each isSeparator ]) asLowercase - ifTrue: [ ^ '' ]. - ^ defaultText + ifFalse: [ ^ defaultText ]. + ^ '' ] { #category : 'initialization' } diff --git a/repository/OpenPonk-ClassEditor/OPUmlDiagramEndLabelsFigureCommand.class.st b/repository/OpenPonk-ClassEditor/OPUmlDiagramEndLabelsFigureCommand.class.st index 1b314c67..46bd4bcb 100644 --- a/repository/OpenPonk-ClassEditor/OPUmlDiagramEndLabelsFigureCommand.class.st +++ b/repository/OpenPonk-ClassEditor/OPUmlDiagramEndLabelsFigureCommand.class.st @@ -11,8 +11,16 @@ OPUmlDiagramEndLabelsFigureCommand class >> canBeExecutedInContext: aToolContext ^ (super canBeExecutedInContext: aToolContext) and: [ aToolContext diagramElements anySatisfy: [ :any | - any supportsHidingLabelEnds and: [ - any showAssociationEndLabels ~= self resultingShowState ] ] ] + any supportsHidingLabelEnds ] ] +] + +{ #category : 'activation' } +OPUmlDiagramEndLabelsFigureCommand class >> contextMenuActivation [ + + + ^ CmdContextMenuActivation + byItemOf: OPUmlDiagramEndLabelsFigureMenuGroup + for: OPCanvasPresenter ] { #category : 'testing' } @@ -21,29 +29,32 @@ OPUmlDiagramEndLabelsFigureCommand class >> isAbstract [ ^ self = OPUmlDiagramEndLabelsFigureCommand ] -{ #category : 'hooks' } -OPUmlDiagramEndLabelsFigureCommand class >> resultingShowState [ +{ #category : 'accessing' } +OPUmlDiagramEndLabelsFigureCommand >> basicMenuItemName [ - ^ self subclassResponsibility + ^ '' ] { #category : 'accessing' } -OPUmlDiagramEndLabelsFigureCommand >> defaultMenuIconName [ +OPUmlDiagramEndLabelsFigureCommand >> defaultMenuItemName [ - ^ #smallLeftFlush + | basicName | + basicName := self basicMenuItemName. + + self isCurrent ifFalse: [ ^ basicName ]. + + ^ basicName , ' [current]' ] -{ #category : 'execution' } -OPUmlDiagramEndLabelsFigureCommand >> execute [ +{ #category : 'testing' } +OPUmlDiagramEndLabelsFigureCommand >> isCurrent [ - diagramElements - select: [ :each | each supportsHidingLabelEnds ] - thenDo: [ :each | - each showAssociationEndLabels: self resultingShowState ] + ^ diagramElements anySatisfy: [ :any | + self isCurrentStyle: any localStyle ] ] -{ #category : 'hooks' } -OPUmlDiagramEndLabelsFigureCommand >> resultingShowState [ +{ #category : 'testing' } +OPUmlDiagramEndLabelsFigureCommand >> isCurrentStyle: aStyle [ - ^ self class resultingShowState + ^ self subclassResponsibility ] diff --git a/repository/OpenPonk-ClassEditor/OPUmlDiagramEndLabelsFigureMenuGroup.class.st b/repository/OpenPonk-ClassEditor/OPUmlDiagramEndLabelsFigureMenuGroup.class.st new file mode 100644 index 00000000..537885cb --- /dev/null +++ b/repository/OpenPonk-ClassEditor/OPUmlDiagramEndLabelsFigureMenuGroup.class.st @@ -0,0 +1,13 @@ +Class { + #name : 'OPUmlDiagramEndLabelsFigureMenuGroup', + #superclass : 'CmdMenuGroup', + #category : 'OpenPonk-ClassEditor-Commands', + #package : 'OpenPonk-ClassEditor', + #tag : 'Commands' +} + +{ #category : 'accessing' } +OPUmlDiagramEndLabelsFigureMenuGroup >> name [ + + ^ 'Association end labels' +] diff --git a/repository/OpenPonk-ClassEditor/OPUmlDiagramHideEndLabelsFigureCommand.class.st b/repository/OpenPonk-ClassEditor/OPUmlDiagramHideEndLabelsFigureCommand.class.st index 6f911844..144ab310 100644 --- a/repository/OpenPonk-ClassEditor/OPUmlDiagramHideEndLabelsFigureCommand.class.st +++ b/repository/OpenPonk-ClassEditor/OPUmlDiagramHideEndLabelsFigureCommand.class.st @@ -1,33 +1,31 @@ Class { #name : 'OPUmlDiagramHideEndLabelsFigureCommand', - #superclass : 'OPUmlDiagramEndLabelsFigureCommand', + #superclass : 'OPUmlDiagramSetEndLabelsFigureCommand', #category : 'OpenPonk-ClassEditor-Commands', #package : 'OpenPonk-ClassEditor', #tag : 'Commands' } -{ #category : 'testing' } -OPUmlDiagramHideEndLabelsFigureCommand class >> canBeExecutedInContext: aToolContext [ +{ #category : 'hooks' } +OPUmlDiagramHideEndLabelsFigureCommand class >> resultingShowState [ - ^ (super canBeExecutedInContext: aToolContext) and: [ - aToolContext diagramElements anySatisfy: [ :any | - any showAssociationEndLabels ] ] + ^ #show ] -{ #category : 'hooks' } -OPUmlDiagramHideEndLabelsFigureCommand class >> resultingShowState [ +{ #category : 'accessing' } +OPUmlDiagramHideEndLabelsFigureCommand >> basicMenuItemName [ - ^ false + ^ 'Hide all' ] { #category : 'accessing' } -OPUmlDiagramHideEndLabelsFigureCommand >> defaultMenuItemName [ +OPUmlDiagramHideEndLabelsFigureCommand >> defaultMenuIconFormSet [ - ^ 'Hide association end labels' + ^ FormSet form: OPCoreIcons opHideLabelsIcon ] { #category : 'accessing' } OPUmlDiagramHideEndLabelsFigureCommand >> description [ - ^ 'Hide association end labels where the text is just name of the class' + ^ 'Hide all association end labels' ] diff --git a/repository/OpenPonk-ClassEditor/OPUmlDiagramHideSameAsClassEndLabelsFigureCommand.class.st b/repository/OpenPonk-ClassEditor/OPUmlDiagramHideSameAsClassEndLabelsFigureCommand.class.st new file mode 100644 index 00000000..b18d7a05 --- /dev/null +++ b/repository/OpenPonk-ClassEditor/OPUmlDiagramHideSameAsClassEndLabelsFigureCommand.class.st @@ -0,0 +1,31 @@ +Class { + #name : 'OPUmlDiagramHideSameAsClassEndLabelsFigureCommand', + #superclass : 'OPUmlDiagramSetEndLabelsFigureCommand', + #category : 'OpenPonk-ClassEditor-Commands', + #package : 'OpenPonk-ClassEditor', + #tag : 'Commands' +} + +{ #category : 'hooks' } +OPUmlDiagramHideSameAsClassEndLabelsFigureCommand class >> resultingShowState [ + + ^ #hideSame +] + +{ #category : 'accessing' } +OPUmlDiagramHideSameAsClassEndLabelsFigureCommand >> basicMenuItemName [ + + ^ 'Hide same as class name' +] + +{ #category : 'accessing' } +OPUmlDiagramHideSameAsClassEndLabelsFigureCommand >> defaultMenuIconFormSet [ + + ^ FormSet form: OPCoreIcons opHideSameLabelsIcon +] + +{ #category : 'accessing' } +OPUmlDiagramHideSameAsClassEndLabelsFigureCommand >> description [ + + ^ 'Hide association end labels where the text is the same as name of the class' +] diff --git a/repository/OpenPonk-ClassEditor/OPUmlDiagramSetEndLabelsFigureCommand.class.st b/repository/OpenPonk-ClassEditor/OPUmlDiagramSetEndLabelsFigureCommand.class.st new file mode 100644 index 00000000..8e45ec7d --- /dev/null +++ b/repository/OpenPonk-ClassEditor/OPUmlDiagramSetEndLabelsFigureCommand.class.st @@ -0,0 +1,44 @@ +Class { + #name : 'OPUmlDiagramSetEndLabelsFigureCommand', + #superclass : 'OPUmlDiagramEndLabelsFigureCommand', + #category : 'OpenPonk-ClassEditor-Commands', + #package : 'OpenPonk-ClassEditor', + #tag : 'Commands' +} + +{ #category : 'testing' } +OPUmlDiagramSetEndLabelsFigureCommand class >> isAbstract [ + + ^ self = OPUmlDiagramSetEndLabelsFigureCommand +] + +{ #category : 'hooks' } +OPUmlDiagramSetEndLabelsFigureCommand class >> resultingShowState [ + + ^ #'' +] + +{ #category : 'execution' } +OPUmlDiagramSetEndLabelsFigureCommand >> execute [ + + diagramElements + select: [ :each | each supportsHidingLabelEnds ] + thenDo: [ :each | + each showAssociationEndLabels: self resultingShowState ] +] + +{ #category : 'testing' } +OPUmlDiagramSetEndLabelsFigureCommand >> isCurrentStyle: aStyle [ + + aStyle ifNil: [ ^ false ]. + ^ aStyle + at: OPUmlAssociationEndLabel showAssociationEndLabelsKey + ifPresent: [ :styleValue | styleValue = self resultingShowState ] + ifAbsent: [ false ] +] + +{ #category : 'hooks' } +OPUmlDiagramSetEndLabelsFigureCommand >> resultingShowState [ + + ^ self class resultingShowState +] diff --git a/repository/OpenPonk-ClassEditor/OPUmlDiagramShowEndLabelsFigureCommand.class.st b/repository/OpenPonk-ClassEditor/OPUmlDiagramShowEndLabelsFigureCommand.class.st index 82917188..40413e9d 100644 --- a/repository/OpenPonk-ClassEditor/OPUmlDiagramShowEndLabelsFigureCommand.class.st +++ b/repository/OpenPonk-ClassEditor/OPUmlDiagramShowEndLabelsFigureCommand.class.st @@ -1,33 +1,31 @@ Class { #name : 'OPUmlDiagramShowEndLabelsFigureCommand', - #superclass : 'OPUmlDiagramEndLabelsFigureCommand', + #superclass : 'OPUmlDiagramSetEndLabelsFigureCommand', #category : 'OpenPonk-ClassEditor-Commands', #package : 'OpenPonk-ClassEditor', #tag : 'Commands' } -{ #category : 'testing' } -OPUmlDiagramShowEndLabelsFigureCommand class >> canBeExecutedInContext: aToolContext [ +{ #category : 'hooks' } +OPUmlDiagramShowEndLabelsFigureCommand class >> resultingShowState [ - ^ (super canBeExecutedInContext: aToolContext) and: [ - aToolContext diagramElements anySatisfy: [ :any | - any showAssociationEndLabels not ] ] + ^ #hide ] -{ #category : 'hooks' } -OPUmlDiagramShowEndLabelsFigureCommand class >> resultingShowState [ +{ #category : 'accessing' } +OPUmlDiagramShowEndLabelsFigureCommand >> basicMenuItemName [ - ^ true + ^ 'Show all' ] { #category : 'accessing' } -OPUmlDiagramShowEndLabelsFigureCommand >> defaultMenuItemName [ +OPUmlDiagramShowEndLabelsFigureCommand >> defaultMenuIconFormSet [ - ^ 'Show association end labels' + ^ FormSet form: OPCoreIcons opShowLabelsIcon ] { #category : 'accessing' } OPUmlDiagramShowEndLabelsFigureCommand >> description [ - ^ 'Show association end labels even where the text is just name of the class' + ^ 'Show all association end labels' ] diff --git a/repository/OpenPonk-ClassEditor/OPUmlDiagramUnsetEndLabelsFigureCommand.class.st b/repository/OpenPonk-ClassEditor/OPUmlDiagramUnsetEndLabelsFigureCommand.class.st new file mode 100644 index 00000000..2e12abdf --- /dev/null +++ b/repository/OpenPonk-ClassEditor/OPUmlDiagramUnsetEndLabelsFigureCommand.class.st @@ -0,0 +1,37 @@ +Class { + #name : 'OPUmlDiagramUnsetEndLabelsFigureCommand', + #superclass : 'OPUmlDiagramEndLabelsFigureCommand', + #category : 'OpenPonk-ClassEditor-Commands', + #package : 'OpenPonk-ClassEditor', + #tag : 'Commands' +} + +{ #category : 'testing' } +OPUmlDiagramUnsetEndLabelsFigureCommand class >> canBeExecutedInContext: aToolContext [ + + ^ (super canBeExecutedInContext: aToolContext) and: [ + aToolContext diagramElements anySatisfy: [ :any | + any owningElement exists ] ] +] + +{ #category : 'accessing' } +OPUmlDiagramUnsetEndLabelsFigureCommand >> basicMenuItemName [ + + ^ 'Use diagram-level setting' +] + +{ #category : 'execution' } +OPUmlDiagramUnsetEndLabelsFigureCommand >> execute [ + + diagramElements + select: [ :each | each owningElement exists ] + thenDo: [ :each | each unsetAssociationEndLabels ] +] + +{ #category : 'testing' } +OPUmlDiagramUnsetEndLabelsFigureCommand >> isCurrentStyle: aStyle [ + + aStyle ifNil: [ ^ true ]. + ^ (aStyle includesKey: + OPUmlAssociationEndLabel showAssociationEndLabelsKey) not +]