Search in sources :

Example 6 with TreeSelection

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);
    }
}
Also used : UiModelSession(org.eclipse.linuxtools.oprofile.ui.model.UiModelSession) TreeSelection(org.eclipse.jface.viewers.TreeSelection)

Example 7 with TreeSelection

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();
}
Also used : UiModelSession(org.eclipse.linuxtools.oprofile.ui.model.UiModelSession) TreeSelection(org.eclipse.jface.viewers.TreeSelection)

Example 8 with TreeSelection

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();
    }
}
Also used : UiModelSample(org.eclipse.linuxtools.oprofile.ui.model.UiModelSample) UiModelEvent(org.eclipse.linuxtools.oprofile.ui.model.UiModelEvent) IUiModelElement(org.eclipse.linuxtools.oprofile.ui.model.IUiModelElement) TreeViewer(org.eclipse.jface.viewers.TreeViewer) UiModelSession(org.eclipse.linuxtools.oprofile.ui.model.UiModelSession) CoreException(org.eclipse.core.runtime.CoreException) TreeSelection(org.eclipse.jface.viewers.TreeSelection) PartInitException(org.eclipse.ui.PartInitException) UiModelImage(org.eclipse.linuxtools.oprofile.ui.model.UiModelImage) UiModelSymbol(org.eclipse.linuxtools.oprofile.ui.model.UiModelSymbol) BadLocationException(org.eclipse.jface.text.BadLocationException)

Example 9 with TreeSelection

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 "";
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) TreeSelection(org.eclipse.jface.viewers.TreeSelection) TextSelection(org.eclipse.jface.text.TextSelection) ISelection(org.eclipse.jface.viewers.ISelection) IEditorPart(org.eclipse.ui.IEditorPart) PathEditorInput(org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.PathEditorInput)

Example 10 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");
    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);
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) MassifHeapTreeNode(org.eclipse.linuxtools.internal.valgrind.massif.MassifHeapTreeNode) TreePath(org.eclipse.jface.viewers.TreePath) TreeSelection(org.eclipse.jface.viewers.TreeSelection) MassifViewPart(org.eclipse.linuxtools.internal.valgrind.massif.MassifViewPart) Test(org.junit.Test)

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