Changes

Jump to: navigation, search

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

1,202 bytes added, 13:31, 9 March 2011
Run your app with view(s)
<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 | 400px]]<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/>
==== 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/>
Add the following code to add view to the perspective. we also are making the view non-closeable, so that user cannot close it.
<code>Perspective.java</code>
<source lang="java">
package cs.ecl.rcp.simplercp;
import org.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>
 
==== Run your app with view(s)====
Run the project now. Here is what you will see:
<br/>
[[Image: RCPView5RCPView7.jpg | 700px400px]]<br/> 
<br/>
[[Image: RCPView6.jpg Teams_Winter_2011/team1| 700pxIndex Page]]<br &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [[Teams_Winter_2011/team1/RCP/Define_and_use_editors| Next><br/>[[Image: RCPView7.jpg | 700px]]<br/>==== Run your app with view(s)====
1
edit

Navigation menu