Difference between revisions of "Teams Winter 2011/team1/RCP/Define and use editors"

From CDOT Wiki
Jump to: navigation, search
Line 1: Line 1:
=== 1. Show Data in Application ===
 
1.1 Columns data in a JFace table can be hold in <code>ModelProvider</code> and it is defined via instances of <code>TableViewerColumn</code>object:<br/>
 
<code>viewer.setInput(ModelProvider.INSTANCE.getStudents());</code><br/>
 
and
 
<code>TableViewerColumn col = createTableViewerColumn(titles[0], bounds[0], 0);</code>
 
1.2 Add the following lines to <code>StudentsView.java</code> class:<br/>
 
Private variable: <br/>
 
<code>private TableViewer viewer;</code><br/>
 
Change the <code>createColumns()method:<br/>
 
<pre>
 
  String[] titles = { "Id", "First name", "Last name", "Program" };
 
</pre>
 
 
 
 
=== 3. Define and Use Editors ===
 
=== 3. Define and Use Editors ===
  

Revision as of 17:47, 4 March 2011

3. Define and Use Editors

3.1 Editor area

The first step to add editor area to the application is to make the editor area visible.

public class Perspective implements IPerspectiveFactory {

	public void createInitialLayout(IPageLayout layout) {
		
		layout.setEditorAreaVisible(true);
		layout.addView(StudentsView.ID, IPageLayout.LEFT, 1.0f, layout.getEditorArea());
		//make the view fixed
		layout.setFixed(true);
		//make the view non-closeable
		layout.getViewLayout(StudentsView.ID).setCloseable(false);
		
	}
}

3.1 Create editor

   String[] titles = { "Id", "First name", "Last name", "Program" };

3.2 Set command for opening the editor