Search in sources :

Example 11 with ScopedPreferenceStore

use of org.eclipse.ui.preferences.ScopedPreferenceStore in project linuxtools by eclipse.

the class CreaterepoPreferencePage method init.

@Override
public void init(IWorkbench workbench) {
    setPreferenceStore(new ScopedPreferenceStore(InstanceScope.INSTANCE, Activator.PLUGIN_ID));
    setDescription(Messages.CreaterepoPreferencePage_description);
}
Also used : ScopedPreferenceStore(org.eclipse.ui.preferences.ScopedPreferenceStore)

Example 12 with ScopedPreferenceStore

use of org.eclipse.ui.preferences.ScopedPreferenceStore in project linuxtools by eclipse.

the class ToggleRpmlintNatureAction method toggleNature.

/**
 * Toggles rpmlint nature on a project.
 *
 * @param project
 *            The project on which to toggle the nature.
 */
private static void toggleNature(IProject project) {
    String rpmlintPath = new ScopedPreferenceStore(InstanceScope.INSTANCE, Activator.PLUGIN_ID).getString(PreferenceConstants.P_RPMLINT_PATH);
    if (!Files.exists(Paths.get(rpmlintPath))) {
        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);
        return;
    }
    try {
        IProjectDescription description = project.getDescription();
        String[] natures = description.getNatureIds();
        for (int i = 0; i < natures.length; ++i) {
            if (RpmlintNature.NATURE_ID.equals(natures[i])) {
                // Remove the nature
                String[] newNatures = new String[natures.length - 1];
                System.arraycopy(natures, 0, newNatures, 0, i);
                System.arraycopy(natures, i + 1, newNatures, i, natures.length - i - 1);
                description.setNatureIds(newNatures);
                project.setDescription(description, null);
                return;
            }
        }
        // Add the nature
        String[] newNatures = new String[natures.length + 1];
        System.arraycopy(natures, 0, newNatures, 0, natures.length);
        newNatures[natures.length] = RpmlintNature.NATURE_ID;
        description.setNatureIds(newNatures);
        project.setDescription(description, null);
    } catch (CoreException e) {
    // TODO log exception
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) IProjectDescription(org.eclipse.core.resources.IProjectDescription) ScopedPreferenceStore(org.eclipse.ui.preferences.ScopedPreferenceStore)

Example 13 with ScopedPreferenceStore

use of org.eclipse.ui.preferences.ScopedPreferenceStore in project yamcs-studio by yamcs.

the class AutoCompleteService method get.

public int get(final Long uniqueId, final AutoCompleteType acType, final String content, final IAutoCompleteResultListener listener) {
    AutoCompletePlugin.getLogger().log(Level.FINE, ">> ChannelNameService get: " + content + " for type: " + acType.value() + " <<");
    if (content == null || content.isEmpty())
        // no result
        return 0;
    // Useful to handle default data source
    ContentDescriptor desc = new ContentDescriptor();
    final IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.csstudio.utility.pv");
    // They need to be kept synchronized.
    if (store != null)
        desc.setDefaultDataSource(store.getString("default_type") + "://");
    desc.setContentType(ContentType.Undefined);
    desc.setAutoCompleteType(acType);
    desc.setOriginalContent(content);
    desc.setValue(content);
    List<ContentDescriptor> descList = parseContent(desc);
    if (DEBUG) {
        System.out.println("=============================================");
        System.out.println("--- ContentDescriptor list ---");
        for (ContentDescriptor ct : descList) System.out.println(ct);
    }
    // Useful to keep the order
    int index = 0;
    List<ScheduledContent> providerList = retrieveProviders(acType, descList);
    if (DEBUG) {
        System.out.println("--- Associated Content ---");
    }
    // Execute them in parallel
    for (ScheduledContent sc : providerList) {
        if (DEBUG) {
            System.out.println(sc.settings + " => " + sc.desc);
        }
        final ProviderTask task = new ProviderTask(uniqueId, index, sc.desc, sc.settings, listener);
        synchronized (workQueue) {
            workQueue.add(task);
        }
        new Thread(task).start();
        index++;
    }
    return index;
}
Also used : ContentDescriptor(org.csstudio.autocomplete.parser.ContentDescriptor) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ScopedPreferenceStore(org.eclipse.ui.preferences.ScopedPreferenceStore)

Example 14 with ScopedPreferenceStore

use of org.eclipse.ui.preferences.ScopedPreferenceStore in project eclipse.platform.text by eclipse.

the class WorkbenchChainedTextFontFieldEditor method startPropagate.

/**
 * Starts the propagation of the text font preference set in the workbench
 * to given target preference store using the given preference key.
 *
 * @param target the target preference store
 * @param targetKey the key to be used in the target preference store
 */
public static void startPropagate(IPreferenceStore target, String targetKey) {
    // $NON-NLS-1$
    IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.ui.workbench");
    PropagatingFontFieldEditor.startPropagate(store, JFaceResources.TEXT_FONT, target, targetKey);
}
Also used : IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ScopedPreferenceStore(org.eclipse.ui.preferences.ScopedPreferenceStore)

Example 15 with ScopedPreferenceStore

use of org.eclipse.ui.preferences.ScopedPreferenceStore in project linuxtools by eclipse.

the class GprofLaunchTest method setUp.

@Before
public void setUp() throws Exception {
    // $NON-NLS-1$
    proj = createProjectAndBuild(FrameworkUtil.getBundle(this.getClass()), "fibTest");
    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());
    // (otherwise test hangs on 'enable GGprof support' dialogue. )
    enableGprofSupport();
    // ---- Continue with launch.
    launch = new Launch(config, ILaunchManager.PROFILE_MODE, null);
    wc = config.getWorkingCopy();
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) Launch(org.eclipse.debug.core.Launch) ILaunch(org.eclipse.debug.core.ILaunch) ScopedPreferenceStore(org.eclipse.ui.preferences.ScopedPreferenceStore) CoreException(org.eclipse.core.runtime.CoreException) Before(org.junit.Before)

Aggregations

ScopedPreferenceStore (org.eclipse.ui.preferences.ScopedPreferenceStore)24 ProjectScope (org.eclipse.core.resources.ProjectScope)9 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)8 IOException (java.io.IOException)4 IProject (org.eclipse.core.resources.IProject)4 IResource (org.eclipse.core.resources.IResource)3 CoreException (org.eclipse.core.runtime.CoreException)3 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)3 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 ILaunch (org.eclipse.debug.core.ILaunch)2 Launch (org.eclipse.debug.core.Launch)2 Before (org.junit.Before)2 BufferedInputStream (java.io.BufferedInputStream)1 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 HashMap (java.util.HashMap)1 Entry (java.util.Map.Entry)1