The Trunk: ToolBuilder-Morphic-cmm.210.mcz

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

The Trunk: ToolBuilder-Morphic-cmm.210.mcz

commits-2
Chris Muller uploaded a new version of ToolBuilder-Morphic to project The Trunk:
http://source.squeak.org/trunk/ToolBuilder-Morphic-cmm.210.mcz

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

Name: ToolBuilder-Morphic-cmm.210
Author: cmm
Time: 7 April 2018, 3:54:49.043193 pm
UUID: 72fd894c-8465-4889-b0af-604220f410c8
Ancestors: ToolBuilder-Morphic-cmm.209

FileSaverDialog support default names with no extension.  Allows saving files without an extension.

=============== Diff against ToolBuilder-Morphic-cmm.209 ===============

Item was changed:
  ----- Method: FileSaverDialog>>selectFilename: (in category 'filename') -----
  selectFilename: aText
  "The user has entered a potential filename in the text field.  Check it against the current pattern; if it is ok we can accept it and then if it is a file in the current list, highlight it.  If it would not match the pattern, alert the user."
  fileName := aText asString.
  ^ self selectExistingFilename
  ifTrue:
  [ self changed: #fileListIndex.
  true ]
  ifFalse:
  [ suffixList size = 1
  ifTrue:
  [ fileName := fileName , '.' , suffixList first.
  true ]
  ifFalse:
  [ suffixList
  at:
  (UIManager default
  chooseFrom: suffixList
  title: 'Please choose the type of file to save.')
  ifPresent:
  [ : choice | fileName := fileName , '.' , choice.
  true ]
  ifAbsent:
+ [ suffixList isEmpty or:
+ [ UIManager default inform: 'WARNING:  File not saved!!  A filename matching one of ' , patternList asArray asString , ' patterns is required.'.
+ false ] ] ] ]!
- [ fileName := nil.
- UIManager default inform: 'WARNING:  File not saved!!  A filename matching one of ' , patternList asArray asString , ' patterns is required.'.
- false ] ] ]!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: ToolBuilder-Morphic-cmm.210.mcz

timrowledge


> On 07-04-2018, at 1:55 PM, [hidden email] wrote:
>
> Chris Muller uploaded a new version of ToolBuilder-Morphic to project The Trunk:
> http://source.squeak.org/trunk/ToolBuilder-Morphic-cmm.210.mcz
>
>
> + [ suffixList isEmpty or:
> + [ UIManager default inform: 'WARNING:  File not saved!!  A filename matching one of ' , patternList asArray asString , ' patterns is required.'.
> + false ] ] ] ]!
> - [ fileName := nil.
> - UIManager default inform: 'WARNING:  File not saved!!  A filename matching one of ' , patternList asArray asString , ' patterns is required.'.
> - false ] ] ]!
>

That's something of an improvement but I think we've stumbled on a logic problem with this.

When an initial filename is specified (FileSaverDialog>>#initialFilename:) the suffix of that filename is used for an initial member of the suffixList. That may be good, or may not be - not entirely sure.

Later, your code change appends the first member of the suffixList to the chosen filename, even if the chosen filename might already have that suffix. This at least explains why my attempts to save my badly named 'foo.image.image' image file as plain old 'foo.image' won't work!

I'm honestly not entirely sure what my intent was when I made the default suffix be derived from the initial filename (I failed to comment adequately!) but combined with code being 'helpful' by adding a suffix it doesn't quite do the right thing. We *could* make the filename absent the suffix but then all the places where we check against existing filenames would need work. We could check the selected filename against all the suffices (which we do already in FileSaverDialog>>#selectFilename:) before adding a best-guess suffix. Or something else?

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
It is easier to change the specification to fit the program than vice versa.



Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: ToolBuilder-Morphic-cmm.210.mcz

Chris Muller-3
I'm not experiencing any of the problems you describe.  I can save my
image with or without ".image" on the end, and the file will save with
only one ".image".

Tell me how to reproduce this.

On Sat, Apr 7, 2018 at 5:22 PM, tim Rowledge <[hidden email]> wrote:

>
>
>> On 07-04-2018, at 1:55 PM, [hidden email] wrote:
>>
>> Chris Muller uploaded a new version of ToolBuilder-Morphic to project The Trunk:
>> http://source.squeak.org/trunk/ToolBuilder-Morphic-cmm.210.mcz
>>
>>
>> +                                                     [ suffixList isEmpty or:
>> +                                                             [ UIManager default inform: 'WARNING:  File not saved!!  A filename matching one of ' , patternList asArray asString , ' patterns is required.'.
>> +                                                             false ] ] ] ]!
>> -                                                     [ fileName := nil.
>> -                                                     UIManager default inform: 'WARNING:  File not saved!!  A filename matching one of ' , patternList asArray asString , ' patterns is required.'.
>> -                                                     false ] ] ]!
>>
>
> That's something of an improvement but I think we've stumbled on a logic problem with this.
>
> When an initial filename is specified (FileSaverDialog>>#initialFilename:) the suffix of that filename is used for an initial member of the suffixList. That may be good, or may not be - not entirely sure.
>
> Later, your code change appends the first member of the suffixList to the chosen filename, even if the chosen filename might already have that suffix. This at least explains why my attempts to save my badly named 'foo.image.image' image file as plain old 'foo.image' won't work!
>
> I'm honestly not entirely sure what my intent was when I made the default suffix be derived from the initial filename (I failed to comment adequately!) but combined with code being 'helpful' by adding a suffix it doesn't quite do the right thing. We *could* make the filename absent the suffix but then all the places where we check against existing filenames would need work. We could check the selected filename against all the suffices (which we do already in FileSaverDialog>>#selectFilename:) before adding a best-guess suffix. Or something else?
>
> tim
> --
> tim Rowledge; [hidden email]; http://www.rowledge.org/tim
> It is easier to change the specification to fit the program than vice versa.
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: ToolBuilder-Morphic-cmm.210.mcz

Chris Muller-3
In reply to this post by timrowledge
Fixed by ToolBuilder-Morphic-cmm.211.mcz.

On Sat, Apr 7, 2018 at 5:22 PM, tim Rowledge <[hidden email]> wrote:

>
>
>> On 07-04-2018, at 1:55 PM, [hidden email] wrote:
>>
>> Chris Muller uploaded a new version of ToolBuilder-Morphic to project The Trunk:
>> http://source.squeak.org/trunk/ToolBuilder-Morphic-cmm.210.mcz
>>
>>
>> +                                                     [ suffixList isEmpty or:
>> +                                                             [ UIManager default inform: 'WARNING:  File not saved!!  A filename matching one of ' , patternList asArray asString , ' patterns is required.'.
>> +                                                             false ] ] ] ]!
>> -                                                     [ fileName := nil.
>> -                                                     UIManager default inform: 'WARNING:  File not saved!!  A filename matching one of ' , patternList asArray asString , ' patterns is required.'.
>> -                                                     false ] ] ]!
>>
>
> That's something of an improvement but I think we've stumbled on a logic problem with this.
>
> When an initial filename is specified (FileSaverDialog>>#initialFilename:) the suffix of that filename is used for an initial member of the suffixList. That may be good, or may not be - not entirely sure.
>
> Later, your code change appends the first member of the suffixList to the chosen filename, even if the chosen filename might already have that suffix. This at least explains why my attempts to save my badly named 'foo.image.image' image file as plain old 'foo.image' won't work!
>
> I'm honestly not entirely sure what my intent was when I made the default suffix be derived from the initial filename (I failed to comment adequately!) but combined with code being 'helpful' by adding a suffix it doesn't quite do the right thing. We *could* make the filename absent the suffix but then all the places where we check against existing filenames would need work. We could check the selected filename against all the suffices (which we do already in FileSaverDialog>>#selectFilename:) before adding a best-guess suffix. Or something else?
>
> tim
> --
> tim Rowledge; [hidden email]; http://www.rowledge.org/tim
> It is easier to change the specification to fit the program than vice versa.
>
>
>