Changes

Jump to: navigation, search

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

1,095 bytes added, 19:19, 4 March 2011
3. Define and Use Editors
We add a command to the <code>''commands''</code> extension as it is explained in [[Teams_Winter_2011/team1/RCP/Define_and_use_commands |part 2 ]] of this tutorial.<br/>
[[Image: rcp_editor4.png | 700px]]<br/>
 
Here is how the <code>''callEditor''</code> class looks like:
 
<source lang=java>
 
public class callEditor extends AbstractHandler {
 
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
//System.out.println("called");
// Get the view
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
IWorkbenchPage page = window.getActivePage();
StudentsView studentsView = (StudentsView) page.findView(StudentsView.ID);
// Get the selection
ISelection selection = studentsView.getSite().getSelectionProvider()
.getSelection();
if (selection != null && selection instanceof IStructuredSelection) {
Object obj = ((IStructuredSelection) selection).getFirstElement();
// If we had a selection lets open the editor
if (obj != null) {
Student student = (Student) obj;
MyStudentEditorInput input = new MyStudentEditorInput(
student.getId());
try {
page.openEditor(input, MyStudentEditor.ID);
 
} catch (PartInitException e) {
throw new RuntimeException(e);
}
}
}
return null;
}
 
}
</source>
3.4.2 Add a "double click" event to the <code>StudentsView</code> class <br/>
1
edit

Navigation menu