platform-ui-home/rcp-proposal/rcp_tutorial/tutorial1.html

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2, Wed Jan 14 02:52:29 2004 UTC revision 1.3, Tue Feb 17 16:20:38 2004 UTC
# Line 29  Line 29 
29  platform. This tutorial is designed to get you started building RCP applications  platform. This tutorial is designed to get you started building RCP applications
30  quickly.</p>  quickly.</p>
31  <p><b>By Ed Burnette, SAS Institute Inc.</b><br>  <p><b>By Ed Burnette, SAS Institute Inc.</b><br>
32  <font size="-1">January 2, 2004 - Updated for 3.0M6, removed plug-in class</font></p>  <font size="-1">February 16, 2004 - Updated for 3.0M7</font></p>
33  <p><i>Note that Eclipse 3 is undergoing constant change so the steps you need to  <p><i>Note that Eclipse 3 is undergoing constant change so the steps you need to
34  take, the APIs, and the results may vary slightly (or not so slightly) from this  take, the APIs, and the results may vary slightly (or not so slightly) from this
35  description.</i></p>  description.</i></p>
# Line 55  Line 55 
55  <h2><a name="section_1"></a> Getting started</h2>  <h2><a name="section_1"></a> Getting started</h2>
56  <p>RCP applications are based on the familiar Eclipse plug-in architecture, (if  <p>RCP applications are based on the familiar Eclipse plug-in architecture, (if
57  it's not familiar to you, see the references section). Therefore, you'll need to  it's not familiar to you, see the references section). Therefore, you'll need to
58  create a plug-in to be your main program. Select New &gt; Project &gt; Plug-in  create a plug-in to be your main program.
59    Select New &gt; Project &gt; Plug-in
60  Development &gt; Plug-in Project to bring up the Plug-in Project wizard. On the  Development &gt; Plug-in Project to bring up the Plug-in Project wizard. On the
61  subsequent pages, enter a Project name such as <b>org.eclipsepowered.rcptutorial1</b>,  subsequent pages, enter a Project name such as <b>org.eclipsepowered.rcptutorial1</b>,
62  and a Plug-in Id (this should match the project name). On the Code Generators  indicate you want a Java project, and
63  page, select the Default Plug-in Structure, then click Next and Finish to  enter a Plug-in Id (this should match the project name).
64  generate the template.</p>  </p>
65  <h2>The plug-in class</h2>  <p>
66  <p>The generated plug-in class that you may be familiar with in previous  The generated plug-in class that you may be familiar with in previous
67  releases is no longer required in Eclipse 3.0.  releases is no longer required in Eclipse 3.0.
68  You can still have one to hold global data if you like, but for this  You can still have one to hold global data if you like, but for this
69  example you can just remove it altogether to save a little space.  example just remove it altogether to save a little space.
70  Right click on the plug-in java file (in our example this is called  To do this, turn off the option that says
71  RcpTutorial1Plugin.java) and delete it.  Generate the Java class that controls the plug-ins life cycle.
72  </p>  Then Click on Finish to
73    generate the template.</p>
74  <h2>The main program</h2>  <h2>The main program</h2>
75  <p>The main program implements IPlatformRunnable, which just has a method called  <p>The main program for an application implements <code>IPlatformRunnable</code>,
76  run(). Listing 1 shows a simple implementation that shows you the minimum you have to  which just has a method called
77    <code>run()</code>.
78    Listing 1 shows a simple implementation that shows you the minimum you have to
79  do.</p>  do.</p>
80  <p><b>Listing 1. RcpApplication class.  <p><b>Listing 1. RcpApplication class.
81  </b></p>  </b></p>
# Line 99  Line 103 
103  <h2>Creating a default perspective</h2>  <h2>Creating a default perspective</h2>
104  <p>  <p>
105  Next, you must define at least one perspective and make it the default.  Next, you must define at least one perspective and make it the default.
106  Perspectives are created by implementing IPerspectiveFactory (see listing 2).  Perspectives are created by implementing <code>IPerspectiveFactory</code> (see listing 2).
107  The important part  The important part
108  of this interface is the createInitialLayout() method where you position and  of this interface is the <code>createInitialLayout()</code> method where you position and
109  open any views and/or editors you'd like the user to start with.  open any views and/or editors you'd like the user to start with.
110  In this example  In this example
111  we're not going to create any views so it will be a pretty boring perspective.  we're not going to create any views so it will be a pretty boring perspective.
# Line 150  Line 154 
154  </pre>  </pre>
155  <h2>Plug-in manifest</h2>  <h2>Plug-in manifest</h2>
156  <p>As usual, the plug-in manifest, plugin.xml, ties everything together.  <p>As usual, the plug-in manifest, plugin.xml, ties everything together.
 <i>Note: Future builds of 3.0 will likely change this further.</i>  
157  The class name in  The class name in
158  the plugin tag refers to the plug-in class we deleted earlier,  the plugin tag refers to the plug-in class we deleted earlier,
159  so you should remove the reference too.  so you should remove the reference too.
160  The main program  The main program
161  class name is defined with the org.eclipse.core.runtime.applications extension  class name is defined with the <code>org.eclipse.core.runtime.applications</code> extension
162  and the perspective with org.eclipse.ui.perspectives.  and the perspective with <code>org.eclipse.ui.perspectives</code>.
 Note you have to manually edit the <code>runtime</code> section to take out  
 the reference to org.eclipse.core.resources and add  
 org.eclipse.core.runtime.compatibility  
 in current builds.  
163  When you're done you should have something that looks like listing 4.  When you're done you should have something that looks like listing 4.
164  </p>  </p>
165    
# Line 241  Line 240 
240  Run &gt; Debug &gt; Debug As &gt; Run-time Workbench. Go ahead and try that now.  Run &gt; Debug &gt; Debug As &gt; Run-time Workbench. Go ahead and try that now.
241  It will give you a full blown Eclipse IDE Workbench window because we haven't  It will give you a full blown Eclipse IDE Workbench window because we haven't
242  overridden the application name - it is still defaulting to the IDE application.  overridden the application name - it is still defaulting to the IDE application.
243    </p>
244    <p>
245  To fix this, edit the launch configuration you just created (select Run &gt;  To fix this, edit the launch configuration you just created (select Run &gt;
246  Debug &gt; Debug..., and then select New_Configuration or create a new one). In  Debug &gt; Debug..., and then select New_Configuration or create a new one). In
247  the Arguments tab, add this to the end of the Program Arguments:</p>  the Arguments tab, select <code>org.eclipsepowered.rcptutorial1.RcpApplication</code>
248  <pre>  for the Application name.
249     -application org.eclipsepowered.rcptutorial1.RcpApplication  This comes from the id specified on the
250  </pre>  <code>org.eclipse.core.runtime.applications</code> extension point
251  <p>This name comes from the id specified on the  (in this example, <code>RcpApplication</code>), prepended with the
252  org.eclipse.core.runtime.applications extension point.</p>  plug-in id (<code>org.eclipsepowered.rcptutorial1</code>).
253    </p>
254  <p>Now switch over to the Plug-ins and Fragments tab. Select the option to  <p>Now switch over to the Plug-ins and Fragments tab. Select the option to
255  Choose plug-ins and fragments, and select the following plug-ins. This is  Launch with this plug-in and all of its pre-requisites.
256  currently the absolute minimum that will work for a GUI RCP program.  Enter the plug-in id (<code>org.eclipsepowered.rcptutorial1</code>)
257  <i>Note: Future builds of 3.0 will likely change this further.</i>  and press Debug. You should see a bare-bones Workbench start up (see figure 1).</p>
 </p>  
 <ul>  
   <li>org.eclipse.core.runtime  
   <li>org.eclipse.core.runtime.compatibility  
   <li>org.eclipse.help  
   <li>org.eclipse.jface  
   <li>org.eclipse.osgi  
   <li>org.eclipse.osgi.services  
   <li>org.eclipse.osgi.util  
   <li>org.eclipse.swt  
   <li>org.eclipse.swt.win32  
   <li>org.eclipse.ui  
   <li>org.eclipse.ui.workbench  
   <li>org.eclipse.update.configurator  
   <li>org.eclipsepowered.rcptutorial1  
 </ul>  
 <p>Now press Debug. You should see a bare-bones Workbench start up (see figure 1).</p>  
258    
259  <p><b>Figure 1. World's simplest RCP application.  <p><b>Figure 1. World's simplest RCP application.
260  </b></p>  </b></p>
261  <img src="images/spin.jpg" width="406" height="269">  <img src="images/spin.png" width="404" height="270">
262    
263  <p>If you don't see this, you should be able to find an error message in the  <p>If you don't see this, you should be able to find an error message in the
264  run-time workbench's .log file (runtime-workspace/.metadata/.log). Simply bring  run-time workbench's .log file (runtime-workspace/.metadata/.log). Simply bring
265  it up in a text editor and look for the most recent errors. You may find it  it up in a text editor and look for the most recent errors. You may find it
266  useful to delete the .log file before running the program so you won't get  useful to delete the .log file before running the program so you won't get
267  confused by older messages.</p>  confused by older messages.</p>
268    <p>
269    <img src="images/tip.gif" alt="Tip: " width="62" height="13">
270    Specify the <code>-consoleLog</code> option
271    in the Arguments tab under Program Arguments to have all error messages
272    sent to the Console. This is easier than searching around for the .log file.
273    </p>
274    
275  <h2>Running it outside of Eclipse</h2>  <h2>Running it outside of Eclipse</h2>
276  <p>The whole point of all this is to be able to run stand-alone applications  <p>The whole point of all this is to be able to run stand-alone applications
# Line 306  Line 297 
297    and populate the directory for you.    and populate the directory for you.
298  </ol>  </ol>
299  <p>To complete the RcpTutorial1 directory, copy the startup.jar file from the Eclipse  <p>To complete the RcpTutorial1 directory, copy the startup.jar file from the Eclipse
300  install directory into the top level, and copy the other org.eclipse plug-ins  install directory into the top level, and copy all the org.eclipse plug-ins
301  from the list of required plug-ins above into the plugins directory. When you're  that are required into the plugins directory.
302    </p>
303    <p>
304    Which ones are required, you ask?
305    You can find out by right-clicking on the project and selecting
306    PDE Tools > Open Dependencies.
307    Add all the plug-ins listed there, including all the ones they depend on (you can
308    see the list by fully expanding the tree).
309    </p>
310    <p>
311    When you're
312  done you should have a structure that looks like this:</p>  done you should have a structure that looks like this:</p>
313  <pre>  <pre>
314          RcpTutorial1          RcpTutorial1
# Line 329  Line 330 
330  </pre>  </pre>
331  <p>That's all you need to run an RCP application, but it would be difficult for  <p>That's all you need to run an RCP application, but it would be difficult for
332  anyone to use it without some kind of launching program. Eclipse uses  anyone to use it without some kind of launching program. Eclipse uses
333  eclipse.exe, but we'll just use a batch file. Create a Windows command file  eclipse.exe, but for this example we'll just use a batch file.
334    Create a Windows command file
335  called rcptutorial1.cmd and place it in the top level RcpTutorial1 directory. A Unix shell  called rcptutorial1.cmd and place it in the top level RcpTutorial1 directory. A Unix shell
336  script version would be similar.  script version would be similar.
337  <pre>  <pre>
# Line 371  Line 373 
373  double-clicking on your new shortcut to try it out. You may want to edit the  double-clicking on your new shortcut to try it out. You may want to edit the
374  shortcut (right click on it and select Properties) to change the default working  shortcut (right click on it and select Properties) to change the default working
375  directory.</p>  directory.</p>
376    <p>
377    <img src="images/tip.gif" alt="Tip: " width="62" height="13">
378    For fully branding a program with a splash screen, custom icons, and so forth
379    you'll need to define a primary feature, some configuration files, and use
380    the eclipse.exe launcher.
381    See the online help under Platform Plug-in Developer Guide >
382    Programmer's Guide > Packaging and delivering Eclipse based products
383    for more information.
384    </p>
385    
386  <h2>Conclusion</h2>  <h2>Conclusion</h2>
387  <p>In part 1 of this tutorial, we looked at what is necessary to create a  <p>In part 1 of this tutorial, we looked at what is necessary to create a
388  bare-bones Rich Client application. The next part will delve into customizations  bare-bones Rich Client application. The next part will delve into customizations

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3