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());
}
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));
}
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);
}
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);
}
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));
}
Aggregations