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

From CDOT Wiki
Jump to: navigation, search
(Add a Command (Print Students) to Your Project)
(Add a Command (Print Students) to Your Project)
Line 4: Line 4:
  
 
Double click on the plugin.xml file of your project in the project explorer view, and then navigate to "Extentions" tab in the project overview window.<br/>
 
Double click on the plugin.xml file of your project in the project explorer view, and then navigate to "Extentions" tab in the project overview window.<br/>
[[Image: RCPCommand1.jpg | 400px]]<br/>
+
[[Image: RCPCommand1.jpg |500px]]<br/>
 
<br/>
 
<br/>
 
Click on "Add" button to add a new extension and add the extension point "org.eclipse.ui.commands" (do not select any template) and click on Finish buttton.<br/>
 
Click on "Add" button to add a new extension and add the extension point "org.eclipse.ui.commands" (do not select any template) and click on Finish buttton.<br/>
Line 10: Line 10:
 
<br/>
 
<br/>
 
Right click on the added extention point and select command from the New menu, to add a command to your commands.<br/>
 
Right click on the added extention point and select command from the New menu, to add a command to your commands.<br/>
[[Image: RCPCommand3.jpg | 400px]]<br/>
+
[[Image: RCPCommand3.jpg | 500px]]<br/>
 
<br/>
 
<br/>
 
select the command and in "Extention Element Details" section, set the id of the command as "cs.rcp.simpleRCP.commands.print". Also name the command "Print", and set the defaultHandler class to be "cs.ecl.rcp.simpleRCP.commands.PrintHandler. Save the file (Ctrl+S).
 
select the command and in "Extention Element Details" section, set the id of the command as "cs.rcp.simpleRCP.commands.print". Also name the command "Print", and set the defaultHandler class to be "cs.ecl.rcp.simpleRCP.commands.PrintHandler. Save the file (Ctrl+S).
[[Image: RCPCommand4.jpg | 400px]]<br/>
+
[[Image: RCPCommand4.jpg | 500px]]<br/>
 
<br/>
 
<br/>
[[Image: RCPCommand5.jpg | 400px]]<br/>
+
[[Image: RCPCommand5.jpg | 500px]]<br/>
 
<br/>
 
<br/>
[[Image: RCPCommand6.jpg | 400px]]<br/>
+
[[Image: RCPCommand6.jpg | 500px]]<br/>
 
<br/>
 
<br/>
[[Image: RCPCommand7.jpg | 400px]]<br/>
+
[[Image: RCPCommand7.jpg | 500px]]<br/>
 
<br/>
 
<br/>
[[Image: RCPCommand8.jpg | 400px]]<br/>
+
[[Image: RCPCommand8.jpg | 500px]]<br/>
 
<br/>
 
<br/>
[[Image: RCPCommand9.jpg | 400px]]<br/>
+
[[Image: RCPCommand9.jpg | 500px]]<br/>
 
<br/>
 
<br/>
 
[[Image: RCPCommand10.jpg | 400px]]<br/>
 
[[Image: RCPCommand10.jpg | 400px]]<br/>

Revision as of 19:44, 8 March 2011

Define And Use Commands

In order to be able to take advantages of user invoked operations and menus in the RCP application we create Commands and add them to menus. For this purpose we will demonstrate here how to create a "Print Students" command, which prints the student's info in the console and then add that command to the top bar menu. Then later, we demonstrate how to implement other commands like "Add Student", "Delete Student" and "Exit" to the top bar.

Add a Command (Print Students) to Your Project

Double click on the plugin.xml file of your project in the project explorer view, and then navigate to "Extentions" tab in the project overview window.
RCPCommand1.jpg

Click on "Add" button to add a new extension and add the extension point "org.eclipse.ui.commands" (do not select any template) and click on Finish buttton.
RCPCommand2.jpg

Right click on the added extention point and select command from the New menu, to add a command to your commands.
RCPCommand3.jpg

select the command and in "Extention Element Details" section, set the id of the command as "cs.rcp.simpleRCP.commands.print". Also name the command "Print", and set the defaultHandler class to be "cs.ecl.rcp.simpleRCP.commands.PrintHandler. Save the file (Ctrl+S). RCPCommand4.jpg

RCPCommand5.jpg

RCPCommand6.jpg

500px

RCPCommand8.jpg

RCPCommand9.jpg

RCPCommand10.jpg

RCPCommand11.jpg

RCPCommand12.jpg

RCPCommand13.jpg

RCPCommand14.jpg

RCPCommand15.jpg

RCPCommand16.jpg

Implement The Command Handler

Use The Command in The Menu

Add Other Necessary Commands to The Application

"Exit" Command

"Delete Student" Command

"Add Student" Command

Define Views in The Application

Create Views

Add view(s) to perspective via code

Run your app with view(s)