Search in sources :

Example 1 with PerfPlugin

use of org.eclipse.linuxtools.internal.perf.PerfPlugin in project linuxtools by eclipse.

the class PerfStatsQuickDiffHandler method execute.

@Override
public Object execute(ExecutionEvent event) {
    // get default files
    PerfPlugin plugin = PerfPlugin.getDefault();
    IPath curStatData = plugin.getPerfFile(PerfPlugin.PERF_DEFAULT_STAT);
    IPath prevStatData = plugin.getPerfFile(PerfPlugin.PERF_DEAFULT_OLD_STAT);
    IResource curStatFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(curStatData);
    IResource prevStatFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(prevStatData);
    // Inject our own selections into the context
    IEvaluationContext ctx = (IEvaluationContext) event.getApplicationContext();
    ctx.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, new StructuredSelection(new IResource[] { prevStatFile, curStatFile }));
    ICommandService cmdService = PlatformUI.getWorkbench().getService(ICommandService.class);
    // $NON-NLS-1$
    Command cmd = cmdService.getCommand("org.eclipse.linuxtools.perf.CompareAction");
    try {
        cmd.executeWithChecks(event);
    } catch (Exception e) {
    }
    return null;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Command(org.eclipse.core.commands.Command) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) PerfPlugin(org.eclipse.linuxtools.internal.perf.PerfPlugin) IResource(org.eclipse.core.resources.IResource) ICommandService(org.eclipse.ui.commands.ICommandService) URISyntaxException(java.net.URISyntaxException) CoreException(org.eclipse.core.runtime.CoreException)

Example 2 with PerfPlugin

use of org.eclipse.linuxtools.internal.perf.PerfPlugin in project linuxtools by eclipse.

the class PerfStatsQuickDiffHandler method isEnabled.

@Override
public boolean isEnabled() {
    PerfPlugin plugin = PerfPlugin.getDefault();
    IPath workingDir = plugin.getWorkingDir();
    URI curStatDataURI = null;
    URI prevStatDataURI = null;
    if (workingDir != null) {
        IPath curStatData = plugin.getPerfFile(PerfPlugin.PERF_DEFAULT_STAT);
        IPath prevStatData = plugin.getPerfFile(PerfPlugin.PERF_DEAFULT_OLD_STAT);
        IRemoteFileProxy proxy = null;
        try {
            curStatDataURI = new URI(curStatData.toPortableString());
            prevStatDataURI = new URI(prevStatData.toPortableString());
            proxy = RemoteProxyManager.getInstance().getFileProxy(curStatDataURI);
        } catch (URISyntaxException e) {
            MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.MsgProxyError, Messages.MsgProxyError);
        } catch (CoreException e) {
            MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.MsgProxyError, Messages.MsgProxyError);
        }
        IFileStore curFileStore = proxy.getResource(curStatDataURI.getPath());
        IFileStore prevFileStore = proxy.getResource(prevStatDataURI.getPath());
        return (curFileStore.fetchInfo().exists() && prevFileStore.fetchInfo().exists());
    }
    return false;
}
Also used : 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) PerfPlugin(org.eclipse.linuxtools.internal.perf.PerfPlugin) URI(java.net.URI)

Aggregations

URISyntaxException (java.net.URISyntaxException)2 CoreException (org.eclipse.core.runtime.CoreException)2 IPath (org.eclipse.core.runtime.IPath)2 PerfPlugin (org.eclipse.linuxtools.internal.perf.PerfPlugin)2 URI (java.net.URI)1 Command (org.eclipse.core.commands.Command)1 IEvaluationContext (org.eclipse.core.expressions.IEvaluationContext)1 IFileStore (org.eclipse.core.filesystem.IFileStore)1 IResource (org.eclipse.core.resources.IResource)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 IRemoteFileProxy (org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy)1 ICommandService (org.eclipse.ui.commands.ICommandService)1