'From Squeak3.1alpha of 28 February 2001 [latest update: #4354] on 28 September 2001 at 9:24:19 am'! "Change Set: undefaulting-sw Date: 28 September 2001 Author: Scott Wallace Changes the wording of selectors for three retrieval-with-default queries from using 'default:' to using 'ifAbsentPut:', as per Andreas's suggestion."! !CodeHolder methodsFor: 'annotation' stamp: 'sw 9/28/2001 08:43'! defaultAnnotationPaneHeight "Answer the receiver's preferred default height for new annotation panes." ^ Preferences parameterAt: #defaultAnnotationPaneHeight ifAbsentPut: [25]! ! !CodeHolder methodsFor: 'annotation' stamp: 'sw 9/28/2001 08:44'! defaultButtonPaneHeight "Answer the user's preferred default height for new button panes." ^ Preferences parameterAt: #defaultButtonPaneHeight ifAbsentPut: [25]! ! !FileList class methodsFor: 'instance creation' stamp: 'sw 9/28/2001 09:21'! defaultButtonPaneHeight "Answer the user's preferred default height for new button panes." ^ Preferences parameterAt: #defaultButtonPaneHeight ifAbsentPut: [25]! ! !FreeTranslation class methodsFor: 'scamper' stamp: 'sw 9/28/2001 08:45'! openScamperOn: currentSelection "Submit the string to the translation server at www.freetranslation.com. Ask it to translate from (Preferences parameterAt: #languageTranslateFrom) to (Preferences parameterAt: #languageTranslateTo). Display the results in a Scamper window, reusing the previous one if possible." | inputs scamperWindow from to | currentSelection size >= 10000 ifTrue: [^ self inform: 'Text selection is too long.']. from _ Preferences parameterAt: #languageTranslateFrom ifAbsentPut: ['English']. to _ Preferences parameterAt: #languageTranslateTo ifAbsentPut: ['German']. from = to ifTrue: [^ self inform: 'You asked to translate from ', from, ' to ', to, '.\' withCRs, 'Use "choose language" to set these.']. inputs _ Dictionary new. inputs at: 'SrcText' put: (Array with: currentSelection). inputs at: 'Sequence' put: #('core'). inputs at: 'Mode' put: #('html'). inputs at: 'template' put: #('TextResult2.htm'). inputs at: 'Language' put: (Array with: from, '/', to). scamperWindow _ Scamper newOrExistingOn: 'http://ets.freetranslation.com'. scamperWindow model submitFormWithInputs: inputs url: 'http://ets.freetranslation.com:5081' asUrl method: 'post'. scamperWindow activate. ! ! !Morph methodsFor: 'access properties' stamp: 'sw 9/28/2001 08:38'! valueOfProperty: propName ifAbsentPut: aBlock "If the receiver possesses a property of the given name, answer its value. If not, then create a property of the given name, give it the value obtained by evaluating aBlock, then answer that value" self assureExtension. ^ extension valueOfProperty: propName ifAbsentPut: aBlock! ! !Morph methodsFor: 'submorphs-add/remove' stamp: 'sw 9/28/2001 08:39'! actWhen "Answer when the receiver, probably being used as a button, should have its action triggered" ^ self valueOfProperty: #actWhen ifAbsentPut: [#buttonDown]! ! !MorphExtension methodsFor: 'other properties' stamp: 'sw 9/28/2001 08:39'! valueOfProperty: propName ifAbsentPut: aBlock "If the receiver possesses a property of the given name, answer its value. If not, then create a property of the given name, give it the value obtained by evaluating aBlock, then answer that value" otherProperties == nil ifTrue: [otherProperties _ IdentityDictionary new]. ^ otherProperties at: propName ifAbsentPut: aBlock! ! !Preferences class methodsFor: 'parameters' stamp: 'sw 9/28/2001 08:52'! parameterAt: aKey default: defaultValueBlock "Deprecated interface; no surviving senders in the released image, but clients probably still use" ^ self parameterAt: aKey ifAbsentPut: defaultValueBlock! ! !Preferences class methodsFor: 'parameters' stamp: 'sw 9/28/2001 08:40'! parameterAt: aKey ifAbsentPut: defaultValueBlock "Return the Parameter setting at the given key. If there is no entry for this key in the Parameters dictionary, create one with the value of defaultValueBlock as its value" ^ Parameters at: aKey ifAbsentPut: defaultValueBlock! ! !Preferences class methodsFor: 'window colors' stamp: 'sw 9/28/2001 08:53'! darkenStandardWindowPreferences "Make all window-color preferences one shade darker" | windowColorDict | windowColorDict _ self parameterAt: #windowColors ifAbsentPut: [IdentityDictionary new]. windowColorDict associationsDo: [:assoc | windowColorDict at: assoc key put: assoc value darker] "Preferences darkenStandardWindowPreferences" ! ! !Preferences class methodsFor: 'window colors' stamp: 'sw 9/28/2001 09:12'! lightenStandardWindowPreferences "Make all window-color preferences one shade darker" | windowColorDict | windowColorDict _ self parameterAt: #windowColors ifAbsentPut: [IdentityDictionary new]. windowColorDict associationsDo: [:assoc | windowColorDict at: assoc key put: assoc value lighter] "Preferences lightenStandardWindowPreferences" ! ! !Project methodsFor: 'project parameters' stamp: 'sw 9/28/2001 08:49'! projectParameterAt: aKey ifAbsentPut: defaultValueBlock "Return the project parameter setting at the given key. If there is no entry for this key in the Parameters dictionary, create one with the value of defaultValueBlock as its value" ^ self projectParameters at: aKey ifAbsentPut: defaultValueBlock! ! !Project methodsFor: 'language' stamp: 'sw 9/28/2001 08:49'! naturalLanguage "Answer the natural language for the project" ^ self projectParameterAt: #naturalLanguage ifAbsentPut: [#English]! ! !WordNet class methodsFor: 'services' stamp: 'sw 9/28/2001 08:46'! verify: aWord "See if this spelling is in the WordNet lexicon. Return a string of success, no-such-word, or can't reach the server." | aDef nl | aDef _ self new. (aDef definition: aWord) ifNil: [^ 'Sorry, cannot reach that web site. Task abandoned. (Make sure you have an internet connection.)']. nl _ Preferences parameterAt: #myLanguage ifAbsentPut: [#English]. (aDef parts) size = 0 ifTrue: [^ 'Sorry, ', aWord, ' not found. (', nl, ' lexicon)'] ifFalse: [^ aWord, ' is spelled correctly.']! ! !WordNet class methodsFor: 'miscellaneous' stamp: 'sw 9/28/2001 08:45'! languagePrefs "Set preference of which natural language is primary. Look up definitions in it, and correct speaLanguageing in it. Also, let user set languages to translate from and to." | ch aLanguage | self canTranslateFrom. "sets defaults" ch _ PopUpMenu withCaption: 'Choose the natural language to use for:' chooseFrom: 'word definition and spelling verification (', (Preferences parameterAt: #myLanguage ifAbsentPut: [#English]) asString ,')...\', 'language to translate FROM (now ', (Preferences parameterAt: #languageTranslateFrom ifAbsentPut: [#English]) asString ,')...\', 'language to translate TO (now ', (Preferences parameterAt: #languageTranslateTo ifAbsentPut: [#German]) asString ,')...\'. ch = 1 ifTrue: [ aLanguage _ PopUpMenu withCaption: 'The language for word definitions and speaLanguageing verification:' chooseFrom: Languages. aLanguage > 0 ifTrue: [^ Preferences setParameter: #myLanguage to: (Languages at: aLanguage) asSymbol]]. ch = 2 ifTrue: [aLanguage _ PopUpMenu withCaption: 'The language to translate from:' chooseFrom: CanTranslateFrom. aLanguage > 0 ifTrue: [^ Preferences setParameter: #languageTranslateFrom to: (CanTranslateFrom at: aLanguage) asSymbol]]. ch = 3 ifTrue: [aLanguage _ PopUpMenu withCaption: 'The language to translate to' chooseFrom: CanTranslateFrom. aLanguage > 0 ifTrue: [^ Preferences setParameter: #languageTranslateTo to: (CanTranslateFrom at: aLanguage) asSymbol]]. "Maybe let the user add another language if he knows the server can take it." " ch _ (PopUpMenu labelArray: Languages, {'other...'. 'Choose language to translate from...'}) startUpWithCaption: 'Choose the language of dictionary for word definitions.'. ch = 0 ifTrue: [^ Preferences setParameter: #myLanguage to: #English]. (ch <= Languages size) ifTrue: [aLanguage _ Languages at: ch]. ch = (Languages size + 1) ifTrue: [ aLanguage _ FillInTheBlank request: 'Name of the primary language']. aLanguage ifNotNil: [^ Preferences setParameter: #myLanguage to: aLanguage asSymbol]. "! ! !WordNet class methodsFor: 'miscellaneous' stamp: 'sw 9/28/2001 08:46'! lexiconServer "Look in Preferences to see what language the user wants, and what class knows about it." | nl | nl _ Preferences parameterAt: #myLanguage ifAbsentPut: [#English]. nl == #English ifTrue: [^ self]. "English, WordNet server" nl == #Portuguese ifTrue: [^ PortugueseLexiconServer]. "www.priberam.pt" " nl == #Deutsch ifTrue: [^ DeutschServerClass]. " "class that knows about a server" self inform: 'Sorry, no known online dictionary in that language.'. ^ self languagePrefs! ! Project removeSelector: #projectParameterAt:default:! Preferences class removeSelector: #darkerWindows! Preferences class removeSelector: #lighterWindows! MorphExtension removeSelector: #valueOfProperty:default:! Morph removeSelector: #valueOfProperty:default:! !FreeTranslation class reorganize! ('translation' extract: translate:from:to: translatePanel:fromTo:) ('scamper' openScamperOn:) !