Introduction
The Eclipse Platform allows you to view the files
comprising a system, to modify these files, and to run
a program. This demo will give you a quick tour of
the functionalities you need to know to carry out this
study.
Perspectives
The Eclipse graphical user
interface (or Workbench), can be organized into
various perspectives. A Perspective is simply
a pre-determined set of views. For this study, you
will only use the Java Perspective. A
perspective tool bar is on the left of the Eclipse
Workbench. To open the Java perspective, click on the
top button and select Java Perspective, or,
alternately, click on the Java perspective shortcut
button. You can also use the general menu: select
Window | Open Perspective, and
select the Java Perspective.
By default, the Java perspective includes four views:
The package explorer (on the left), the editor (in the
middle), the outline view (on the right), and the
tasks view (on the bottom). If at any point your
views get mixed up, you can come back to the default
Java perspective by selecting the menu Window
| Reset Perspective. However, it is not
recommended to do this as some short cuts which are
preset for this study will be removed. The package
explorer, editor, and task views will be explained in
detail as part of this demo. The outline view will
not be used in this study. You should close the view
by clicking on the X in the top right corner, and
refrain from using it during the study.
To open or close individual views, use the menu and select Window | Show View.
To close all the editors, use the menu and select File | Close All.
Tutorial
- Close the Java perspective (right-click on the
button with the 'J' in its icon, in the left tool bar, and select close.
- Open the Java perspective (in the same tool bar,
click on the button with the 'plus' in its icon.
Choose Java from the menu.
- Close the Outline view.
- Close all the editors.
- Close the package explorer.
- Open the package explorer (In the workbench menu,
select Window | Show View | Packages. You
might have to close the hierarchy view to reveal the
package view).
Package Explorer
The Package Explorer contains the structure and files
of the system you are to modify. In this demo, we use
the example system JHotDraw 5.3. The top-level node
in the package explorer is the the project:
JHotDraw5.3. Clicking on the plus sign expands the
project to reveal its various components: in this case
a single source directory. Double-clicking on the
source directory (or clicking on the corresponding
plus sign) will reveal all the packages and source
directories which constitute the system. The package
directories contain java files, and the other
directories contains other source files such as icons.
If you expand the CH.ifa.draw.figures
package, a collection of Java source objects will
appear. There are various actions you can perform on
Java files. Double-click on the
ArrowTip.java object. The code for this file
should appear in the editor. You can also expand an
object. Expand the ArrowTip.java object.
This will reveal the internal structure of the object,
in this case, an import declarations node and the
ArrowTip class. Expand the ArrowTip
class. You will see the class members. A red square
indicates a private member, a yellow diamond a
protected member, a blue triangle a default member,
and a green circle a public member. Clicking on a
member will show the declaration of this member in the
editor.
To create a new element in the package explorer, right-click on a package a select New.
Tutorial
- Show the CH.ifa.draw.applet.DrawApplet.java file in the Editor.
- Display the fDrawing field in the window.
- Create a new class Test in the package CH.ifa.draw.contrib.
Editor
The editor lets you change a file. Modifications in a Java file are automaticaly compiled in the
project when a file is saved. To save a file in the editor, type Ctrl-S, or use the File menu. If
file contains compilation errors, they will automatically be indicated in the editor. Errors for which
a suggestion is available are indicated on the left side bar with a yellow light bulb.
Clicking on the light bulb will reveal a set of possible corrections. Otherwise, the error will be
indicated with a red X. All errors also appear in the task view, in at the bottom of the screen.
Clicking on a task in the task view will show the corresponding part in the code which needs to be addressed.
The side bar on the right of the editor contains bookmarks for the various errors.
The editor also supports an auto-completion feature. When an identifier is partially typed, typing Ctrl-Spacebar
will attempt to complete the identifier. Ctrl-Spacebar after a type name will attempt to enter an
import declaration for this name.
Tutorial
- Open ArrowTip.java.
- Change
getAngle() to getAngleX().
- Observe the different errors and bookmarks. Click
on the errors in the Tasks view to go to the
corresponding location in the editor. Use the
bookmarks in the right side bar to navigate to the
locations of the errors.
- Make a new
TextFigure object in the ArrowTip
constructor to show the autocomplete.
Search
It is possible to search for the references and
declarations to a class or class member, either from
the package explorer, or through a search menu. To
start a general search, select Search from
the menu, then click on the Java Search tab.
The results of the search will be displayed in a view
below the editor. Clicking on a search result will
display the corresponding code in the editor.
Right-clicking on a search result will allow you to
perform new searches, for the references or
declarations of the search result element.
It is also possible to launch a search from the
package explorer. Right-click on an element and
select references or declarations, and then Workspace. This will produce
a list of all the elements in the workspace referring
to the selected element.
Tutorial
- Search for all Text* class declarations.
- Sort by parent name (Right-click in the search
results view, and select Sort by | Parent Name.
- Search for references to class
TextHolder: Right-click on
TextHolder in the search results view, and
select References | Workspace.
- Display a few of them in the editor.
- Obtain all the methods accessing the field
CH.ifa.draw.figures.TextTool.fTypingTarget
(in the search results or in the package explorer,
right-click on the field, and select References | Workspace.
- Display the field accesses by double-clicking on
the search results.
- Remove all searches by clicking on the 5th icon
from the left in the search results tool bar.
Running a program
You run a compiled program by launching it through the run button on the menu, or through the Run | Run...
menu. The configuration for the program you will need to execute will be pre-set for you.
Tutorial
- Run the JHotDraw5.3 configuration.