Search in sources :

Example 1 with UiModelSession

use of org.eclipse.linuxtools.oprofile.ui.model.UiModelSession 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 2 with UiModelSession

use of org.eclipse.linuxtools.oprofile.ui.model.UiModelSession 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 3 with UiModelSession

use of org.eclipse.linuxtools.oprofile.ui.model.UiModelSession 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 4 with UiModelSession

use of org.eclipse.linuxtools.oprofile.ui.model.UiModelSession in project linuxtools by eclipse.

the class OprofileViewSaveDefaultSessionAction method run.

@Override
public void run() {
    boolean defaultSessionExists = false;
    UiModelRoot modelRoot = UiModelRoot.getDefault();
    String defaultSessionName = null;
    IUiModelElement[] modelEvents = null;
    if (modelRoot.hasChildren()) {
        IUiModelElement[] sessions = modelRoot.getChildren();
        for (IUiModelElement e : sessions) {
            if (e instanceof UiModelError)
                break;
            if (e instanceof UiModelSession) {
                if (((UiModelSession) e).isDefaultSession()) {
                    defaultSessionExists = true;
                    defaultSessionName = e.getLabelText();
                    modelEvents = ((UiModelSession) e).getChildren();
                    break;
                }
                if (defaultSessionExists)
                    break;
            }
        }
        if (defaultSessionExists) {
            // the following code was originially written by Keith Seitz
            InputDialog dialog = new InputDialog(OprofileUiPlugin.getActiveWorkbenchShell(), // $NON-NLS-1$
            OprofileUiMessages.getString("savedialog.title"), // $NON-NLS-1$
            OprofileUiMessages.getString("savedialog.message"), // $NON-NLS-1$
            OprofileUiMessages.getString("savedialog.initial"), new SaveSessionValidator());
            int result = dialog.open();
            if (result == Window.OK) {
                SessionManager.saveSession(dialog.getValue());
                // remove the default session
                for (int i = 0; i < modelEvents.length; i++) {
                    SessionManager.deleteSession(defaultSessionName, modelEvents[i].getLabelText());
                }
                if (Oprofile.OprofileProject.OPERF_BINARY.equals(Oprofile.OprofileProject.getProfilingBinary())) {
                    // remove oprofile_data so current event no longer
                    // be there
                    OprofileViewDeleteSessionAction.deleteOperfDataFolder(Oprofile.OprofileProject.getProject().getFolder(Oprofile.OprofileProject.OPERF_DATA));
                }
                OprofileUiPlugin.getDefault().getOprofileView().refreshView();
            }
        } else {
            MessageDialog.openError(OprofileUiPlugin.getActiveWorkbenchShell(), OprofileUiMessages.getString(// $NON-NLS-1$
            "defaultsessiondialog.nodefaultsession.title"), OprofileUiMessages.getString(// $NON-NLS-1$
            "defaultsessiondialog.nodefaultsession.message"));
        }
    }
}
Also used : UiModelSession(org.eclipse.linuxtools.oprofile.ui.model.UiModelSession) InputDialog(org.eclipse.jface.dialogs.InputDialog) IUiModelElement(org.eclipse.linuxtools.oprofile.ui.model.IUiModelElement) UiModelError(org.eclipse.linuxtools.oprofile.ui.model.UiModelError) UiModelRoot(org.eclipse.linuxtools.oprofile.ui.model.UiModelRoot)

Aggregations

UiModelSession (org.eclipse.linuxtools.oprofile.ui.model.UiModelSession)4 TreeSelection (org.eclipse.jface.viewers.TreeSelection)3 IUiModelElement (org.eclipse.linuxtools.oprofile.ui.model.IUiModelElement)2 CoreException (org.eclipse.core.runtime.CoreException)1 InputDialog (org.eclipse.jface.dialogs.InputDialog)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 UiModelError (org.eclipse.linuxtools.oprofile.ui.model.UiModelError)1 UiModelEvent (org.eclipse.linuxtools.oprofile.ui.model.UiModelEvent)1 UiModelImage (org.eclipse.linuxtools.oprofile.ui.model.UiModelImage)1 UiModelRoot (org.eclipse.linuxtools.oprofile.ui.model.UiModelRoot)1 UiModelSample (org.eclipse.linuxtools.oprofile.ui.model.UiModelSample)1 UiModelSymbol (org.eclipse.linuxtools.oprofile.ui.model.UiModelSymbol)1 PartInitException (org.eclipse.ui.PartInitException)1