The Inbox: ToolBuilder-Kernel-ct.135.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: ToolBuilder-Kernel-ct.135.mcz

commits-2
Christoph Thiede uploaded a new version of ToolBuilder-Kernel to project The Inbox:
http://source.squeak.org/inbox/ToolBuilder-Kernel-ct.135.mcz

==================== Summary ====================

Name: ToolBuilder-Kernel-ct.135
Author: ct
Time: 24 January 2020, 6:34:43.604574 pm
UUID: 3ec2613e-56d3-2d41-b5c3-799a66a986e9
Ancestors: ToolBuilder-Kernel-mt.134

Provides fallback implementations for some UIManager messages

=============== Diff against ToolBuilder-Kernel-mt.134 ===============

Item was changed:
  ----- Method: UIManager>>chooseFrom:values:lines:title: (in category 'ui requests') -----
  chooseFrom: labelList values: valueList lines: linesArray title: aString
+ "Choose an item from the given list. Answer the corresponding value."
+ | result |
+ result := self chooseFrom: labelList lines: linesArray title: aString.
+ (result isNil or: [result isZero]) ifTrue: [^ nil].
+ ^ valueList at: result!
- "Choose an item from the given list. Answer the selected item."
- ^self subclassResponsibility!

Item was changed:
  ----- Method: UIManager>>confirm:orCancel: (in category 'ui requests') -----
  confirm: aString orCancel: cancelBlock
+ "Put up a yes/no/cancel menu with caption aString. Answer true if the response is yes, false if no. If cancel is chosen, evaluate cancelBlock. This is a modal question--the user must respond yes or no."
+ ^ (self confirm: aString)
+ ifFalse: [cancelBlock value];
+ yourself!
- "Put up a yes/no/cancel menu with caption aString. Answer true if  
- the response is yes, false if no. If cancel is chosen, evaluate  
- cancelBlock. This is a modal question--the user must respond yes or no."
- ^self subclassResponsibility!

Item was changed:
  ----- Method: UIManager>>confirm:orCancel:title: (in category 'ui requests') -----
  confirm: aString orCancel: cancelBlock title: titleString
+ "Put up a yes/no/cancel menu with caption aString, and titleString to label the dialog. Answer true if the response is yes, false if no. If cancel is chosen, evaluate cancelBlock. This is a modal question--the user must respond yes or no."
+ ^ (self confirm: aString title: titleString)
+ ifFalse: [cancelBlock value];
+ yourself!
- "Put up a yes/no/cancel menu with caption aString, and titleString to label the dialog.
- Answer true if  the response is yes, false if no. If cancel is chosen, evaluate cancelBlock.
- This is a modal question--the user must respond yes or no."
- ^self subclassResponsibility!

Item was changed:
  ----- Method: UIManager>>request:initialAnswer:centerAt: (in category 'ui requests - text') -----
  request: queryString initialAnswer: defaultAnswer centerAt: aPoint
+ "Create an instance of me whose question is queryString with the given initial answer. Invoke it centered at the given point, and answer the string the user accepts. Answer the empty string if the user cancels."
- "Create an instance of me whose question is queryString with the given
- initial answer. Invoke it centered at the given point, and answer the
- string the user accepts. Answer the empty string if the user cancels."
 
+ ^ self request: queryString initialAnswer: defaultAnswer!
- ^self subclassResponsibility!


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: ToolBuilder-Kernel-ct.135.mcz

Christoph Thiede

We could define even more of these fallback methods. However, I'm not sure how we should choose the kernel methods we could fall back to:

For example, in #multilineRequest:..., we could fall back to #request:.... However, wouldn't it be easier for a lazy subclass implementor that only wants to implement a single one method if we fell back just the other way around and called #multilineRequest:... from #request:...? On the other hand, multiline requests might be a rather rare use case.

To demonstrate the relevance of this design problem, I would like to ask the same question for #confirm:title: vs. #confirm:title:trueChoice:falseChoice:. Actually, the short version is only an edge case of the long version. But would we really want to require each possible subclass to implement the long and complex version?


And just another question:

Would it be okay to add further fallbacks for #chooseDirectory:from: and the #chooseFileMatching: versions? Basically, they can be implemented via simple #request: ("enter a filepath"), but to ensure that the path is valid, we would need to depend on Files. At the moment, we require each concrete subclass of UIManager to depend so.


Tricky questions (at least for me) ... I am looking forward to your help!


Best,

Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von [hidden email] <[hidden email]>
Gesendet: Freitag, 24. Januar 2020 18:34:44
An: [hidden email]
Betreff: [squeak-dev] The Inbox: ToolBuilder-Kernel-ct.135.mcz
 
Christoph Thiede uploaded a new version of ToolBuilder-Kernel to project The Inbox:
http://source.squeak.org/inbox/ToolBuilder-Kernel-ct.135.mcz

==================== Summary ====================

Name: ToolBuilder-Kernel-ct.135
Author: ct
Time: 24 January 2020, 6:34:43.604574 pm
UUID: 3ec2613e-56d3-2d41-b5c3-799a66a986e9
Ancestors: ToolBuilder-Kernel-mt.134

Provides fallback implementations for some UIManager messages

=============== Diff against ToolBuilder-Kernel-mt.134 ===============

Item was changed:
  ----- Method: UIManager>>chooseFrom:values:lines:title: (in category 'ui requests') -----
  chooseFrom: labelList values: valueList lines: linesArray title: aString
+        "Choose an item from the given list. Answer the corresponding value."
+        | result |
+        result := self chooseFrom: labelList lines: linesArray title: aString.
+        (result isNil or: [result isZero]) ifTrue: [^ nil].
+        ^ valueList at: result!
-        "Choose an item from the given list. Answer the selected item."
-        ^self subclassResponsibility!

Item was changed:
  ----- Method: UIManager>>confirm:orCancel: (in category 'ui requests') -----
  confirm: aString orCancel: cancelBlock
+        "Put up a yes/no/cancel menu with caption aString. Answer true if the response is yes, false if no. If cancel is chosen, evaluate cancelBlock. This is a modal question--the user must respond yes or no."
+        ^ (self confirm: aString)
+                ifFalse: [cancelBlock value];
+                yourself!
-        "Put up a yes/no/cancel menu with caption aString. Answer true if 
-        the response is yes, false if no. If cancel is chosen, evaluate 
-        cancelBlock. This is a modal question--the user must respond yes or no."
-        ^self subclassResponsibility!

Item was changed:
  ----- Method: UIManager>>confirm:orCancel:title: (in category 'ui requests') -----
  confirm: aString orCancel: cancelBlock title: titleString
+        "Put up a yes/no/cancel menu with caption aString, and titleString to label the dialog. Answer true if the response is yes, false if no. If cancel is chosen, evaluate cancelBlock. This is a modal question--the user must respond yes or no."
+        ^ (self confirm: aString title: titleString)
+                ifFalse: [cancelBlock value];
+                yourself!
-        "Put up a yes/no/cancel menu with caption aString, and titleString to label the dialog.
-        Answer true if  the response is yes, false if no. If cancel is chosen, evaluate cancelBlock.
-        This is a modal question--the user must respond yes or no."
-        ^self subclassResponsibility!

Item was changed:
  ----- Method: UIManager>>request:initialAnswer:centerAt: (in category 'ui requests - text') -----
  request: queryString initialAnswer: defaultAnswer centerAt: aPoint
+        "Create an instance of me whose question is queryString with the given initial answer. Invoke it centered at the given point, and answer the string the user accepts. Answer the empty string if the user cancels."
-        "Create an instance of me whose question is queryString with the given
-        initial answer. Invoke it centered at the given point, and answer the
-        string the user accepts. Answer the empty string if the user cancels."
 
+        ^ self request: queryString initialAnswer: defaultAnswer!
-        ^self subclassResponsibility!




Carpe Squeak!
Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: ToolBuilder-Kernel-ct.135.mcz

marcel.taeumel
In reply to this post by commits-2
Hi Christoph.

-1 because "false" is typically different than "cancellation" in the context
where that UI request is posed.

Imagine that a user says "No, do not overwrite but duplicate that item." but
your logic could trigger something like "Close this dialog" just because the
current UI manager omitted to implement that case. It would be more
discoverable to raise that #subclassResponsibility exception.

Best,
Marcel


commits-2 wrote

> Christoph Thiede uploaded a new version of ToolBuilder-Kernel to project
> The Inbox:
> http://source.squeak.org/inbox/ToolBuilder-Kernel-ct.135.mcz
>
> ==================== Summary ====================
>
> Name: ToolBuilder-Kernel-ct.135
> Author: ct
> Time: 24 January 2020, 6:34:43.604574 pm
> UUID: 3ec2613e-56d3-2d41-b5c3-799a66a986e9
> Ancestors: ToolBuilder-Kernel-mt.134
>
> Provides fallback implementations for some UIManager messages
>
> =============== Diff against ToolBuilder-Kernel-mt.134 ===============
>
> Item was changed:
>   ----- Method: UIManager>>chooseFrom:values:lines:title: (in category 'ui
> requests') -----
>   chooseFrom: labelList values: valueList lines: linesArray title: aString
> + "Choose an item from the given list. Answer the corresponding value."
> + | result |
> + result := self chooseFrom: labelList lines: linesArray title: aString.
> + (result isNil or: [result isZero]) ifTrue: [^ nil].
> + ^ valueList at: result!
> - "Choose an item from the given list. Answer the selected item."
> - ^self subclassResponsibility!
>
> Item was changed:
>   ----- Method: UIManager>>confirm:orCancel: (in category 'ui requests')
> -----
>   confirm: aString orCancel: cancelBlock
> + "Put up a yes/no/cancel menu with caption aString. Answer true if the
> response is yes, false if no. If cancel is chosen, evaluate cancelBlock.
> This is a modal question--the user must respond yes or no."
> + ^ (self confirm: aString)
> + ifFalse: [cancelBlock value];
> + yourself!
> - "Put up a yes/no/cancel menu with caption aString. Answer true if  
> - the response is yes, false if no. If cancel is chosen, evaluate  
> - cancelBlock. This is a modal question--the user must respond yes or
> no."
> - ^self subclassResponsibility!
>
> Item was changed:
>   ----- Method: UIManager>>confirm:orCancel:title: (in category 'ui
> requests') -----
>   confirm: aString orCancel: cancelBlock title: titleString
> + "Put up a yes/no/cancel menu with caption aString, and titleString to
> label the dialog. Answer true if the response is yes, false if no. If
> cancel is chosen, evaluate cancelBlock. This is a modal question--the user
> must respond yes or no."
> + ^ (self confirm: aString title: titleString)
> + ifFalse: [cancelBlock value];
> + yourself!
> - "Put up a yes/no/cancel menu with caption aString, and titleString to
> label the dialog.
> - Answer true if  the response is yes, false if no. If cancel is chosen,
> evaluate cancelBlock.
> - This is a modal question--the user must respond yes or no."
> - ^self subclassResponsibility!
>
> Item was changed:
>   ----- Method: UIManager>>request:initialAnswer:centerAt: (in category
> 'ui requests - text') -----
>   request: queryString initialAnswer: defaultAnswer centerAt: aPoint
> + "Create an instance of me whose question is queryString with the given
> initial answer. Invoke it centered at the given point, and answer the
> string the user accepts. Answer the empty string if the user cancels."
> - "Create an instance of me whose question is queryString with the given
> - initial answer. Invoke it centered at the given point, and answer the
> - string the user accepts. Answer the empty string if the user cancels."
>  
> + ^ self request: queryString initialAnswer: defaultAnswer!
> - ^self subclassResponsibility!





--
Sent from: http://forum.world.st/Squeak-Dev-f45488.html

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: ToolBuilder-Kernel-ct.135.mcz

Christoph Thiede

Hi Marcel!


Fair point, I will revert that.

Would you agree with the rest of the patch when I reupload it?


This commit was a first step towards the implementation of a CommandLineUIManager as discussed here: http://forum.world.st/CommandLineUIManager-td5106538.html By the way, my image already contains an early prototype version of it.

If there is anyone else interested in this extension, my questions from the post below are still up to date! :-)


Best,

Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von Taeumel, Marcel
Gesendet: Donnerstag, 1. Oktober 2020 16:28:53
An: [hidden email]
Betreff: Re: [squeak-dev] The Inbox: ToolBuilder-Kernel-ct.135.mcz
 
Hi Christoph.

-1 because "false" is typically different than "cancellation" in the context
where that UI request is posed.

Imagine that a user says "No, do not overwrite but duplicate that item." but
your logic could trigger something like "Close this dialog" just because the
current UI manager omitted to implement that case. It would be more
discoverable to raise that #subclassResponsibility exception.

Best,
Marcel


commits-2 wrote
> Christoph Thiede uploaded a new version of ToolBuilder-Kernel to project
> The Inbox:
> http://source.squeak.org/inbox/ToolBuilder-Kernel-ct.135.mcz
>
> ==================== Summary ====================
>
> Name: ToolBuilder-Kernel-ct.135
> Author: ct
> Time: 24 January 2020, 6:34:43.604574 pm
> UUID: 3ec2613e-56d3-2d41-b5c3-799a66a986e9
> Ancestors: ToolBuilder-Kernel-mt.134
>
> Provides fallback implementations for some UIManager messages
>
> =============== Diff against ToolBuilder-Kernel-mt.134 ===============
>
> Item was changed:
>   ----- Method: UIManager>>chooseFrom:values:lines:title: (in category 'ui
> requests') -----
>   chooseFrom: labelList values: valueList lines: linesArray title: aString
> +      "Choose an item from the given list. Answer the corresponding value."
> +      | result |
> +      result := self chooseFrom: labelList lines: linesArray title: aString.
> +      (result isNil or: [result isZero]) ifTrue: [^ nil].
> +      ^ valueList at: result!
> -      "Choose an item from the given list. Answer the selected item."
> -      ^self subclassResponsibility!
>
> Item was changed:
>   ----- Method: UIManager>>confirm:orCancel: (in category 'ui requests')
> -----
>   confirm: aString orCancel: cancelBlock
> +      "Put up a yes/no/cancel menu with caption aString. Answer true if the
> response is yes, false if no. If cancel is chosen, evaluate cancelBlock.
> This is a modal question--the user must respond yes or no."
> +      ^ (self confirm: aString)
> +              ifFalse: [cancelBlock value];
> +              yourself!
> -      "Put up a yes/no/cancel menu with caption aString. Answer true if 
> -      the response is yes, false if no. If cancel is chosen, evaluate 
> -      cancelBlock. This is a modal question--the user must respond yes or
> no."
> -      ^self subclassResponsibility!
>
> Item was changed:
>   ----- Method: UIManager>>confirm:orCancel:title: (in category 'ui
> requests') -----
>   confirm: aString orCancel: cancelBlock title: titleString
> +      "Put up a yes/no/cancel menu with caption aString, and titleString to
> label the dialog. Answer true if the response is yes, false if no. If
> cancel is chosen, evaluate cancelBlock. This is a modal question--the user
> must respond yes or no."
> +      ^ (self confirm: aString title: titleString)
> +              ifFalse: [cancelBlock value];
> +              yourself!
> -      "Put up a yes/no/cancel menu with caption aString, and titleString to
> label the dialog.
> -      Answer true if  the response is yes, false if no. If cancel is chosen,
> evaluate cancelBlock.
> -      This is a modal question--the user must respond yes or no."
> -      ^self subclassResponsibility!
>
> Item was changed:
>   ----- Method: UIManager>>request:initialAnswer:centerAt: (in category
> 'ui requests - text') -----
>   request: queryString initialAnswer: defaultAnswer centerAt: aPoint
> +      "Create an instance of me whose question is queryString with the given
> initial answer. Invoke it centered at the given point, and answer the
> string the user accepts. Answer the empty string if the user cancels."
> -      "Create an instance of me whose question is queryString with the given
> -      initial answer. Invoke it centered at the given point, and answer the
> -      string the user accepts. Answer the empty string if the user cancels."
>  
> +      ^ self request: queryString initialAnswer: defaultAnswer!
> -      ^self subclassResponsibility!





--
Sent from: http://forum.world.st/Squeak-Dev-f45488.html



Carpe Squeak!