Error dialog?

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

Error dialog?

Luke Gorrie
Hoi!

Suppose that my GTInspector extension method fails for some interesting reason. How should I present an error message to the user?

I'm am especially thinking of cases where I am spawning a Unix command behind the scenes and I want to show the (possibly long) output of the command to the user. Could happen either in an inspector extension method or also in a "Go" action of the inspector.

Tips would be much appreciated :).


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Error dialog?

Luke Gorrie
Related question:

Is there a simple way to show a progress meter while I am running actions in the inspector? Perhaps with a 'Cancel' button if the user becomes impatient?

Some of my inspections can take a long time, either to read a file or to render a visualization, and it would be great to keep users in the loop a bit.



On 26 March 2018 at 12:29, Luke Gorrie <[hidden email]> wrote:
Hoi!

Suppose that my GTInspector extension method fails for some interesting reason. How should I present an error message to the user?

I'm am especially thinking of cases where I am spawning a Unix command behind the scenes and I want to show the (possibly long) output of the command to the user. Could happen either in an inspector extension method or also in a "Go" action of the inspector.

Tips would be much appreciated :).



_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Error dialog?

Johan Fabry

Hi Luke,

 

I'm doing something similar right now:

 

For the class that will trigger the long computation:

gtInspectorPreviewIn: composite

                <gtInspectorPresentationOrder: -10>

                ^ composite fastTable

                                title: 'Matches';

                                display: [ self patterns ];

                                enableElementIndex;

                                column: 'Index' evaluated: [ :val :i | i asString  ] width: 40;

                                column: 'Item' evaluated: [ :val | GTObjectPrinter asTruncatedTextFrom: val ast];

                                send: [:res | res findMatchesWith: matcher. res ].

 

And then in that findMatchesWith: method, the code that performs the long computation displays a progress bar like this:

 

                'Searching in programs'

                                displayProgressFrom: 1 to: programs size

                                during: [:bar |   

                                                                1 to: programs size do: [ :i | | prog |

                                                                                bar current: i.

                                                                                prog := programs at: i.

                                                                                result at: prog key put: (self findMatchesOf: aRCPatternMatch ast in: prog value)]].

 

HTH

 

--

Johan Fabry,  Senior Software Engineer. 

[hidden email] | Email too brief? Here's whyhttp://emailcharter.org

 

From: Moose-dev [mailto:[hidden email]] On Behalf Of Luke Gorrie
Sent: Tuesday, March 27, 2018 1:48 PM
To: Moose-related development <[hidden email]>
Subject: [Moose-dev] Re: Error dialog?

 

Related question:

 

Is there a simple way to show a progress meter while I am running actions in the inspector? Perhaps with a 'Cancel' button if the user becomes impatient?

 

Some of my inspections can take a long time, either to read a file or to render a visualization, and it would be great to keep users in the loop a bit.

 

 

 

On 26 March 2018 at 12:29, Luke Gorrie <[hidden email]> wrote:

Hoi!

 

Suppose that my GTInspector extension method fails for some interesting reason. How should I present an error message to the user?

 

I'm am especially thinking of cases where I am spawning a Unix command behind the scenes and I want to show the (possibly long) output of the command to the user. Could happen either in an inspector extension method or also in a "Go" action of the inspector.

 

Tips would be much appreciated :).

 

 


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Error dialog?

Luke Gorrie
Thanks for the tip, Johan!

I have just stumbled upon the UIManager class. This looks like finally the right place to look for ways to show error dialogs, display a "waiting" cursor while work is being done, etc. Is that right or should I be looking somewhere else in the context of GTInspector extensions?



_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Error dialog?

Johan Fabry

 

Yes, I'd say that UIManager is a good starting point to look for all kinds of dialogs.

 

--

Johan Fabry,  Senior Software Engineer. 

[hidden email] | Email too brief? Here's whyhttp://emailcharter.org

 

From: Moose-dev [mailto:[hidden email]] On Behalf Of Luke Gorrie
Sent: Tuesday, March 27, 2018 2:52 PM
To: Moose-related development <[hidden email]>
Subject: [Moose-dev] Re: Error dialog?

 

Thanks for the tip, Johan!

 

I have just stumbled upon the UIManager class. This looks like finally the right place to look for ways to show error dialogs, display a "waiting" cursor while work is being done, etc. Is that right or should I be looking somewhere else in the context of GTInspector extensions?

 

 


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Error dialog?

Tudor Girba-2
+1

You should also look at the following utility:

(1 to: 10000000) do: [ :x | ] displayingProgress: [ :x | x asString ]

Doru

> On Mar 27, 2018, at 3:07 PM, Johan Fabry <[hidden email]> wrote:
>
>  
> Yes, I'd say that UIManager is a good starting point to look for all kinds of dialogs.
>  
> --
> Johan Fabry,  Senior Software Engineer.
> [hidden email] | Email too brief? Here's why! http://emailcharter.org
>  
> From: Moose-dev [mailto:[hidden email]] On Behalf Of Luke Gorrie
> Sent: Tuesday, March 27, 2018 2:52 PM
> To: Moose-related development <[hidden email]>
> Subject: [Moose-dev] Re: Error dialog?
>  
> Thanks for the tip, Johan!
>  
> I have just stumbled upon the UIManager class. This looks like finally the right place to look for ways to show error dialogs, display a "waiting" cursor while work is being done, etc. Is that right or should I be looking somewhere else in the context of GTInspector extensions?
>  
>  
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.list.inf.unibe.ch/listinfo/moose-dev

--
www.tudorgirba.com
www.feenk.com

"Presenting is storytelling."

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Error dialog?

Luke Gorrie
Thanks guys!

Related question:

I'd like to show progress messages from Unix commands by screen-scraping their output using PetitParser2. Especially Nix prints lots of progress messages that are all mixed in together due to parallel operation. I think that showing each one with UIManager>>inform: would be a nice match i.e. they will flash across the Pharo UI much like they flash across the Unix shell.

Can I create a parser and feed it input one chunk at a time? Or do I need to somehow create a stream object for the parser and let it drive the control?

On 27 March 2018 at 15:32, Tudor Girba <[hidden email]> wrote:
+1

You should also look at the following utility:

(1 to: 10000000) do: [ :x | ] displayingProgress: [ :x | x asString ]

Doru

> On Mar 27, 2018, at 3:07 PM, Johan Fabry <[hidden email]> wrote:
>
>
> Yes, I'd say that UIManager is a good starting point to look for all kinds of dialogs.
>
> --
> Johan Fabry,  Senior Software Engineer.
> [hidden email] | Email too brief? Here's why! http://emailcharter.org
>
> From: Moose-dev [mailto:[hidden email]] On Behalf Of Luke Gorrie
> Sent: Tuesday, March 27, 2018 2:52 PM
> To: Moose-related development <[hidden email]>
> Subject: [Moose-dev] Re: Error dialog?
>
> Thanks for the tip, Johan!
>
> I have just stumbled upon the UIManager class. This looks like finally the right place to look for ways to show error dialogs, display a "waiting" cursor while work is being done, etc. Is that right or should I be looking somewhere else in the context of GTInspector extensions?
>
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.list.inf.unibe.ch/listinfo/moose-dev

--
www.tudorgirba.com
www.feenk.com

"Presenting is storytelling."

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Error dialog?

Sven Van Caekenberghe-2
In reply to this post by Tudor Girba-2


> On 27 Mar 2018, at 15:32, Tudor Girba <[hidden email]> wrote:
>
> +1
>
> You should also look at the following utility:
>
> (1 to: 10000000) do: [ :x | ] displayingProgress: [ :x | x asString ]

That is certainly the easiest to write, but the Job class is nicer as an OO approach.

[ :job |
  job title: 'Let us get started'.
  1 to: 10 do: [ :each |
    job
      progress: (0.1 * each);
      title: 'Youpi ', each printString.
    (Delay forMilliseconds: 100) wait ] ] asJob run.

Here is another example where the progress is based on notifications:

[ :bar |
  bar title: 'Downloading Sources...'.
  [
    ZnClient new
      url: 'http://files.pharo.org/sources/PharoV30.sources'; 
      signalProgress: true;
      downloadTo: FileLocator temp ]
    on: HTTPProgress
    do: [ :progress |
      progress isEmpty ifFalse: [ bar current: progress percentage ].
      progress resume ] ] asJob run.

Sven

> Doru
>
>> On Mar 27, 2018, at 3:07 PM, Johan Fabry <[hidden email]> wrote:
>>
>>
>> Yes, I'd say that UIManager is a good starting point to look for all kinds of dialogs.
>>
>> --
>> Johan Fabry,  Senior Software Engineer.
>> [hidden email] | Email too brief? Here's why! http://emailcharter.org
>>
>> From: Moose-dev [mailto:[hidden email]] On Behalf Of Luke Gorrie
>> Sent: Tuesday, March 27, 2018 2:52 PM
>> To: Moose-related development <[hidden email]>
>> Subject: [Moose-dev] Re: Error dialog?
>>
>> Thanks for the tip, Johan!
>>
>> I have just stumbled upon the UIManager class. This looks like finally the right place to look for ways to show error dialogs, display a "waiting" cursor while work is being done, etc. Is that right or should I be looking somewhere else in the context of GTInspector extensions?
>>
>>
>> _______________________________________________
>> Moose-dev mailing list
>> [hidden email]
>> https://www.list.inf.unibe.ch/listinfo/moose-dev
>
> --
> www.tudorgirba.com
> www.feenk.com
>
> "Presenting is storytelling."
>
> _______________________________________________
> Moose-dev mailing list
> [hidden email]
> https://www.list.inf.unibe.ch/listinfo/moose-dev

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Error dialog?

Luke Gorrie
In reply to this post by Johan Fabry
On 27 March 2018 at 15:07, Johan Fabry <[hidden email]> wrote:

 

Yes, I'd say that UIManager is a good starting point to look for all kinds of dialogs.


I'm finding it a bit fiddly.

For example, I would like to show an error message that includes the output of a Unix command (potentially quite long.)

One option is:

UIManager default abort: error messageText title: 'Error'

but this does not provide scrolling and it tries to center all the lines.

One other option is:

UIManager default longMessage: error messageText title: 'Error'

which is better in that it provides a scrollbar but worse in that the dialog window is initially very tiny and it shows the icon of "information" rather than "error."

I'm looking for ways to tailor the dialogs to my needs but it is a bit of a maze of pluggability and indirection with UIManagers and UIThemes and so on.

Help? :-)

Is there an easy way to display a bespoke dialog e.g. a large scrollable window with an error icon?



 

 

--

Johan Fabry,  Senior Software Engineer. 

[hidden email] | Email too brief? Here's whyhttp://emailcharter.org

 

From: Moose-dev [mailto:[hidden email]] On Behalf Of Luke Gorrie
Sent: Tuesday, March 27, 2018 2:52 PM
To: Moose-related development <[hidden email]>
Subject: [Moose-dev] Re: Error dialog?

 

Thanks for the tip, Johan!

 

I have just stumbled upon the UIManager class. This looks like finally the right place to look for ways to show error dialogs, display a "waiting" cursor while work is being done, etc. Is that right or should I be looking somewhere else in the context of GTInspector extensions?

 

 


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev



_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Error dialog?

Peter Uhnák
Hi Luke,

For example, I would like to show an error message that includes the output of a Unix command (potentially quite long.)

I had similar issue and in the end I decided to just create a custom dialog using Spec.

tm := TextModel new.
tm title: 'Failed to do something useful'.
tm enabled: false.
tm text: 'A ' asText, ('lot' asText allItalic), ' of ' asText, ('text' asText allBold makeAllColor: Color red), ' can fit into this box.' asText.
tm openDialogWithSpec



 Obviously this is literally the most basic way, I could e.g. compose multiple Spec Models etc.

Peter

_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Error dialog?

Johan Fabry

My thoughts exactly! 😊 There is a description on how to do this i the spec book, here https://ci.inria.fr/pharo-contribution/view/Books/job/BuildingUIWithSpec/lastSuccessfulBuild/artifact/book-result/SpecBooklet.pdf#section*.20

 

More about the book at http://books.pharo.org/spec-tutorial/

 

--

Johan Fabry,  Senior Software Engineer. 

[hidden email] | Email too brief? Here's whyhttp://emailcharter.org

 

From: Moose-dev [mailto:[hidden email]] On Behalf Of Peter Uhnák
Sent: Tuesday, March 27, 2018 6:38 PM
To: Moose-related development <[hidden email]>
Subject: [Moose-dev] Re: Error dialog?

 

Hi Luke,

 

For example, I would like to show an error message that includes the output of a Unix command (potentially quite long.)

 

I had similar issue and in the end I decided to just create a custom dialog using Spec.

 

tm := TextModel new.

tm title: 'Failed to do something useful'.

tm enabled: false.

tm text: 'A ' asText, ('lot' asText allItalic), ' of ' asText, ('text' asText allBold makeAllColor: Color red), ' can fit into this box.' asText.

tm openDialogWithSpec

 

 Obviously this is literally the most basic way, I could e.g. compose multiple Spec Models etc.

 

Peter


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev
Reply | Threaded
Open this post in threaded view
|

Re: Error dialog?

Luke Gorrie
Thanks for the tips!

Creating a custom dialog with spec has worked great. So has the Job interface. My UI is improving quickly now!

On 27 March 2018 at 19:28, Johan Fabry <[hidden email]> wrote:

My thoughts exactly! 😊 There is a description on how to do this i the spec book, here https://ci.inria.fr/pharo-contribution/view/Books/job/BuildingUIWithSpec/lastSuccessfulBuild/artifact/book-result/SpecBooklet.pdf#section*.20

 

More about the book at http://books.pharo.org/spec-tutorial/

 

--

Johan Fabry,  Senior Software Engineer. 

[hidden email] | Email too brief? Here's whyhttp://emailcharter.org

 

From: Moose-dev [mailto:[hidden email]] On Behalf Of Peter Uhnák
Sent: Tuesday, March 27, 2018 6:38 PM
To: Moose-related development <[hidden email]>
Subject: [Moose-dev] Re: Error dialog?

 

Hi Luke,

 

For example, I would like to show an error message that includes the output of a Unix command (potentially quite long.)

 

I had similar issue and in the end I decided to just create a custom dialog using Spec.

 

tm := TextModel new.

tm title: 'Failed to do something useful'.

tm enabled: false.

tm text: 'A ' asText, ('lot' asText allItalic), ' of ' asText, ('text' asText allBold makeAllColor: Color red), ' can fit into this box.' asText.

tm openDialogWithSpec

 

 Obviously this is literally the most basic way, I could e.g. compose multiple Spec Models etc.

 

Peter


_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev



_______________________________________________
Moose-dev mailing list
[hidden email]
https://www.list.inf.unibe.ch/listinfo/moose-dev