Open main menu

CDOT Wiki β

Changes

Teams Winter 2011/team1/RCP/Define and use commands

1,382 bytes added, 13:31, 9 March 2011
Run your app with view(s)
Click on the Extensions tab in the plugin.xml window in the project and add a new Extension Point as "org.eclipse.ui.views".
<br/>
[[Image: RCPView3.jpg | 700px400px]]<br/>
<br/>
Right click on the newly added Extension Point and choose: New > View.<br/>
<br/>
Double click on the class link and the New Java Class window will open. Notice that the StudentView class is a subclass of "org.eclipse.ui.part.ViewPart" class.<br/>
 [[Image: RCPView1.jpg | 700px400px]]<br/><br/>Go to the project in project explorer and find the StudentView in the "cs.ecl.rcp.simplercp" package in the src folder. Here is how it looks like ( we added a text to this view).
<br/>
[[Image: RCPView2.jpg | 700px]]<br/>
==== Add view(s) to perspective via code ====Now we have to add our view to the perspective.We could do this in Extensions window, but here we want to show you how to do it programmatically.<br/>Find the "Perspective" class in src folder of your project in the "cs.ecl.rco.simplercp" package.Here is how it looks like:<br/>
[[Image: RCPView5.jpg | 700px]]<br/>
<br/>
[[Image: RCPView6Add the following code to add view to the perspective.jpg | 700px]]we also are making the view non-closeable, so that user cannot close it.<code>Perspective.java<br/code><br/source lang="java">[[Image: RCPView7package cs.ecl.rcp.simplercp; import org.jpg | 700px]]<br/>eclipse.ui.IPageLayout;import org.eclipse.ui.IPerspectiveFactory;  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);
}
}
</source>
==== Add view(s) to perspective via code ====
==== Run your app with view(s)====
Run the project now. Here is what you will see:
<br/>
[[Image: RCPView7.jpg | 400px]]<br/>
 
<br/>
[[Teams_Winter_2011/team1| Index Page]] &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [[Teams_Winter_2011/team1/RCP/Define_and_use_editors| Next>>]]
1
edit