Changes

Jump to: navigation, search

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

1,024 bytes added, 13:28, 9 March 2011
Define Views in The Application
==== 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>
<br/>==== Run your app with view(s)====[[Image: RCPView5Run the project now.jpg | 700px]]<br/><br/>[[ImageHere is what you will see: RCPView6.jpg | 700px]]<br/>
<br/>
[[Image: RCPView7.jpg | 700px]]<br/>
==== Run your app with view(s)====
1
edit

Navigation menu