Search in sources :

Example 11 with TreeSelection

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

the class CModelLabelsTest method checkLabelProvider.

private static void checkLabelProvider(TreeViewer viewer, TreePath path, ICachegrindElement element) {
    // expand only the interesting item
    viewer.expandToLevel(element, AbstractTreeViewer.ALL_LEVELS);
    TreeSelection selection = new TreeSelection(path);
    viewer.setSelection(selection);
    TreeItem item = viewer.getTree().getSelection()[0];
    // ensure the CElementLabelProvider is called correctly
    CElementLabelProvider provider = ((CachegrindLabelProvider) viewer.getLabelProvider(0)).getCLabelProvider();
    assertEquals(provider.getText(element.getModel()), item.getText());
    assertEquals(provider.getImage(element.getModel()), item.getImage());
}
Also used : CachegrindLabelProvider(org.eclipse.linuxtools.internal.valgrind.cachegrind.CachegrindLabelProvider) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeSelection(org.eclipse.jface.viewers.TreeSelection) CElementLabelProvider(org.eclipse.cdt.ui.CElementLabelProvider)

Example 12 with TreeSelection

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

the class DoubleClickTest method doDoubleClick.

private static void doDoubleClick(TreePath path) {
    CachegrindViewPart view = (CachegrindViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
    TreeViewer treeViewer = view.getViewer();
    ICachegrindElement element = (ICachegrindElement) path.getLastSegment();
    treeViewer.expandToLevel(element, AbstractTreeViewer.ALL_LEVELS);
    TreeSelection selection = new TreeSelection(path);
    IDoubleClickListener listener = view.getDoubleClickListener();
    listener.doubleClick(new DoubleClickEvent(treeViewer, selection));
}
Also used : ICachegrindElement(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.ICachegrindElement) AbstractTreeViewer(org.eclipse.jface.viewers.AbstractTreeViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) TreeSelection(org.eclipse.jface.viewers.TreeSelection) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) CachegrindViewPart(org.eclipse.linuxtools.internal.valgrind.cachegrind.CachegrindViewPart)

Example 13 with TreeSelection

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

the class ExpandCollapseTest method testCollapse.

@Test
public void testCollapse() throws Exception {
    // Expand the element first
    testExpand();
    // Then collapse 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(1).notifyListeners(SWT.Selection, null);
    checkExpanded(output, false);
}
Also used : TreePath(org.eclipse.jface.viewers.TreePath) CachegrindOutput(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindOutput) TreeSelection(org.eclipse.jface.viewers.TreeSelection) Test(org.junit.Test)

Example 14 with TreeSelection

use of org.eclipse.jface.viewers.TreeSelection 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");
    ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView();
    viewer = view.getMessagesViewer();
    contextMenu = viewer.getTreeViewer().getTree().getMenu();
    // Select first error and expand it
    IValgrindMessage[] messages = (IValgrindMessage[]) viewer.getTreeViewer().getInput();
    IValgrindMessage element = messages[0];
    TreeSelection selection = new TreeSelection(new TreePath(new Object[] { element }));
    viewer.getTreeViewer().setSelection(selection);
    contextMenu.notifyListeners(SWT.Show, null);
    contextMenu.getItem(0).notifyListeners(SWT.Selection, null);
    checkExpanded(element, true);
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ValgrindViewPart(org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart) IValgrindMessage(org.eclipse.linuxtools.valgrind.core.IValgrindMessage) TreePath(org.eclipse.jface.viewers.TreePath) TreeSelection(org.eclipse.jface.viewers.TreeSelection) Test(org.junit.Test)

Example 15 with TreeSelection

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

the class LinkedResourceDoubleClickTest method doDoubleClick.

private void doDoubleClick() {
    ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView();
    CoreMessagesViewer viewer = view.getMessagesViewer();
    // get first leaf
    IValgrindMessage[] elements = (IValgrindMessage[]) viewer.getTreeViewer().getInput();
    IValgrindMessage element = elements[0];
    TreePath path = new TreePath(new Object[] { element });
    frame = null;
    while (element.getChildren().length > 0) {
        element = element.getChildren()[0];
        path = path.createChildPath(element);
        if (element instanceof ValgrindStackFrame) {
            frame = (ValgrindStackFrame) element;
        }
    }
    assertNotNull(frame);
    viewer.getTreeViewer().expandToLevel(frame, AbstractTreeViewer.ALL_LEVELS);
    TreeSelection selection = new TreeSelection(path);
    // do double click
    IDoubleClickListener listener = viewer.getDoubleClickListener();
    listener.doubleClick(new DoubleClickEvent(viewer.getTreeViewer(), selection));
}
Also used : ValgrindViewPart(org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart) IValgrindMessage(org.eclipse.linuxtools.valgrind.core.IValgrindMessage) TreePath(org.eclipse.jface.viewers.TreePath) TreeSelection(org.eclipse.jface.viewers.TreeSelection) ValgrindStackFrame(org.eclipse.linuxtools.internal.valgrind.core.ValgrindStackFrame) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) CoreMessagesViewer(org.eclipse.linuxtools.internal.valgrind.ui.CoreMessagesViewer)

Aggregations

TreeSelection (org.eclipse.jface.viewers.TreeSelection)31 TreePath (org.eclipse.jface.viewers.TreePath)12 ISelection (org.eclipse.jface.viewers.ISelection)7 TreeViewer (org.eclipse.jface.viewers.TreeViewer)6 Test (org.junit.Test)6 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)4 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)4 ITreeSelection (org.eclipse.jface.viewers.ITreeSelection)4 IValgrindMessage (org.eclipse.linuxtools.valgrind.core.IValgrindMessage)4 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)3 ValgrindViewPart (org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart)3 UiModelSession (org.eclipse.linuxtools.oprofile.ui.model.UiModelSession)3 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)2 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 List (java.util.List)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 CachegrindViewPart (org.eclipse.linuxtools.internal.valgrind.cachegrind.CachegrindViewPart)2 CachegrindOutput (org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindOutput)2