The Trunk: ToolBuilder-MVC-pre.54.mcz

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

The Trunk: ToolBuilder-MVC-pre.54.mcz

commits-2
Patrick Rein uploaded a new version of ToolBuilder-MVC to project The Trunk:
http://source.squeak.org/trunk/ToolBuilder-MVC-pre.54.mcz

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

Name: ToolBuilder-MVC-pre.54
Author: pre
Time: 1 November 2018, 2:48:01.588001 pm
UUID: e488697b-2d4c-1143-bd7a-bdd8ff4c8b0c
Ancestors: ToolBuilder-MVC-tpr.53

Refactors the MVCUIManager to capture and use the ProvideAnswerNotification

=============== Diff against ToolBuilder-MVC-tpr.53 ===============

Item was changed:
  ----- Method: MVCUIManager>>chooseFileMatching:label: (in category 'ui requests') -----
  chooseFileMatching: patterns label: labelString
+ "Let the user choose a file matching the given patterns. Returns a file name."
- "Let the user choose a file matching the given patterns"
  ^self notYetImplemented!

Item was changed:
  ----- Method: MVCUIManager>>chooseFileMatchingSuffixes:label: (in category 'ui requests') -----
  chooseFileMatchingSuffixes: suffixList label: aString
+ "Let the user choose a file matching the given suffixes. Returns a file name."
- "Let the user choose a file matching the given suffix list"
  ^self notYetImplemented!

Item was changed:
  ----- Method: MVCUIManager>>chooseFont:for:setSelector:getSelector: (in category 'ui requests') -----
  chooseFont: aPrompt for: aTarget setSelector: setSelector getSelector: getSelector
  "MVC Only!! prompt for a font and if one is provided, send it to aTarget using a message with selector aSelector."
  | aMenu aChoice aStyle namesAndSizes aFont |
+ self askForProvidedAnswerTo: aPrompt ifSupplied: [:answer |
+ ^ answer].
+
  aMenu := CustomMenu new.
  TextStyle actualTextStyles keysSortedSafely do:
  [:styleName |
  aMenu add: styleName action: styleName].
  aChoice := aMenu startUpWithCaption: aPrompt.
  aChoice ifNil: [^ self].
  aMenu := CustomMenu new.
  aStyle := TextStyle named: aChoice.
  (namesAndSizes := aStyle fontNamesWithPointSizes) do:
  [:aString | aMenu add: aString action: aString].
  aChoice := aMenu startUpWithCaption: nil.
  aChoice ifNil: [^ self].
  aFont := aStyle fontAt: (namesAndSizes indexOf: aChoice).
  aTarget perform: setSelector with: aFont!

Item was changed:
  ----- Method: MVCUIManager>>chooseFrom:lines:title: (in category 'ui requests') -----
  chooseFrom: aList lines: linesArray title: aString
  "Choose an item from the given list. Answer the index of the selected item."
  | menu |
+ self askForProvidedAnswerTo: aString ifSupplied: [:answer |
+ (answer = #cancel or: [answer isNil]) ifTrue: [^ 0].
+ ^ aList indexOf: answer].
+
  menu := PopUpMenu labelArray: aList lines: linesArray.
+ ^ aString isEmpty ifTrue:[menu startUp] ifFalse:[menu startUpWithCaption: aString]!
- ^aString isEmpty ifTrue:[menu startUp] ifFalse:[menu startUpWithCaption: aString]!

Item was changed:
  ----- Method: MVCUIManager>>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 selected item."
  | menu |
+ self askForProvidedAnswerTo: aString ifSupplied: [:answer |
+ (answer = #cancel or: [answer isNil]) ifTrue: [^ nil].
+ ^ valueList at: (valueList indexOf: answer)].
+
  menu := SelectionMenu labels: labelList lines: linesArray selections: valueList.
+ ^ aString
+ ifEmpty: [menu startUp]
+ ifNotEmpty: [menu startUpWithCaption: aString]!
- ^aString isEmpty ifTrue:[menu startUp] ifFalse:[menu startUpWithCaption: aString]!

Item was changed:
  ----- Method: MVCUIManager>>confirm: (in category 'ui requests') -----
  confirm: queryString
  "Put up a yes/no menu with caption queryString. Answer true if the
  response is yes, false if no. This is a modal question--the user must
  respond yes or no."
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer].
+
+ ^ PopUpMenu confirm: queryString!
- ^PopUpMenu confirm: queryString!

Item was changed:
  ----- Method: MVCUIManager>>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 askForProvidedAnswerTo: aString ifSupplied: [:answer |
+ ^ (answer = #cancel or: [answer isNil])
+ ifTrue: [cancelBlock value]
+ ifFalse: [answer]].
+
+ ^ PopUpMenu confirm: aString orCancel: cancelBlock!
- ^PopUpMenu confirm: aString orCancel: cancelBlock!

Item was changed:
  ----- Method: MVCUIManager>>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 askForProvidedAnswerTo: aString ifSupplied: [:answer |
+ ^ (answer = #cancel or: [answer isNil])
+ ifTrue: [cancelBlock value]
+ ifFalse: [answer]].
+
  ^ PopUpMenu
  confirm: (self dialogStringFromQuery: aString withTitle: titleString)
  orCancel: cancelBlock!

Item was changed:
  ----- Method: MVCUIManager>>confirm:title: (in category 'ui requests') -----
  confirm: queryString title: titleString
  "Put up a yes/no menu with caption queryString, and titleString to label the dialog.
  Answer true if the response is yes, false if no. This is a modal question--the user
  must respond yes or no."
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer].
+
+ ^ PopUpMenu confirm: (self dialogStringFromQuery: queryString withTitle: titleString)
- ^PopUpMenu confirm: (self dialogStringFromQuery: queryString withTitle: titleString)
  !

Item was changed:
  ----- Method: MVCUIManager>>confirm:title:trueChoice:falseChoice: (in category 'ui requests') -----
  confirm: queryString title: titleString trueChoice: trueChoice falseChoice: falseChoice
  "Put up a yes/no menu with caption queryString, and titleString to label the dialog.
  The actual wording for the two choices will be as provided in the trueChoice and
  falseChoice parameters. Answer true if the response is the true-choice, false if it
  is the false-choice. This is a modal question -- the user must respond one way or
  the other."
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer isBoolean
+ ifTrue: [answer]
+ ifFalse: [trueChoice = answer]].
+
  ^ PopUpMenu
  confirm: (self dialogStringFromQuery: queryString withTitle: titleString)
  trueChoice: trueChoice
  falseChoice: falseChoice!

Item was changed:
  ----- Method: MVCUIManager>>confirm:trueChoice:falseChoice: (in category 'ui requests') -----
  confirm: queryString trueChoice: trueChoice falseChoice: falseChoice
  "Put up a yes/no menu with caption queryString. The actual wording for the two choices will be as provided in the trueChoice and falseChoice parameters. Answer true if the response is the true-choice, false if it's the false-choice.
  This is a modal question -- the user must respond one way or the other."
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer].
+
+ ^ PopUpMenu confirm: queryString trueChoice: trueChoice falseChoice: falseChoice!
- ^PopUpMenu confirm: queryString trueChoice: trueChoice falseChoice: falseChoice!

Item was changed:
  ----- Method: MVCUIManager>>inform: (in category 'ui requests') -----
  inform: aString
  "Display a message for the user to read and then dismiss"
+ self askForProvidedAnswerTo: aString ifSupplied: [:answer |
+ ^ answer].
+
+ ^ PopUpMenu inform: aString!
- ^PopUpMenu inform: aString!

Item was changed:
  ----- Method: MVCUIManager>>multiLineRequest:centerAt:initialAnswer:answerHeight: (in category 'ui requests') -----
  multiLineRequest: queryString centerAt: aPoint initialAnswer: defaultAnswer answerHeight: answerHeight
  "Create a multi-line 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 nil if the user cancels.  An
  empty string returned means that the ussr cleared the editing area and
  then hit 'accept'.  Because multiple lines are invited, we ask that the user
  use the ENTER key, or (in morphic anyway) hit the 'accept' button, to
  submit; that way, the return key can be typed to move to the next line."
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer = #default
+ ifTrue: [defaultAnswer]
+ ifFalse: [answer]].
+
+ ^ FillInTheBlank
+ multiLineRequest: queryString
+ centerAt: aPoint
+ initialAnswer: defaultAnswer
+ answerHeight: answerHeight!
- ^FillInTheBlank multiLineRequest: queryString centerAt: aPoint initialAnswer: defaultAnswer answerHeight: answerHeight!

Item was changed:
  ----- Method: MVCUIManager>>request:initialAnswer: (in category 'ui requests') -----
  request: queryString initialAnswer: defaultAnswer
  "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 askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer = #default
+ ifTrue: [defaultAnswer]
+ ifFalse: [answer]].
+
  ^FillInTheBlank request: queryString initialAnswer: defaultAnswer !

Item was changed:
  ----- Method: MVCUIManager>>request:initialAnswer:centerAt: (in category 'ui requests') -----
  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."
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer = #default
+ ifTrue: [defaultAnswer]
+ ifFalse: [answer]].
+
  ^ FillInTheBlank request: queryString initialAnswer: defaultAnswer centerAt: aPoint !

Item was changed:
  ----- Method: MVCUIManager>>requestPassword: (in category 'ui requests') -----
  requestPassword: queryString
  "Create an instance of me whose question is queryString. Invoke it centered
  at the cursor, and answer the string the user accepts. Answer the empty
  string if the user cancels."
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer].
+
+ ^ FillInTheBlank requestPassword: queryString!
- ^FillInTheBlank requestPassword: queryString!

Item was changed:
  ----- Method: MVCUIManager>>saveFilenameRequest:initialAnswer: (in category 'ui requests') -----
  saveFilenameRequest: queryString initialAnswer: defaultAnswer
  "Open a FileSaverDialog to ask for a place and filename to use for saving a file. The initial suggestion for the filename is defaultAnswer but the user may choose any existing file or type in a new name entirely"
  "MVC has to stick with the boring way of doing it"
  | result |
+ self askForProvidedAnswerTo: queryString ifSupplied: [:answer |
+ ^ answer = #default
+ ifTrue: [defaultAnswer]
+ ifFalse: [answer]].
+
  result := self request: queryString initialAnswer: defaultAnswer.
  ^result isEmpty ifTrue: [nil] ifFalse:[result]
  !