Open main menu

CDOT Wiki β

Teams Winter 2011/team1/RCP/Create RPC Application

Revision as of 15:45, 8 March 2011 by Ladanzahir (talk | contribs) (Add Model)

Create a RCP Application

This tutorial uses the ... Tutorial as reference.
In this tutorial we are going to demonstrate how to build a simple RCP application to maintain student's information. We keep the data in a List object and will not preserve data.

To begin with, we create a simple RCP from the "Hello World" RCP template. The will add our Model classes. Eventually we use perspective, view, Jface viewe and Commands, to display, edit, Add and Delete students' records.

Start The Application

Create a new plug-in project from File menu (File>New>Project>Plug-in Development> Plug-in project).
 

Name it: "cs.ecl.rcp.SimpleRCP"
 

Select "Yes" in responce to the question:" Would you like to create a rich client application?"
 

Select the "Hello RCP" in the Templates screen.
 

Un-check "Add branding".
 

The "RCP" project is created with some classes already in it. We will modify this project to create our RCP application for the purpose if this tutorial.
 

Run The Application

To run the application, right click on the project and select :Run As> Eclipse Application. Alternatively, you can click on the "Run an Eclipse Application" In the "Testing section of the project Overview window.  

At this point, the application starts and looks like this:
 

Add Model

Create Model Package

Add Model Class(s)

Student.java to true .

package cs.ecl.rcp.simplercp.model;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

public class Student {
    private String id;
    private String firstName;
    private String lastName;
    private String program;   
   
    private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
   
    public Student(){
    }
   
    public Student(String id, String firstName, String lastName, String program){
        super();
        this.id= id;
        this.firstName= firstName;
        this.lastName= lastName;
        this.program= program;
    }
   
   
    public void addPropertyChangeListener(String propertyName,PropertyChangeListener listener) {
        propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
    }
   
    public void removePropertyChangeListener(PropertyChangeListener listener) {
        propertyChangeSupport.removePropertyChangeListener(listener);
    }

    public String getId() {
        return id;
    }

    public String getFirstName() {
        return firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public String getProgram() {
        return program;
    }

   
   
    public void setId(String id) {
        propertyChangeSupport.firePropertyChange("id", this.id,
                this.id = id);
    }
   
    public void setFirstName(String firstName) {
        propertyChangeSupport.firePropertyChange("firstName", this.firstName,
                this.firstName = firstName);
    }
   
    public void setLastName(String lastName) {
        propertyChangeSupport.firePropertyChange("lastName", this.lastName,
                this.lastName = lastName);
    }
   
    public void setProgram(String program) {
        propertyChangeSupport.firePropertyChange("program", this.program,
                this.program = program);
    }
    public String toString() {
        return id +" "+firstName + " " + lastName + " "+ program ;
    }
}

Add Model Provider