diff options
Diffstat (limited to 'rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/outline/SpecfileContentOutlinePage.java')
-rw-r--r-- | rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/outline/SpecfileContentOutlinePage.java | 160 |
1 files changed, 80 insertions, 80 deletions
diff --git a/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/outline/SpecfileContentOutlinePage.java b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/outline/SpecfileContentOutlinePage.java index b78a14f1de..e4a50595fa 100644 --- a/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/outline/SpecfileContentOutlinePage.java +++ b/rpm/org.eclipse.linuxtools.rpm.ui.editor/src/org/eclipse/linuxtools/internal/rpm/ui/editor/outline/SpecfileContentOutlinePage.java @@ -25,85 +25,85 @@ import org.eclipse.ui.views.contentoutline.ContentOutlinePage; public class SpecfileContentOutlinePage extends ContentOutlinePage { - private ITextEditor editor; - private IEditorInput input; - - public SpecfileContentOutlinePage(SpecfileEditor editor) { - super(); - this.editor = editor; - } - - public void setInput(IEditorInput editorInput) { - this.input = editorInput; - update(); - } - - public void update() { - //set the input so that the outlines parse can be called - //update the tree viewer state - final TreeViewer viewer = getTreeViewer(); - - if (viewer != null) - { - final Control control = viewer.getControl(); - if (control != null && !control.isDisposed()) - { - control.getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - if (!control.isDisposed()) { - control.setRedraw(false); - if (input != null) { - viewer.setInput(input); - } - viewer.expandAll(); - control.setRedraw(true); - } - } - }); - } - } - } - - @Override - public void createControl(Composite parent) { - - super.createControl(parent); - - TreeViewer viewer= getTreeViewer(); - viewer.setContentProvider(new SpecfileContentProvider(editor)); - SpecfileLabelProvider labelProvider = new SpecfileLabelProvider(); - viewer.setLabelProvider(labelProvider); - viewer.addSelectionChangedListener(this); - - if (input != null) { - viewer.setInput(input); - } - } - - /* - * Change in selection - */ - @Override - public void selectionChanged(SelectionChangedEvent event) - { - super.selectionChanged(event); - - //find out which item in tree viewer we have selected, and set highlight range accordingly - ISelection selection = event.getSelection(); - if (selection.isEmpty()) { - editor.resetHighlightRange(); - } else { - SpecfileElement element = (SpecfileElement) ((IStructuredSelection) selection) - .getFirstElement(); - - int start = element.getLineStartPosition(); - try { - editor.setHighlightRange(start, 1, true); - } catch (IllegalArgumentException e) { - editor.resetHighlightRange(); - } - } - } + private ITextEditor editor; + private IEditorInput input; + + public SpecfileContentOutlinePage(SpecfileEditor editor) { + super(); + this.editor = editor; + } + + public void setInput(IEditorInput editorInput) { + this.input = editorInput; + update(); + } + + public void update() { + //set the input so that the outlines parse can be called + //update the tree viewer state + final TreeViewer viewer = getTreeViewer(); + + if (viewer != null) + { + final Control control = viewer.getControl(); + if (control != null && !control.isDisposed()) + { + control.getDisplay().asyncExec(new Runnable() { + @Override + public void run() { + if (!control.isDisposed()) { + control.setRedraw(false); + if (input != null) { + viewer.setInput(input); + } + viewer.expandAll(); + control.setRedraw(true); + } + } + }); + } + } + } + + @Override + public void createControl(Composite parent) { + + super.createControl(parent); + + TreeViewer viewer= getTreeViewer(); + viewer.setContentProvider(new SpecfileContentProvider(editor)); + SpecfileLabelProvider labelProvider = new SpecfileLabelProvider(); + viewer.setLabelProvider(labelProvider); + viewer.addSelectionChangedListener(this); + + if (input != null) { + viewer.setInput(input); + } + } + + /* + * Change in selection + */ + @Override + public void selectionChanged(SelectionChangedEvent event) + { + super.selectionChanged(event); + + //find out which item in tree viewer we have selected, and set highlight range accordingly + ISelection selection = event.getSelection(); + if (selection.isEmpty()) { + editor.resetHighlightRange(); + } else { + SpecfileElement element = (SpecfileElement) ((IStructuredSelection) selection) + .getFirstElement(); + + int start = element.getLineStartPosition(); + try { + editor.setHighlightRange(start, 1, true); + } catch (IllegalArgumentException e) { + editor.resetHighlightRange(); + } + } + } } |