Search in sources :

Example 1 with SonarLintGlobalConfigurable

use of org.sonarlint.intellij.config.global.SonarLintGlobalConfigurable in project sonarlint-intellij by SonarSource.

the class SonarLintProjectConfigurable method reset.

@Override
public void reset() {
    if (panel == null) {
        return;
    }
    List<SonarQubeServer> currentServers = null;
    // try get the global settings that are currently being configured in the configurable, if it is open
    DataContext ctx = DataManager.getInstance().getDataContextFromFocus().getResult();
    if (ctx != null) {
        Settings allSettings = Settings.KEY.getData(ctx);
        if (allSettings != null) {
            final SonarLintGlobalConfigurable globalConfigurable = allSettings.find(SonarLintGlobalConfigurable.class);
            if (globalConfigurable != null) {
                currentServers = globalConfigurable.getCurrentSettings();
            }
        }
    }
    // get saved settings if needed
    if (currentServers == null) {
        currentServers = SonarLintUtils.get(SonarLintGlobalSettings.class).getSonarQubeServers();
    }
    panel.load(currentServers, projectSettings);
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) SonarLintGlobalConfigurable(org.sonarlint.intellij.config.global.SonarLintGlobalConfigurable) SonarQubeServer(org.sonarlint.intellij.config.global.SonarQubeServer) Settings(com.intellij.openapi.options.ex.Settings) SonarLintGlobalSettings(org.sonarlint.intellij.config.global.SonarLintGlobalSettings)

Example 2 with SonarLintGlobalConfigurable

use of org.sonarlint.intellij.config.global.SonarLintGlobalConfigurable in project sonarlint-intellij by SonarSource.

the class SonarLintProjectBindPanel method actionConfigureServers.

/**
 * Navigates to global configuration. There are 2 possible ways of doing it, depending on how the settings are opened.
 */
private void actionConfigureServers() {
    Settings allSettings = Settings.KEY.getData(DataManager.getInstance().getDataContext(rootPanel));
    if (allSettings != null) {
        final SonarLintGlobalConfigurable globalConfigurable = allSettings.find(SonarLintGlobalConfigurable.class);
        if (globalConfigurable != null) {
            allSettings.select(globalConfigurable);
        }
    } else {
        SonarLintGlobalConfigurable globalConfigurable = new SonarLintGlobalConfigurable();
        ShowSettingsUtil.getInstance().editConfigurable(rootPanel, globalConfigurable);
    }
}
Also used : SonarLintGlobalConfigurable(org.sonarlint.intellij.config.global.SonarLintGlobalConfigurable) Settings(com.intellij.openapi.options.ex.Settings)

Aggregations

Settings (com.intellij.openapi.options.ex.Settings)2 SonarLintGlobalConfigurable (org.sonarlint.intellij.config.global.SonarLintGlobalConfigurable)2 DataContext (com.intellij.openapi.actionSystem.DataContext)1 SonarLintGlobalSettings (org.sonarlint.intellij.config.global.SonarLintGlobalSettings)1 SonarQubeServer (org.sonarlint.intellij.config.global.SonarQubeServer)1