use of org.eclipse.jface.viewers.TreeSelection in project linuxtools by eclipse.
the class OprofileView method selectionChanged.
@Override
public void selectionChanged(SelectionChangedEvent event) {
TreeSelection tsl = (TreeSelection) viewer.getSelection();
if (tsl.getFirstElement() instanceof UiModelSession) {
if (!deleteSessionAction.isEnabled()) {
deleteSessionAction.setEnabled(true);
}
if (((UiModelSession) tsl.getFirstElement()).isDefaultSession()) {
if (!saveDefaultSessionAction.isEnabled()) {
saveDefaultSessionAction.setEnabled(true);
}
}
} else {
deleteSessionAction.setEnabled(false);
saveDefaultSessionAction.setEnabled(false);
}
}
use of org.eclipse.jface.viewers.TreeSelection in project linuxtools by eclipse.
the class OprofileViewDeleteSessionAction method run.
@Override
public void run() {
TreeSelection tsl = (TreeSelection) treeViewer.getSelection();
if (tsl.getFirstElement() instanceof UiModelSession) {
UiModelSession sess = (UiModelSession) tsl.getFirstElement();
deleteSession(sess);
}
OprofileUiPlugin.getDefault().getOprofileView().refreshView();
}
use of org.eclipse.jface.viewers.TreeSelection in project linuxtools by eclipse.
the class OprofileViewDoubleClickListener method doubleClick.
@Override
public void doubleClick(DoubleClickEvent event) {
TreeViewer tv = (TreeViewer) event.getSource();
TreeSelection tsl = (TreeSelection) tv.getSelection();
IUiModelElement element = (IUiModelElement) tsl.getFirstElement();
try {
if (element instanceof UiModelEvent) {
// UiModelEvent event = (UiModelEvent)element;
} else if (element instanceof UiModelSession) {
/* moved into an action menu */
} else if (element instanceof UiModelImage) {
// UiModelImage image = (UiModelImage)element;
} else if (element instanceof UiModelSymbol) {
final UiModelSymbol symbol = (UiModelSymbol) element;
final String fileName = symbol.getFileName();
int line = symbol.getLineNumber();
ProfileUIUtils.openEditorAndSelect(fileName, line);
} else if (element instanceof UiModelSample) {
// jump to line number in the appropriate file
UiModelSample sample = (UiModelSample) element;
int line = sample.getLine();
// get file name from the parent sample
final String fileName = sample.getFile();
ProfileUIUtils.openEditorAndSelect(fileName, line, getProject());
}
} catch (BadLocationException e1) {
e1.printStackTrace();
} catch (PartInitException e2) {
e2.printStackTrace();
} catch (CoreException e) {
e.printStackTrace();
}
}
use of org.eclipse.jface.viewers.TreeSelection in project linuxtools by eclipse.
the class SystemTapScriptLaunchConfigurationTab method getSelectedScriptPath.
private String getSelectedScriptPath() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
// $NON-NLS-1$
String pathString = "";
if (window != null) {
ISelection selection = window.getSelectionService().getSelection();
// Figure out the selected systemtap script
if (selection instanceof TreeSelection) {
Object selectedElement = ((TreeSelection) selection).getFirstElement();
if (selectedElement instanceof IFile) {
IPath path = ((IFile) selectedElement).getLocation();
pathString = path.toOSString();
}
}
// If it is a text selection use the path from the active editor.
if (selection instanceof TextSelection) {
IEditorPart ed = window.getActivePage().getActiveEditor();
if (ed.getEditorInput() instanceof PathEditorInput) {
pathString = ((PathEditorInput) ed.getEditorInput()).getPath().toString();
} else {
pathString = ResourceUtil.getFile(ed.getEditorInput()).getLocation().toString();
}
}
}
if (pathString.endsWith(".stp")) {
// $NON-NLS-1$
return pathString;
}
// $NON-NLS-1$
return "";
}
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");
MassifViewPart view = (MassifViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
viewer = view.getTreeViewer().getViewer();
contextMenu = viewer.getTree().getMenu();
// Select first snapshot and expand 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(0).notifyListeners(SWT.Selection, null);
checkExpanded(snapshot, true);
}
Aggregations