onAnswerCommand and structure change

Nick Ager nick.ager at gmail.com
Fri Oct 22 19:01:11 MEST 2010


Hi Norbert,

I think I might have solved a similar problem in a different way.  I created
a "clean" environment specifically for non-view commands.

Then I derived from PRPierFrame and implemented:

environment
^ self context command useEditingEnvironment ifTrue: [
self kernel editingEnvironment
] ifFalse: [
self context structure environment
]

Then:

PRCommand>>useEditingEnvironment
^ (self isView or: [self isQuick]) not


---

Other ways round would be to create your own PRContents widget or return a
command with the structure you want to display, instead of returning nil

---

I only mention the above work-arounds as I don't have enough knowledge to
say for certain that your changes wouldn't cause unintended side-effects..


Hope this helps

Nick





On 22 October 2010 12:57, Norbert Hartl <norbert at hartl.name> wrote:

> I like to execute a command in a way that the structure is changed while
> the command is being executed. If the command is commited I like to advance
> the structure to another structure. If the command is aborted than I like to
> return to the structure from where the command has been invoked.
>
> Basically I do something like this
>
>        html anchor
>                goto: (self context
>                                structure: self
> structureWhileCommandIsExecuting
>                                command: MyPierCommand new);
>                with: 'do it' ]
>
> In MyPierCommand>>doExecute I do at the end
>
> self answer: (self context structure: self
> structureAfterCommandHasBeingCommited )
>
> This way I have chose a structure for command execution and the structure
> if the command is commited. But on abort it stays where it has been executed
> (structureWhileCommandIsExecuting). Looking at
>
> PRContentsWidget>>onAnswerCommand: aCommand
>        aCommand isNil
>                ifTrue: [ ^ self context: (self context structure: self
> context structure) ].
>        [ aCommand execute ]
>                on: MAError
>                do: [ :err | ^ self component errors add: err ].
>        self context: aCommand answer
>
> we see that if aCommand isNil (abort) the structure is nailed to the
> current one (while executing). Would it be ok to change that so it is
> answering every time? I simple change would be to change
>
> buildComponent: aContext
>        ^ aContext command asComponent
>                onAnswer: [ :value | self onAnswerCommand: value ];
>                yourself
>
> to
>
> buildComponent: aContext
>        ^ aContext command asComponent
>                onAnswer: [ :value | value ifNotNil: [ self onAnswerCommand:
> value ] ifNil: [ aContext command doAnswer ] ];
>                yourself
>
> this way
>
> PRCommand>>doAnswer
>        self answer ifNil: [ self answer: (self context structure: self
> structure) ]
>
> would the same but some could overwrite the answer when creating the link
>
> what do you think?
>
> Norbert
> _______________________________________________
> Magritte, Pier and Related Tools ...
> https://www.iam.unibe.ch/mailman/listinfo/smallwiki
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.iam.unibe.ch/pipermail/smallwiki/attachments/20101022/3660b93e/attachment-0001.html>


More information about the smallwiki mailing list