use of org.eclipse.ui.preferences.ScopedPreferenceStore in project linuxtools by eclipse.
the class GprofShortcutTest method setUp.
@Before
public void setUp() throws Exception {
// $NON-NLS-1$
proj = createProjectAndBuild(FrameworkUtil.getBundle(this.getClass()), "fibTest2");
ProjectScope ps = new ProjectScope(proj.getProject());
ScopedPreferenceStore scoped = new ScopedPreferenceStore(ps, ProviderProfileConstants.PLUGIN_ID);
scoped.setSearchContexts(new IScopeContext[] { ps, InstanceScope.INSTANCE });
scoped.setValue(ProviderProfileConstants.PREFS_KEY + GPROF_CATEGORY, GPROF_PROVIDER_ID);
scoped.setValue(ProviderProfileConstants.USE_PROJECT_SETTINGS + GPROF_CATEGORY, true);
scoped.save();
IExtensionPoint extPoint = Platform.getExtensionRegistry().getExtensionPoint(LAUNCH_SHORT_EXTPT);
IConfigurationElement[] configs = extPoint.getConfigurationElements();
for (IConfigurationElement cfg : configs) {
if (cfg.getAttribute("id").equals(ID)) {
// $NON-NLS-1$
try {
// $NON-NLS-1$
shortcut = (ProviderLaunchShortcut) cfg.createExecutableExtension("class");
// $NON-NLS-1$
launchConfigTypeId = cfg.getChildren("class")[0].getChildren("parameter")[1].getAttribute("value");
} catch (Exception e) {
fail(e.getMessage());
}
}
}
config = createConfiguration(proj.getProject());
launch = new Launch(config, ILaunchManager.PROFILE_MODE, null);
wc = config.getWorkingCopy();
}
use of org.eclipse.ui.preferences.ScopedPreferenceStore in project linuxtools by eclipse.
the class ProviderFramework method getProviderIdToRun.
/**
* Get a provider id to run for the given profiling type.
*
* This first checks for a provider in the project properties if the project
* can be found and has indicated that project preferences are to override
* the workspace preferences. If no project is obtainable or the project
* has not indicated override, then it looks at provider preferences. If these
* are not set or the specified preference points to a non-installed provider,
* it will look for the provider with the highest priority for the specified type.
* If this fails, it will look for the default provider.
*
* @param wc The launch configuration.
* @param type A profiling type
* @return A provider id that contributes to the specified type
* @since 2.0
*/
public static String getProviderIdToRun(ILaunchConfigurationWorkingCopy wc, String type) {
String providerId = null;
// Look for a project first
if (wc != null) {
try {
IResource[] resources = wc.getMappedResources();
if (resources != null) {
for (int i = 0; i < resources.length; ++i) {
IResource resource = resources[i];
if (resource instanceof IProject) {
IProject project = (IProject) resource;
ScopedPreferenceStore store = new ScopedPreferenceStore(new ProjectScope(project), ProviderProfileConstants.PLUGIN_ID);
boolean use_project_settings = store.getBoolean(ProviderProfileConstants.USE_PROJECT_SETTINGS + type);
if (use_project_settings) {
String provider = store.getString(ProviderProfileConstants.PREFS_KEY + type);
if (!provider.isEmpty())
providerId = provider;
}
}
}
}
} catch (CoreException e) {
e.printStackTrace();
}
}
// if no providerId specified for project, get one from the preferences
if (providerId == null) {
// Look in the preferences for a provider
providerId = ConfigurationScope.INSTANCE.getNode(ProviderProfileConstants.PLUGIN_ID).get(ProviderProfileConstants.PREFS_KEY + type, // $NON-NLS-1$
"");
if (providerId.isEmpty() || getConfigurationDelegateFromId(providerId) == null) {
// Get highest priority provider
providerId = getHighestProviderId(type);
}
}
return providerId;
}
use of org.eclipse.ui.preferences.ScopedPreferenceStore in project linuxtools by eclipse.
the class CreaterepoPropertyPage method createContents.
@Override
protected Control createContents(Composite parent) {
if (getElement() instanceof IResource) {
project = ((IResource) getElement()).getProject();
} else {
Object adapter = getElement().getAdapter(IResource.class);
if (adapter instanceof IResource) {
project = ((IResource) adapter).getProject();
}
}
setPreferenceStore(new ScopedPreferenceStore(new ProjectScope(project), Activator.PLUGIN_ID));
preferenceStore = getPreferenceStore();
return addContents(parent);
}
use of org.eclipse.ui.preferences.ScopedPreferenceStore in project linuxtools by eclipse.
the class RunRpmlintAction method runRpmlint.
private static void runRpmlint(String location) {
String rpmlintPath = new ScopedPreferenceStore(InstanceScope.INSTANCE, Activator.PLUGIN_ID).getString(PreferenceConstants.P_RPMLINT_PATH);
try {
if (Files.exists(Paths.get(rpmlintPath))) {
// $NON-NLS-1$
String output = Utils.runCommandToString(rpmlintPath, "-i", location);
MessageConsole myConsole = findConsole(Messages.RunRpmlintAction_0);
MessageConsoleStream out = myConsole.newMessageStream();
myConsole.clearConsole();
myConsole.activate();
out.println(output);
} else {
IStatus warning = new Status(IStatus.WARNING, Activator.PLUGIN_ID, 1, Messages.RunRpmlintAction_1, null);
ErrorDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.RunRpmlintAction_2, null, warning);
}
} catch (IOException e) {
// FIXME: rpmlint is not installed in the default place
// -> ask user to open the prefs page.
RpmlintLog.logError(e);
}
}
use of org.eclipse.ui.preferences.ScopedPreferenceStore in project linuxtools by eclipse.
the class RpmlintParser method runRpmlintCommand.
/**
* Run rpmlint command on given visitedResources.
*
* @param specContent
* The specfile content.
* @return The rpmlint command <code>InputStream</code>.
*/
private static BufferedInputStream runRpmlintCommand(List<String> visitedResources) {
BufferedInputStream in = null;
int i = 2;
String[] cmd = new String[visitedResources.size() + i];
cmd[0] = new ScopedPreferenceStore(InstanceScope.INSTANCE, Activator.PLUGIN_ID).getString(PreferenceConstants.P_RPMLINT_PATH);
// $NON-NLS-1$
cmd[1] = "-i";
for (String resource : visitedResources) {
cmd[i] = resource;
i++;
}
try {
in = Utils.runCommandToInputStream(cmd);
} catch (IOException e) {
// FIXME: rpmlint is not installed in the default place -> ask user
// to open the prefs page.
RpmlintLog.logError(e);
}
return in;
}
Aggregations