Changes

Jump to: navigation, search

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

926 bytes added, 19:23, 4 March 2011
3. Define and Use Editors
</source>
3.4.2 Add a "double click" event to the <code>StudentsView</code> class <br/>
For this, we need to add <code>doubleClick</code> method to the </code>StudentsView.java </code>:
 
<source lang=java>
 
private void hookDoubleClickCommand() {
viewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
IHandlerService handlerService = (IHandlerService) getSite()
.getService(IHandlerService.class);
try {
handlerService.executeCommand(
"cs.ecl.rcp.simplercp.openEditor", null);
} catch (Exception ex) {
throw new RuntimeException(
"cs.ecl.rcp.simplercp.openEditor not found");
}
}
});
 
}
</source>
We will call this command from <code>''createPartControl()''</code> method.
<source lang=java>
 
// add double click listener for editing fields in a text editor
viewer.setInput(ModelProvider.INSTANCE.getStudents());
getSite().setSelectionProvider(viewer);
</source>
hookDoubleClickCommand();
1
edit

Navigation menu