====== Eclipse view quick start guide ======
{{tag>eclipse tutorial}}
Martin posted this on the mailing list, I thought it was a good intro so have added it to the list - Luke
Right, heres the slightly more detailed steps towards getting a custom
swf view :
- Install the Plug-In development environment (PDE) if you need to.
- Read the docs.
:)
really though, goto
* Help Contents
* Platform PlugIn developer guide
* Programmers Guide
* Simple plug-in example
This gives you a nice run through creating your first plug-in, the only
problem i had is that i couldnt view the help properly when a dialog was
showing in eclipse, so i ended getting halfway through the tutorial and
being confronted with a panel and no assistance, so in case that happens
on your eclipse, i'll rewrite all the steps here and try and give them a
bit of explanation.
//(Note that you can also just open a second instance of Eclipse and follow the tutorial in that. This way, the dialogs won't get into the way of using the help system.)//
BUT, please read the tutorial itself, because im not going to ^C ^V the
whole lot in here :)
Im running 3.02, so i cant say what the steps are for 3.1, if someone
else wants to run through this in 3.1 and say if its the same, or where
things are different that would be handy, because i guess most of you
are running 3.1 for the latest version of flashout
Ok, so start with creating a new plug-in project, File->New->Project and
choose Plug-in project.
Next we give the project a name, and the convention for naming plugin
projects is with the classpath style com.foo.blah so use your own here
i'll call mine com.relivethefuture.flashpanel
my project settings say create a java project and use src and bin
folders, the way nature intended.
i wont worry about the OSGI stuff about the bottom yet, i havent got a
clue what it means.
Next up are the plugin properties, we'll go through them one by one so
that when eclipse generates the project you hopefully wont be thinking,
why the hell has it got that name? (which ive done multiple times :)
ID : from what i can find in the help docs this is a unique way of
naming your plugin so you can do things with it later on in other parts
of the platform, so i'll follow the example and just use the package
name : com.relivethefuture.flashpanel
Version : :)
Plug-in name : This is what will appear in the Window->Show View menu
underneath our category
Plug-in provider : thats your provider name, leave it as is.
Runtime Library : the name of the .jar file it will build containing
your binary code.
In the next box we have some settings for a plug-in class. This is the
class that will be created for managing and controlling the plugin. It
does things like managing its lifecycle and gives you somewhere to add
resource control or something.
The name of the class looks fine from the default, so lets leave that,
and im certain were making contributions to the UI, so that should be
checked.
If you are making a plugin thats just a resource like documentation then
you wont need this checked.
Click Next
Template
We'll do as the manual says and create a template, and we'll select
plugin with a view.
Click Next
Now we have to configure the class responsible for creating and managing
the view we actually want to work with.
The manual says to change the package back to the base package, but i
quite like it in its own package, so i leave that at the default.
Next we have to choose a name for the class, so if were intending to
make a log viewer, lets says so and call it : LogViewer
Now we can give it the name that appears under the category in the View
menu, lets use : Log Viewer
The next two boxes control our category information, which you will see
as a folder in the View menu.
Stick with the default ID, but i fancy giving it a nice name, so im
going to use : FreeFlash
The next bit doesnt matter too much for this demo (as in the manual
we'll just delete it all and replace it with something else, but its
worth having a look through it to get an idea of what youre dealing with)
But, we'll follow their advice and not add the view to the resource
perspective. (Untick the box)
Once ive got through this and understand it i'll have a look at creating
and configuring perspectives so we can combine our custom panels with
asdt / flashout / whatever in our own layouts which can be triggered by
choosing a .as file or similar.
:)
so, on we go, click next
Lets follow the instructions and not add any of these features, so
untick all the boxes, although they do look interesting, maybe next time.
so, click Finish, and you'll probably be asked to switch to the plug-in
development perspective, which is a good idea.
so, click Yes and we should see the plugin configuration panel.
Onto the next section, creating the view.
We want to use the SWT Browser in our view, and nothing else yet, so
we'll start with a skeleton view and add the browser code later.
so, open up the src folder and dig right down to the bottom where our
view class is. Open the .java file and either read it now, or delete
everything apart from the package declaration and carry on.
Now we have a nice clean file, paste in this code :
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.*;
public class LogViewer extends ViewPart
{
/**
* The constructor.
*/
public LogViewer()
{
}
/**
* This is a callback that will allow us
* to create the viewer and initialize it.
*/
public void createPartControl(Composite parent)
{
}
/**
* This is where we do something useful if we are bothered
* about the focus.
*/
public void setFocus()
{
}
}
right, so we'll need to create the browser in the createPartControl
method, kind of like an onLoad for our plugin view.
the SWT is just called browser, so with the minimum of typing lets do :
new and select the 'new' template
Browser b parent, SWT.WRAP
nice :)
now we get the lovely red cross on the side complaining about not
knowing what a Browser is and what SWT is, so click it and let it fill
in the imports with SWT and org.eclipse.swt.Browser.
so, make sure your problems panel is up and theres nothing in there for
this project (i often use the filter settings on the panel to just show
problems for the enclosing project)
Now we need to stick some content in the panel, so find where the swf
you want to use is on your hard drive and add the call to setUrl :
b.setUrl("file:///D:/Work/Dev/Flash/Tools/LogViewer.swf");
but with your own path of course :)
now save the file, and lets launch a test. The easy way to do this is
with a run-time workbench, basically another copy of eclipse but that
can run plugins and features you are developing. very handy. :)
So you should be able to drop the menu by the Run button, go to Run As..
and select Runtime Workbench
Another copy of eclipse should fire up.
In the runtime workbench, go to the Window menu, Show View -> Other, and
in the dialog you should find your new view with the names from earlier.
So mine has a FreeFlash folder and inside is the Log Viewer, double
click that and bingo (hopefully), a nice panel you can call home.
if you do have any problems, please read the help provided with eclipse
and check everything, i'll try and answer what i can, but this is all i
know :)
but do let me know if ive got something blatantly wrong.
thanks, martin