Java Reference
In-Depth Information
selectionTreeEditorPart.setInput(getEditingDomain()
.getResourceSet());
} catch (PartInitException e) {
RequirementsEditorPlugin.INSTANCE.log(e);
}
// Removed all remaining pages original generated here
getSite().getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
setActivePage(0);
}
});
}
//. . .
}
Selection Handling
Before we clean up our RequirementsEditor class, we need to fix the selec-
tion handling we disrupted by splitting up the editor. MultiPageEditorPart
already provides a mechanism to handle selection changes, so we can refactor the
code to use it. We add a MultiPageSelectionProvider selection
Provider attribute to the class and initialize it in the constructor. We then set
this instance as the sitewide provider in the init() method, thereby eliminating
the need for the editor to implement ISelectionProvider . Changes are
in bold.
MultiPageSelectionProvider selectionProvider;
private int diagramPageIndex;
/**
* This creates a model editor.
* Modified to initialize selection provider.
*
* @generated NOT
*/
public RequirementsEditor() {
super();
initializeEditingDomain();
selectionProvider = new MultiPageSelectionProvider(this);
selectionProvider.addSelectionChangedListener(new
ISelectionChangedListener()
{
public void selectionChanged(SelectionChangedEvent event) {
setStatusLineManager(event.getSelection());
IEditorPart activeEditor = getSite().getPage().getActiveEditor();
if (selectionProvider.getMultiPageEditor().equals(activeEditor)
Search WWH ::




Custom Search