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