Search in sources :

Example 1 with OpModelRoot

use of org.eclipse.linuxtools.internal.oprofile.core.model.OpModelRoot in project linuxtools by eclipse.

the class OprofileView method refreshView.

/**
 * Extremely convoluted way of getting the running and parsing to happen in
 *   a separate thread, with a progress monitor. In most cases and on fast
 *   machines this will probably only be a blip.
 */
public void refreshView() {
    try {
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(OprofileUiPlugin.ID_OPROFILE_VIEW);
    } catch (PartInitException e) {
        e.printStackTrace();
    }
    IRunnableWithProgress refreshRunner = monitor -> {
        // $NON-NLS-1$
        monitor.beginTask(OprofileUiMessages.getString("view.dialog.parsing.text"), 2);
        OpModelRoot dataModelRoot = OpModelRoot.getDefault();
        dataModelRoot.refreshModel();
        monitor.worked(1);
        final UiModelRoot UiRoot = UiModelRoot.getDefault();
        UiRoot.refreshModel();
        Display.getDefault().asyncExec(() -> OprofileUiPlugin.getDefault().getOprofileView().getTreeViewer().setInput(UiRoot));
        monitor.worked(1);
        monitor.done();
    };
    ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
    try {
        dialog.run(true, false, refreshRunner);
    } catch (InvocationTargetException | InterruptedException e) {
        e.printStackTrace();
    }
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) UiModelSession(org.eclipse.linuxtools.oprofile.ui.model.UiModelSession) UiModelRoot(org.eclipse.linuxtools.oprofile.ui.model.UiModelRoot) ViewPart(org.eclipse.ui.part.ViewPart) PlatformUI(org.eclipse.ui.PlatformUI) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) MenuManager(org.eclipse.jface.action.MenuManager) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IAction(org.eclipse.jface.action.IAction) Display(org.eclipse.swt.widgets.Display) InvocationTargetException(java.lang.reflect.InvocationTargetException) OprofileUiPlugin(org.eclipse.linuxtools.internal.oprofile.ui.OprofileUiPlugin) IMenuManager(org.eclipse.jface.action.IMenuManager) Composite(org.eclipse.swt.widgets.Composite) PartInitException(org.eclipse.ui.PartInitException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) TreeSelection(org.eclipse.jface.viewers.TreeSelection) OprofileUiMessages(org.eclipse.linuxtools.internal.oprofile.ui.OprofileUiMessages) SWT(org.eclipse.swt.SWT) TreeViewer(org.eclipse.jface.viewers.TreeViewer) OpModelRoot(org.eclipse.linuxtools.internal.oprofile.core.model.OpModelRoot) OpModelRoot(org.eclipse.linuxtools.internal.oprofile.core.model.OpModelRoot) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) UiModelRoot(org.eclipse.linuxtools.oprofile.ui.model.UiModelRoot)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IAction (org.eclipse.jface.action.IAction)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TreeSelection (org.eclipse.jface.viewers.TreeSelection)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 OpModelRoot (org.eclipse.linuxtools.internal.oprofile.core.model.OpModelRoot)1 OprofileUiMessages (org.eclipse.linuxtools.internal.oprofile.ui.OprofileUiMessages)1 OprofileUiPlugin (org.eclipse.linuxtools.internal.oprofile.ui.OprofileUiPlugin)1 UiModelRoot (org.eclipse.linuxtools.oprofile.ui.model.UiModelRoot)1 UiModelSession (org.eclipse.linuxtools.oprofile.ui.model.UiModelSession)1 SWT (org.eclipse.swt.SWT)1 Composite (org.eclipse.swt.widgets.Composite)1 Display (org.eclipse.swt.widgets.Display)1 PartInitException (org.eclipse.ui.PartInitException)1 PlatformUI (org.eclipse.ui.PlatformUI)1