@@ -10,7 +10,8 @@ Class {
1010 ' shortcuts' ,
1111 ' cursorsUpdater' ,
1212 ' textUpdater' ,
13- ' addOnsElementFuture'
13+ ' addOnsElementFuture' ,
14+ ' menuItemsElementFuture'
1415 ],
1516 #category : #' GToolkit-Coder-UI-Coder - Textual'
1617}
@@ -66,12 +67,12 @@ GtTextualCoderEditorElement >> createContextMenu [
6667 " wait for the addons to be computed"
6768 < return: #BrMenuItems >
6869
69- | aMenu aMenuItemsPromise |
70+ | aMenu aMenuItemsFuture |
7071 aMenu := BrMenuItems new .
7172 aMenu beGroupedElementType.
7273
73- aMenuItemsPromise := self textualCoderViewModel addOns
74- asyncThen : [ :theAddOns |
74+ aMenuItemsFuture := self textualCoderViewModel addOnsFuture
75+ map : [ :theAddOns |
7576 | theItems theContextMenuAstAddons theMenuItems |
7677 " extra context menu items that depend on ast and view model state such as selection"
7778 theContextMenuAstAddons := self textualCoderViewModel
@@ -83,13 +84,11 @@ GtTextualCoderEditorElement >> createContextMenu [
8384 collect: [ :eachAction | eachAction asBrMenuItemForCoderElement: self ]
8485 thenReject: #isNil .
8586
86- self enqueueTask: ( BlTaskAction new
87- action: [
88- aMenu items: theMenuItems ]) ] .
87+ aMenu - > theMenuItems ].
88+
89+ menuItemsElementFuture future: aMenuItemsFuture .
8990
90- self enqueueTask: (BlPromiseTask new promise: aMenuItemsPromise).
91-
92- ^ aMenu
91+ ^ aMenu
9392]
9493
9594{ #category : #initialization }
@@ -157,6 +156,13 @@ GtTextualCoderEditorElement >> initialize [
157156 self textualCoderViewModel onAddOnsChanged: theAddOns ];
158157 whenError: [ :anEditorElement :anError |
159158 self onAddOnsError: anError ].
159+
160+ menuItemsElementFuture := (BrAsyncElementFuture on: self )
161+ executionConfiguration: (GtSingleCoderViewModel methodAddOnsExecutionConfiguration);
162+ whenSuccess: [ :anEditorElement :anAssoc |
163+ anAssoc key items: anAssoc value ];
164+ whenError: [ :anEditorElement :anError |
165+ self onContextMenuError: anError ].
160166
161167 self initializeListeners.
162168
@@ -249,6 +255,15 @@ GtTextualCoderEditorElement >> onCoderViewModelFocused: aBoolean [
249255 ifFalse: [ self loseFocus ]
250256]
251257
258+ { #category : #initialization }
259+ GtTextualCoderEditorElement >> onContextMenuError: anError [
260+ anError emit.
261+ NonInteractiveTranscript stderr
262+ show: ' [GtTextualCoderEditorElement>>#onContextMenuError:] ' ;
263+ show: anError;
264+ newLine
265+ ]
266+
252267{ #category : #' private - event handling' }
253268GtTextualCoderEditorElement >> onFocusChangedAnnouncement: anAnnouncement [
254269 anAnnouncement source == self ifTrue: [ ^ self ].
0 commit comments