WWDC2004 Session 305
Transcript
Kind: captions
Language: en
please now welcome to the stage Tim
Bumgarner
welcome it's exciting to be here this is
our fourth year i believe at presenting
apple scripts to do at the developer
conference and it's been straight
exciting a terrific ride that we've been
working on here before i get started
with my presentation I'd actually like
to take a little bit of a poll so it'll
help me gear what we talked about how
many people have ever actually used
apple scripts to do great how many use
Apple scripts to be on a regular basis
okay terrific so i'll i'll keep it about
that intermediate level thank you all
right let's talk a little bit about it
and of course I'm to Bumgarner Apple
scripts to do lead engineer what did
what I like to do is to show you a
little bit about what you're going to
learn today in this session and we're
going to do an overview of Apple scripts
to do so for those of you that haven't
ever seen it or ever used it will give
you a quick tour of what it's like to
create an apple script studio
application we're going to touch a
little bit upon the enhancements we've
made for xcode to better support apple
scripts to do and of course the most
exciting thing is to talk about some of
the new features that we're going to be
providing in studio for a tiger what is
Apple scripts to do apples for studios
is very exciting technology that we've
put together and it pulls together a lot
of different aspects of technologies
that we have at apple it takes the
advantage of the developer tools we have
so that this we could integrate
applescript support into Xcode in
interface builder to make it very easy
for you to create these applications
that are in fact native Mackel has 10
applications so that's when you build
these and instruct them using Apple
script is your language you can save it
up and distribute these applications to
anybody else that has a blacklisted
system and they can run that application
without needing any other additional
frameworks or components to go with it
it all just works now additionally you
can take advantage of all the features
of xcode such that you could add
additional functionality using either of
Apple script or objective c or other
languages even Java and you get to take
advantage of cocoa it's rich user
interface so it's really a two-part
solution it has a run time component
and this is an apple script kit it's a
public framework that's provided with
the system it contains in essence is the
glue between cocoa and the cyst and
Apple script itself so it will know when
something happens in the user interface
and it knows how to call your script and
execute a particular Handler and that's
what provides the functionality of a
studio application as it's run by the
user now it's also a development side
piece to it and we've developed plugins
into Xcode so that it knows how to edit
add or edit compile and build and even
debug applescript inside of the
development environment and we've also
added a palette in interface builder to
make it very easy to put these things
all together so how's it being used well
it has been about four years so we've
been paying attention watching what's
been happening with studi and how people
are actually using it out there in the
real world and we found that a lot of
people have taken studio and it's a
great tool to use to wrap shell commands
so there's these low-level tools that
are laying around in this wonderful unix
environment that we have but smear
mortals don't know how to use them for
the most part there's a lot of
parameters I don't know how that you've
ever actually pulled up a man page and
go hmm what was that some of us quite
long so but people that you understand
it understand studio can take and put
the best of both together so that they
could provide a nice simple user
interface that has checkboxes and
pop-ups with little fields and when it
runs it actually execute that low-level
functionality and there's a lot of great
examples of that in use we also find
it's a great prototyping tool and the
reason it's such a good prototyping tool
is that you get to use the same exact
developer tools the same process as you
do as if you were to start off with a
cocoa application so that you learn all
of the methodology of creating that
application so you can start off in
studio put together some things very
quickly get a look and feel that you
like and then as needed you could
replace performance of critical areas
with direct protocols or correct cocoa
classes as you need them and of course
the other thing that we've seen is
people create applications using studio
to control other applications because
that's really where the leverage comes
in applescript is awesome at being able
to talk to other
applications and to be better scriptable
of course and get data from the other
application and even to control them so
we find a lot of examples of that and we
also find that of course our core
customers really use it for their
workflow solutions so they will create
their workflows as needed and use these
controls excuse me up so that they can
put together these nice interfaces and
have this workflow instead of the old
way with apple script is you would have
to prompt the user dialogue after
dialogue after dialogue you have a
dialogue and come up ask a question hit
okay and it would bring up another
dialog well you can do away with all of
that with Apple scripts to do and last
but not least and the thing I'm most
excited about is that Automator users
studio itself as a matter of fact many
of the actions that you've seen an
automator are done with Apple scripts to
do in conjunction with cocoa bindings
and objective-c and it's a they all work
just seamlessly together and we're very
excited about them so what I would like
to do is just take a moment switch over
the demo machine and just give you a
quick feel of what it's like to create a
s studio application from scratch so I'm
going to go into Xcode it closed this
project and we're going to start off
with a new project in the file menu and
you'll notice that when I bring up the
new project assistant that there are
several different templates that are
already pre-built for you in order to
create a studio application the first
one will create a very simple
application that has a single window the
second one is a document based
application so if you need multiple
documents this would be the one you
choose the third one is a droplet so if
you need to be able to create an
application that sits on the desktop and
users drag files on to it you can
process those files of interesting ways
for those of you that have used
applescript a lot to see in the past
this is very similar to an applet that
you would say for a droplet that you
would space from the script editor for
our purposes we're going to go ahead and
choose the Apple script application and
i'm going to call this project user info
and we're going to go ahead and hold
right these selected files
and I'm going to go into the very first
thing we're going to do just a quick
overview of where things are located in
a project first as there's a scripts
folder this is typically where you put
all of your dot Apple script files and
the resources and here is our main menu
nib those are the two most important
aspects of that we need to deal with in
this project so I don't go ahead and
double click on this nib which is our
interface and it will open it up inside
of interface builder and here I've got a
simple window and what I'm going to do
is actually create instead of creating a
simple hello world which I've done in
the past it has a simple button you
click it mrs. hello world we're going to
take advantage of a new feature that we
have an applescript that we've been
added for tiger and it's called system
information so actually if I fire up
script editor and we'll take a look at
the library window there this is an easy
way to get to the dictionary of the
standard editions I'm going to double
click this and take a look at and i
believe it's under the miscellaneous
classes you will see that there's this
new thing called system information it's
a new class or record so now it's very
simple to get for instance the
applescript version i can get the system
version i can get the short username or
long username there's other things like
its home directory the computer name IP
address the cpu type so it's a really
new functionality here so it makes it
very easy for you to determine what type
of environment in is the script running
in so for our purposes of the demo all I
want to do is grab the username the long
username and I want to also use the
computer name so go ahead and hide this
and we'll drag out a text field and
you'll see as I'm dragging around I get
the nice interface builder will put out
the guideline so I know that I'm
actually putting everything as far as
aquas concerned in the right location
and i'll drag out a text field and we'll
go ahead and call this one user name and
will write a line that is it should be
and get those all lined up nice to meet
make a copy of that and just will add a
simple button in order to fill that data
out and we'll call this get info
and grab Luke don't quit grab all these
again line them up here as close to
enough at the moment and then the next
thing we need to do is we've got our
interface laid out now Apple script is
very containment oriented it needs to be
able to talk to objects to its
containment in this case window is the
top level and I'll make sure that I
named that window by going to the apple
script panel in the info window and
we'll call this main and I'm going to
then name from other objects that I need
to reference so I'm going to reference
this field and I'm going to give that a
name of user name oh good thank you good
catch thank you Paul so we're going to
go to some computer name and name are
not name okay there we go and we'll
change this to computer name thanks okay
well it's not quite wide enough so we'll
fix that one too it goes a little
lighter it's the simplest things right
shouldn't be this hard okay that's the
worst that happens we're we're in good
shape okay now finally I've got the
objects name that I want to name and I'm
going to want to know when the user
clicks on this get info button so I'll
select that and I'll go over here to my
event handlers and I see that there's an
event handler called quit this is the
handler that will get called in my
script when the user clicks the button
and then I make sure that that goes
inside of the user info script so let me
save that and we'll go ahead and edit
script and what it is done is it put me
back into Xcode and it automatically
looked at the script determined whether
or not that handler existed and inserted
the handler for me it automatically
determined what the parameters are in
the name of it I don't have to remember
that it's actually called quick tour the
object is one of the parameters passed
to it so what I'm going to do is use my
fancy dancing one-handed typing that's
very fast and we're going to bring up a
little bit of script here and the first
line that you'll see is making that call
in the standard editions called system
info and it's going to store it in our
little
variable here it's a record of the stuff
that we just discussed before in this
library window and then I'm going to
talk to the window and this is a very
common Apple scripting to do tell window
of the object now the object happens to
be the button window is a property of
that button and then I'm going to simply
set the context of that text field too
long either name Oh Sissonville and then
for the computer name i'm going to set
the computer name so if everything is
all set i should go ahead and do a
building go and it will launch the
application of everything is right I'm
going to click get info and there you go
it went and got the username logged in
as Apple scripts to do and it happens to
be the computer name is WWDC 2014
iterative process then you just go back
into interface builder add your
additional interface and just keep
attaching handlers and scripts and
filling those out so I could go back to
slides please let's talk just a second
of a few minutes about the new Xcode
support we've added we've added native
target support to Xcode so now and
that's very important for a very several
good reasons what the main reason is
that the native target system or native
build system in Xcode is where all the
new features are going in so for things
like a zero link we now get to take
advantage of so it's very quick and in
your turnaround as you build your
application you don't have to go through
this long link process it just it's very
quick and so any other new features that
come into Xcode will be able to take
advantage of that so we stay current
with all the other languages that are
supported we also took advantage of
thinking we also took advantage of the
improving the code assisted it had a
very limited amount of support we've now
increased that so there is on the parity
with the script editor script assistance
which also got enhanced so now we're
going to have the same look and feel no
matter where you're editing scripts it
will have all the same terminologies and
not of completions for you so at the
consistent look and feel and we've also
added support for compiled scripts up to
this point Apple script files have been
saved as dot applescript and what we
wanted to do is also be able to support
scpt or compiled scripts so that you can
compile a script on your machine and
what
might do something like a tell
application FileMaker Pro it will save
that application if I give that project
to somebody else they don't necessarily
have to have FileMaker Pro on their
system whereas before they did so this
makes it a little more convenient and if
anything and the terminology changes you
get that for free the next time you open
up that script the terminology will
automatically change whereas before you
would have a gun in fix with the broken
terminology finally get to the fun stuff
that's been to an intermediate level
we'll talk about some of the new
technologies the new features that we've
added to Apple scripts to do for the
tiger release the first thing I want to
say is we actually do listen I
personally read every male that comes
across the Apple scripts to do mailing
list and we look at that right answer as
many as I can unfortunate as many as I
would like to but we do read them and we
see the trends where are people
struggling what are they having
difficulties with what areas are is a
performance issue where is it not
flexible enough and so we've tried to
incorporate as many of those as we could
in the best priorities that we could
determine so where are the some of those
new features we've got more data view
support the date of you seem to be one
of the top things that people want to
script and so we've found that we've
tried to make it easier and better
performance to add data to your data
source but we found that it's still
difficult to get that data back out so
that you can do something meaningful
with it for its and store that data and
put it back with the same fidelity as
you put it in so we've made that simpler
we've also made it sure that it works
for both table views and outline views
outlined views sort of in the stepchild
a little league often ignored so we've
taken care of that we've also found that
people wanted to be able to have better
control in their drag and drop for data
view so we've had some supports you
could drag in items but we haven't given
you the opportunity to determine where
in that view you want that data to drop
and more importantly people wanted to be
able to reorder items within their table
or outline view very simply so we've
provided that and another one I'm very
excited about is toolbar support it's
sort of the one thing that if you looked
at studio it was sort of missing from a
native total application there was very
difficult for you to actually add
your own toolbar you would have to go
directly to Coco to do that we've made
it incredibly simple for you to do that
to add to your own applications we've
also taken care of some of the
terminology that we have and I had to do
a review over the documentation of the
reference manual and there were just too
many places where it said not supported
we'd have it defined but not supported
so we're going to address that as well
and of course we've added some
additional functionality to better
support automator so that's built right
into the new features that we have so
let's go look through these one at a
time more data view support we've had
this command for a little while called a
pen and it was very simple to append
data to a data source unfortunately it
only worked for table views now works
for outline view so you can append
hierarchical data at any place that you
want within the data source and the
thing that's really cool is the content
property for most the applescript people
is like sort of those does things why
wasn't there one to begin with but now
there's a content property so it's very
simple to simply say set content of
table view to some data and it just
creates it for you does it takes care of
all of the work that needs to be done
but since it is a Content property you
can get it right back out you can say
get content of table view and or outline
view and you get all your data right
back and you can also control how that
data comes back you can put the data
into the list of lists or a list of
record so then you can also figure out
how you want to get it back is the same
format and we've also added support for
the sort indicators and the last one is
that data sources who historically has
been sort of this all knowing all
powerful thing that gave you great
performance that was very inflexible it
didn't want to give out any control back
to you as the scripture or the
application writer and so we've tried to
add that support as well and as I
discussed it now the append command
works for both outline of date abuse you
can end data as a list of strings so if
you have a simple table with a call our
table view it's one data what table
column you can list that as added the
list of strings or a list of lists or
list of records whatever is the most
convenient for you to use the content
property what's exciting about this is
that you can set the content of that
table view
it will do everything for you it will
create the data source great all the
necessary data columns and create all
the data rows or data items that are
needed for that view for other data
that's provided with one line of script
you can now populate an entire data
source or date of you and that's very
exciting and again as I mentioned before
both table view and outline view our
line view is no longer the stepchild
getting data out again as I mentioned
you simply ask for the content of a data
of a table viewer now I've you and you
get that data back now the problem with
a Content getting the data is that we
have to give it back to you in sub floor
map and there's unfortunate applescript
is not possible to say get content of
table view as a list of records or the
list of Lists that just doesn't work
that way so we have a property on the
data source it's called returns records
you could set that to true the data
comes back as a list of Records vaults
you get it back of the list of Lists so
you get to the flexibility that you want
to decide what formats you want that
data in and here's back to that sort of
all knowing all powerful data source
he's a it's been a wonderful thing
because the performance was so much
better the very first iterations is you
had to provide all the event handlers
but the table view every time we needed
to update that sell it we ask you for
the value well that's terribly slow
because it has to send an event every
single time when we added the data
source support it all came very fast
because it took care of everything that
I was sort of the problem it took care
of everything you didn't get an
opportunity to know when a user changed
something in your table view so if they
edited a data a table cell you didn't
know it's a lil event handler even we
would let you have the event handler we
just ignored it so a little table event
handler ago tell me tell me tell me when
you change data please advances I know
better I know better i'm not going to
talk to this guy over here so he ain't
go ahead and do it and you just ignored
but we finally realized the data source
got smart and said you know what that
little bit ever know something I don't
so it gives us an opportunity to call
you so you get to pick and choose which
event handler you want to implement in
your table view so that you can get the
best flexibility out of it as you want
so we're much
here with the new way and sword
indicator so it's very simple to set now
a boolean property on the table view to
say whether or not you want little
indicators up in your table columns you
don't have to call Coco to do that and
the default is false the moment so what
I'd like to do is invite jonquil oh he's
our apple script studio quality
assurance engineer and to help make sure
I don't know stuff like I did before
thank you John and we're going to give
you some quick demonstrations of this
technology it's always going to do is
we're going to first start off with our
table view or and the first thing we do
is Glen to the interface builder and
we're going to see we have a very simple
table view here with two columns and
he's going to drill down and select the
table view and what we're going to do is
we're going to use a wig from nib that's
a handler that gets called when the
window is open it's a good place to
populate our data and then let's go to
the application object and we're going
to make sure that we've got the launched
handler because a very good strategy in
studio is if there's something you need
to put in the window add data change the
UI make sure you do that before the
window becomes visible so by default we
make sure that the window is not visible
and launched is a good place to show our
window so let's go ahead and save that
John and we'll go back in and we'll add
our code so from weight from Gabe he's
going to add our code and quitting I've
that line and let's take a look at it
there you go one line of script is going
to populate the table it does all of
that work that i mentioned greats the
datasource crates the data columns
creates all the necessary data rows
before this would have been about 10
lines of scripts now it's one let's go
ahead and build and run this and there
you go just that quick it's populated
the table view and it works just fine
matter of fact let's show you now how
easy it was to get it in that's how easy
it is to get it back out and he's going
to go into script editor dragging a
little bit of script it's going to talk
to the table view and ask it for its
content now you'll notice that it came
back is a list of records how did we put
it in it was a list of lips so we can go
and set our returns records to fall
and run it again and you see it comes
back now as a list of lists so you've
got fidelity with the data going into
your data source you can get it back out
in that same format that way it makes it
very simple distorted and just any type
of a file that you like okay now one
more thing we talked about is that
flexibility issue what we want to know
is when the user actually changes one of
the table cells so that we can do
something about it so let's quit the
application John learn interface builder
and what we're going to do is we're
going to go to the table view category
and we're going to add a change cell
value event hammer this handle gets
called when the user tries to change the
data so let's say that and go ahead and
add our line now looking at the handler
itself it passes a few objects the
interesting one is at the end is the
value this value is whatever the user
typed in so you can decide to do
something interesting like if the
checkbox that changed in one column
update something in another column in
this case we're just going to force it
to return a different value so that we
can actually change the value as a cub
dense let's build and run this okay and
so when john goes over and tries to type
know and let him type no but as soon as
it goes off of it you'll see it says i
don't think so so we actually got to
control we get to work with the data
source instead of the data source
working against us all right thank you
John let's go back slide please
[Applause]
drag-and-drop support don't lay where
John lottie's going to get away so we're
going to do up our drag and drop support
talk a little bit about them now what
we've done is that made it very simple
for you to not only drag items in but
control where they go within the drag
and then also be able to reorder items
within the drag and we've done this also
by making it very simple with one
property you set allows reordering to
true you don't have to do anything you
just set the one line of script and you
can automatically drag items cocoa
doesn't even make this available so this
is something we've got a leg up on we do
the new drag and drop to three new event
handlers so now that there's a handler
for when the drag begins and you can put
whatever type of data you want on the
pace Ward as the user drag things around
there's a handler think it's called as
the drag is happening so you get to
decide whether it's a copy or a move or
if it should happen at a particular
location and then there's another handle
that gets called when the item is
dropped and there's three handlers for a
table view three handlers for outline
view and there's also two additional
ones we've added to event handlers
called Rose changed and items changed
you can have these peddlers attached to
a view and so that you can find out
whenever the data changes so for
instance some other data is driving this
source you can get notified of those
changes and we orders to reading
reordering support I mentioned is simply
setting a boolean property on the table
view just a couple notes obviously if
you're going to reorder that means it's
not a sort of date of you so if you said
sorting on you're not going to be able
to reorder you have to decide which is
more important it only works this
automatic support only works if you drag
items within a table view if you need to
support dragging things in you're going
to have to do that work as well so it's
not on it it doesn't automatically
support the external drags let's take a
look at an example of this now we've
showed you the table view and just to
prove the fact that it actually does
work with the outline view this time
we're going to start with an outline
view and let's look at the bib and again
he's going to drill in and we need to
attach we're going to go to our outline
view
and we're going to add these three new
event hammers can't quite see it down
though still have to look up here and
what we're going to add is the prepare
outline drag we're going to add prepare
outline drop and the last one is accept
that line drop and that's all we need to
do in this so good save and edit the
script and John's going to enter in the
first thing we need to do is whenever
you're going to start a drag and drop
you need to tell the view what type of
drags you want to receive so whether
it's files or other type of things or
colors in this case we want to make sure
that we register for the items that are
being drugged so that we could do
reordering or we want also to support
file name so let's go down to the
prepare for drag and add that script and
what it does is it sets the contents on
the pasteboard and then the very last
thing and that handlers to make sure you
return true or false if you don't want
to drag the start just simply return
false and it will stop but you always
would typically want to return true so
he's now going to fill out the handler
that gets called as user drag things up
and down in your view and the thing
that's most important in here is we have
to return a type of Dragon operation
that it's an enumerated type there's
like a no drag operation move or copy
and we determined that based on whether
or not they're holding down the option
key and now we'll go down to the last
one now admittedly this is a fairly long
bit of script here and we'll let John
put those in there till we get down to
right about here you were an incredibly
fast typer John okay so we're down as
the bottom of this handler and let's go
ahead and check this indexing let's go
back up and look at just very quickly
this is the handle that gets called when
you use to drop something on the outline
view and what it will do is gets the
data from the tail the pasteboard it's
going to check to see what type of data
it is if it's items that means it's a
reorder it then looks to see it the
option the state of the key the option
key if it's a copy operation it's going
to do a copy let scroll down a little
further John and if it's a move will do
that otherwise it goes down further else
if the file names is being dragged in
then we look at it again and decide it's
always a copy and we're just going to
copy and that
item so let's go ahead and run this John
take a look so here's our outline view
and he didn't go ahead and expand that
and he's going to drag one of the items
and you'll see that way let's go of it
too puts it inside of that one actually
and we can actually take another one on
the bottom and put it inside that we can
reorder and put items wherever we like
now he's going to take an item from the
desktop and drag it in and you'll notice
that if he drags on the outside it would
have added it to the end or you can
decide where he wants to put that item
in the outline view so it's just that
simple in order to now support the fine
control that you need in and out like
you thanks Jeff as slides please toolbar
support as I said very excited about
this because it sort of filled in that
the missing gap that we had and we do
this through a new couple new classes
there's a toolbar class a toolbar item
class we then also had a window or the
window gets a new property called
toolbar and we do this through a quick
toolbar item and update toolbar I'm
these two get called the update gets
called whenever the toolbar items in the
toolbar need to be updated so you can
set the label you can change the icon so
you can do anything you need to do
enable or disable it the clicks gets
called whenever the user clicks on that
toolbar item so let's take a look at
that so the process how do you create a
toolbar in order to create a toolbar you
simply make it just like you do anything
announce an apple script you set it too
loud and default identifier these are
identified that say the allowed our what
possible set of toolbar items can I have
in my tool are so for instance if you go
to the customization palette you'll see
all of the possible choices and the the
default identifiers are the identifiers
that the user sees the initial time that
he starts your application so you set
those two sensors and they're a list of
strings you make the toolbar items so
now you go through and create all the
custom toolbar items that you have in
your toolbar and then you assign that
toolbar to the window now what happens
when the user starts working with your
toolbar so as I mentioned the update
tool bar item gets called by the system
the system will say okay these toolbar
items need to be adjusted the user's
done something in the menu or click
somewhere and we need to make sure that
the toolbar states are all correct and
so it will call that and you get the
opportunity to change the title you can
change the icon change the tooltip as
they move the mouse over that and the
most important thing in this handlers
that you decide whether or not that
given toolbar item is enabled and you
return true if you want it enabled false
if not and then when the user actually
clicks on a toolbar item you just
respond and add this event handler to
your window and you can find out which
one was clicked by just comparing its
name its identifier there's several
different ways that you can find out
which one was quick now for if you're
really advanced we actually can set the
script object of a toolbar item so if
that script object contains a quick
tandler we're going to call that one so
it's not you don't necessarily have to
say if name of this is that help this
name is this help to set you can just go
ahead and define stupid scripts for each
item in your toolbar and we'd like to
show you how that works so demo machine
okay now one reason why there hasn't
been support is that interface builder
itself doesn't support toolbar creation
right in inside of it so we needed to be
able to do the script and what we're
going to do is we make sure we go to the
window that we want the toolbar attached
to and we're going to go to it go ahead
and go to the Apple script panel and
we're going to set the away from them
that'll be the place to create it and
then there's a new toolbar category and
we're going to use the click and update
of items i'm going to edit that script
but it doesn't we'll see if you may be
right then I look really foolish really
oh you're twice ok let's go through and
this was a document based application so
it already had a couple of items here
and we're going to go down to the week
from him and he's going to place paste
that in and we'll let him go ahead and
fill that out
and when he's finished we'll go ahead
and check the syntax on this handler and
then talk about each of the item that's
very difficult to see on this monitor so
I'm going to look up here and one more
so let's go back up to the lake from
they have done and look at each of the
pieces to this so the object again rees
the window this is what the event
handler is attached to and it's going to
make them toolbar and it's going to
create it with some properties what is
the name and that's just like anything
we use in studio that's the name of the
toolbar then it's going to create a use
an identifier identifier is very
important to toolbars in cocoa each of
them have to have a unique name and so
we've got it an identifier here and then
there's some other properties that you
can set whether or not the toolbar is
resizable or could be customized what
size it starts off in in our case we're
going to set these all to develop values
and then the next line is the allowed
identifier and this is the possible set
of identifiers that we want to allow at
our toolbar you'll notice the first
three is compile run and stop these are
our toolbar items that we want to add to
the toolbar everything from that point
on our standard identifier so there's
such things as what do we have there
we've got customized flexible space
space a separator those are we just set
those in there when we'll get those
support for free the next line is the
default a set of identifiers what do I
want my toolbar to look like initially
the first time they start their
application and so that will set that in
our case we just want the compile run
and stop toolbar items and then what we
do is we create each of those toolbar
items so we have make new toolbar item
and again we with the property so we
make sure that the identify is exactly
the same as what we specified in the the
other lists above if there's a
misspelling or you've not quite a guy
right it's not going to work correctly
so make sure those are the same and so
we've created one for our compile we've
created one for the run and we prayed
one for the stop and finally now we've
got all the pieces in place we just set
the toolbar item
the toolbar property of the window it's
all done this is even simpler than it is
in cocoa as well and then the last thing
we do is look at the last two handlers
if the user clicks in this case we're
going to only look for one click we're
going to look and see if they clicked on
the compile button and if it does we're
going to simply display a dialog if they
click on the Update toolbar item or the
when this update gets called we're going
to just simply say we want them all
enabled I could have easily checked for
a state I might have been compiling in
that floor I want to make sure the stop
is enabled but the run is disabled or
change the state this is the place to do
that so let's go ahead and run them and
you'll see there's our toolbar very
simply done we can customize it we can
go ahead and look at that and add our
items and finish that up and we can see
that when we actually click on it adds
our calls our display dialogue and
create a new window and there you go
just that simple thank you John select
slides please ok i mentioned terminology
improvements we are going to look at all
of the broken terminology all the
terminology that says not supported if
it's defined and we can fix it we'll fix
it if it's defined and we just can't fix
it well it didn't work to begin with so
we'll just deprecated it and take it out
of the terminology there are a couple
conflicts currently I believe file type
in file kind as a problem will address
that make sure that's fixed and well of
course at any new terminology is needed
there's my guy like that robot alright
we've added some support for Automator
one of the things you'll find is that as
you're putting together not a major
action that you can quite often do
everything with cocoa binding some
matter of fact that's what we recommend
use cocoa bindings it's very simple it
takes care of the UI issues for you but
sometimes it's not enough for instance
we have many actions that when the
action is that it's Automator it needs
to go talk to another application in
order to populate something like a
pop-up button so for instance when we
bring in the new mail automator action
the first thing we do is
go talk to mail and ask you through all
of its accounts so that we can then
populate that account pop up for you so
Coco vitamins can't quite do that unless
I were to go write some cocoa code well
that's not sufficient if we were trying
to do it all in Apple script this is
where studio comes in and makes it very
simple for you to go in there is a wait
from you but you can attach to the view
and then populate whatever you need to
do so another example there are several
actions that change the file names in
certain ways and so we've added an
example section so as you click on the
UI objects we update that example so you
can see how that is actually going to
change your file names it makes it much
more obvious so there's another great
example of that but that we found that
it was necessary at the point when you
want to run or save your workflow that
we find out what things have changed
because it wasn't bad with Coco bindings
which takes a lot of this for you we
have to give you an opportunity so that
you can update that parameters object so
if you saw our demos yesterday you saw
that parameters object this is what
we're doing to give you that
functionality and as we mentioned before
it works right alongside of cocoa
bindings it's not in competition with it
one doesn't replace the other they can
work together seamlessly and you can mix
in cocoa as needed going very fast today
is going to be a short session which
probably makes you all very happy so
we've got to do incredibly easy to use
data sources we made it even easier than
we've done in the past but at the same
time we've made it much more flexible so
that you have the opportunity to decide
what it is what you want to do to
interact with it we've had a cool new
drag and drop support and there's
actually we forgot one demo yes we did
thank you that's okay I got time to burn
going anywhere all right let's go over
here I'll actually run this with by
myself let's go back to the demo machine
I'm sorry John we should you should have
said something one of them we forgot to
show you is the auto of support for
reordering and I'm going to go ahead and
fire up that demo and we'll go into the
interface builder
forgot this very cool demo I can't
believe that so we're going to go into
the into the table view itself I'm going
to go ahead and add the lake from nib so
that I can populate the table view and
then I'm going to actually add a handler
to this check box was the user chicks
that will turn on that state of Laos
reordering so I'll go ahead and click on
the click and assign it to their save it
edit the script now the interesting part
is remembering what the code is for this
so I believe that we have the final one
because now I don't get to use my fancy
dancing demo assistant so let's open
this up and text edit and we'll grab
everything that's inside of this awake
from nib and we'll put it inside of here
so we populate the data in a way from it
and we'll go down here and we'll grab
the simple line and go back up here to
click check the syntax looks good so one
x-ray we can give good catch and we'll
run that and you'll see here is my
application that's up and running and if
I try to drag it won't let me drag so if
i go down clicks allows reordering i can
now reorder items without having to
write any code whatsoever other than
simply enabling that so let's look at
that again so it's just a matter of
populating your date with the table and
then you just turn on that simple
property and it's very simple again this
works for both tables views and outline
views we make sure it works you're both
so let's go back to the slides please my
apologies John sorry okay at man also
toolbar support so we've shown you how
easy it is to add toolbar support now we
showed you that there are actually a
conflict and on update for the toolbar
we've actually added a couple additional
pieces you can even call cocoa things
from these toolbars so now there's an
optional parameters to a toolbar item
one of them is target so just as you've
used in cocoa if you know anything of
code where you can actually establish
the target of that action and then you
get to define what Coco method gets
called and makes it very simple to tie
into other applications and take
advantage of things like a WebKit
or something else that we might make
available and automate are absolutely
love studio I can't express it enough
that it's a very powerful combination in
order to make it very easy for you to
create these autumn interactions with
fur automator now it seems like I've
been very forgetful I've already
forgotten at least one demo and I know
that there's something else what did I
forget what is something else I read
niggers oh yeah well let's take it you
know I thought about this and I thought
you know WebKit has its own web you know
our Web Services has the WebKit I see
that quicktime now has a cutie kit so
why doesn't know sa get its own kid so
that's what we've done we've actually
taken and created a public framework so
that you can take advantage of the same
things that we have underlying all of
our cocoa technologies so there's
actually a public framework is called OS
a kit it's in it provides several public
classes for you to use there's no essay
script class this class is a superset of
abilities of the NS applescript class
that's in cocoa it will allow you to do
load and execute which Dennis Apple
script does but will also let you save
scripts and it will also let you execute
scripts in different ways that are
provided by NS applescript it I will say
a note that it is no way replaces in a
sample script if you need to simply do
the things that it provides when we
recommend that because then you don't
have to link in this additional
framework but if you do have a little
higher needs we recommend that you then
use vos a script class we have this OS a
script view that then makes it very
simple for you to edit script and we do
this by providing a new palette and so
that you can actually go into interface
builder and drag out of you and as in
bed within your own application the
ability to edit scripts and so I'd
actually want to also mention that we
use this as our foundation OS a kid is
now the foundation for all of our cocoa
applescript uses within the applescript
team so it underlies the applescript kit
itself we use it in the script editor
much of the functionality moved from a
script editor into as they kit itself
it's being used an automator how many
saw the run script
action in youth well that's being driven
by USA kit and then we all the plugins
we added to xcode four studio are driven
with LLS a kid and so I'd like to give
you a demo of that as well back up Bella
machine so what I'm going to do is we're
going to build an entire script editor
ni be no code and I'm going to go ahead
and create a new application and there
is a new palette called osa now i will
mention that it's not in by default you
actually have to go to the developer
extras and add that palette to your
application in order for it to show up
but once you do it stays there so you'll
see that i have two objects here and i
have a window i'm going to drag out this
script view and we'll drop it right
about here and drag it over and then
we'll drag that down a little for this
we get some room to type now i'm going
to put a few buttons now again i can
easily put this back into our toolbar
example if we needed to but for purposes
of this we're going to do it right here
and i'm going to do a compile and let's
do another one let's run so i'll drag
that over now i just simply have to make
a few connections by going back to the
USA palette and i dragged off what's
called an OS a script controller this is
the thing that knows how to talk between
commands and the different views and so
I'm going to make a connection from that
controller and go into the connections
palette and I'm going to sign it as a
script view and then I'm going to take
the compile button and I'm not going to
tell the script you directly I'm going
to tell the controller that it's time to
in this case compile and also run and
will bind those together and i'll go
ahead and run this and you'll see as i
begin to type it's also doing all the
script assistant i don't have to do
anything to support this it just happens
so that now as i bring up a leek soup
the right thing here there we go so it
brings up the assistant it'll have nice
little icons to differentiate between
types let's do find your name of every
window and I'll wait for the window to
populate well it seems our tacoma by
default so
once again window and end so I'm going
to go ahead and click on the compile
button and just that simply compiled it
and all not well in this case nothing
happened nor did I see any results so it
might be actually kind of interesting to
see the results so I'm going to go back
choose a text view any old text view
will work drag that out and we'll put it
down here and all I have to do in order
to enable results is to make a
connection assign it to the result view
so now that when i run this and type in
like red dates and compile run you'll
see that i get the result there was no
work whatsoever the wait it gets better
so will actually come in here and will
this time let's try recording i'm going
to put in a record button and i'm going
to wire that again to my controller and
we'll assign that and let's go ahead and
run this and now if I click record and
go over here and start opening windows
you'll see that the recording goes right
into that view again with no code just
that simple
[Applause]
as slides please now you might ask well
well that's that's interesting but why
is it important i think we found that in
particularly an automator where we're
trying to descriptive workflow sometimes
it is important to be able to edit your
script in line and particularly if you
support recording you can record from
within yourself and that might be very
interesting I think we're looking
forward to some very wonderful examples
of how to use this technology and of
course the great benefit is that as we
add new features and functionality to
osa kit not only will all of apple's
tools take advantage of that but
whatever you put on top will also get
advantage of that and so just to quickly
wrap up here is to talk about the
reference library we did provide all of
the sample demos that you saw today are
available as session material wherever
you get those from atc side i believe so
go ahead and grab those take a look at
them see how they work they're very
close very cleared symbol of some of the
even boilerplate you'll just copy paste
it into your own applications then of
course all the various other
documentation we have a great apple
script documentation if you go to the
apple script site you'll find the studio
terminology reference in a building a
guide there's also cocoa and xcode
documentation to go along with that who
to contact you can talk to Jason John
mantri on for DTS needs and I highly
highly recommend the Apple scripts to do
mailing list there are some terrific
people on that list some of them are
here today I thank them for their
support it's really beginning to grow
into a very wonderful community that
helped each other out and we try to put
our foot in wherever we can to help
along the way and it's wonderful to make
sure you go there sign up for it if you
haven't already and then the applescript
mailing list is exactly the same way