Java Reference
In-Depth Information
public void
createPartControl(Composite parent) {
viewer =
new
TreeViewer(parent, SWT.MULTI);
viewer.setContentProvider(
new
AdapterFactoryContentProvider(getAdapterFactory()));
viewer.setLabelProvider(
new
AdapterFactoryLabelProvider(getAdapterFactory()));
viewer.setSelection(
new
StructuredSelection(getEditingDomain().getResourceSet()
.getResources().get(0)),
true
);
getEditorSite().setSelectionProvider(viewer);
new
AdapterFactoryTreeEditor(viewer.getTree(),
getAdapterFactory());
createContextMenuFor(viewer);
}
public void
setFocus() {
viewer.getTree().setFocus();
}
}
We can refactor the
RequirementsEditor.createPages()
method now
to use our
SelectionTreeEditorPart
class. As mentioned, we eliminate all
but one of the standard EMF-generated pages, including the parent tree view,
which means that we can eliminate the inner
ReverseAdapter
FactoryContentProvider
class altogether. Following is our
createPages()
method, which initializes the
selectionTreeEditorPart
class attribute that
we'll add to the class. We'll return to this method to add our diagram page later.
/**
* This is the method used by the framework to install your controls.
* Modified to include diagram page and use standalone
* EditorPart classes for each page.
*
* @generated
NOT
*/
@Override
public void
createPages() {
// Creates the model from the editor input
createModel();
// Only creates the other pages if there is something to be edited
if
(!getEditingDomain().getResourceSet().getResources().isEmpty()
&& !(getEditingDomain().getResourceSet().getResources().get(0))
.getContents().isEmpty()) {
try
{
int
pageIndex;
// Create selection tree viewer page
selectionTreeEditorPart = new SelectionTreeEditorPart(this);
pageIndex = addPage(selectionTreeEditorPart, getEditorInput());
setPageText(pageIndex, getString("_UI_SelectionPage_label"));
Search WWH ::
Custom Search