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

From CDOT Wiki
Jump to: navigation, search
Line 31: Line 31:
 
[[Image: PluginXml.png | 400px]]<br/>
 
[[Image: PluginXml.png | 400px]]<br/>
 
2.2 Specify the id ''cs.ecl.simpleRCP.perspective'', name ''RCP Perspective'' and class ''cs.ecl.rcp.simplercp.Perspective'':<br/>
 
2.2 Specify the id ''cs.ecl.simpleRCP.perspective'', name ''RCP Perspective'' and class ''cs.ecl.rcp.simplercp.Perspective'':<br/>
[[Image: PluginXml2.png | 700px]]<br/>
+
[[Image: PluginXml2.png | 800px]]<br/>
 
2.3 Click on the <code>class*</code> link to create a class. The method <code>createInitialLayout()</code> in this class is responsible for creating the new perspective.
 
2.3 Click on the <code>class*</code> link to create a class. The method <code>createInitialLayout()</code> in this class is responsible for creating the new perspective.
 
2.4 The perspective is defined but not yet reachable via the application. To activate the switch between perspectives add the following line to the<br/> <code>ApplicationWorkbenchWindowAdvisor.java</code> in method preWindowOpen():<br/>
 
2.4 The perspective is defined but not yet reachable via the application. To activate the switch between perspectives add the following line to the<br/> <code>ApplicationWorkbenchWindowAdvisor.java</code> in method preWindowOpen():<br/>

Revision as of 11:30, 4 March 2011

1. Adding status line

1.1 Open ApplicationWorkbenchWindowAdvisor.java file in your project and add the following line at the end of preWindowOpen() method:

configurer.setShowStatusLine(true); 

1.2 Add a new method to this class to set text in status line from different parts of application:

  
   @Override
   public void postWindowOpen() {
      IStatusLineManager statusline = getWindowConfigurer().getActionBarConfigurer().getStatusLineManager();
      statusline.setMessage(null, "Status line is ready");
   }
 

1.3 Run the application you should see the following:
StatusLine.png
1.4 Change the status line from StudentsView.java. Add the following method to this class:

   private void setStatusLine(String message) {
        // Get the status line and set the text
        IActionBars bars = getViewSite().getActionBars();
        bars.getStatusLineManager().setMessage(message);
    }
 

Use this method to change text in status line. In the createColumn() method insert the following line at the end of column's update() method:</br>

setStatusLine("Student search has been updated");

1.5 Run the application and try to use Search to find a student. You should get the following:
StatusLine2.png
1.6 To access status line from the editor use the following line:

IEditorPart.getEditorSite().getActionBars();

2. Adding a perspective

2.1 Add necessary extensions to the plugin.xml:
PluginXml.png
2.2 Specify the id cs.ecl.simpleRCP.perspective, name RCP Perspective and class cs.ecl.rcp.simplercp.Perspective:
PluginXml2.png
2.3 Click on the class* link to create a class. The method createInitialLayout() in this class is responsible for creating the new perspective. 2.4 The perspective is defined but not yet reachable via the application. To activate the switch between perspectives add the following line to the
ApplicationWorkbenchWindowAdvisor.java in method preWindowOpen():

configurer.setShowPerspectiveBar(true);

2.5 Run the application. You should be able to select your perspective interactively:
Perspective1.png