Commit c6f5fce6 authored by Miklos Magyari's avatar Miklos Magyari Committed by Arpad Lovassy
Browse files

Fixed cursor navigation for outline selection (issue #488)

parent 3068817d
......@@ -40,7 +40,12 @@ import org.eclipse.titan.designer.parsers.GlobalParser;
import org.eclipse.titan.designer.parsers.ProjectSourceParser;
import org.eclipse.titan.designer.preferences.PreferenceConstants;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.texteditor.AbstractTextEditor;
import org.eclipse.ui.views.contentoutline.ContentOutline;
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
/**
......@@ -341,6 +346,12 @@ public final class OutlinePage extends ContentOutlinePage {
public void selectionChanged(final SelectionChangedEvent event) {
super.selectionChanged(event);
final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if (page == null) {
return;
}
final IWorkbenchPart part = page.getActivePart();
if (part instanceof ContentOutline) {
final ISelection selection = event.getSelection();
if (selection.isEmpty()) {
return;
......@@ -360,6 +371,7 @@ public final class OutlinePage extends ContentOutlinePage {
editor.selectAndReveal(location.getOffset(), location.getEndOffset() - location.getOffset());
}
}
private Module getModule() {
final IFile file = (IFile) editor.getEditorInput().getAdapter(IFile.class);
......
......@@ -37,10 +37,13 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.titan.designer.Activator;
import org.eclipse.titan.designer.HeadlessStorage;
import org.eclipse.titan.designer.AST.Assignment;
import org.eclipse.titan.designer.AST.Module;
import org.eclipse.titan.designer.declarationsearch.Declaration;
import org.eclipse.titan.designer.declarationsearch.IdentifierFinderVisitor;
......@@ -463,11 +466,16 @@ public final class TTCN3Editor extends AbstractDecoratedTextEditor implements IS
if (declaration == null) {
return;
}
TreeSelection selection = (TreeSelection)outlinePage.getSelection();
TreePath[] paths = selection.getPaths();
TreePath tp = paths.length > 0 ? paths[0] : null;
if (tp == null || ! tp.getLastSegment().equals(declaration.getAssignment())) {
Object segments[] = new Object[2];
segments[1] = declaration.getAssignment();
outlinePage.setSelection(new StructuredSelection(segments));
}
}
@Override
protected ISourceViewer createSourceViewer(final Composite parent, final IVerticalRuler ruler, final int styles) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment