@Override public void dispose() { editor.getSelectedElementField().removeListener(structureListener); editor.getStructureField().removeListener(structureListener); super.dispose(); }
public static void revealInEditor(IEditorPart part, StructureElement element) { if (element == null || part == null) return; if (part instanceof AbstractLangStructureEditor) { ((AbstractLangStructureEditor) part).setElementSelection(element); return; } if (part instanceof ITextEditor) { AbstractLangStructureEditor.setElementSelection((ITextEditor) part, element); return; } }
/** * Note: createControl/dispose can be called multiple times per receiver lifetime. (it's a bit * unusual/strange for a control to allow that, but it's helpfull if LangOutlinePage works like * that) */ @Override public void createControl(Composite parent) { super.createControl(parent); getTreeViewer().setContentProvider(new StructureElementContentProvider()); getTreeViewer().setLabelProvider(StructureElementLabelProvider.createLangLabelProvider()); customizeCreateControl(); editor.getStructureField().registerListener(structureListener); editor.getSelectedElementField().registerListener(structureListener); updateTreeViewer(); }
protected void updateSelectionFromEditor() { StructuredSelection newSelection = editor.getSelectedElementAsStructureSelection(); try { updatingFromEditor = true; getTreeViewer().setSelection(newSelection, true); } finally { updatingFromEditor = false; } }
@Override protected void treeViewerPostSelectionChanged(SelectionChangedEvent event) { Object firstElement = ((IStructuredSelection) event.getSelection()).getFirstElement(); if (firstElement instanceof StructureElement) { StructureElement structureElement = (StructureElement) firstElement; if (!updatingFromEditor) { editor.setElementSelection(structureElement); } } super.treeViewerPostSelectionChanged(event); }
protected void updateTreeViewer() { if (getTreeViewer() == null) { return; } SourceFileStructure structure = editor.getSourceStructure(); if (getTreeViewer().getInput() != structure) { getTreeViewer().setInput(structure); getTreeViewer().refresh(); } updateSelectionFromEditor(); }