Search in sources :

Example 1 with PerfProfileView

use of org.eclipse.linuxtools.internal.perf.ui.PerfProfileView in project linuxtools by eclipse.

the class PerfCore method refreshView.

public static void refreshView(final String title) {
    Display.getDefault().syncExec(() -> {
        try {
            PerfProfileView view = (PerfProfileView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(PerfPlugin.VIEW_ID);
            view.setContentDescription(title);
            view.refreshModel();
        } catch (PartInitException e) {
            logException(e);
        }
    });
}
Also used : PerfProfileView(org.eclipse.linuxtools.internal.perf.ui.PerfProfileView) PartInitException(org.eclipse.ui.PartInitException)

Example 2 with PerfProfileView

use of org.eclipse.linuxtools.internal.perf.ui.PerfProfileView in project linuxtools by eclipse.

the class PerfSaveSessionHandler method saveData.

@Override
public IPath saveData(String filename) {
    // get paths
    IPath newDataLoc = getNewDataLocation(filename, DATA_EXT);
    IPath defaultDataLoc = PerfPlugin.getDefault().getPerfProfileData();
    URI newDataLocURI = null;
    URI defaultDataLocURI = null;
    // get files
    IRemoteFileProxy proxy = null;
    try {
        newDataLocURI = new URI(newDataLoc.toPortableString());
        defaultDataLocURI = new URI(defaultDataLoc.toPortableString());
        proxy = RemoteProxyManager.getInstance().getFileProxy(newDataLocURI);
    } catch (URISyntaxException e) {
        openErroDialog(Messages.MsgProxyError, Messages.MsgProxyError, newDataLoc.lastSegment());
    } catch (CoreException e) {
        openErroDialog(Messages.MsgProxyError, Messages.MsgProxyError, newDataLoc.lastSegment());
    }
    IFileStore newDataFileStore = proxy.getResource(newDataLocURI.getPath());
    IFileStore defaultDataFileStore = proxy.getResource(defaultDataLocURI.getPath());
    if (canSave(newDataLoc)) {
        // copy default data into new location
        try {
            defaultDataFileStore.copy(newDataFileStore, EFS.OVERWRITE, null);
            PerfPlugin.getDefault().setPerfProfileData(newDataLoc);
            try {
                PerfProfileView view = (PerfProfileView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(PerfPlugin.VIEW_ID);
                view.setContentDescription(newDataLoc.toOSString());
            } catch (PartInitException e) {
            // fail silently
            }
            IFileInfo info = newDataFileStore.fetchInfo();
            info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, true);
            newDataFileStore.putInfo(info, EFS.SET_ATTRIBUTES, null);
            return newDataLoc;
        } catch (CoreException e) {
            openErroDialog(Messages.PerfSaveSession_failure_title, Messages.PerfSaveSession_failure_msg, newDataLoc.lastSegment());
        }
    }
    return null;
}
Also used : PerfProfileView(org.eclipse.linuxtools.internal.perf.ui.PerfProfileView) IFileInfo(org.eclipse.core.filesystem.IFileInfo) IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) IRemoteFileProxy(org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy) IFileStore(org.eclipse.core.filesystem.IFileStore) URISyntaxException(java.net.URISyntaxException) PartInitException(org.eclipse.ui.PartInitException) URI(java.net.URI)

Example 3 with PerfProfileView

use of org.eclipse.linuxtools.internal.perf.ui.PerfProfileView in project linuxtools by eclipse.

the class ModelTest method testDoubleClickAction.

@Test
public void testDoubleClickAction() {
    TreeParent invisibleRoot = buildModel("resources/defaultevent-data/perf.data", "resources/defaultevent-data/perf.data.txt", "resources/defaultevent-data/perf.data.err.log");
    PerfPlugin.getDefault().setModelRoot(invisibleRoot);
    // update the model root for the view
    PerfCore.refreshView("resources/defaultevent-data/perf.data");
    // number of parents excluding invisibleRoot
    int numOfParents = getNumberOfParents(invisibleRoot) - 1;
    // create a double click action to act on the tree viewer
    try {
        PerfProfileView view = (PerfProfileView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(PerfPlugin.VIEW_ID);
        TreeViewer tv = view.getTreeViewer();
        PerfDoubleClickAction dblClick = new PerfDoubleClickAction(tv);
        // double click every element
        doubleClickAllChildren(invisibleRoot, tv, dblClick);
        // If all elements are expanded, this is the number of elements
        // in our model that have children.
        assertEquals(numOfParents, tv.getExpandedElements().length);
    } catch (PartInitException e) {
        fail("Failed to open the Profiling View.");
    }
}
Also used : PerfProfileView(org.eclipse.linuxtools.internal.perf.ui.PerfProfileView) TreeParent(org.eclipse.linuxtools.internal.perf.model.TreeParent) TreeViewer(org.eclipse.jface.viewers.TreeViewer) PartInitException(org.eclipse.ui.PartInitException) PerfDoubleClickAction(org.eclipse.linuxtools.internal.perf.ui.PerfDoubleClickAction) Test(org.junit.Test) AbstractTest(org.eclipse.linuxtools.profiling.tests.AbstractTest)

Aggregations

PerfProfileView (org.eclipse.linuxtools.internal.perf.ui.PerfProfileView)3 PartInitException (org.eclipse.ui.PartInitException)3 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 IFileInfo (org.eclipse.core.filesystem.IFileInfo)1 IFileStore (org.eclipse.core.filesystem.IFileStore)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 TreeParent (org.eclipse.linuxtools.internal.perf.model.TreeParent)1 PerfDoubleClickAction (org.eclipse.linuxtools.internal.perf.ui.PerfDoubleClickAction)1 IRemoteFileProxy (org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy)1 AbstractTest (org.eclipse.linuxtools.profiling.tests.AbstractTest)1 Test (org.junit.Test)1