Search in sources :

Example 1 with WorkingCopyManager

use of org.eclipse.ui.preferences.WorkingCopyManager in project mdw-designer by CenturyLinkCloud.

the class WorkspaceConfigurator method setFormatter.

protected void setFormatter() {
    IScopeContext instanceScope = InstanceScope.INSTANCE;
    IEclipsePreferences uiPrefs = instanceScope.getNode(JavaUI.ID_PLUGIN);
    if (getWorkspaceConfig().getCodeFormatter().equals(WorkspaceConfig.CODE_FORMATTERS[0]))
        uiPrefs.put("formatter_profile", "_CenturyLinkIT");
    else
        uiPrefs.put("formatter_profile", "_MDWCodeFormatter");
    try {
        uiPrefs.flush();
        uiPrefs.sync();
        IProfileVersioner profileVersioner = new ProfileVersioner();
        ProfileStore profileStore = new FormatterProfileStore(profileVersioner);
        List<ProfileManager.Profile> profiles = profileStore.readProfiles(instanceScope);
        if (profiles == null)
            profiles = profileStore.readProfiles(DefaultScope.INSTANCE);
        if (profiles == null)
            profiles = new ArrayList<>();
        WorkingCopyManager workingCopyManager = new WorkingCopyManager();
        PreferencesAccess access = PreferencesAccess.getWorkingCopyPreferences(workingCopyManager);
        ProfileManager profileManager = new FormatterProfileManager(profiles, instanceScope, access, profileVersioner);
        profileManager.commitChanges(instanceScope);
    } catch (Exception ex) {
        PluginMessages.uiError(getShell(), ex, "Set Code Formatter");
    }
}
Also used : FormatterProfileManager(org.eclipse.jdt.internal.ui.preferences.formatter.FormatterProfileManager) ProfileManager(org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) ArrayList(java.util.ArrayList) PreferencesAccess(org.eclipse.jdt.internal.ui.preferences.PreferencesAccess) ProfileStore(org.eclipse.jdt.internal.ui.preferences.formatter.ProfileStore) FormatterProfileStore(org.eclipse.jdt.internal.ui.preferences.formatter.FormatterProfileStore) FormatterProfileStore(org.eclipse.jdt.internal.ui.preferences.formatter.FormatterProfileStore) CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) IOException(java.io.IOException) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) WorkingCopyManager(org.eclipse.ui.preferences.WorkingCopyManager) ProfileVersioner(org.eclipse.jdt.internal.ui.preferences.formatter.ProfileVersioner) IProfileVersioner(org.eclipse.jdt.internal.ui.preferences.formatter.IProfileVersioner) FormatterProfileManager(org.eclipse.jdt.internal.ui.preferences.formatter.FormatterProfileManager) IProfileVersioner(org.eclipse.jdt.internal.ui.preferences.formatter.IProfileVersioner)

Example 2 with WorkingCopyManager

use of org.eclipse.ui.preferences.WorkingCopyManager in project xtext-eclipse by eclipse.

the class PropertyAndPreferencePage method getWorkingCopyManager.

protected IWorkingCopyManager getWorkingCopyManager() {
    IWorkbenchPreferenceContainer container = (IWorkbenchPreferenceContainer) getContainer();
    IWorkingCopyManager manager;
    if (container == null) {
        manager = new WorkingCopyManager();
    } else {
        manager = container.getWorkingCopyManager();
    }
    return manager;
}
Also used : IWorkingCopyManager(org.eclipse.ui.preferences.IWorkingCopyManager) WorkingCopyManager(org.eclipse.ui.preferences.WorkingCopyManager) IWorkbenchPreferenceContainer(org.eclipse.ui.preferences.IWorkbenchPreferenceContainer) IWorkingCopyManager(org.eclipse.ui.preferences.IWorkingCopyManager)

Aggregations

WorkingCopyManager (org.eclipse.ui.preferences.WorkingCopyManager)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 CoreException (org.eclipse.core.runtime.CoreException)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)1 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)1 PreferencesAccess (org.eclipse.jdt.internal.ui.preferences.PreferencesAccess)1 FormatterProfileManager (org.eclipse.jdt.internal.ui.preferences.formatter.FormatterProfileManager)1 FormatterProfileStore (org.eclipse.jdt.internal.ui.preferences.formatter.FormatterProfileStore)1 IProfileVersioner (org.eclipse.jdt.internal.ui.preferences.formatter.IProfileVersioner)1 ProfileManager (org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager)1 ProfileStore (org.eclipse.jdt.internal.ui.preferences.formatter.ProfileStore)1 ProfileVersioner (org.eclipse.jdt.internal.ui.preferences.formatter.ProfileVersioner)1 IWorkbenchPreferenceContainer (org.eclipse.ui.preferences.IWorkbenchPreferenceContainer)1 IWorkingCopyManager (org.eclipse.ui.preferences.IWorkingCopyManager)1