diff options
author | Otavio Pontes | 2012-06-29 18:07:07 +0000 |
---|---|---|
committer | Otavio Pontes | 2012-06-29 18:09:17 +0000 |
commit | 33b3f1ddcbd92db22694e60703a5bfeaa6761bb5 (patch) | |
tree | af8aa1be224bf9eb85eae85048ed4179c851f694 /oprofile | |
parent | 0412db01a448cd2cefe4883d589593b19aeed022 (diff) | |
download | org.eclipse.linuxtools-33b3f1ddcbd92db22694e60703a5bfeaa6761bb5.tar.gz org.eclipse.linuxtools-33b3f1ddcbd92db22694e60703a5bfeaa6761bb5.tar.xz org.eclipse.linuxtools-33b3f1ddcbd92db22694e60703a5bfeaa6761bb5.zip |
Oprofile: Fixing api breakage when oprofile remote was added.
Diffstat (limited to 'oprofile')
6 files changed, 85 insertions, 14 deletions
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpcontrolProvider.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpcontrolProvider.java index fc0ceea2cb..42a1067db5 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpcontrolProvider.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpcontrolProvider.java @@ -91,10 +91,4 @@ public interface IOpcontrolProvider { public void deleteSession (String sessionName, String sessionEvent) throws OpcontrolException; public boolean status() throws OpcontrolException; - - /** - * @since 1.1 - */ - public boolean hasPermissions(IProject project) throws OpcontrolException; - } diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpcontrolProvider2.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpcontrolProvider2.java new file mode 100644 index 0000000000..fdfd239fcc --- /dev/null +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/IOpcontrolProvider2.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2004 Red Hat, Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Keith Seitz <keiths@redhat.com> - initial API and implementation + *******************************************************************************/ +package org.eclipse.linuxtools.internal.oprofile.core; + +import org.eclipse.core.resources.IProject; +import org.eclipse.linuxtools.internal.oprofile.core.daemon.OprofileDaemonEvent; +import org.eclipse.linuxtools.internal.oprofile.core.daemon.OprofileDaemonOptions; + +/** + * Interface for oprofile core to utilize opcontrol program. Platform plugins should define/register + * an OpcontrolProvider for the core to use. + * @since 1.1 + */ +public interface IOpcontrolProvider2 extends IOpcontrolProvider { + //TODO: Merge this interface with IOpcontrolProvider for 2.0 version + public boolean hasPermissions(IProject project) throws OpcontrolException; +} diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/LinuxOpcontrolProvider.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/LinuxOpcontrolProvider.java index 31d55c1c68..bfa425f75d 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/LinuxOpcontrolProvider.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/linux/LinuxOpcontrolProvider.java @@ -23,7 +23,7 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; -import org.eclipse.linuxtools.internal.oprofile.core.IOpcontrolProvider; +import org.eclipse.linuxtools.internal.oprofile.core.IOpcontrolProvider2; import org.eclipse.linuxtools.internal.oprofile.core.OpcontrolException; import org.eclipse.linuxtools.internal.oprofile.core.Oprofile; import org.eclipse.linuxtools.internal.oprofile.core.OprofileCorePlugin; @@ -36,7 +36,7 @@ import org.eclipse.linuxtools.tools.launch.core.properties.LinuxtoolsPathPropert /** * A class which encapsulates running opcontrol. */ -public class LinuxOpcontrolProvider implements IOpcontrolProvider { +public class LinuxOpcontrolProvider implements IOpcontrolProvider2 { private static final String OPCONTROL_EXECUTABLE = "opcontrol"; private static final int SUDO_TIMEOUT = 2000; @@ -256,7 +256,7 @@ public class LinuxOpcontrolProvider implements IOpcontrolProvider { IProject project = Oprofile.OprofileProject.getProject(); - args.add(0, findOpcontrol()); + args.add(0, findOpcontrolExecutable()); // Verbosity hack. If --start or --start-daemon, add verbosity, if set String cmd = args.get(1); @@ -363,7 +363,10 @@ public class LinuxOpcontrolProvider implements IOpcontrolProvider { System.out.println(OprofileCorePlugin.DEBUG_PRINT_PREFIX + buf.toString()); } - protected String findOpcontrol() { + /** + * @since 1.1 + */ + protected String findOpcontrolExecutable() { IProject project = Oprofile.OprofileProject.getProject(); if (!LinuxtoolsPathProperty.getInstance().getLinuxtoolsPath(project).equals("")){ return OPCONTROL_EXECUTABLE; @@ -384,7 +387,7 @@ public class LinuxOpcontrolProvider implements IOpcontrolProvider { } return null; - } + } // Convert the event into arguments for opcontrol private void eventToArguments(ArrayList<String> args, OprofileDaemonEvent event) { @@ -513,8 +516,31 @@ public class LinuxOpcontrolProvider implements IOpcontrolProvider { } private boolean isInstalled(){ - findOpcontrol(); + findOpcontrolExecutable(); return isInstalled; } + /** + * Use {@link findOpcontrolExecutable} + */ + @Deprecated + private static String findOpcontrol() throws OpcontrolException { + IProject project = Oprofile.OprofileProject.getProject(); + URL url = FileLocator.find(Platform.getBundle(OprofileCorePlugin + .getId()), new Path(OPCONTROL_REL_PATH), null); + + if (url != null) { + try { + return FileLocator.toFileURL(url).getPath(); + } catch (IOException ignore) { + } + // If no linuxtools' toolchain is defined for this project and oprofile is not + // installed, throw exception + } else if(project == null || LinuxtoolsPathProperty.getInstance().getLinuxtoolsPath(project).equals("")){ + throw new OpcontrolException(OprofileCorePlugin.createErrorStatus( + "opcontrolProvider", null)); //$NON-NLS-1$ + } + + return null; + } } diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/info/InfoAdapter.java b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/info/InfoAdapter.java index a79fed0bfd..38a1ad72f8 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/info/InfoAdapter.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/src/org/eclipse/linuxtools/internal/oprofile/core/opxml/info/InfoAdapter.java @@ -11,6 +11,8 @@ package org.eclipse.linuxtools.internal.oprofile.core.opxml.info; import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -109,6 +111,9 @@ public class InfoAdapter extends AbstractDataAdapter{ } } + /** + * @since 1.1 + */ public InfoAdapter(IFileStore resourceFile) { InputStream inputStream = null; try { @@ -120,6 +125,19 @@ public class InfoAdapter extends AbstractDataAdapter{ } /** + * Use {@link InfoAdapter(IFileStore)} + */ + @Deprecated + public InfoAdapter(File resourceFile) { + try { + FileInputStream fileInpStr = new FileInputStream(resourceFile); + createDOM(fileInpStr); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + } + + /** * Set up the DOM for later manipulation * @param is the InpuStream resulting from running the ophelp command. * This will be passed in as null for timer mode. diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileEventConfigTab.java b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileEventConfigTab.java index 9066e7fefb..7fc30ae0d7 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileEventConfigTab.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/configuration/OprofileEventConfigTab.java @@ -41,6 +41,7 @@ import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.Viewer; import org.eclipse.linuxtools.internal.oprofile.core.IOpcontrolProvider; +import org.eclipse.linuxtools.internal.oprofile.core.IOpcontrolProvider2; import org.eclipse.linuxtools.internal.oprofile.core.OpcontrolException; import org.eclipse.linuxtools.internal.oprofile.core.Oprofile; import org.eclipse.linuxtools.internal.oprofile.core.OprofileCorePlugin; @@ -437,7 +438,10 @@ public class OprofileEventConfigTab extends AbstractLaunchConfigurationTab { protected boolean hasPermissions(IProject project) throws OpcontrolException{ if (this.hasPermissions == null){ IOpcontrolProvider provider = OprofileCorePlugin.getDefault().getOpcontrolProvider(); - this.hasPermissions = provider.hasPermissions(project); + if (provider instanceof IOpcontrolProvider2) + this.hasPermissions = ((IOpcontrolProvider2)provider).hasPermissions(project); + else + this.hasPermissions = true; } return this.hasPermissions; } diff --git a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/OprofileLaunchConfigurationDelegate.java b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/OprofileLaunchConfigurationDelegate.java index f50f00e386..5732479c87 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/OprofileLaunchConfigurationDelegate.java +++ b/oprofile/org.eclipse.linuxtools.oprofile.launch/src/org/eclipse/linuxtools/internal/oprofile/launch/launching/OprofileLaunchConfigurationDelegate.java @@ -16,6 +16,8 @@ import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.core.ILaunchesListener2; +import org.eclipse.linuxtools.internal.oprofile.core.IOpcontrolProvider; +import org.eclipse.linuxtools.internal.oprofile.core.IOpcontrolProvider2; import org.eclipse.linuxtools.internal.oprofile.core.OpcontrolException; import org.eclipse.linuxtools.internal.oprofile.core.Oprofile; import org.eclipse.linuxtools.internal.oprofile.core.OprofileCorePlugin; @@ -35,7 +37,9 @@ public class OprofileLaunchConfigurationDelegate extends AbstractOprofileLaunchC //check if user has NOPASSWD sudo permission for opcontrol //if the Linux Tools Path property was changed if(project != null && !LinuxtoolsPathProperty.getInstance().getLinuxtoolsPath(project).equals("")){ - if(!OprofileCorePlugin.getDefault().getOpcontrolProvider().hasPermissions(project)){ + IOpcontrolProvider provider = OprofileCorePlugin.getDefault().getOpcontrolProvider(); + if (provider instanceof IOpcontrolProvider2 && + !((IOpcontrolProvider2)provider).hasPermissions(project)){ throw new OpcontrolException(OprofileCorePlugin.createErrorStatus("opcontrolSudo", null)); } } |