'From Squeak3.6gamma of ''11 September 2003'' [latest update: #5497] on 30 October 2003 at 7:45:40 pm'! "Change Set: ProxyEditor-dgd Date: 29 October 2003 Author: Diego Gomez Deck An editor for the http proxy settings. To open it evaluate: HTTPProxyEditor open. or use the World Menu (open... >> http proxy editor). "! SystemWindow subclass: #HTTPProxyEditor instanceVariableNames: 'serverName port serverNameWidget portWidget serverNameLabelWidget portLabelWidget acceptWidget cancelWidget ' classVariableNames: '' poolDictionaries: '' category: 'Proxy-Editor'! !HTTPProxyEditor commentStamp: 'dgd 10/29/2003 14:29' prior: 0! An editor for the http proxy settings. To open it evaluate: HTTPProxyEditor open. or use the World Menu (open... >> http proxy editor). ! ]style[(63 21 56)f3cblack;,f3dHTTPProxyEditor open.;;,f3cblack;! !HTTPProxyEditor methodsFor: 'accessing' stamp: 'dgd 10/29/2003 13:44'! port "answer the receiver's port" ^ port! ! !HTTPProxyEditor methodsFor: 'accessing' stamp: 'dgd 10/29/2003 13:44'! port: anInteger "change the receiver's port" port := anInteger. self changed: #port! ! !HTTPProxyEditor methodsFor: 'accessing' stamp: 'dgd 10/29/2003 13:44'! serverName "answer the receiver's serverName" ^ serverName! ! !HTTPProxyEditor methodsFor: 'accessing' stamp: 'dgd 10/29/2003 13:44'! serverName: aString "change the receiver's serverName" serverName := aString. self changed: #serverName! ! !HTTPProxyEditor methodsFor: 'initialization' stamp: 'dgd 10/29/2003 14:19'! createButtonLabel: aString action: actionSelector help: helpString "private - create a button for the receiver" | button | button := SimpleButtonMorph new target: self; label: aString translated; actionSelector: actionSelector; setBalloonText: helpString translated; borderWidth: 2; useSquareCorners. "" ^ button! ! !HTTPProxyEditor methodsFor: 'initialization' stamp: 'dgd 10/29/2003 13:57'! createLabel: aString "private - create a label with aString" | labelWidget | labelWidget := PluggableButtonMorph on: self getState: nil action: nil. labelWidget hResizing: #spaceFill; vResizing: #spaceFill; label: aString translated. "" labelWidget onColor: Color transparent offColor: Color transparent. "" ^ labelWidget! ! !HTTPProxyEditor methodsFor: 'initialization' stamp: 'dgd 10/29/2003 14:20'! createText: selector "private - create a text widget on selector" | widget | widget := PluggableTextMorph on: self text: selector accept: (selector , ':') asSymbol. widget acceptOnCR: true. ^ widget! ! !HTTPProxyEditor methodsFor: 'initialization' stamp: 'dgd 10/29/2003 14:13'! initialize "initialize the receiver" super initialize. "" serverName := HTTPSocket httpProxyServer ifNil: ['']. port := HTTPSocket httpProxyPort asString. "" self setLabel: 'HTTP Proxy Editor' translated. self setWindowColor: (Color r: 0.9 g: 0.8 b: 1.0). "" self initializeWidgets. self updateWidgets. "" self extent: 300@180! ! !HTTPProxyEditor methodsFor: 'initialization' stamp: 'dgd 10/29/2003 14:03'! initializeWidgets "initialize the receiver's widgets" self addMorph: (serverNameLabelWidget := self createLabel: 'Server Name:') frame: (0 @ 0 corner: 0.5 @ 0.33). self addMorph: (serverNameWidget := self createText: #serverName) frame: (0.5 @ 0 corner: 1 @ 0.33). "" self addMorph: (portLabelWidget := self createLabel: 'Port:') frame: (0 @ 0.33 corner: 0.5 @ 0.67). self addMorph: (portWidget := self createText: #port) frame: (0.5 @ 0.33 corner: 1 @ 0.67). "" self addMorph: (acceptWidget := self createButtonLabel: 'Accept' action: #accept help: 'Accept the proxy settings') frame: (0 @ 0.67 corner: 0.5 @ 1). self addMorph: (cancelWidget := self createButtonLabel: 'Cancel' action: #cancel help: 'Cancel the proxy settings') frame: (0.5 @ 0.67 corner: 1 @ 1)! ! !HTTPProxyEditor methodsFor: 'initialization' stamp: 'dgd 10/29/2003 14:20'! updateWidgets "update the receiver's widgets" acceptWidget isNil ifFalse: ["" acceptWidget color: Color lightGreen; borderWidth: 2; borderColor: #raised]. cancelWidget isNil ifFalse: ["" cancelWidget color: Color lightRed; borderWidth: 2; borderColor: #raised]. "" serverNameLabelWidget isNil ifFalse: ["" serverNameLabelWidget color: self paneColor lighter; borderColor: #raised]. portLabelWidget isNil ifFalse: ["" portLabelWidget color: self paneColor lighter; borderColor: #raised]! ! !HTTPProxyEditor methodsFor: 'open/close' stamp: 'dgd 10/29/2003 14:21'! initialExtent "answer the receiver's initialExtent" ^ 300 @ 180! ! !HTTPProxyEditor methodsFor: 'panes' stamp: 'dgd 10/29/2003 14:20'! paneColor: aColor "the pane color was changed" super paneColor: aColor. "" self updateWidgets! ! !HTTPProxyEditor methodsFor: 'user interface' stamp: 'dgd 10/29/2003 14:30'! accept "the user press the [accept] button" serverNameWidget hasUnacceptedEdits ifTrue: [serverNameWidget accept]. portWidget hasUnacceptedEdits ifTrue: [portWidget accept]. "" self applyChanges. "" self delete! ! !HTTPProxyEditor methodsFor: 'user interface' stamp: 'dgd 10/29/2003 14:39'! applyChanges "apply the changes on HTTPSocket" | finalServerName finalPort | finalServerName := serverName asString withBlanksTrimmed. [finalPort := port asString withBlanksTrimmed asNumber] on: Error do: [:ex | finalPort := 0]. "" (finalServerName isNil or: [finalServerName isEmpty] or: [finalPort isZero]) ifTrue: ["" Transcript show: ('Stop using Proxy Server.' translated ); cr. "" HTTPSocket stopUsingProxyServer. ^ self]. "" Transcript show: ('Proxy Server Named: ''{1}'' port: {2}.' translated format: {finalServerName. finalPort}); cr. HTTPSocket useProxyServerNamed: finalServerName port: finalPort! ! !HTTPProxyEditor methodsFor: 'user interface' stamp: 'dgd 10/29/2003 14:18'! cancel "the user press the [cancel] button" self delete! ! !HTTPProxyEditor class methodsFor: 'class initialization' stamp: 'asm 10/30/2003 19:42'! initialize self registerInOpenMenu! ! !HTTPProxyEditor class methodsFor: 'class initialization' stamp: 'dgd 10/29/2003 14:25'! registerInOpenMenu "Register the receiver in the system's open menu" TheWorldMenu registerOpenCommand: {'http proxy editor'. {HTTPProxyEditor. #open}. 'An editor for the http proxy settings'}! ! !HTTPProxyEditor class methodsFor: 'class initialization' stamp: 'asm 10/30/2003 19:42'! unload "Called when the class is being removed" TheWorldMenu unregisterOpenCommandWithReceiver: self! ! !HTTPProxyEditor class methodsFor: 'instance creation' stamp: 'dgd 10/29/2003 14:27'! activateWindow: aWindow "private - activate the window" aWindow right: (aWindow right min: World bounds right). aWindow bottom: (aWindow bottom min: World bounds bottom). aWindow left: (aWindow left max: World bounds left). aWindow top: (aWindow top max: World bounds top). "" aWindow comeToFront. aWindow flash! ! !HTTPProxyEditor class methodsFor: 'instance creation' stamp: 'dgd 10/29/2003 14:26'! open "open the receiver" World submorphs do: [:each | "" ((each isKindOf: self) ) ifTrue: ["" self activateWindow: each. ^ self]]. "" ^ self new openInWorld! ! !HTTPSocket class methodsFor: 'proxy settings' stamp: 'dgd 10/29/2003 14:21'! httpProxyPort "answer the httpProxyPort" ^ HTTPProxyPort! ! !HTTPSocket class methodsFor: 'proxy settings' stamp: 'dgd 10/29/2003 14:21'! httpProxyServer "answer the httpProxyServer" ^ HTTPProxyServer! ! HTTPProxyEditor initialize! !HTTPProxyEditor class reorganize! ('class initialization' initialize registerInOpenMenu unload) ('instance creation' activateWindow: open) ! !HTTPProxyEditor reorganize! ('accessing' port port: serverName serverName:) ('initialization' createButtonLabel:action:help: createLabel: createText: initialize initializeWidgets updateWidgets) ('open/close' initialExtent) ('panes' paneColor:) ('user interface' accept applyChanges cancel) ! "Postscript: " !