WWDC2003 Session 306
Transcript
Kind: captions
Language: en
thank you thank you for all coming here
thank you for being part of the
experience and the ran a renovation
rejuvenation revolution that Apple's
going through right now it's an
incredible time to be a developer it's
an incredible time to be an Apple
employee and especially for Apple script
over the last year Apple script has
progressed more and more and grown
faster and faster it's just on fire and
with the evolution of Apple script
becoming a peer development language
with Objective C and Java and cocoa
carbon and the rest of it in the
development tools and Xcode we have
pushed farther and grown faster and
we're reaching farther and farther every
day we want to deliver more for you with
Apple script and we want to be able to
be your hands and fingers into the world
to get the things done that make you
money because this is all about money
well some of it's about fun but some of
it's about money and making sure that
you're successful at what you do
Apple script studio can be a great part
and a component of that process for you
in that it can combined disparate parts
of code and resources and put them
together in a way that not only makes
your users and customers satisfied and
easy to use but it can also deliver a
lot of power under the hood so today
you're gonna see an overview of some of
the new things that are an Apple script
studio plus a good portion of what Apple
script studio can do in its new
environment and to do that we have a
couple people today that are the key to
this technology first is Tim Bumgarner
who is the senior engineer for Apple
script studio he's the brains and
execution behind it and the man behind
the man who couldn't be the man without
the mandy as john quello venerable Apple
script studio guide and source and sage
so with that I'll let you Tim take it
away thank you
[Applause]
alright thanks oh well I was thinking
about last year's session and I just
knew what I started my session out last
year would come back to haunt me because
if you'll remember I had a slide that
came out and said maybe I'd consider
myself mr. Apple script studio and of
course the acronym was a SS and they
would be known as mr. s and sure enough
somebody walks up to me of colleague and
says I'd like to introduce you to my
friend and this is a mr. ass today great
so I think I'm gonna go with mr. studio
so the worst you can call me is mr. s
and that's the subtle difference but
important ok the other thing I noticed
when I went through my session last year
is that I've talked a million miles an
hour and hopefully I can slow down but
my apologies to the language translator
because I have no clue how she kept up
last year great so let's go ahead and
get started and talk about Apple script
studio and hopefully we'll have good
luck with the clicker must be the bane
of our existence in Apple script we had
the same problem at Apple scripts to do
or the Apple script update so ok looks
like a slide is probably at the end and
it's the wrong one that's loaded so we
didn't get the right slide try this
again okay simple enough to fix there if
this is the worst that happens to me I'm
pretty happy all right this way we get
to see the nice movie for running along
I knew we were missing something I'm ok
and Sal's already been here I'm here
we're all here let's get going ok so
let's talk about the agenda and what
we're going to do is a little bit of an
introduction we'll go through a little
overview I'm not gonna go through the
detail I did last year hopefully or
nothing you have used it and looked at
it to know how it works but we'll just
do a quick demonstration of how to do
that now last year we were talking about
what was in studio one one we also
previewed a little bit about what was in
studio one - we weren't able to actually
show you the features because we hadn't
shipped Jaguar yet or were far enough
long and so we're gonna go through some
of those important key features that we
added in studio 1.2 and the Jaguar
timeframe in studio 1.3 we're going to
talk about what we're releasing for the
up
at the release and some of these things
are already in the preview release and
we'll talk about that in a bit and then
we'll just discuss a little again about
future features documentation and QA
introduction what is Apple script studio
and so what we've done is we've taken a
combination of all these wonderful
technologies we've taken advantage of
Apple script and we've integrated it
into every one of these technologies
we've integrated it into Xcode it was in
project builder in the previous versions
we've moved it right directly straight
into Xcode and insidiously enough have
even inserted ourselves even deeper it's
a requirement it has to be there we've
also through a palette have been able to
integrate it into our interface builder
and then all of that is built on top of
the cocoa application frameworks and so
we get advantage of everything that
cocoa provides but it's also two things
it's the development environment it's
where you get to go in and you develop
your application and then it's also a
runtime so that when you get your
application built you can send it out
put it out on the web put it distribute
it through your company and then anybody
can just run it they don't need any
extra extensions they don't need any
additions any plugins it just works and
that makes it really terrific to do that
for deployment so what can you do with
studio first and foremost we're creating
native Macintosh applications it's for
all fundamental purposes as a cocoa
application but it uses Apple script as
the development language now we get to
take advantage of everything that cocoa
provides we get all of the wonderful
table views outline views buttons
widgets you name it we've got it we can
script those and of course with Apple
script we really get to leverage we get
to take advantage of being able to
create solutions that uses applications
that are local to my computer I continue
to talk to other applications that are
across the network or even out through
the internet and take advantage of the
next thing that which our web services
just like we talked to a local
application we can talk to a web service
we simply say tell application and we
use using XML RPC and soap we can go get
data from that and populate and provide
a front-end to it with a nice UI and
then we can go down into a very deeper
level and since Mac os10 is is basically
a unix-like applica operating system
built on top of that we can take
advantage of the do shell script that
Apple script gives us
you can go down and you put a nice
wrapper around some of those gnarly
terminal applications or code pieces and
fundamentally put something that people
just wouldn't fund or usually understand
they can use a really nice simple UI to
do that and then of course with being
inside of Xcode Mexico it allows you to
build see applications C++ we can use
objective-c we can use Java any of those
languages we can actually call directly
from inside of Apple script and what
some of the process their progress
that's being made with Apple script
itself at cocoa level you can turn
around and from those other languages
particularly cocoa you can actually
create an Apple script and then talk
back into your studio application so
it's a bit of a round trip which is
great it's a little bit of an overview
let's talk about where we've been studio
1.0 was released we came out that with
that in our December 2001 developer
tools and that was I believe Mac OS 10
version 10.1 point 2 so you can run your
studio apps for many from that time
forward then we released in April about
four months later we released our 1.1
release in the April developer tools and
then we of course released 1.2 which was
a big feature release in the Jaguar of
last year and there was a point released
some bug fixes that we needed to get in
without the December tools and then of
course we're gonna talk about Apple
script studio 1.3 a little point of
clarification I want to make sure that
everybody understands that what went out
in the Developer Preview lease is
exactly that the the studio 1.3 is just
a preview release it's not finished it
will be finished as part of Panther so
it's a sneak preview for you to look at
it use it take advantage some of the new
features but you really can't employ any
applications until Panther goes to GM
and so what I like to do is show you how
easy it is to create a studio
application and if we look at it we
basically go through this same cycle we
create a project in Xcode we open up the
interface lay it out the way we want to
we name our objects attached some
handlers we edit the script we build and
run and then just go through the cycle
making sure adding to it and enhancing
that application so I'd like to actually
go right to that and we will demonstrate
how easy that is to do so if we go to
the demo machine
excellent so I'm going to go right into
Xcode and I'm going to choose new
project from the file menu and you can
see that Xcode itself is able to create
all kinds of different applications
there's applications bundles frameworks
Java tools you name it we've got it the
first three are the ones of course
create with Apple script starting with a
we always get to go at the head of the
class and we've got three different
types of project templates here we have
the Apple script application we have a
document based application if we want
multiple documents and then we have
something we call a droplet it's very
similar to the applet that you would
create with script editor so I'm in this
case we're going to just choose the
Apple script application and we're going
to use of course the good old standby
our hello world and I'll name that a
project and the first thing I do is I'm
going to go right into the nib file or
mainmenu.nibux since this is hello world
there's not much interface in matter of
fact I'm actually going to get rid of
this default window that you see here
I'm just going to go ahead and delete
that and then I'm going to go to the
show info panel and I'm going to select
this files owner this represents the
application object and anytime you want
to do anything with Apple script inside
of interface builder you go to the Apple
script inspector and that's in this
cases command 7 as a shortcut and I
notice that there are different aspects
here we have our name field this lets me
name objects whatever you reference
something inside of Apple script there
are several different ways that you can
do that and one of them is by name and
that's the most recommended you could
also do it by index or by ID and then
the next section shows us the event
handlers these are the handlers that are
related to the object that is currently
selected so if I had a button selected
it would have a different set of event
handlers and then down finally the last
is the script section that shows us all
the scripts that are currently in our
project so if you see over here we have
a hello world dot Apple script back in
Xcode so what I want to find out is when
the application is launched so what I
simply do is go in click on the launched
event handler I go down attach it to
this hello world which is our
application script and then I'm going to
click the edit script button and when I
do that it jumps me back over an Xcode
and it selects the contents of the
onlaunched handler it actually inserted
that for
me so I don't have to remember what the
parameters are or how it's spelled I
just choose it that it inserts it for me
and we're going to go with about the
simplest bit of code that you can write
in Apple script and it's just display
dialogue hello world and then when that
dialogue is done I'm just going to go
ahead and tell the application to quit I
don't want to have to quit it I just
want it to go away so we're gonna go
ahead and and save that and then from
the build menu we're gonna go ahead and
choose build and run and it's going to
go ahead and compiles the dot Apple
script file links it and then runs it
there you go you've got the display
dialog and so when I go ahead and choose
okay the application actually quits and
finished so that's just as simple as it
is to create a you know obviously a very
simple app but from here it's the same
process edit the interface attach your
handlers edit your script build and run
and then just keep building and keep
building alright so we go back to slides
please
okay so let's talk about some of the
studio one two features that we added in
the Jaguar that we didn't get a chance
to actually demonstrate and talk about
but they're really important and there
were some of the most requested features
that we had and the first is drag and
drop support and then also pasteboard
support data source enhancements and
document based applications and so we're
going to go through each of these
features and what we're going to do is
we're gonna develop an application from
start to finish that employs and builds
upon and adds each of these features as
we go so let's talk about drag-and-drop
support we've got a series of new event
handlers there's actually about six of
them here I believe there's a drag
entered exiting updated this is while
you're dragging objects across a view
there's a drop which is the one that we
almost always care about this the only
one that's the most important there's a
prepare drop and conclude these happen
before and after the drop handler we've
also added a new command or variant on
the command register we need to be able
to tell the view what is it that we want
to listen for what kind of drop do we
want what type of data and so we do that
with the register drag types so in order
to help me with this I'm going to bring
up John Coelho he's our QA engineer for
studio and he's going to help me to make
sure I don't mess up so let's walk him
up
[Applause]
okay so what we're going to do and for
the sake of time we don't have time to
lay out everything as far as the
interface is concerned so we're gonna go
ahead and we've already laid out a
project but we haven't had and we
haven't added any script yet so we're
just going to bring up the interface so
let's go ahead and double click on
document onion and you'll see that what
we have here is our application is going
to be a document based application it's
going to present a window that has a
table you on the top it's in a split
view and then below at the bottom is a
text view and so what we're going to be
able to do is drag files from the finder
into the table view it'll list that
information in the table view and then
in the bottom we'll actually have a
script we can put in some Apple script
and when we're all done we're going to
be able to build and execute that Apple
script for every item in the table view
so this is something that an app that
we're calling batch processor so let's
go ahead and take a look at we're gonna
start attaching subscripts to it so we
see that we've named some objects
already and we've named the table view
and we can tell that we've got the table
view selected because you can see that
it has the table view name up in the
title of the info panel and we're going
to look for is that there's a category
called drag and drop and so he's going
to check the drop event handler for us
and then also when the nib is loaded we
want to set and make sure that we
register for a particular type of drag
so let's go ahead and click the drag all
the way from there but then okay we're
going to attach this to our document dot
apple script file so let's go ahead and
we'll edit the script now so he's going
to fill out now lest you think that
John's the world's fastest typer we're
actually using something called demo
assistant it's a sample that ships with
Mac OS 10 and the developer tools allows
you to this fancy little command to and
we populate all this script for you and
so he's filled out the awake from there
but let's go ahead and fill out the on
drop and then we'll talk about that okay
so let's look at the auto wake from nip
and you can see we have a the tell the
object in this case the object is the
table view to register for drag types
and we want the file names we could pass
it a full list we could pass it string
color font there's a lot of different
types that you can register for
in this case we just want file names now
up in the on dropped handler you'll see
that we have simply just a display
dialog because we're just going to test
this we're going to drag in some files
and what we should get when we're done
is the dialog popping up so let's go
ahead and build and run this John okay
so the application comes up and he's
going to go into the finder and we're
going to show a kind of cool Mac os10
thing we can do we can go to our Apple
script Studios examples and go into the
little search field and type PB proj and
it will quickly filter all of the
project files because when we're done
we're actually going to build some
things using some Xcode Script ability
so now he's going to move that over drag
those files in great as you see now as
he's dragging that over the tableview
get the little plus indicator indicating
that it actually drops if you were to
try to drag it over the textview you see
nothing because we've only registered
for a drag in the table view so go ahead
and drop those in jar and there you go
we've got the drop handler just got
executed okay so that's how easy it is
to add at least it get notified that a
drop has happened so if we go back to
slides please
okay now that's great so we've got a
drop happening we've got the right kind
of data at least we hope so and this is
what we're going to find out so in order
to support drag and drop we had to do
the next step we had to expose the
pasteboard class and so we've done that
and it actually has a series of named
paste boards there's a general paste
board a drag paste board find if you
ever notice in Cocoa you do a fine and
one app for better or worse that same
find is it another cocoa app and we can
actually script that as well and we also
then have a preferred contents property
you can put data on a paste board in a
lot of different formats you can have
strings files lists images this way we
could say we want this type of data in
this format and we can get it set it in
that particular format so what we're
going to do is demonstrate a little bit
using bring up our new script editor and
having the application still running
we're going to look and find out what we
can about paste boards so John is going
to use the contextual menu on-screen
predator and he's going to actually
insert some script in a tell application
block and he's gonna type in batch
processor and then he's going to fill
out and we're going to just ask it for
the pay sports what paid sports do you
have in your application and when he
goes ahead and checks and run that
you'll see down in the result window
that we have a series of pasteboards
they're all named there's a general
there's a font find and drag and the one
that we're going to test at the moment
is just look at the general pasteboard
so let's see what the pasteboard what
the things there are about it pace where
that are interesting so let's look at
the properties of the pace board and
we'll look at the particular pace board
we're going to do it by main so I'll go
ahead and run that and you'll see that
there is actually a lot of different
types of data on that pace board some of
it is listed as rich tax string there's
also some Carbon types don't ask me what
they are but they're there if you need
them and then there's also the different
type of class the preferred type in this
case is defaults to string and the
contents at the moment has the string
general and so we can actually go ahead
and change the contents of the
pasteboard and we'll do a sec contents
and face board general and he's gonna go
ahead and run that and then he'll just
choose paste somewhere and you'll see
that it now has that variable now
there's a reason why I demonstrated this
for you and this is a great tool while
developing studio apps they're live
they're running they're scriptable you
can easily delve in use it as a great
debugging tool to figure out where your
views are why something is or isn't
responding and so this is a great way to
do that so let's go ahead and we'll quit
that real quick project builder I'm
sorry I knew I'd do that
Xcode there our batch processor and the
other application are script editor and
let's go back in and we're going to fill
out the drop handler so we'll get rid of
that display dialogue and we'll go ahead
and let John put all these lines in and
we'll quickly talk about them now so
what's going to happen is that the drop
is going to happen and you'll see up
there that there's a variable called
drag info and that's a type of called
drag info and it has a couple different
things it has one of them than one we
care about is it has the pasteboard
property and so what we're going to do
is we're going to find out the types
that are in the page
sport of this drag and then we want to
go on to the next line and make sure
that what we have in that list or array
is the the file names so let's go on
down to it it's hard to see on this
monitor so I'll look over here and we're
going to get to prefer we're going to
set the preferred type we want to make
sure that we get the data out of that
paste board as file names and then we're
going to simply get the contents and put
it in a list and in this case we're
going to just display a dialog show the
fact that we got the data that we were
expecting so let's go ahead and build
run as John compiles and launches and
he's going to drag that out we'll open
up our list of files again and this time
as he adds it you will get it to the
dialog that lists the fact that we're
actually we're not getting files or
aliases but we're getting full POSIX
paths typically everything in studio
works because it's built on top of cocoa
scripting currently works in the notion
of POSIX pass we're hopefully to unify
that in some future release so let's go
ahead and go back and now that will go
out to you back to the slides please so
that talks about the face board so now
we've done the drag we got the data out
of it out of the paste boards now we
need to do something with it
we need to populate that table and put
the data so that you can see that and
the way that we do that is with data
sources and we've made some enhancements
we had there were several you know some
issues that came up when we've listened
to that then we tried to fix as many
things as we could and one of them was
make new we wanted to be able to support
make new for data sources you used to
have to go and drag this funny-looking
cube thing out make a connection it was
about a page and a half of documentation
to describe something that should be
simple but we did it has made it very
simple you just simply say make new data
source and you get you to your data
source in one line we also found that it
wasn't terribly fast to creating new
data rows individually populating the
data cells and we found that we can just
simply do it with an append command you
give it an append command with a list of
Records AppleScript records and it does
it all for you very very quickly much
faster than you could do it yourself we
also added sorting support so you could
sort the data sources and you can pick
out which is the default sort column
what if they have ascending descending
what type of sort that they will have
and so we'll take a look at that so
we're gonna go on to the next step so
let's go back to our demo machine and so
what we're going to do is we're gonna go
back to our weight from nib and when the
tableview is loaded from the nib we need
to set some things up in order to make
this happen and so again I'll just let
John go ahead and fill those out and
then we'll come back and we'll talk
about that
so the idea is we're gonna create a data
source we're going to create a data
column that matches every table view
column that we had in our table view and
then after that when we do the drag will
later add the data rows that go with
them so let's take a look at that make
make new data source okay you can see
that we make a new data source and we
put it at the end of the data source
Apple script always wants to know where
to put things when you make them quite
often there's a default place in this
case we need to specify that to put it
at the end of the data sources the next
section just creates all of our data
columns again using make new and we
actually pass a few different parameters
to it name we have to name each of these
data columns and this is an important
thing to remember when you're using data
sources the name of each data column has
to match the Apple script name of the
table view column and that's how it does
all of its magic and matching it up if
those are if they're renamed or their
name done correctly or they don't match
they won't work you won't get any data
in your column so you have to make sure
those are correct and there's also some
sort information you can specify for a
data sort whether it's ascending or
descending alphabetical or numerical had
some other data so let's go on and look
at the rest of it okay the next thing
you need to do is to tell it that it is
sorted because you can go ahead and set
everything up and then turn off sorting
or turn it off as you like can you
simply do that by setting the property
and then the next thing we want to do is
make sure we set the sort column for
that and then the very last thing and
the most important is to hook it up so
we basically set the datasource property
again of the object which is the table
view to this new data source that we
created all right and then what we're
going to do is we're gonna go replace
that display dialog so we've got our
data source all ready to go and we're
going to add a few lines here to replace
that and we want to make sure that we
got at least one file dropped onto our
table view and we're going to call this
handler called add files to data source
and we're gonna go add that down at the
end here
and you can see that it's a local
handler that we're going to call we're
going to pass it the files and we're
going to pass it the data source that we
want to append this information to and
we'll go to the first line it's an
important line the set up date I'll go
ahead add the next piece John okay and
let's take a look at the update views of
data source whenever you're going to put
a bunch of data into the data source you
want to make sure that you turn off the
updating of views otherwise what will
happen is in the table view you see them
individually added and not only is it
distracting to see them individually
added up it's much slower so turn those
off go into a repeat loop we make new
each new data row we're going to store
away a reference to that full file path
we're going to set the contents of each
data cell because what happens is when
we make a new data row it creates for
you a named data cell for every row or
there's a cell for every table or data
row call them okay and then we go down
and we're going to set the contents of
the name one in this particular case and
we're going to use call method and I
remember I told you that we can actually
use objective-c or other languages and
there's happens to be this wonderful
little utility class on Objective C C NS
string and it's a last path component
what it does is it takes a POSIX path it
gives me the last item I don't have to
worry about parsing that slashes of the
colons and with a simple little call
method I can directly message the object
and it will get it of the item again is
this the string the full POSIX path and
then we'll do the same thing with dates
that data is actually going to call a
local handler which we'll skip for now
and then it goes in sets of the path and
now what we want is just the opposite we
want everything but the last path
component there happens to ghin be in
that same utility class another method
called string by deleting last path
component and then we go on we finish
our repeat and then the last thing that
you want to do is turning the updates
back on so that you can see them all
populated so I think we're ready John
you ready all right
let's build and run that so we're
getting closer getting closer building
this application so now what it's up and
running he's gonna go in there and drag
some files and you can see wallah we've
added our files and they've all shown up
all parsed correctly and it has our date
modified filled out
our name filled out in the path and the
status will take care of in a minute now
you'll notice that John's going to try
clicking on the columns well we said
he'd be sorted but unfortunately we
forgot one thing to add and we're not
recognizing the fact that the column got
clicked so we need to add that event
handler so we'll go back into our
document bin in interface builder and
we'll go to the data view categories and
we'll look for I know that there's one
of there called column clicked and we
want to select that one and it's already
attached to the document out as
AppleScript so it'll click our edit
script now the the script that he's
inserting here is pretty much
boilerplate anytime that you're going to
do sorting on a table view just go copy
this code there's examples already that
we ship that has this bit of script and
it basically looks at it says Oh what
was the last column if it's the last
sort of column is different switch to
that make that the primary column if
it's the same one just switch the
ordering so it's something that we'll do
there what we'd like to do is make this
even more automatic excuse me automatic
so that it just happens you don't have
to worry about clicking on the clip
we're doing a clicked and we'll try to
do that for you so I think that should
be good for sorting John let's go ahead
and go and run that okay let's drag out
some items see what we got
drag it a few more and we just keep
adding as we like and you'll notice now
as it clicks
that it actually changes the ascending
and descending order if it clicks on a
different column we could change the
type and date modified now you'll notice
there's no little indicator I'm hoping
that KOCO puts that in there for us but
I'll probably have to put that in there
myself so that you'll know which way
that those are sorting so again those
are as much as we can do for you that's
what we want to do so that takes care of
doing the datasource support with
supporting so let's go back to the
slides please okay in the process of
building this application we started out
with a document based app and what we
wanted to do ultimately is to be able to
save those files that we drug in there
plus plus the script and save it as a
document and then we could propa knit up
in processes later and there are two
ways that you can do document based
support in Apple script studio one is
there's two event handlers that are hot
antlers
there are two low level now the high
level are the easiest ones well they're
both pretty easy but the top the first
three are the easiest and those are the
ones that are on by default this is when
you what you'll do as data
representation gets called to when the
document is about to be saved and you
just return the data that you want saved
in the document you don't have to worry
about writing the file or anything like
that you just pass back the Apple script
data that you want saved then when the
document is open you go to the load the
load data representation handler gets
called and it passes back to you the
data that you gave it when it was saved
before so then you simply update your UI
with that data now if it's important to
you to actually be concerned about how
each byte is read from the disk or the
format or the structure of the file you
can use the low level event hammers and
you just get past the POSIX path to the
file and you could write out the data
and then you can read the data back
yourself and so in this case we're going
to use the high level event handlers
their exclusive though you can't pick
and choose you either have to go high or
you have to go a low so we're gonna go
high so let's switch back to our demo
machine and you'll see that this
particular it since we chose a document
based applicator project it already
starts out with those two handlers
checks we don't have to go into the
document app but you have been putting
them on there already there we're just
gonna go ahead and fill them out so
let's fill out the data representation
one now let them put that in and again
remember this will get called when it's
time to save your application and the
object represents the document object
and if type just tells you a type of
file that you might want to save and you
can set up for multiple types in this
case we just have the default and it's
been filled out the load data
representation then we'll quickly talk
about those let's go back up to the
first one and so the first thing we do
is we have the document but we really
need to do is get the data out of the
table view or out of the data source of
the table view and we could do that by
using the window elements of a document
so we get window 1 of that document and
then we go ahead and get the table view
and get the data source out of the table
view and then we're going to get the
Associated object of every data row this
is the thing I love about Apple script
this one single line saves me from
repeating over
I just say give me this property of
every single one of those data roasts
what we get back is originally what we
were giving in the truck excuse me in
the drop that we could we get a list of
files of posix paths so then we'll get
the contents of the textview because we
also want to save out the script and
then we want to return that so look at
what we're experiencing returning is we
are returning the files to process and
we're returning the script as an apple
script record so that when load data
representation happens that's what we're
going to get passed back in we're gonna
get passed back in an apple script
record it has this two io elements so
let's go ahead and look at the load data
representation basically the same thing
you need to get the window need to get
the data source and then we're going to
use that same handler that we had before
the add files the data source because
we'll have exactly the same format of
data and then let's take a look and then
we'll set the contents of the script
view so let's go ahead and build and run
this let's see if it works okay so we
got our view we've got our table view
ready to go we'll open up our files drag
some files in and then we'll actually go
modify the script because it always
comes up with a default script so you'll
see that we're actually going to be
saving a different script and let's
choose this say from the file menu and
we'll give it a name and save that and
we already have one there before this
okay we'll go ahead close it now and I'm
gonna go to the file menu and we'll go
to open recent and we're going to choose
that file we just saved and there you go
we've opened back up the files and the
script with just very little script okay
so let's go back to the slides please so
that was the stood that the 1.2 features
so we were able to drag and drop be able
to get the data from a paste board we
were able to add data to the table view
through the data source with the
enhancements we made and then very
easily create a document from that which
is far support that we had to our
earlier releases so now what I'd like to
do is talk about some of the features
that were releasing in studio 1.3 drum
roll please
what is it well it may look like a short
list but it's very very important list
and the first one is a script property
and the second one is plug-in support
and we're going to show you that with
some Xcode script ability let's talk
about that first one this is the one I'm
most excited about it's really going to
have a great terrific impact on the way
that you write studio applications the
fact is every object any cocoa innocence
masked object gets a script property so
that you can do things like access the
properties or Global's or event handlers
of a script so you can imagine that you
have a food property on a script on a
button so now you can say foo of script
of button 1 or if we're able to step
over the script you'll just be able to
say foo of button 1 and get that
property or set foo of button 1 to some
new value so you can imagine instead of
these big monolithic scripts that we've
had to write in the past that you can
have very small scripts because now it's
very easy to talk to scripts of other
objects and we can call their handlers
as well
the other cool thing is that you can
take those scripts and you can set new
ones dynamically you could change during
runtime set the button to actually have
a different on clicked handler or a new
menu item if you like and be able to
create those things on the fly and have
different behaviors and another cool
thing is that external applications can
access that same script property so you
can have another studio app or some
other script editor or script running
and you can get the properties the
Global's and the handlers of that
running studio application so you can
now call back in to a studio application
and execute that end or that event
handler using AppleScript studio all
right we'd like to demonstrate just a
little bit about that and this is going
to put the finishing touches on the
antelope the last of our batch process
there demonstration so what we'd like to
do is go into our main menu nib this
time because we're going to fill out the
hook some handlers to our file menu and
you'll see that there are two menu items
already added for us one is process all
and the other one is process selected so
we want to be able just easily choose a
file our men
and have all of those items in our table
review processed so we first thing we
have to do is we have to name it we just
name it so that we can refer to it by
name and I'll show you why in a second
then we want to make sure we have the
choose menu item selected and we're
going to attach it this time to the
application script which is our batch
supporter Apple script and we'll do the
same thing for this selected ok well
choose our choose menu item and add it
to that let's go ahead and edit our
script now we had two menu items they're
both going to execute the same handler
at least the way that we set it up at
the moment and so we need to know which
one was chosen and the way we do that is
we use the name of the object so go
ahead and finish that out and we'll take
a look at it when you're finished and
this is a common practice we do this a
lot yeah you'll have a four or five
buttons in a window and they're all
going to call the same click camera so
the easiest thing to do is just to look
at the name of the object and do
something appropriately remember back to
what I talked about the script property
and the few in the next release is that
we're gonna be able to even make smaller
ones you could have four different
scripts one for each button doing their
own thing you won't have to do this if
naming well we didn't get into demo this
today so let's go ahead look at that so
we get the again we get the window of
the front document we get the table view
and then this is the fun part we get the
script of the front document remember
document dot Apple script we're gonna
get that doc your that script object and
then we're going to be able to call a
handler in that Apple script in this
case when it's for the all menu we're
gonna call process all files of table
view and then on the else case we're
checking to see if it was the selected
items and then we go through and we get
the window get the table view and we get
the script again and this time we're
going to call the different hand we're
going to call process selected files so
let's go ahead and save this document
we'll go and add that Handler to our
document dot Apple script
so John with his amazing dexterity is
going to drag in a bit of a little more
script this time and we'll just kind of
go quickly over it I can't see it on
this monitor so I'm reading from here
those the first one is to clear the
status of the data rows in the table
view when it's time to process remember
we had that status column we just want
to wipe out whatever was currently
setting in those data cells that we know
that we're starting over fresh we also
have another one below that called a
process data rows using script text so
we're going to do is get this text out
of that script and we're going to
execute the script on every one of those
items that we pass in to this handler
and you'll see that it does that right
in there with the run script so run the
script for this item calls run script
and we pass it the script text with a
set of parameters and we'll look at and
see how that works and then of course
these are the two handlers that we're
calling from our main application script
one is process all files and the other
one is processed selected files the only
real difference is one just gives us the
list of the files of all of them the
other one is just whatever is currently
selected so I think we're all right go
ahead and build and run now what it's
going to do is we're going to bring it
up this time we're gonna drag in a bunch
of several apple scripts to do projects
and what we're going to do is we're
going to actually put a real script or
running script in here this time now
this isn't a script view so it's not
going to check the syntax but I've just
able to paste in a little script here so
let's go ahead an put that in John first
thing we do is the file to process is
going to get is the file that's passed
to us it's going to be a POSIX pass so
we have to get the alias to it using the
POSIX file it's a good way to transfer
from POSIX file the POSIX path we added
that support and a couple of versions of
Apple script go and then we're gonna go
and we're going to tell application
because xcode is scriptable now it has
more work to go yet but there's still
quite a bit of functionality there so
we're going to do is we're going to open
the file and that's just a standard open
message and then we're going to set the
status message because what we're going
to do is call the build last project
document there's a build command in
xcode it's going to build and know tell
us right now it tells us if it succeeded
or failed and then we return that status
message and our code that we didn't go
through in detail will actually put the
status message in the in the column for
us so let's go ahead and we'll build and
run this
or actual just choose now from the file
menu our process all and you'll see that
it says processing it's going to tell
Xcode open the the document it compiles
it switches back and you see that it's
succeeded in each of these cases so
there you go we're able to run that
process over each of those o items in
that rocket house it's actually quite
useful because I could save this as a
document now and whenever I want to open
those up and process that I can't but
it's very flexible if I wanted to had a
bunch of images I could drag some images
in and that little run script can call
something to manipulate those images so
we're gonna put this out as an example
it'll be out there certainly in the
Panther release hopefully we can put it
up sooner so you can play with it with
the code that you have and with that I'd
like to thank John for his help on that
part of the demo today thanks John of
course there I went all my support now
and all probably goes downhill from here
cuz I'll Drive the rest of the demo so
let's see we got okay next thing plugins
support I'm also very excited about this
what we can do with Xcode script ability
we can now create studio plugins that
are written an Apple script that you can
plug into Xcode and enhance the
environment in ways that we haven't even
begun to think of and we're able to do
that we've added a new plugin loaded
event handler and through that it's
supported currently with Xcode beliefs
Al's got lots of ideas where to plug
these things in so just stay tuned okay
we've also in order to do anything
meaningful we needed to add more make
new support in particular menu items or
menus and menu items because it's not
very interesting if your plugin gets
loaded and you can't really do anything
in the environment you need to at least
provide some access to your plugin so
this is the first steps we're going to
add more in the future so I want to talk
a little bit about the Xcode Script
ability there are a set of low-level
classes that will have they talk about
projects and targets and file references
and there's lots more believe me and
then there's the high level classes
documents windows and views and so we're
just beginning on this there's quite a
bit in the preview release there's more
to come and
we're going to take advantage of this
what I'm going to do is put together a
plugin that we're gonna add to Xcode and
cross your fingers and hope it all works
let's go back to our demo machine and
what I like to do is open up a different
project again there's a bit of UI
involved in this I didn't want to bore
you with going through the process of
setting up the UI but I do have a nib
here that's set up already
it's our settings viewer plug-in now
actually before I get started with that
I did want to show you one thing and I
want to go back to script editor and
show you a little bit of that script
ability so I'm gonna go in here and do
it actually I'm open up the nice library
window I worked hard we worked hard we
want to make sure we show it so I can
come in here and I can find open up the
dictionary for Xcode and you can see
that there are a low level some of these
are the build phases they still
unfortunately have P beam but the
references targets applications and
document views lots of different Suites
they're actually quite large some of
these and there's there's a lot to play
with which is great I think that's
probably the first thing that most
people do when they see a new scriptable
application is look at all their for an
object so you get to play with a great
big sandbox it's great it's lovely and
so what we can do is kind of play with
that a bit and I'm going to go over and
create a new script for Xcode and what I
want to do is just let's look at what
projects we have running and right now I
have project settings viewer and we
could do things like look at the targets
of projects well it's just in this case
we'll name it so we'll just call it
settings viewer run that so I actually
see that I have a bundle target this
part of that and we can even keep
drilling further and further down and
this is where it's going to get
interesting and pertinent to that the
demo that we're going to create today
and we're gonna look at the build
settings of the target and you'll see
that there's these funny-looking archaic
constants here with various settings and
I want to relate this you would get to
the same information from the UI itself
by going to the target selecting the
inspector the target there and bring up
the inspector well actually in this case
we have to look at it in a different
place we have to go into our editor and
look at the expert view and here they
are those are the things that you
actually saw now the cool thing is you
can do it from inside a script editor
you can actually set build settings or
change those build settings back in the
target but what I wanted to do and I
thought about the inspect
are cool and everything but and I have
reasons for it asked me later and I'll
tell you why well I think the inspectors
are cool but they that's top down you
have to drill down to get to that
particular build setting what I wanted
you to do was turn it upside down I
wanted to go find out every build
setting that's defined in my project and
find out who defines it so that's not in
the application itself yet so I can
write a plug-in to do that so I'll jump
over and I've called the settings of
your settings of your plug-in and I open
up the plug-in try this again and what
I'm going to do is bring up my Apple
script panel inspector and I see that
there's now a new category called
plug-in loaded so I choose that and I'm
going to set it on the settings viewer
plug-in and we'll go over and edit the
script and we'll ignore that error and
I've no clue what it said we'll just
ignore it and I'm gonna make a new
script and my wonderful one-handed
typing here we're gonna go off and I'll
come back and talk about this in a
second okay so what I'm going to do is
I'm actually going to create this local
script and in that script I'm going to
put an on choose menu item just like you
saw back in the last demonstration but
it's actually now inside of a script
object then the next thing I'm going to
do is I'm going to find another one of
those lovely Apple script things I'm
gonna go find the first menu item whose
title is Project so I'm gonna go over to
find the project menu now I'm gonna get
the class browser and what I want to do
is insert a menu item right after the
show class browser menu item so what I
do is I sort of get a couple of
references for those and then I'm going
to make a new menu item and I set it to
be after that show browser clouds a menu
item and then I set it with some
properties I set a title and a name and
then finally you see I dynamically set
the script of that menu item by passing
it this script right here so what it's
going to do is when I build this when we
actually install the plug-in and run it
it's going to add a menu item and then
when I choose it it should present a
display dialogue for us so we do need to
in this case quit Xcode and I'm going to
bring up hide this for the moment and
we're going to find the build and just
to show you this is where I built the
project and this is my plug and it's an
extension of PB plugin
this is the local plugins on my library
and my users of cancellous library
application support apple developer
tools plugins so I just copy that over
drop it in and I go back into Xcode
launch that and now what's happened is
that that plugin got loaded in the
process of starting Xcode and if I go
and open up a project oh let's do
countdown timer and you'll see now under
the project menu this wasn't here before
of course I should have shown that to
you because you may not believe me now I
could if you want me to I'll throw the
plug-in out and we'll start over but
let's go we'll go on so now when I
choose this if all is working well it
actually will display my dialog so that
at least I know I've got the plug-in
loaded okay well that's not very
interesting and that certainly doesn't
get the job done so let's go and finish
working on that project so I'm gonna go
back in I'm going to open up my settings
viewer plug-in and this time we're going
to go into the much easier to sort it
this way and I'm going to the settings
viewer itself and I'm going to describe
a little bit about the UI for this
plug-in when you choose that menu item
I'm going to present this outline view
and I'm going to go through and I'm
going to ask every single project or ask
the project ask every target ask every
build face everything I could possibly
ask for it's build settings and then I'm
going to list the build settings as
top-level items and then child items
will be added as from the whoever
defines those particular settings and
that's the way that this should look
it's what I need to do is actually add
an event handler and I want to know when
this window gets opened because we're
going to add something back in our menu
item chooser to do that to load the nib
for us so I go in here and we'll click
on the open and this time I'm going to
put it in the settings viewer and since
there's a little bit of code here I'm
actually hopefully going to be able to
do this right and drag in our snippet
one now this is a little bit of code
here and what I want to describe is that
we in this case we need to use the terms
from Xcode and we're going to fix this
is just a limitation of the current
implementation but we want to do is get
the last project document I'm going to
do a little bit of call methods I do a
lot of this Salas goals me but you know
I'll learn sooner or later but again I
use that string by deleting path extent
it's so simple it's just one call I know
it's there so I want to use that and
then I've got a little spinny indicator
you didn't see it but it's a little
progress indicator up in the view and
I'm going to tell it that I want to use
threaded animation so it just spins on
its own and I don't need to tell it to
do anything and then I'm going to start
that indicator spinning and then what
I'm going to do is there's a little
status text field I guess I could show
these where these things are here
there's actually a little indicator
there and there's actually a little
status indicator here and I'm going to
set that status right here passing it in
the project title that we're currently
looking at we have update the object
that's to tell it to redraw please
ignore the delay 0.1 that's just a
little Cluj but okay
under long view settings of scroll view
we get the outline view out of that
window and then we get the data source
we make a new one just like we did
before we make a new data source we're
going to create three new columns name
kind and value and then again we're
going to set that data source of the
outline view and then we're going to
call a couple handlers here one is
called find settings for items in
project so we're going to pass with the
project go find all those items and then
we're going to expand the settings what
I want to do is find every setting
that's defined more than once so I can
look at like build Styles check
development versus deployment and you'll
see how that works and then at the end
we're going to turn off the progress
indicator and then we're going to update
the status of the field to clear it out
or at least set the project title there
update the object ignore the obvious
Cluj with the blazer about 1 that's to
make sure that it draws correctly all
right trust me it's needed but we'll fix
them so that part is in there we
actually need to add a little bit more
here resize this down we need to add
these two handlers and any supporting
items that go with that so hopefully
it's this piece that I've got copied off
here all right and so what it's going to
do again we have to use the using terms
block it's going to turn off the
updating just like we did before because
we're gonna add some data to it and yes
it's going to do some call methods that
I've added to this project repeats
through reach the build Styles adding
those settings reprocess each target
adding those build settings and if I
would like I could go actually find
every build file and get its settings so
what it's going to return me as a whole
data source populated with all the build
settings and those that define it and
then finally at the end it's going to
call expand settings
it's gonna go through it's going to find
out which ones have more than one data
item and then expand it so I think it
takes care of that and then the last
thing we need to do is go back into the
plugin script and we need to replace
this display dialog and we'll put that
in and again call method you know
there's lots of call method I love it
it's great it makes it easy to add
things but this is sort of a workaround
for a bug we're going to fix this by the
time release comes out so that it's easy
to load a name that's actually now in a
plugin we already have support for load
nib you just pass it load name in the
name of the nib and it just works in
this case though the plug-in doesn't or
the the Nira isn't in the application
it's in the plug-in so what you need to
add an extension will get that in there
so I'm gonna go ahead and build this and
it's built so I'm going to have to quit
again and we'll quit this and I have to
go throw this one away because I don't
need it anymore copy that one over and
now when I go back into Xcode magically
appears right okay so then let's go in
and let's open up another project here
and cross your fingers I choose this it
should open a window spins the indicator
goes finds all the settings and expands
all of the settings that are defined
multiply so I can look and see that zero
link is on for development it's off for
deployment I could check all of these
various settings it's just a way to look
at the settings I know this appeals to
all the engineers in the crowd so some
of us made I get it but this is a very
cool thing and we've been able to plug
it right in take advantage of that the
script ability in Xcode thank you
[Applause]
okay back to the slides future features
well I won't tell you that I looked at
last year's list of future features and
did a scorecard so we'll just go right
along here we're going to add make new
and delete support I think it's really
important especially with things like
plugins and other type of dynamic
especially with the script property
you're gonna want to be able to create
new things and one of the some of those
new things you want to create toolbars
may be excellent to be able to take
advantage of the toolbars that are in
cocoa the reason that it isn't there
currently is that there is no way to put
toolbars together an interface builder
and that's where we hook everything up
but now that we're dynamic now you can
see the picture right we can start
creating these things same thing with
the dock menu you're going to be able to
support the dock a menu that pops up and
add your own items and respond to those
dictionary viewer there's sometimes it's
a bit difficult especially when you get
very large terminologies to find the
data that you need and to find the code
the classes and the commands and so
we're going to do is build on all the
wonderful things we've done an Xcode can
you can imagine a little search field so
as you type window we're going to filter
that for you or a particular code we're
going to pull that into the dictionary
viewer and make it a much nicer place
we're gonna be able to show you
hopefully documentation examples right
in line in the dictionary viewer okay
thank you
roadmap so obviously we've already had
some of these slow for the disk will
look at 4:01 it was I had our Apple
script update we already had our
feedback form it would be nice that we
had these at the end but that's okay
we've had our out we have our Apple
script and QuickTime already happened it
too we have a session tomorrow 4:14 this
is to show you if you're interested how
to make your carbon or cocoa application
scriptable so that we can take advantage
of do even more cool things with Apple
script studio will open up much more
applications and they'll show you how to
do that session 311 on Friday will show
you how to automate your testing with
some of the things like GUI scripting
that we've provided you can actually
click on buttons and choose menu items
and there's other tools that can be used
to check in and test your software and
then then 623 we have an Apple script
for system administrators I feel like a
flight attendant it's like you know this
is Apple script Airlines welcome to
flight 306
on your tour our deaf final destination
is AppleScript nirvana if this is not
your destination there are exits for now
okay okay
whom to contact well give me a call well
don't call me but you can send me an
email
I'll try to respond as best I can we
have Todd Fernandez who is our
engineering manager Sal Sugoi and
everybody knows Sal knows and loves them
and then we have Jason yo who is our
technology manager and for more
information you can find all of these
wonderful references that we have
building applications which is a bit of
a tutorial this is probably our first
documentation that we wrote and we know
that we're going to enhance it hopefully
in the future and make it even better
and the studio terminology reference was
new with Jaguar last year it's a
wonderful reference and actually can I
switch back over to the machine for just
a minute because I've had a lot of
requests for this it used to be in
project builder it showed up right here
and said show or Apple script studio
help what we've done is consolidated or
bit so you have to have fortunately
pushed it down a level a little lower
you bring up the documentation viewer
but we get to be at the top of the class
we're a first thing Apple script and you
can actually just come in here and find
out about Apple scripts to do the
references they're all right there and
you actually even get to can take
advantage of some of the searching
features to get to that help okay we go
back to the slides again thank you
release notes every time we send out a
revision we didn't get them in the 1.3
preview release but in the final release
we'll make sure we have a good set of
release notes there is also lots and
lots I think I have 33 examples at this
point you know we'll keep adding more of
those the ones you saw today and other
examples that's probably your best
resource when you're getting right into
it go open those each of those examples
build it run it I tried to be we tried
to be very specific to the the tasks
that we're trying to demonstrate and of
course there was a studio website that's
updated all the time
you