Skip to content

Commit b4f16ef

Browse files
committed
add GTCoderAction>>#priority: [feenkcom/gtoolkit#4725]
1 parent 258f67c commit b4f16ef

File tree

3 files changed

+39
-15
lines changed

3 files changed

+39
-15
lines changed

src/GToolkit-Coder-AddOns/GtTextualCoder.extension.st

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Extension { #name : #GtTextualCoder }
22

33
{ #category : #'*GToolkit-Coder-AddOns' }
44
GtTextualCoder >> addContextMenuItemFrom: shortcut group: menuGroup withId: menuId to: coderAddOns [
5+
<return: #GtCoderContextMenuAction>
56
^ coderAddOns
67
addContextMenuItem: shortcut name
78
group: menuGroup
@@ -16,6 +17,7 @@ GtTextualCoder >> addContextMenuItemFrom: shortcut group: menuGroup withId: menu
1617

1718
{ #category : #'*GToolkit-Coder-AddOns' }
1819
GtTextualCoder >> addContextMenuItemFrom: shortcut withId: menuId to: coderAddOns [
20+
<return: #GtCoderContextMenuAction>
1921
^ coderAddOns
2022
addContextMenuItem: shortcut name
2123
action: [ :aCoderViewModel :anEditorElement |
@@ -55,20 +57,23 @@ GtTextualCoder >> addContextMenuItemWithNoShortcutFrom: shortcut withId: menuId
5557
{ #category : #'*GToolkit-Coder-AddOns' }
5658
GtTextualCoder >> addCopyCutPasteContextMenuAddOnsAst: anAst to: coderAddOns [
5759
<gtCoderContextMenuAddOns: 1000>
58-
self
60+
(self
5961
addContextMenuItemFrom: BrEditorShortcut cut
60-
withId: GtTextualCoderCutContextMenuItemId
61-
to: coderAddOns;
62+
withId: GtTextualCoderCutContextMenuItemId
63+
to: coderAddOns) ifNotNil: [ :anAction | anAction priority: 1000 ].
64+
(self
6265
addContextMenuItemFrom: BrEditorShortcut copy
63-
withId: GtTextualCoderCopyContextMenuItemId
64-
to: coderAddOns;
66+
withId: GtTextualCoderCopyContextMenuItemId
67+
to: coderAddOns) ifNotNil: [ :anAction | anAction priority: 1000 ].
68+
(self
6569
addContextMenuItemFrom: BrEditorShortcut paste
66-
withId: GtTextualCoderPasteContextMenuItemId
67-
to: coderAddOns
70+
withId: GtTextualCoderPasteContextMenuItemId
71+
to: coderAddOns) ifNotNil: [ :anAction | anAction priority: 1000 ]
6872
]
6973

7074
{ #category : #'*GToolkit-Coder-AddOns' }
7175
GtTextualCoder >> addExplicitContextMenu: aString block: aBlock to: coderAddOns [
76+
<return: #GtCoderExplicitContextMenuItemAction>
7277
^ coderAddOns addExplicitContextMenu: aString block: aBlock
7378
]
7479

src/GToolkit-Coder/GtCoderAction.class.st

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ Class {
1111
'allowAltClick',
1212
'actionDefinition',
1313
'isEnabled',
14-
'properties'
14+
'properties',
15+
'priority'
1516
],
1617
#category : #'GToolkit-Coder-Coders - Addons'
1718
}
@@ -163,6 +164,16 @@ GtCoderAction >> printOn: aStream [
163164
nextPut: $)
164165
]
165166

167+
{ #category : #accessing }
168+
GtCoderAction >> priority [
169+
^ priority ifNil: [ priority := 50 ]
170+
]
171+
172+
{ #category : #accessing }
173+
GtCoderAction >> priority: aNumber [
174+
priority := aNumber
175+
]
176+
166177
{ #category : #'accessing properties' }
167178
GtCoderAction >> properties [
168179
^ properties ifNil: [

src/GToolkit-Coder/GtCoderAddOns.class.st

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ GtCoderAddOns >> addContextMenuActions: aCollectionOfContextMenuActions [
9292

9393
{ #category : #'api - context menu' }
9494
GtCoderAddOns >> addContextMenuItem: aString action: aBlock [
95+
<return: #GtCoderContextMenuAction>
9596
^ self
9697
addContextMenuItem: aString
9798
hover: nil
@@ -111,6 +112,7 @@ GtCoderAddOns >> addContextMenuItem: aString action: aBlock id: aSymbol [
111112

112113
{ #category : #'api - context menu' }
113114
GtCoderAddOns >> addContextMenuItem: aString action: aBlock id: aSymbol shortcutKey: shortcutString [
115+
<return: #GtCoderContextMenuAction>
114116
^ self
115117
addContextMenuItem: aString
116118
hover: nil
@@ -143,6 +145,7 @@ GtCoderAddOns >> addContextMenuItem: aString group: menuGroup action: aBlock id:
143145

144146
{ #category : #'api - context menu' }
145147
GtCoderAddOns >> addContextMenuItem: aString group: menuGroup action: aBlock id: aSymbol shortcutKey: shortcutString [
148+
<return: #GtCoderContextMenuAction>
146149
^ self
147150
addContextMenuItem: aString
148151
group: menuGroup
@@ -167,20 +170,22 @@ GtCoderAddOns >> addContextMenuItem: aString group: menuGroup hover: hoverBlock
167170

168171
{ #category : #'api - context menu' }
169172
GtCoderAddOns >> addContextMenuItem: aString group: menuGroup hover: hoverBlock leave: leaveBlock action: aBlock id: aSymbol [
173+
<return: #GtCoderContextMenuAction>
170174
| newAction |
171175
newAction := GtCoderContextMenuAction new
172-
title: aString;
173-
group: menuGroup;
174-
action: aBlock;
175-
hoverAction: hoverBlock;
176-
leaveAction: leaveBlock;
177-
id: aSymbol.
176+
title: aString;
177+
group: menuGroup;
178+
action: aBlock;
179+
hoverAction: hoverBlock;
180+
leaveAction: leaveBlock;
181+
id: aSymbol.
178182
self addContextMenuAction: newAction.
179183
^ newAction
180184
]
181185

182186
{ #category : #'api - context menu' }
183187
GtCoderAddOns >> addContextMenuItem: aString group: menuGroup hover: hoverBlock leave: leaveBlock action: aBlock id: aSymbol shortcutKey: shortcutString [
188+
<return: #GtCoderContextMenuAction>
184189
| newAction |
185190
newAction := GtCoderContextMenuAction new
186191
title: aString;
@@ -196,7 +201,8 @@ GtCoderAddOns >> addContextMenuItem: aString group: menuGroup hover: hoverBlock
196201

197202
{ #category : #'api - context menu' }
198203
GtCoderAddOns >> addContextMenuItem: aString group: menuGroup hover: hoverBlock leave: leaveBlock action: aBlock shortcutKey: shortcutString [
199-
self
204+
<return: #GtCoderContextMenuAction>
205+
^ self
200206
addContextMenuItem: aString
201207
group: menuGroup
202208
hover: hoverBlock
@@ -232,6 +238,7 @@ GtCoderAddOns >> addContextMenuItem: aString hover: hoverBlock leave: leaveBlock
232238

233239
{ #category : #'api - context menu' }
234240
GtCoderAddOns >> addContextMenuItem: aString hover: hoverBlock leave: leaveBlock action: aBlock id: aSymbol shortcutKey: shortcutString [
241+
<return: #GtCoderContextMenuAction>
235242
| newAction |
236243
newAction := GtCoderContextMenuAction new
237244
title: aString;
@@ -328,6 +335,7 @@ GtCoderAddOns >> addDropDownWithPreviewAction: aString icon: anIcon action: acti
328335

329336
{ #category : #'api - context menu' }
330337
GtCoderAddOns >> addExplicitContextMenu: aString block: aBlock [
338+
<return: #GtCoderExplicitContextMenuItemAction>
331339
| newAction |
332340
newAction := GtCoderExplicitContextMenuItemAction new
333341
title: aString;

0 commit comments

Comments
 (0)