Search in sources :

Example 11 with SpecfileElement

use of org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileElement in project linuxtools by eclipse.

the class SpecfileContentOutlinePage method selectionChanged.

/*
	 * 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
    IStructuredSelection selection = event.getStructuredSelection();
    if (selection.isEmpty()) {
        editor.resetHighlightRange();
    } else {
        SpecfileElement element = (SpecfileElement) selection.getFirstElement();
        int start = element.getLineStartPosition();
        try {
            editor.setHighlightRange(start, 1, true);
        } catch (IllegalArgumentException e) {
            editor.resetHighlightRange();
        }
    }
}
Also used : SpecfileElement(org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileElement) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

SpecfileElement (org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileElement)11 Test (org.junit.Test)7 SpecfileSection (org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfileSection)6 HashSet (java.util.HashSet)1 Position (org.eclipse.jface.text.Position)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SpecfilePreamble (org.eclipse.linuxtools.internal.rpm.ui.editor.parser.SpecfilePreamble)1 Specfile (org.eclipse.linuxtools.rpm.ui.editor.parser.Specfile)1 SpecfilePackage (org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfilePackage)1 SpecfilePackageContainer (org.eclipse.linuxtools.rpm.ui.editor.parser.SpecfilePackageContainer)1