<?xml version='1.0' encoding='UTF-8' ?>
<rss version="2.0" xml:base="http://www.jarober.com/blog/" xmlns:admin="http://webns.net/mvcb/" xmlns:blogChannel="http://backend.userland.com/blogChannelModule" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:icbm="http://postneo.com/icbm" xmlns:includedComments="http://www.laudably.com/rss2-comments" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:media="http://search.yahoo.com/mrss/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/">
	<channel>
		<title>Smalltalk with James Robertson: category: tutorial</title>
		<link>http://www.jarober.com/blog/blogView</link>
		<description>Smalltalk Ecangelist, Industry Watcher</description>
		<webMaster>jarober@gmail.com</webMaster>
		<lastBuildDate>Mon, 18 Oct 2010 12:20:55 GMT</lastBuildDate>
		<image>
			<url>http://www.cincomsmalltalk.com/images/cst_small.jpg</url>
			<title>Smalltalk with James Robertson</title>
			<link>http://www.jarober.com/blog/blogView</link>
			<height>50</height>
			<width>81</width>
		</image>
		<admin:generatorAgent rdf:resource="http://www.cincomsmalltalk.com/CincomSmalltalkWiki/Silt"></admin:generatorAgent>
		<admin:errorReportsTo rdf:resource="mailto:jarober@gmail.com"></admin:errorReportsTo>
		<dc:language>en-us</dc:language>
		<dc:creator>James A. Robertson</dc:creator>
		<dc:rights>Copyright 2010 James Robertson</dc:rights>
		<dc:date>2010-10-18T12:20:55-04:00</dc:date>
		<icbm:latitude>39.214103</icbm:latitude>
		<icbm:longitude>-76.878807</icbm:longitude>
		<item>
			<title>Getting GLASS Running with Pharo</title>
			<link>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=Getting_GLASS_Running_with_Pharo&amp;entry=3464857254</link>
			<category>tutorial</category>
			<pubDate>Mon, 18 Oct 2010 12:20:54 GMT</pubDate>
			<description><![CDATA[<div xmlns="http://www.w3.org/1999/xhtml">

<p>I'll do a screencast on this later this week, but I thought it might be useful to toss out some quick &quot;how do I get it running?&quot; instructions. I <a href="http://seaside.gemstone.com/downloads.html">downloaded GLASS and a &quot;one click&quot; Pharo image from Gemstone's website</a>, but then I ran into problems connecting to the database. ,a href="http://programminggems.wordpress.com/">James Foster</a> was extremely helpful, and the steps I'm outlining here came from him. </p>
<p>Step one - if you're on Mac or Linux, as I am, use the <a href="http://seaside.gemstone.com/scripts/installGemstone.sh">installGemstone.sh script.</a> </p><p>Step two - grab the <a href="http://seaside.gemstone.com/squeak/GemTools-1.0-beta.8-244x.app.zip">one-click Pharo image</a></p><p>Step three - do this in a terminal window </p>

<p>
<pre>

source /opt/gemstone/product/seaside/defSeaside

</pre>
</p>

<p>That sets up the environment variables you'll need.  Next, you'll want to get the server running, and for the &quot;I'm just experimenting&quot; case, you probably don't want all the security bells and whistles.  So, do the following:</p>

<p>
<pre>


/opt/gemstone/product/bin/startnetldi -g -a YourUserNameHere
/opt/gemstone/product/bin/startstone seaside


</pre></p>

<p>It's probably simplest if you set up a scrpt, something like this:</p>

<p>
<pre>

#! /bin/sh
source /opt/gemstone/product source /opt/gemstone/product/seaside/defSeaside
cd $GEMSTONE
./startnetldi -g -a jarober
./startstone seaside

</pre>
</p>

<p>And then one to shut things down:</p>

<p>
<pre>

#! /bin/sh
source /opt/gemstone/product source /opt/gemstone/product/seaside/defSeaside
cd $GEMSTONE
./stopnetldi
./stopstone seaside

</pre>
</p>

<p>Now, you should have GLASS running.  You'll need to start your Pharo image.  I used a command line from the same terminal I started GLASS from, but that's not essential - you can just double click on the app bundle.  You'll get something like this:</p>


<p><img src="http://www.jarober.com/images/code/startGSPharo1.png" title="Pharo GS"/></p>

<p>Next, you'll want to edit the settings for the connection:</p>
<p><img src="http://www.jarober.com/images/code/startGSPharo2.png" title="Change Connection Parameters"/></p>

<p>Now, hit the &quot;Login&quot; button, and you'll get prompted for your name:</p>
<p><img src="http://www.jarober.com/images/code/startGSPharo3.png" title="add name"/></p>

<p>After you enter that, here's what you should see:</p>


<p><img src="http://www.jarober.com/images/code/startGSPharo4.png" title="logged in"/></p>
<p>From there, you can get started with your first GLASS/Pharo project!</p><!-- technorati tags start --><p style="text-align:right;font-size:10px;">Technorati Tags: 
<a href="http://www.technorati.com/tag/seaside" rel="tag">seaside</a>, <a href="http://www.technorati.com/tag/gemstone" rel="tag">gemstone</a>, <a href="http://www.technorati.com/tag/pharo" rel="tag">pharo</a>, <a href="http://www.technorati.com/tag/glass" rel="tag">glass</a></p><!-- technorati tags end -->
</div>]]></description>
			<guid isPermaLink="false">3464857254</guid>
			<pingback:server>http://www.jarober.com/blog/servlet/CommentAPIPBServlet?guid=3464857254</pingback:server>
			<pingback:target>http://www.jarober.com/blog/blogView?guid=3464857254</pingback:target>
			<includedComments:comment-collection></includedComments:comment-collection>
			<wfw:comment>http://www.jarober.com/blog/servlet/CommentAPIServlet?guid=3464857254</wfw:comment>
		</item>
		<item>
			<title>Using the Amazon Cloud with Smalltalk</title>
			<link>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=Using_the_Amazon_Cloud_with_Smalltalk&amp;entry=3463052773</link>
			<category>tutorial</category>
			<pubDate>Mon, 27 Sep 2010 15:06:13 GMT</pubDate>
			<description><![CDATA[<div xmlns="http://www.w3.org/1999/xhtml">

<p>One of the cooler packages in the <a href="http://www.cincomsmalltalk.com/CincomSmalltalkWiki/Public+Store+Repository">public store repository</a> is Cloudfork - to get it, just load &quot;<strong>Cloudfork-all</strong>&quot; into <a href="http://www.cincomsmalltalk.com/main/products/visualworks/">VisualWorks</a> or <a href="http://www.cincomsmalltalk.com/main/products/products-objectstudio/">ObjectStudio.</a> from there, and then you can access whatever cloud services you use on Amazon. You'll need key info (you get that from Amazon), and you'll need something actually stored there. From there:</p>
<p>

<pre>

&quot;get access&quot;
credentials := CFAWSCredentials newWith: key andSecret: secret.
s3 := CFSimpleStorageService newWith: credentials.

</pre></p>

<p>Now that you have your credentials lined up, you can query the buckets you have on S3:</p>

<p>
<pre>

&quot;get buckets&quot;
buckets := (s3 allBuckets) result.
Transcript clear.
buckets do: [:each |
	Transcript show: 'Bucket: &lt;', each name, '&gt;'.
	Transcript cr].

</pre>
</p>

<p>Now open up a bucket and see what's inside it:</p>

<p>
<pre>

&quot;open a bucket&quot;
bucket := s3 openBucketNamed: 'jar-images'.
all := bucket getList result.

</pre>
</p>

<p>Finally, now get an item and have a look at it.  In my case, it's a JPEG:</p>

<p>
<pre>

&quot;now extract first item&quot;
key := all first key.
byteArray  := (bucket getObject: key) result.

&quot;save to a file&quot;
file := 'imgFroms3.jpg' asFilename writeStream.
file binary.
file nextPutAll: byteArray.
file close.

&quot;now open it&quot;
img := (ImageReader fromFile: 'imgFroms3.jpg') image.

</pre></p>

<p>And that's it. I did a <a href="http://www.cincomsmalltalk.com/blog/blogView?entry=3420785233">screencast</a> on this awhile back as well:</p>




<!-- technorati tags start --><p style="text-align:right;font-size:10px;">Technorati Tags: 
<a href="http://www.technorati.com/tag/cloud" rel="tag">cloud</a>, <a href="http://www.technorati.com/tag/amazon" rel="tag">amazon</a>, <a href="http://www.technorati.com/tag/s3" rel="tag">s3</a>, <a href="http://www.technorati.com/tag/smalltalk" rel="tag">smalltalk</a></p><!-- technorati tags end -->
</div>]]></description>
			<guid isPermaLink="false">3463052773</guid>
			<pingback:server>http://www.jarober.com/blog/servlet/CommentAPIPBServlet?guid=3463052773</pingback:server>
			<pingback:target>http://www.jarober.com/blog/blogView?guid=3463052773</pingback:target>
			<includedComments:comment-collection></includedComments:comment-collection>
			<wfw:comment>http://www.jarober.com/blog/servlet/CommentAPIServlet?guid=3463052773</wfw:comment>
		</item>
		<item>
			<title>A Look at the Comparison Tool</title>
			<link>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=A_Look_at_the_Comparison_Tool&amp;entry=3460457771</link>
			<category>tutorial</category>
			<pubDate>Sat, 28 Aug 2010 14:16:11 GMT</pubDate>
			<description><![CDATA[<div xmlns="http://www.w3.org/1999/xhtml">

<p>The Comparison tool - used to compare versions of code in <a href="http://www.cincomsmalltalk.com">Cincom Smalltalk</a> - is new in VisualWorks 7.7.1, and there's been a bunch of talk about it on the mailing lists lately. I thought it might be useful to take a look at one of the common use paths you might take through it. To start, I connected to the public store repository, and selected part of my Silt blog server package:</p>
<p><img src="http://www.jarober.com/images/examples/compare1.jpg" title="selecting a version"/></p>

<p>What I was doing above was selecting the package I wanted (Blog), and then, using the menu, comparing it with another version.  That prompted a selection dialog - so I could select which version to compare to:</p>


<p><img src="http://www.jarober.com/images/examples/compare2.jpg" title="Select a Version"/></p>
<p>After selecting the package, the following window comes up - and this is where you start to see the new UI:</p><p><img src="http://www.jarober.com/images/examples/compare3.jpg" title="The New Comparison Tool"/></p>

<p>On the left side is the version I selected to compare against - on the right is what's loaded in the image.  Notice the expansion symbol in the lower part of the UI; you click that to expand out and see the differences:</p>


<p><img src="http://www.jarober.com/images/examples/compare4.jpg" title="Comparison Tool"/></p>

<p>Notice how the green line runs from the left to the right, showing the changed/added/removed (in this case, added) text?  That's how you can spot the changes quickly.  When there are multiple changes, you can expand/collapse them individually.  Now, if you do what I do, and patch a running system with diffs, you'll want the next option - right click at the top to summon an action menu:</p>


<p><img src="http://www.jarober.com/images/examples/compare5.jpg" title="Actions for Diffs"/></p>

<p>And there's a menu on the left hand side at the top as well:</p>


<p><img src="http://www.jarober.com/images/examples/compare6.jpg" title="Actions for Diffs"/></p>

<p>That wraps up the brief tour of the new Comparison tool - I'll be doing a screencast on it soon.  </p>
<!-- technorati tags start --><p style="text-align:right;font-size:10px;">Technorati Tags: 
<a href="http://www.technorati.com/tag/cincom smalltalk" rel="tag">cincom smalltalk</a>, <a href="http://www.technorati.com/tag/comparison tool" rel="tag">comparison tool</a>, <a href="http://www.technorati.com/tag/visualworks" rel="tag">visualworks</a>, <a href="http://www.technorati.com/tag/objectstudio" rel="tag">objectstudio</a></p><!-- technorati tags end -->
</div>]]></description>
			<guid isPermaLink="false">3460457771</guid>
			<pingback:server>http://www.jarober.com/blog/servlet/CommentAPIPBServlet?guid=3460457771</pingback:server>
			<pingback:target>http://www.jarober.com/blog/blogView?guid=3460457771</pingback:target>
			<includedComments:comment-collection></includedComments:comment-collection>
			<wfw:comment>http://www.jarober.com/blog/servlet/CommentAPIServlet?guid=3460457771</wfw:comment>
		</item>
		<item>
			<title>Creating a Simple Runtime</title>
			<link>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=Creating_a_Simple_Runtime&amp;entry=3454574071</link>
			<category>tutorial</category>
			<pubDate>Mon, 21 Jun 2010 11:54:31 GMT</pubDate>
			<description><![CDATA[<div xmlns="http://www.w3.org/1999/xhtml">

<p>I received a question about creating a runtime image via my chatback widget this morning - I've done <a href="http://www.cincomsmalltalk.com/userblogs/cincom/blogView?content=smalltalk_daily_deployment">screencasts</a> on that, but those use <a href="http://www.cincomsmalltalk.com/BottomFeeder">BottomFeeder</a> as an example. While that's a real example, it's also fairly large, and somewhat complex. So - I thought a very simple example might be useful. </p>
<p>First, I created a new package, and then a new class (subclassed from Object) with no instance variables. </p>

<p>
<pre>

Smalltalk defineClass: #Sample
	superclass: #{Core.Object}
	indexedType: #none
	private: false
	instanceVariableNames: ''
	classInstanceVariableNames: ''
	imports: ''
	category: ''

</pre>
</p>

<p>I gave this class one method:</p>

<p>
<pre>

doMyThing
	Transcript show: 'This is from the Sample App'; cr.
	ObjectMemory quit.

</pre>
</p>

<p>So that the results are clear, I ran the application in headless mode - the Transcript write  drops to a file called 'headless-transcript.log' (that's configurable, but never mind). Next, I need a way to have this application startup. I created a new class:</p>

<p>
<pre>

Smalltalk defineClass: #SampleUserApp
	superclass: #{Core.UserApplication}
	indexedType: #none
	private: false
	instanceVariableNames: ''
	classInstanceVariableNames: ''
	imports: ''
	category: ''

</pre>
</p>

<p>
That's a class that exists to define a startup procedure.  You create a new method called #main, and put your startup code there:</p>

<p>
<pre>

main
	Sample new doMyThing.

</pre>
</p>

<p>Next, I need a script that creates a new image, and puts it into &quot;runtime&quot; mode - the #main method will not fire unless the image is in that state. Here's the script:</p>

<p>
<pre>

&quot;build a simple app&quot;

&quot;load all my needed parcels (Non-Windows)&quot;
[#('SampleApp.pcl') do: [:each |
        Parcel loadParcelFrom: each]]
	on: MissingParcelSource
	do: [:ex | ex resume: true].

&quot;turn change log off, so that we can ship patches reasonably&quot;
'ChangeSet.BroadcastChanges' asQualifiedReference 
	ifDefinedDo: [:flag | 'ChangeSet.BroadcastChanges' asQualifiedReference value: false].

&quot;Set herald string&quot;
ObjectMemory setHeraldString: 'This is an Example Application in VisualWorks'.

&quot;reset parcel path&quot;
Parcel searchPathModel value removeAll.

&quot;set up runtime state&quot;
DeploymentOptionsSystem current startInRuntime: true.

&quot;set up runtime state&quot;
UI.WindowManager noWindowBlock: [:windowManager | ].
stream := WriteStream on: String new.
stream nextPutAll: 'changeRequest'; cr; cr; tab.
stream nextPutAll: '^true'.
VisualLauncher compile: stream contents.
VisualLauncher allInstances do: [:each | each closeAndUnschedule.  each release].

ObjectMemory garbageCollect.
Workbook allInstances do: [:each | each closeRequest].
(Delay forSeconds: 20) wait.
Parcel searchPathModel value: (List with: (PortableFilename named: '.')).
SourceFileManager default discardSources.

&quot;Now save the image such that this file does not get looked for at startup&quot;
[ObjectMemory permSaveAs: 'sample' thenQuit: false] fork.
[(Delay forSeconds: 45) wait.
RuntimeSystem isRuntime ifFalse: [ObjectMemory quit]] fork

</pre>
</p>

<p>I saved the code I created to a parcel, so that I could do a clean load.  On my Mac, the command line looked like this (I have a symlink from visual to where the VM actually resides):</p>

<p>./visual visual.im -filein sampleDeploy.st</p>

<p>Where 'sampleDeploy.st' is the script above.  Running that drops a single line to 'headless-transcript.log' and quits, just as you would expect.  You can copy the script from above, and <a href="http://www.jarober.com/code/sampleApp.zip">download the example parcel here.</a></p>


<!-- technorati tags start --><p style="text-align:right;font-size:10px;">Technorati Tags: 
<a href="http://www.technorati.com/tag/smalltalk" rel="tag">smalltalk</a>, <a href="http://www.technorati.com/tag/deployment" rel="tag">deployment</a>, <a href="http://www.technorati.com/tag/build%20script" rel="tag">build script</a></p><!-- technorati tags end -->
</div>]]></description>
			<guid isPermaLink="false">3454574071</guid>
			<pingback:server>http://www.jarober.com/blog/servlet/CommentAPIPBServlet?guid=3454574071</pingback:server>
			<pingback:target>http://www.jarober.com/blog/blogView?guid=3454574071</pingback:target>
			<includedComments:comment-collection>
				<includedComments:comment>
					<includedComments:guid>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=Creating_a_Simple_Runtime&amp;entry=3454574071</includedComments:guid>
					<includedComments:puid>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=Creating_a_Simple_Runtime&amp;entry=3454574071</includedComments:puid>
					<includedComments:author>Gï¿¿nter Fahrnberger</includedComments:author>
					<includedComments:pubDate>2010-06-22T05:00:07-04:00</includedComments:pubDate>
					<includedComments:content>&lt;div xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;p&gt;Hi James!&lt;/p&gt;&lt;p&gt;Thanks for this small example. Do you also have suggestions or videos for redirections of errors into the file headless-transcript.log?&lt;/p&gt;&lt;p&gt;Best regards,&lt;/p&gt;&lt;p&gt;ï¿¿nter&lt;/p&gt;
&lt;/div&gt;</includedComments:content>
					<includedComments:title>Re: Creating a Simple Runtime</includedComments:title>
				</includedComments:comment>
			</includedComments:comment-collection>
			<wfw:comment>http://www.jarober.com/blog/servlet/CommentAPIServlet?guid=3454574071</wfw:comment>
		</item>
		<item>
			<title>Adding a Custom Tab to the Smalltalk Browser</title>
			<link>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=Adding_a_Custom_Tab_to_the_Smalltalk_Browser&amp;entry=3453486533</link>
			<category>tutorial</category>
			<pubDate>Tue, 08 Jun 2010 21:48:53 GMT</pubDate>
			<description><![CDATA[<div xmlns="http://www.w3.org/1999/xhtml">

<p>This is a written companion piece to <a href="http://www.jarober.com/blog/blogView?showComments=true&printTitle=Smalltalk_Daily_06/08/10:_Adding_Custom_Browser_Tabs&entry=3453443448">this morning's screencast</a> - I'm going to cover how to add a custom tab to the browser. The example I'm using is simple - every class understands the method #printHierarchy, which gives you a textual hierarchy diagram. At one time, that was a view possibility in the browser (circa 5i). Today, we'll add that back in a tab. To start, create a new package:</p>
<p><img src="http://www.jarober.com/images/examples/printTool1.png" title="Create a new package"/></p>

<p>With that package created, we need a UI for the tab.  It's a simple one, with a text widget filling the canvas.  Using the UIPainter, create something like this:</p>
<p><img src="http://www.jarober.com/images/examples/printTool2.png" title="Create the UI"/></p>

<p>Once that's created, install it as a subclass of <strong>Refactory.Browser.CodeTool</strong>.  Select the &quot;other&quot; drop down option in the install tool and enter that in:</p>

<p><img src="http://www.jarober.com/images/examples/printTool3.png" title="Install the class"/></p>

<p>With that installed, we need to write some code - in this case, three instance side methods:</p>

<p>
<pre>


isActive
	^self classOrNameSpace notNil

</pre>
</p>

<p>#isActive is sent to determine whether or not the tab should be visible.  In this example, it should only be there if a class or namespace is selected.  You an examine the methods in class <strong>CodeTool</strong> to see what's easily possible.  Next, the tab needs a name:</p>

<p>
<pre>

tabName
	^'Print Hierarchy'

</pre>
</p>

<p>Finally, something needs to actually <em>happen</em> when the tab is selected; we'll add a #postBuildWith: method to fill our text widget with the text for the &quot;diagram&quot;</p>

<p>
<pre>

postBuildWith: bldr
	| classOrNamespace |
	super postBuildWith: bldr.

	classOrNamespace := codeModel classOrNameSpace.
	self printText value: classOrNamespace printHierarchy

</pre>
</p>

<p>That's almost enough. What we need to do now is tell the browser that our new extension exists.  To do  that, we'll extend class <strong>CodeModel</strong></p>


<p><img src="http://www.jarober.com/images/examples/printTool4.png" title="Class Extension"/></p>
<p><img src="http://www.jarober.com/images/examples/printTool5.png" title="Class Extension"/></p>

<p>Go to the class side, and add this method:</p>

<p>
<pre>

browserPrintHierarchyToolClass
	&lt;tool&gt;

	^RBPrintHierarchyTool

</pre>
</p>

<p>The part in brackets is a pragma.  The code simply tells the browser what class to throw into our tab.  That's it; open a new browser, and select a class:</p>


<p><img src="http://www.jarober.com/images/examples/printTool6.png" title="New Tab shows up"/></p>

<p>Now, select a class, and watch your new tab in action:</p>


<p><img src="http://www.jarober.com/images/examples/printTool7.png" title="New tab Working"/></p>

<p>You can <a href="http://www.jarober.com/code/RBPrintHierarchyTool.zip">download the code here</a>, or just head over to the <a href="http://www.jarober.com/blog/blogView">Public Store Repository</a> and load the <strong>RBPrintHierarchyTool</strong> package</p>



<!-- technorati tags start --><p style="text-align:right;font-size:10px;">Technorati Tags: 
<a href="http://www.technorati.com/tag/smalltalk" rel="tag">smalltalk</a>, <a href="http://www.technorati.com/tag/refactoring+browser" rel="tag">refactoring+browser</a></p><!-- technorati tags end -->
</div>]]></description>
			<guid isPermaLink="false">3453486533</guid>
			<pingback:server>http://www.jarober.com/blog/servlet/CommentAPIPBServlet?guid=3453486533</pingback:server>
			<pingback:target>http://www.jarober.com/blog/blogView?guid=3453486533</pingback:target>
			<includedComments:comment-collection></includedComments:comment-collection>
			<wfw:comment>http://www.jarober.com/blog/servlet/CommentAPIServlet?guid=3453486533</wfw:comment>
		</item>
		<item>
			<title>Open a Window Where You Want It</title>
			<link>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=Open_a_Window_Where_You_Want_It&amp;entry=3451273842</link>
			<category>tutorial</category>
			<pubDate>Fri, 14 May 2010 07:10:42 GMT</pubDate>
			<description><![CDATA[<div xmlns="http://www.w3.org/1999/xhtml">
	


	<p>Ever wanted to set a window's opening location programmatically in VisualWorks? It looks harder than it is. As you wend your way through the opening code, it's easy to just throw your hands in the air. </p>
	

	<p>Here's a simple solution (thanks to <a href="http://www.cincomsmalltalk.com/userblogs/travis/blogView">Travis</a> for this one)</p>
	<ul xmlns="http://www.w3.org/1999/xhtml">
		
			
		<li>Create the window using the UI tools</li>
		<li>Copy the #windowSpec method (class side) to something else, like #baseWindowSpec</li>
		<li>Now, create a new #windowSpec method like this:</li>
		
		
	</ul>

<p>
<pre>

windowSpec
	&quot;make it open where I want it&quot;

	| spec |
	spec := self baseWindowSpec decodeAsLiteralArray.
	spec window bounds: (100 @ 100 extent: 400 @ 500).
	^spec literalArrayEncoding

</pre>
</p>

<p>Replacing the dimensions, of course, with what you actually want.  What does that do?  It grabs the spec <em>and manipulates the object directly</em> - which, insofar as the framework allows, is the right thing to do.  Anyway, it's a simple way of getting a Window to open where you want it to - enjoy.</p>
<!-- technorati tags start --><p style="text-align:right;font-size:10px;">Technorati Tags: 
<a href="http://www.technorati.com/tag/smalltalk" rel="tag">smalltalk</a>, <a href="http://www.technorati.com/tag/visualworks" rel="tag">visualworks</a>, <a href="http://www.technorati.com/tag/UI" rel="tag">UI</a></p><!-- technorati tags end -->
</div>]]></description>
			<guid isPermaLink="false">3451273842</guid>
			<pingback:server>http://www.jarober.com/blog/servlet/CommentAPIPBServlet?guid=3451273842</pingback:server>
			<pingback:target>http://www.jarober.com/blog/blogView?guid=3451273842</pingback:target>
			<includedComments:comment-collection>
				<includedComments:comment>
					<includedComments:guid>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=Open_a_Window_Where_You_Want_It&amp;entry=3451273842</includedComments:guid>
					<includedComments:puid>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=Open_a_Window_Where_You_Want_It&amp;entry=3451273842</includedComments:puid>
					<includedComments:author>anonymous</includedComments:author>
					<includedComments:pubDate>2010-05-17T08:05:28-04:00</includedComments:pubDate>
					<includedComments:content>&lt;div xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;p&gt;This is useful to me. Thanks for sharing.&lt;/p&gt;
&lt;/div&gt;</includedComments:content>
					<includedComments:title>Re: Open a Window Where You Want It</includedComments:title>
				</includedComments:comment>
			</includedComments:comment-collection>
			<wfw:comment>http://www.jarober.com/blog/servlet/CommentAPIServlet?guid=3451273842</wfw:comment>
		</item>
		<item>
			<title>Setting Up Store for SQLite</title>
			<link>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=Setting_Up_Store_for_SQLite&amp;entry=3451210218</link>
			<category>tutorial</category>
			<pubDate>Thu, 13 May 2010 13:30:18 GMT</pubDate>
			<description><![CDATA[<div xmlns="http://www.w3.org/1999/xhtml">

<p>One of the hurdles to using version control with Cincom Smalltalk has been the requirement that you set up a relational database - Oracle, SQLServer (etc) are fairly complex beasts. Even PostgreSQL, which is free, can be difficult to set up. Recently, however, it became possible to use SQLite as the back end for Store - and nothing could be easier than using that - it's a simple file based database. If you're on Windows you might have to visit the website and install <a href="http://www.sqlite.org/download.html">SQLite,</a> but that's a simple matter of pushing a dll or two onto your system - you can set up databases on the fly. </p>
<p>For Store itself, here are the steps - first, open the parcel manager and load the appropriate support:</p><p><img src="http://www.jarober.com/images/examples/sqlite1.png" title="Load SQLite for Store support"/></p>

<p>Next, just type the following code into a workspace and execute it:</p>

<p>
<pre>

Store.DbRegistry installDatabaseTables.

</pre>
</p>


<p><img src="http://www.jarober.com/images/examples/sqlite2.png" title="Create the Store repository"/></p>

<p>You'll be prompted a few times; first is a login.  For this, the username and password don't really matter; just put in anything.  Be sure to pick SQLite3Connection from the drop down though:</p>

<p><img src="http://www.jarober.com/images/examples/sqlite3.png" title="Create the Store repository"/></p>

<p>Next, fill in the same name you used above for the repository:</p>

<p><img src="http://www.jarober.com/images/examples/sqlite4.png" title="Create the Store repository"/></p>

<p>For the next two prompts, just let them default:</p>

<p><img src="http://www.jarober.com/images/examples/sqlite5.png" title="Create the Store repository"/></p>

<p><img src="http://www.jarober.com/images/examples/sqlite6.png" title="Create the Store repository"/></p>

<p>That's it for installation.  Now pull down the Store menu and connect to your new repository:</p>

<p><img src="http://www.jarober.com/images/examples/sqlite7.png" title="Connect to the new repository"/></p>

<p>And that's it - notice the name in the lower corner of the launcher - you're up and running!</p>

<p><img src="http://www.jarober.com/images/examples/sqlite8.png" title="Ready to Go"/></p>

<!-- technorati tags start --><p style="text-align:right;font-size:10px;">Technorati Tags: 
<a href="http://www.technorati.com/tag/smalltalk" rel="tag">smalltalk</a>, <a href="http://www.technorati.com/tag/SQLite" rel="tag">SQLite</a>, <a href="http://www.technorati.com/tag/store" rel="tag">store</a>, <a href="http://www.technorati.com/tag/version%20control" rel="tag">version control</a></p><!-- technorati tags end -->
</div>]]></description>
			<guid isPermaLink="false">3451210218</guid>
			<pingback:server>http://www.jarober.com/blog/servlet/CommentAPIPBServlet?guid=3451210218</pingback:server>
			<pingback:target>http://www.jarober.com/blog/blogView?guid=3451210218</pingback:target>
			<includedComments:comment-collection></includedComments:comment-collection>
			<wfw:comment>http://www.jarober.com/blog/servlet/CommentAPIServlet?guid=3451210218</wfw:comment>
		</item>
		<item>
			<title>Using ActiveX Controls with VisualWorks</title>
			<link>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=Using_ActiveX_Controls_with_VisualWorks&amp;entry=3446885321</link>
			<category>tutorial</category>
			<pubDate>Wed, 24 Mar 2010 12:08:41 GMT</pubDate>
			<description><![CDATA[<div xmlns="http://www.w3.org/1999/xhtml">

<p>I thought a small walkthrough on using the new ActiveX control capabilities of VisualWorks 7.7 might be useful, so here goes - you can <a href="http://www.jarober.com/code/VideoDemo.zip">download the code I built in the screencaptures below here.</a></p>
<p>With that out of the way, here's how to build it yourself. First, load the ActiveX support - to do that, you need to open the parcel manager, and switch to the directories tab - then select &quot;com&quot;:</p><p><img src="http://www.jarober.com/images/examples/com1.png" title="Load ActiveX Support"/></p>

<p>Once that's in, open the GUI builder, and you should notice a new widget: the ActiveX widget.  This functions (from a Smalltalk perspective) a lot like the subcanvas:</p>


<p><img src="http://www.jarober.com/images/examples/com2.png" title="Select the ActiveX Widget"/></p>
<p>Once that's selected, add it to the canvas. In the properties tool, give it an aspect, and then pick (from the collection of items in the lower menu) the control you want. Your list will vary, based on what happens to be installed on Windows:</p><p><img src="http://www.jarober.com/images/examples/com3.png" title="Set Properties"/></p>

<p>Now, add an input field (for the url you'll be loading) and a button (to do the load).  It should look like this:</p>

<p><img src="http://www.jarober.com//images/examples/com4.png" title="The Full UI"/></p>

<p>Install that to a class, and then use the &quot;define&quot; menu option to set up the method stubs.  Now, go to a browser, and change the #load method (the one being used by the button) to look like this:</p>

<p><img src="http://www.jarober.com/images/examples/com5.png" title="Edit the Code"/></p>

<p>That's it for the hard stuff - now open the UI, and enter an <a href="http://www.cincomsmalltalk.com/video/2009/esug/retrObjects.mp4">URL for something that Quicktime can play:</a></p>

<p><img src="http://www.jarober.com/images/examples/com6.png" title="Try it out"/></p>

<p>You may have to wait a bit for it to buffer, depending on how fast your internet connection is (use a file url if you have a very slow one).  If you use the link above, a short video from ESUG, of Gabriel Honore demonstrating his RetrObjects project, will play.  That's it!</p>
<!-- technorati tags start --><p style="text-align:right;font-size:10px;">Technorati Tags: 
<a href="http://www.technorati.com/tag/windows" rel="tag">windows</a>, <a href="http://www.technorati.com/tag/COM" rel="tag">COM</a>, <a href="http://www.technorati.com/tag/visualworks" rel="tag">visualworks</a>, <a href="http://www.technorati.com/tag/activex" rel="tag">activex</a></p><!-- technorati tags end -->
</div>]]></description>
			<guid isPermaLink="false">3446885321</guid>
			<pingback:server>http://www.jarober.com/blog/servlet/CommentAPIPBServlet?guid=3446885321</pingback:server>
			<pingback:target>http://www.jarober.com/blog/blogView?guid=3446885321</pingback:target>
			<includedComments:comment-collection></includedComments:comment-collection>
			<wfw:comment>http://www.jarober.com/blog/servlet/CommentAPIServlet?guid=3446885321</wfw:comment>
		</item>
		<item>
			<title>Using Excel from ObjectStudio</title>
			<link>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=Using_Excel_from_ObjectStudio&amp;entry=3446266213</link>
			<category>tutorial</category>
			<pubDate>Wed, 17 Mar 2010 08:10:13 GMT</pubDate>
			<description><![CDATA[<div xmlns="http://www.w3.org/1999/xhtml"><p> Yesterday, I pushed up a short <a href="http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=Using_Excel_with_VisualWorks&amp;entry=3446211461">walkthrough on using Excel from VisualWorks</a>; this morning I did a <a href="http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=Excel_from_ObjectStudio:_Video&amp;entry=3446264308">screencast on using Excel from ObjectStudio</a>. Here's the walkthrough for that piece.</p><p>First, you'll need to load the required support. Using File&gt;&gt;Load Application in the launcher menu, select &quot;OLE&quot; and load:</p><p><img src="http://www.jarober.com/images/examples/os_support.png" title="Load COM support"/></p>
<p>Once you have that loaded, open a workspace (from the Tools menu) and add the following script - you can start exploring the COM APIs from here and tweak the script as needed:</p>

<p>
<pre>

| ole excel wb range value |
&quot;get the dispatcher for Excel&quot;
ole := OLEObject newProgId: 'Excel.Application'.
excel := ole dispatcher.

&quot;open Excel and get a worksheet&quot;
excel call: 'Visible' params: (Array with: true).
wb := excel call: 'Workbooks' params: #().
wb call: 'Add' params: #().

&quot;Now add some data&quot;
range := excel call: 'Range' params: (Array with: 'A1').
range at: 'Value' put: 'Fred'.
range := excel call: 'Range' params: (Array with: 'A2').
range at: 'Value' put: 'Flintstone'.

&quot;make the range bold&quot;
range := excel call: 'Range' params: (Array with: 'A1:A2').
(range at: 'Font') at: 'Bold' put: (Array with: true).

&quot;Now read a cell back&quot;
range := excel call: 'Range' params: (Array with: 'A1').
value := range at: 'Value'.
^value

</pre>
</p>

<p>Unlike VisualWorks, you don't need to highlight that code - simply pull down the Smalltalk menu in the workspace and try &quot;Insert&quot; (which will print the results into the workspace) - you should end up with Excel opened up, with &quot;Fred&quot; in A1 and &quot;Flintstone&quot; in A2, and &quot;Fred&quot; in your workspace at the bottom - like this:</p>
<p><img src="http://www.jarober.com/images/examples/os_results.png" title="Success - added data to Excel"/></p>

<p>That's pretty much it - you can explore the available COM APIs and work from there - but this should get you started.</p>
<!-- technorati tags start --><p style="text-align:right;font-size:10px;">Technorati Tags: 
<a href="http://www.technorati.com/tag/smalltalk" rel="tag">smalltalk</a>, <a href="http://www.technorati.com/tag/excel" rel="tag">excel</a>, <a href="http://www.technorati.com/tag/com" rel="tag">com</a>, <a href="http://www.technorati.com/tag/objectstudio" rel="tag">objectstudio</a></p><!-- technorati tags end -->
</div>]]></description>
			<guid isPermaLink="false">3446266213</guid>
			<pingback:server>http://www.jarober.com/blog/servlet/CommentAPIPBServlet?guid=3446266213</pingback:server>
			<pingback:target>http://www.jarober.com/blog/blogView?guid=3446266213</pingback:target>
			<includedComments:comment-collection></includedComments:comment-collection>
			<wfw:comment>http://www.jarober.com/blog/servlet/CommentAPIServlet?guid=3446266213</wfw:comment>
		</item>
		<item>
			<title>Using Excel with VisualWorks</title>
			<link>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=Using_Excel_with_VisualWorks&amp;entry=3446211461</link>
			<category>tutorial</category>
			<pubDate>Tue, 16 Mar 2010 16:57:41 GMT</pubDate>
			<description><![CDATA[<div xmlns="http://www.w3.org/1999/xhtml"><p> This morning I did a <a href="http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=Working_with_Excel:_Video&amp;entry=3446179541">screencast on using Excel with VisualWorks</a>; I thought a simple walkthrough might be handy as well. The first thing you need to do after starting VW is pull up the Parcel Manager, select &quot;OS-Windows&quot; on the left, and &quot;COM-All&quot; on the right. Right click and load:</p><p><img src="http://www.jarober.com/images/examples/vw_support.png" title="Load COM support"/></p>

<p>Next, close that window, and in a workspace, add this little script.  Once you try it out, you can experiment on your own - and use the &quot;Browse Automation Classes&quot; option under the COM menu in the Launcher to explore the interfaces available to you:</p>

<p>
<pre>

&quot;Start Excel, get dispatch driver&quot;
excel := COMDispatchDriver createObject: 'Excel.Application'.

&quot;Open Excel visibly&quot;
excel setVisible: true.
excel getWorkbooks Add.
sheet := excel getActiveSheet.

&quot;Write some data&quot;
(excel getRange: 'A1') setValue: 'Name'.
(excel getRange: 'A2') setValue: 'Fred Flintstone'.
(excel getRange: 'A1:A2') getFont setBold: true.

&quot;Read a cell&quot;
(excel getRange: 'A1') getValue.

&quot;Copy Cells&quot;
(excel getRange: 'A1:A2') Select.
excel setCutCopyMode: false.
excel getSelection Copy.
Transcript show: Screen default getExternalSelection.

</pre>
</p>

<p>That code creates a dispatch driver, and then calls various COM APIs exposed by Excel.  You'll see a few dialogs like this pop up as you execute that, as the message sends are going to COM, not Smalltalk - and thus, they don't exist in the image:</p>

<p><img src="http://www.jarober.com/images/examples/vw_warn.png" title="jarober added a file"/></p>
<p>Just use the &quot;proceed&quot; button to dismiss those. Once you've executed all the code, you should see something like this:</p><p><img src="http://www.jarober.com/images/examples/vw_results.png" title="Results"/></p>

<p>Which should be Excel with the data you entered highlighted, and the copied data sitting in the Transcript, where we printed it.  That's it - you're now working with Excel from VW.  Go ahead and use the automation browser to explore the full API set.</p>
<!-- technorati tags start --><p style="text-align:right;font-size:10px;">Technorati Tags: 
<a href="http://www.technorati.com/tag/visualworks" rel="tag">visualworks</a>, <a href="http://www.technorati.com/tag/excel" rel="tag">excel</a>, <a href="http://www.technorati.com/tag/com" rel="tag">com</a></p><!-- technorati tags end -->
</div>]]></description>
			<guid isPermaLink="false">3446211461</guid>
			<pingback:server>http://www.jarober.com/blog/servlet/CommentAPIPBServlet?guid=3446211461</pingback:server>
			<pingback:target>http://www.jarober.com/blog/blogView?guid=3446211461</pingback:target>
			<includedComments:comment-collection></includedComments:comment-collection>
			<wfw:comment>http://www.jarober.com/blog/servlet/CommentAPIServlet?guid=3446211461</wfw:comment>
		</item>
		<item>
			<title>Using the Smalltalk Facebook Interface</title>
			<link>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=Using_the_Smalltalk_Facebook_Interface&amp;entry=3444479460</link>
			<category>tutorial</category>
			<pubDate>Wed, 24 Feb 2010 15:51:00 GMT</pubDate>
			<description><![CDATA[<div xmlns="http://www.w3.org/1999/xhtml"><p> I've seen a few questions pop up on getting started with the Facebook interface I wrote, so I thought I'd post a basic &quot;getting started&quot; tutorial. First off, you need to go to the <a href="http://www.facebook.com/developers/apps.php#!/developers/createapp.php">Facebook website (developer pages)</a> and create an application definition - you'll get your application keys (you'll need those to make any Facebook API callls). </p><p><img src="http://www.jarober.com/images/examples/fb1.png" title="Get App keys"/></p>
<p>Once you've done that, start VisualWorks 7.7 (or ObjectStudio 8.2) and load the <strong><a href="http://www.cincomsmalltalk.com/userblogs/cincom/blogView?content=facebookConnect">FacebookBundle</a></strong> from the <a href="http://www.cincomsmalltalk.com/CincomSmalltalkWiki/Public+Store+Repository">public store repository</a>. </p>

<p>Once you've done that, you need to execute the following code (use a workspace for now) with your application credentials:</p>

<p>
<pre>

&quot;login&quot;
holder := FacebookSecretHolder new
		apiKey: apiKey;
		secretKey: secret;
		applicationId: appId.

&quot;now get the connection (will spawn a web browser&quot;
connection := Connection withSecretHolder: holder.
connection login.

</pre>
</p>

<p>At the end of that, your default browser should pop up - it may show you what's below, or it may prompt you to login:</p>
<p><img src="http://www.jarober.com/images/examples/fb2.png" title="Login to Facebook"/></p>
<p>Once you've logged in, execute the following code to start a session:</p>

<p>
<pre>

&quot;get auth token&quot;
connection authGetSession.

</pre>
</p>

<p>At this point, you can start using the API - but you may notice that some calls don't work as you expect. For instance, #getStream will only return your news updates, and trying to publish to the news stream (#streamPublish:) will fail. Why? Well, your application needs to have permissions granted. Execute the following code, which will spin your browser back up, prompting you to authorize the relevant permissions:</p>

<p>
<pre>

&quot;only need to ask for these authorizations once - grants permission to read news feed
and to write to the news feed&quot;
connection grantExtendedPermissionFor: 'read_stream'.
connection grantExtendedPermissionFor: 'publish_stream'.

</pre>
</p>

<p>As the comment notes, you only need to do that <em>once</em>.  Not once per session, once, period - unless Facebook changes something, or you use the APIs (or website) to revoke the granted rights.  Now, use this to read the stream (inspect the results), and then publish an update:</p>

<p>
<pre>

&quot;now read the news feed&quot;
connection streamGet.


&quot;update status in stream&quot;
connection streamPublish: 'Writing to my Facebook news stream from Smalltalk!'.

</pre>
</p>

<p>Use the browser to verify that it all worked.  That's pretty much it - to disconnect your session, use the code below:</p>

<p>
<pre>

&quot;logout&quot;
connection clearSession

</pre>
</p>

<p>You should be good to go.  If anything seems wrong, just <a href="mailto:jarober.com">let me know</a></p><!-- technorati tags start --><p style="text-align:right;font-size:10px;">Technorati Tags: 
<a href="http://www.technorati.com/tag/smalltalk" rel="tag">smalltalk</a>, <a href="http://www.technorati.com/tag/social media" rel="tag">social media</a>, <a href="http://www.technorati.com/tag/facebook" rel="tag">facebook</a></p><!-- technorati tags end -->
</div>]]></description>
			<guid isPermaLink="false">3444479460</guid>
			<pingback:server>http://www.jarober.com/blog/servlet/CommentAPIPBServlet?guid=3444479460</pingback:server>
			<pingback:target>http://www.jarober.com/blog/blogView?guid=3444479460</pingback:target>
			<includedComments:comment-collection></includedComments:comment-collection>
			<wfw:comment>http://www.jarober.com/blog/servlet/CommentAPIServlet?guid=3444479460</wfw:comment>
		</item>
		<item>
			<title>Working with Silt</title>
			<link>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=Working_with_Silt&amp;entry=3443471551</link>
			<category>tutorial</category>
			<pubDate>Fri, 12 Feb 2010 23:52:31 GMT</pubDate>
			<description><![CDATA[<div xmlns="http://www.w3.org/1999/xhtml"><p> I have recieved a few questions about <a href="http://www.cincomsmalltalk.com/CincomSmalltalkWiki/Silt">Silt</a> recently, so I cleaned up the blog creation tool some (it could still use some work), and I added some basic documentation to the bundle comment. If you want to try the system out, here's what you do:</p>

<p>
<ul>
<li>Load the <strong>Silt</strong> bundle from the <a href="http://www.cincomsmalltalk.com/CincomSmalltalkWiki/Public+Store+Repository">public repository</a>.  When it prompts you to save files, select all and hit &quot;ok&quot;</li>
<li>To Create a new blog, use Tools&gt;&gt;Blog Manager, then the &quot;New&quot; button.  All you need to add is an email address for the &quot;maintainer&quot; field. </li>
<li>You should now be able to access the blog via <a href="http://localhost:8008/blog/blogView">http://localhost:8008/blog/blogView</a></li>
<li>To login and adminster or post, use <a href="http://localhost:8008/blog/blogLogin">http://localhost:8008/blog/blogLogin</a></li>
</ul>
</p>

<p>You can change the css references in View.ssp to use any of the CSS templates that come down with the installation; you could derive a new one based on them as well, using the same API that View.ssp uses.  Alternatively, you can set things up any way you want using the API in class <strong>BlogSaver</strong>.  For example:</p>

<p>
<pre>

blog := BlogSaver named: 'blog'.

&quot;get all recent posts&quot;
recentPosts := blog fetchAllRecentPosts.

&quot;get all recent posts for a category&quot;
recentInCategory := blog fetchBlogsbySearchCategory: someCategory

&quot;get the most recent N posts in a category&quot;
recentInCategory := blog fetchBlogs: howMany bySearchCategory: someCategory

&quot;get a specific post by entry ID&quot;
blogPost := blog entryFor: entryID

&quot;get most recent post&quot;
lastPost := blog blog fetchAllRecentPosts first.

</pre>
</p>

<p>To learn more about the API, look at class BlogSaver, specifically, the api categories</p>

<p>The server also manages &quot;static&quot; pages; you can create one using the administration pages.  It will land in a directory named 'blog/content', where 'blog' is the name you used when you set the site up.  If you edit the resulting file by hand, you'll need to tell the server that it's been changed (if you edit with the tools, it'll get handled for you).  To reset by hand:</p>

<p>
<pre>

blog (Blog.BlogSaver named: 'blog') cache clearHTMLCaches.

</pre>
</p>

<p>Finally, if you want WYSIWYG online editing, you need to install TinyMCE.  <a href="http://tinymce.moxiecode.com/">Download that here</a>, and install it on your server.  Edit the file editor.inc to reflect the proper location.</p>



<!-- technorati tags start --><p style="text-align:right;font-size:10px;">Technorati Tags: 
<a href="http://www.technorati.com/tag/silt" rel="tag">silt</a>, <a href="http://www.technorati.com/tag/smalltalk" rel="tag">smalltalk</a>, <a href="http://www.technorati.com/tag/blog%20server" rel="tag">blog server</a></p><!-- technorati tags end -->
</div>]]></description>
			<guid isPermaLink="false">3443471551</guid>
			<pingback:server>http://www.jarober.com/blog/servlet/CommentAPIPBServlet?guid=3443471551</pingback:server>
			<pingback:target>http://www.jarober.com/blog/blogView?guid=3443471551</pingback:target>
			<includedComments:comment-collection></includedComments:comment-collection>
			<wfw:comment>http://www.jarober.com/blog/servlet/CommentAPIServlet?guid=3443471551</wfw:comment>
		</item>
		<item>
			<title>Cairo Graphics: Getting Started</title>
			<link>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=Cairo_Graphics:_Getting_Started&amp;entry=3442830883</link>
			<category>tutorial</category>
			<pubDate>Fri, 05 Feb 2010 13:54:43 GMT</pubDate>
			<description><![CDATA[<div xmlns="http://www.w3.org/1999/xhtml"><p> Next week I'll be redoing some of the Cairo screencasts - they are all outdated, simply due to the fact that you can load cairo much more easily now:</p><p><img src="http://www.jarober.com/images/examples/loadcairo.jpg" title="Cairo"/></p>

<p>On Windows and OS X, you'll have the shared libraries installed as well (assuming you picked those when you ran the installer.  If you didn't, re-run the installer and do so).  For Linux or Unix platforms, you'll have to get Cairo installed yourself.</p>

<p>Once you have it loaded, try this as a simple &quot;Is Cairo Working&quot; test:</p>

<p>
<pre>

| win component |
win := ApplicationWindow new.
win
	component: (VisualBlock block: 
					[:gc :box |
					gc newCairoContextWhile: 
						[:cr |
						cr
							source: ColorValue red;
							rectangle: (box insetBy: 20);
							fillPreserve;
							source: ColorValue blue;
							strokeWidth: 20;
							stroke]]).
win open.

</pre>
</p>

<p>If it worked, you should get this (make the window bigger to see it:</p>


<p><img src="http://www.jarober.com/images/examples/cairotest.jpg" title="Cairo Window"/></p>
<!-- technorati tags start --><p style="text-align:right;font-size:10px;">Technorati Tags: 
<a href="http://www.technorati.com/tag/graphics" rel="tag">graphics</a>, <a href="http://www.technorati.com/tag/cairo" rel="tag">cairo</a>, <a href="http://www.technorati.com/tag/smalltalk" rel="tag">smalltalk</a></p><!-- technorati tags end -->
</div>]]></description>
			<guid isPermaLink="false">3442830883</guid>
			<pingback:server>http://www.jarober.com/blog/servlet/CommentAPIPBServlet?guid=3442830883</pingback:server>
			<pingback:target>http://www.jarober.com/blog/blogView?guid=3442830883</pingback:target>
			<includedComments:comment-collection>
				<includedComments:comment>
					<includedComments:guid>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=Cairo_Graphics:_Getting_Started&amp;entry=3442830883</includedComments:guid>
					<includedComments:puid>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=Cairo_Graphics:_Getting_Started&amp;entry=3442830883</includedComments:puid>
					<includedComments:author>anonymous</includedComments:author>
					<includedComments:pubDate>2010-02-05T14:52:55-05:00</includedComments:pubDate>
					<includedComments:content>&lt;div xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;p&gt;What is Cairo?&lt;/p&gt;&lt;p&gt;n which versions of smalltalk does it run?&lt;/p&gt;
&lt;/div&gt;</includedComments:content>
					<includedComments:title>Re: Cairo Graphics: Getting Started</includedComments:title>
				</includedComments:comment>
				<includedComments:comment>
					<includedComments:guid>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=Cairo_Graphics:_Getting_Started&amp;entry=3442830883</includedComments:guid>
					<includedComments:puid>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=Cairo_Graphics:_Getting_Started&amp;entry=3442830883</includedComments:puid>
					<includedComments:author>James Robertson</includedComments:author>
					<includedComments:pubDate>2010-02-05T16:10:27-05:00</includedComments:pubDate>
					<includedComments:content>&lt;div xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;p&gt;Cairo is a cross platform graphics library - see:&lt;/p&gt;&lt;p&gt;
&lt;a href="http://www.cairographics.org/"&gt;[link 1]&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There's an interface to it from VisualWorks and ObjectStudio; no idea whether anyone has built anything for Pharo/Squeak, or any other Smalltalk&lt;/p&gt;

&lt;p&gt;
&lt;a href="http://www.cairographics.org/"&gt;[1 http://www.cairographics.org/]&lt;/a&gt;&lt;br/&gt;
&lt;/p&gt;


&lt;/div&gt;</includedComments:content>
					<includedComments:title>Re: Cairo Graphics: Getting Started</includedComments:title>
				</includedComments:comment>
			</includedComments:comment-collection>
			<wfw:comment>http://www.jarober.com/blog/servlet/CommentAPIServlet?guid=3442830883</wfw:comment>
		</item>
		<item>
			<title>RESTful Services in Seaside</title>
			<link>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=RESTful_Services_in_Seaside&amp;entry=3442551543</link>
			<category>tutorial</category>
			<pubDate>Tue, 02 Feb 2010 08:19:03 GMT</pubDate>
			<description><![CDATA[<div xmlns="http://www.w3.org/1999/xhtml"><p> Over the weekend, I demonstrated a RESTful JSON service using the WebToolkit. Today, I'm going to do the same thing using Seaside 3.0 in VisualWorks (the same code should work in ObjectStudio). If you <a href="http://www.cincomsmalltalk.com/casts/stDaily/code/2010/MyService.zip">want the code, here it is</a>.  First, load Seaside from the Parcel Manager - it's now under &quot;Web Development&quot;:</p><p><img src="http://www.jarober.com/images/examples/seaside1.png" title="Load Seaside"/></p>

<p>The example I'm building uses JSON (although it could just as easily be XML or anything else) - so we'll connect to the <a href="http://www.cincomsmalltalk.com/CincomSmalltalkWiki/Public+Store+Repository">public store</a> and get the JSON code support:</p>
<p><img src="http://www.jarober.com/images/examples/seaside2.png" title="Load JSON Support"/></p>

<p>Next, we'll create a subclass of WAComponent that will render the JSON for us.  As I did over the weekend, I'll just create a simple dictionary for the example:</p>


<p><img src="http://www.jarober.com/images/examples/seaside3.png" title="Our Component"/></p>

<p>Next, we need to write some code.  Add the following two class methods:</p>

<p>
<pre>

canBeRoot
	^true



initialize
	&quot;MyService initialize&quot;

	self registerAsApplication: 'SvcPoint'.

</pre>
</p>

<p>In a workspace, execute <em>MyService initialize</em>.  At this point, you have a working service, it just doesn't do anything.  Go to the launcher and pull down the <em>Seaside</em> menu and start the server.  If you go to <a href="http://localhost:7777/">SvcPoint</a>, you should get a blank page.</p>

<p>Now, you need to create the rendering code to respond with JSON.  This is a bit different than it would have been in Seaside 2.8 - the session and request context code have changed.  </p>


<p><img src="http://www.jarober.com/images/examples/seaside4.png" title="Add the rendering code"/></p>

<p>Write the code above:</p>

<p>
<pre>

renderContentOn: html
	&quot; Render our object as generic json. &quot;


	self requestContext respond: [:response | 
		| json |
		json := self data asJson.
		response contentType: 'application/json'.
		response nextPutAll: json ]
</pre>
</p>

<p>Now browse the entry point again - you should be prompted to download a file (or it'll just download, depending on the browser you're using):</p>



<p><img src="http://www.jarober.com/images/examples/seaside6.png" title="Downloaded File"/></p>

<p>Finally, if you open that response file in a text editor, you should see this:</p>


<p><img src="http://www.jarober.com/images/examples/seaside7.png" title="The actual JSON"/></p>

<p>And that's it!  You now have a RESTful service implemented in Seaside.  Here's the <a href="http://www.cincomsmalltalk.com/casts/stDaily/code/2010/MyService.zip">code in a zip file</a> if you just want to load it and take a look.</p>
<!-- technorati tags start --><p style="text-align:right;font-size:10px;">Technorati Tags: 
<a href="http://www.technorati.com/tag/seaside" rel="tag">seaside</a>, <a href="http://www.technorati.com/tag/smalltalk" rel="tag">smalltalk</a>, <a href="http://www.technorati.com/tag/json" rel="tag">json</a>, <a href="http://www.technorati.com/tag/REST" rel="tag">REST</a></p><!-- technorati tags end -->
</div>]]></description>
			<guid isPermaLink="false">3442551543</guid>
			<pingback:server>http://www.jarober.com/blog/servlet/CommentAPIPBServlet?guid=3442551543</pingback:server>
			<pingback:target>http://www.jarober.com/blog/blogView?guid=3442551543</pingback:target>
			<includedComments:comment-collection></includedComments:comment-collection>
			<wfw:comment>http://www.jarober.com/blog/servlet/CommentAPIServlet?guid=3442551543</wfw:comment>
		</item>
		<item>
			<title>A RESTful Web Service in Smalltalk</title>
			<link>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=A_RESTful_Web_Service_in_Smalltalk&amp;entry=3442393375</link>
			<category>tutorial</category>
			<pubDate>Sun, 31 Jan 2010 12:22:55 GMT</pubDate>
			<description><![CDATA[<div xmlns="http://www.w3.org/1999/xhtml"><p>I got a question via Twitter earlier today about creating a RESTful web service in Smalltalk - I'll do a screencast on this tomorrow, but I thought a quick walkthrough might be useful as well. This example uses the VisualWorks Web Toolkit (which would also work in ObjectStudio) - I'll create a Seaside based example later this week. </p>

<p>Want the code? <a href="http://www.cincomsmalltalk.com/casts/stDaily/code/2010/Services-Example.zip">You can grab that here.</a></p>

<p>So: step one, load the Web Toolkit - right click and select &quot;Load&quot; after getting the Parcel Manager open:</p><p><img src="http://www.jarober.com/images/examples/rest1.png" title="Load the Web Toolkit"/></p>

<p>Once that's in, connect to the <a href="http://www.cincomsmalltalk.com/CincomSmalltalkWiki/Public+Store+Repository">public store repository</a>, and load JSONReader - that's just what I'm using in this example.  You could just as easily answer an XML document using the SAX driver, or some other format entirely.  Anyway, load this via a right click on the latest version:</p>
<p><img src="http://www.jarober.com/images/examples/rest2.png" title="Load JSON Support"/></p>

<p>Next, you need to create a &quot;site definition&quot;.  You don't need to do this for each service; just for each named site (path) you want to support.  You'll have two files: <em>webtools.ini</em> (copy that over from the $(VISUALWORKS)/web directory and edit it), and <em>services-site.ini</em>.  The name of the latter file is whatever you want to call it, so long as you reference it in webtools.ini:</p>


<p><img src="http://www.jarober.com/images/examples/rest3.png" title="webtools.ini"/></p>
<p><img src="http://www.jarober.com/images/examples/rest4.png" title="services-site.ini"/></p>

<p>Now you can create your new service.  Define a subclass of <strong>SingleThreadModelServlet</strong>:</p>
<p><img src="http://www.jarober.com/images/examples/rest6.png" title="jarober added a file"/></p>

<p>I added the <em>data</em> instance variable just to have something to respond with.  The superclass I'm using ensures that each request will spawn a new instance (thus sharing no data) instead of assuming a stateless model.  Next, add these two methods:</p>

<p>
<pre>

initialize
	&quot;Initialize a newly created instance. This method must answer the receiver.&quot;

	super initialize.
	data := Dictionary new.
	data at: 'name' put: 'James Robertson'.
	data at: 'title' put: 'Smalltalk Product Evangelist'.
</pre>
</p>

<p>
<pre>

doGet
	&quot;entry point for this service&quot;

	| content |
	response contentType: 'application/json'.
	response status: 200.
	content := self data asJson.
	response contentLength:  content size.
	response write: content

</pre>
</p>

<p>Finally, define a listener so that you can make requests.  In the launcher, over on the far right is a button for doing that.  Press that, then create the listener (on any available port), and click <em>Create and Start</em>:</p>


<p><img src="http://www.jarober.com/images/examples/rest5.png" title="Define Your Listener"/></p>

<p>I put that on port 8011, so using this url: <a href="http://localhost:8011/services/servlet/MyService">http://localhost:8011/services/servlet/MyService</a>, I should get this (I'm using Firefox):</p>


<p><img src="http://www.jarober.com/blog/images/examples/rest7.png" title="Receiving JSON"/></p>

<p>If you use some application that expects JSON, you'll get the actual object.  And that's it - having the service read from a database (etc) is just a detail - the actual RESTful part is pretty easy.  Questions?  <a href="mailto:jarober@gmail.com">Send them here</a>.</p>
<p>Want the code? <a href="http://www.cincomsmalltalk.com/casts/stDaily/code/2010/Services-Example.zip">You can grab that here.</a></p>

<!-- technorati tags start --><p style="text-align:right;font-size:10px;">Technorati Tags: 
<a href="http://www.technorati.com/tag/REST" rel="tag">REST</a>, <a href="http://www.technorati.com/tag/web%20services" rel="tag">web services</a>, <a href="http://www.technorati.com/tag/http" rel="tag">http</a>, <a href="http://www.technorati.com/tag/json" rel="tag">json</a>, <a href="http://www.technorati.com/tag/smalltalk" rel="tag">smalltalk</a></p><!-- technorati tags end -->
</div>]]></description>
			<guid isPermaLink="false">3442393375</guid>
			<pingback:server>http://www.jarober.com/blog/servlet/CommentAPIPBServlet?guid=3442393375</pingback:server>
			<pingback:target>http://www.jarober.com/blog/blogView?guid=3442393375</pingback:target>
			<includedComments:comment-collection>
				<includedComments:comment>
					<includedComments:guid>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=A_RESTful_Web_Service_in_Smalltalk&amp;entry=3442393375</includedComments:guid>
					<includedComments:puid>http://www.jarober.com/blog/blogView?showComments=true&amp;printTitle=A_RESTful_Web_Service_in_Smalltalk&amp;entry=3442393375</includedComments:puid>
					<includedComments:author>Rob Fahrni</includedComments:author>
					<includedComments:pubDate>2010-02-01T10:12:11-05:00</includedComments:pubDate>
					<includedComments:content>&lt;div xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;p&gt;This is fantastic! Thanks James!&lt;/p&gt;
&lt;/div&gt;</includedComments:content>
					<includedComments:title>Re: A RESTful Web Service in Smalltalk</includedComments:title>
				</includedComments:comment>
			</includedComments:comment-collection>
			<wfw:comment>http://www.jarober.com/blog/servlet/CommentAPIServlet?guid=3442393375</wfw:comment>
		</item>
	</channel>
</rss>
