Search in sources :

Example 71 with TreePath

use of org.eclipse.jface.viewers.TreePath in project linuxtools by eclipse.

the class DoubleClickTest method testDoubleClickLine.

@Test
public void testDoubleClickLine() throws Exception {
    ILaunchConfiguration config = createConfiguration(proj.getProject());
    // $NON-NLS-1$
    doLaunch(config, "testDoubleClickFunction");
    CachegrindViewPart view = (CachegrindViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
    CachegrindOutput output = view.getOutputs()[0];
    // $NON-NLS-1$
    CachegrindFile file = getFileByName(output, "cpptest.cpp");
    // $NON-NLS-1$
    CachegrindFunction func = getFunctionByName(file, "main");
    CachegrindLine line = func.getLines()[0];
    TreePath path = new TreePath(new Object[] { output, file, func });
    doDoubleClick(path);
    // check file in editor
    IEditorPart editor = checkFile(file);
    // check line number
    ITextEditor textEditor = (ITextEditor) editor;
    ISelection selection = textEditor.getSelectionProvider().getSelection();
    TextSelection textSelection = (TextSelection) selection;
    // zero-indexed
    int actualLine = textSelection.getStartLine() + 1;
    assertEquals(line.getLine(), actualLine);
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) TreePath(org.eclipse.jface.viewers.TreePath) CachegrindOutput(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindOutput) CachegrindFile(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindFile) CachegrindFunction(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindFunction) TextSelection(org.eclipse.jface.text.TextSelection) ISelection(org.eclipse.jface.viewers.ISelection) CachegrindViewPart(org.eclipse.linuxtools.internal.valgrind.cachegrind.CachegrindViewPart) CachegrindLine(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindLine) IEditorPart(org.eclipse.ui.IEditorPart) Test(org.junit.Test)

Example 72 with TreePath

use of org.eclipse.jface.viewers.TreePath in project linuxtools by eclipse.

the class ExpandCollapseTest method testExpand.

@Test
public void testExpand() throws Exception {
    ILaunchConfiguration config = createConfiguration(proj.getProject());
    // $NON-NLS-1$
    doLaunch(config, "testDefaults");
    CachegrindViewPart view = (CachegrindViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
    viewer = view.getViewer();
    contextMenu = viewer.getTree().getMenu();
    // Select first snapshot and expand it
    CachegrindOutput[] outputs = (CachegrindOutput[]) viewer.getInput();
    CachegrindOutput output = outputs[0];
    TreeSelection selection = new TreeSelection(new TreePath(new Object[] { output }));
    viewer.setSelection(selection);
    contextMenu.notifyListeners(SWT.Show, null);
    contextMenu.getItem(0).notifyListeners(SWT.Selection, null);
    checkExpanded(output, true);
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) TreePath(org.eclipse.jface.viewers.TreePath) CachegrindOutput(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindOutput) TreeSelection(org.eclipse.jface.viewers.TreeSelection) CachegrindViewPart(org.eclipse.linuxtools.internal.valgrind.cachegrind.CachegrindViewPart) Test(org.junit.Test)

Example 73 with TreePath

use of org.eclipse.jface.viewers.TreePath in project linuxtools by eclipse.

the class EnableConnectionCommandHandler method execute.

@Override
public Object execute(ExecutionEvent event) {
    final IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
    if (activePart instanceof CommonNavigator) {
        final CommonViewer viewer = ((CommonNavigator) activePart).getCommonViewer();
        final ITreeSelection selection = (ITreeSelection) viewer.getSelection();
        for (TreePath treePath : selection.getPaths()) {
            final IDockerConnection conn = (IDockerConnection) treePath.getLastSegment();
            if (!conn.isOpen()) {
                final Job openConnectionJob = new Job(CommandMessages.getFormattedString(// $NON-NLS-1$
                "command.enableconnection", conn.getUri())) {

                    @Override
                    protected IStatus run(IProgressMonitor monitor) {
                        try {
                            conn.open(true);
                            Display.getDefault().asyncExec(() -> viewer.refresh(conn));
                        } catch (DockerException e) {
                            Activator.logErrorMessage(CommandMessages.getString(// $NON-NLS-1$
                            "command.enableconnection.failure"), e);
                            return Status.CANCEL_STATUS;
                        }
                        return Status.OK_STATUS;
                    }
                };
                openConnectionJob.schedule();
            }
        }
    }
    return null;
}
Also used : DockerException(org.eclipse.linuxtools.docker.core.DockerException) CommonNavigator(org.eclipse.ui.navigator.CommonNavigator) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) TreePath(org.eclipse.jface.viewers.TreePath) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) CommonViewer(org.eclipse.ui.navigator.CommonViewer) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection) Job(org.eclipse.core.runtime.jobs.Job)

Example 74 with TreePath

use of org.eclipse.jface.viewers.TreePath in project linuxtools by eclipse.

the class DoubleClickTest method doDoubleClick.

private void doDoubleClick() {
    MassifViewPart view = (MassifViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
    MassifTreeViewer treeViewer = view.getTreeViewer();
    MassifSnapshot[] snapshots = view.getSnapshots();
    // first detailed
    node = snapshots[1].getRoot();
    TreePath path = new TreePath(new Object[] { node });
    while (node.getChildren().length > 0 && !node.hasSourceFile()) {
        node = node.getChildren()[0];
        path = path.createChildPath(node);
    }
    assertTrue(node.hasSourceFile());
    treeViewer.getViewer().expandToLevel(node, AbstractTreeViewer.ALL_LEVELS);
    TreeSelection selection = new TreeSelection(path);
    // do double click
    IDoubleClickListener listener = treeViewer.getDoubleClickListener();
    listener.doubleClick(new DoubleClickEvent(treeViewer.getViewer(), selection));
}
Also used : MassifTreeViewer(org.eclipse.linuxtools.internal.valgrind.massif.MassifTreeViewer) TreePath(org.eclipse.jface.viewers.TreePath) TreeSelection(org.eclipse.jface.viewers.TreeSelection) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) MassifSnapshot(org.eclipse.linuxtools.internal.valgrind.massif.MassifSnapshot) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) MassifViewPart(org.eclipse.linuxtools.internal.valgrind.massif.MassifViewPart)

Example 75 with TreePath

use of org.eclipse.jface.viewers.TreePath in project linuxtools by eclipse.

the class ExpandCollapseTest method testCollapse.

@Test
public void testCollapse() throws Exception {
    // Expand the element first
    testExpand();
    // Then collapse it
    MassifHeapTreeNode[] snapshots = (MassifHeapTreeNode[]) viewer.getInput();
    MassifHeapTreeNode snapshot = snapshots[0];
    TreeSelection selection = new TreeSelection(new TreePath(new Object[] { snapshot }));
    viewer.setSelection(selection);
    contextMenu.notifyListeners(SWT.Show, null);
    contextMenu.getItem(1).notifyListeners(SWT.Selection, null);
    checkExpanded(snapshot, false);
}
Also used : MassifHeapTreeNode(org.eclipse.linuxtools.internal.valgrind.massif.MassifHeapTreeNode) TreePath(org.eclipse.jface.viewers.TreePath) TreeSelection(org.eclipse.jface.viewers.TreeSelection) Test(org.junit.Test)

Aggregations

TreePath (org.eclipse.jface.viewers.TreePath)104 TreeSelection (org.eclipse.jface.viewers.TreeSelection)55 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)22 ArrayList (java.util.ArrayList)20 ITreeSelection (org.eclipse.jface.viewers.ITreeSelection)18 XSDComponent (org.eclipse.xsd.XSDComponent)14 Test (org.junit.Test)14 Iterator (java.util.Iterator)13 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)13 Element (org.w3c.dom.Element)13 XSDAnnotationsStructure (com.amalto.workbench.utils.XSDAnnotationsStructure)12 HashSet (java.util.HashSet)10 Set (java.util.Set)10 ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)10 List (java.util.List)7 TreeViewer (org.eclipse.jface.viewers.TreeViewer)7 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)6 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)6 IProject (org.eclipse.core.resources.IProject)5 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)5