This is an automated email from the ASF dual-hosted git repository. matthiasblaesing pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push: new 241a4180d5 Maven indexing: Retain download index setting even if index setting is disabled new 58ea71d87e Merge pull request #5673 from matthiasblaesing/maven_index_settings 241a4180d5 is described below commit 241a4180d5ec494d83399fb8c722ff9acbdf744c Author: Matthias Bläsing <mblaes...@doppel-helix.eu> AuthorDate: Fri Mar 17 17:43:45 2023 +0100 Maven indexing: Retain download index setting even if index setting is disabled When the maven general indexing is disabled, the setting for the index download is lost and forced to be false. Instead of loosing the value a new preferences getter is introduced, that calculates the effective value based on the two components: - general indexing - download index Only if both settings are true, the effective value will be true. --- .../modules/maven/indexer/NexusRepositoryIndexerImpl.java | 4 ++-- .../modules/maven/indexer/api/RepositoryPreferences.java | 11 +++++++++++ .../src/org/netbeans/modules/maven/ProjectOpenedHookImpl.java | 2 +- .../src/org/netbeans/modules/maven/options/SettingsPanel.java | 11 ----------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/java/maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryIndexerImpl.java b/java/maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryIndexerImpl.java index 8363a3142a..f0e2989086 100644 --- a/java/maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryIndexerImpl.java +++ b/java/maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryIndexerImpl.java @@ -653,7 +653,7 @@ public class NexusRepositoryIndexerImpl implements RepositoryIndexerImplementati //spawn the indexing into a separate thread.. private boolean spawnIndexLoadedRepo(final RepositoryInfo repo) { - if (!RepositoryPreferences.isIndexDownloadEnabled() && repo.isRemoteDownloadable()) { + if (!RepositoryPreferences.isIndexDownloadEnabledEffective() && repo.isRemoteDownloadable()) { LOGGER.log(Level.FINE, "Skipping remote index request for {0}", repo); return false; } @@ -678,7 +678,7 @@ public class NexusRepositoryIndexerImpl implements RepositoryIndexerImplementati @Override public void indexRepo(final RepositoryInfo repo) { - if (!RepositoryPreferences.isIndexDownloadEnabled() && repo.isRemoteDownloadable()) { + if (!RepositoryPreferences.isIndexDownloadEnabledEffective() && repo.isRemoteDownloadable()) { LOGGER.log(Level.FINE, "Skipping remote index request for {0}", repo); return; } diff --git a/java/maven.indexer/src/org/netbeans/modules/maven/indexer/api/RepositoryPreferences.java b/java/maven.indexer/src/org/netbeans/modules/maven/indexer/api/RepositoryPreferences.java index 08878229fa..7c1b79ab0a 100644 --- a/java/maven.indexer/src/org/netbeans/modules/maven/indexer/api/RepositoryPreferences.java +++ b/java/maven.indexer/src/org/netbeans/modules/maven/indexer/api/RepositoryPreferences.java @@ -390,6 +390,17 @@ public final class RepositoryPreferences { return getPreferences().getBoolean(PROP_DOWNLOAD_INDEX, getDefaultDownloadIndexEnabled()); } + /** + * Downloading the remote index should only happen if indexing in general + * and downloading in particular are enabled. + * + * @since 2.60 + * @return true if indexing and downloading are both enabled. + */ + public static boolean isIndexDownloadEnabledEffective() { + return isIndexRepositories() && isIndexDownloadEnabled(); + } + @NbBundle.Messages({ "# true or false:", "DEFAULT_DOWNLOAD_INDEX=true" diff --git a/java/maven/src/org/netbeans/modules/maven/ProjectOpenedHookImpl.java b/java/maven/src/org/netbeans/modules/maven/ProjectOpenedHookImpl.java index 8fae98a1c3..14f716d712 100644 --- a/java/maven/src/org/netbeans/modules/maven/ProjectOpenedHookImpl.java +++ b/java/maven/src/org/netbeans/modules/maven/ProjectOpenedHookImpl.java @@ -203,7 +203,7 @@ public class ProjectOpenedHookImpl extends ProjectOpenedHook { LOGGER.log(Level.FINER, "Index once a Week :{0}", ri.getId());//NOI18N run = true; } - if (run && ri.isRemoteDownloadable() && RepositoryPreferences.isIndexDownloadEnabled()) { + if (run && ri.isRemoteDownloadable()) { RepositoryIndexer.indexRepo(ri); } } diff --git a/java/maven/src/org/netbeans/modules/maven/options/SettingsPanel.java b/java/maven/src/org/netbeans/modules/maven/options/SettingsPanel.java index 5877c3b5e9..0a34f3fd7e 100644 --- a/java/maven/src/org/netbeans/modules/maven/options/SettingsPanel.java +++ b/java/maven/src/org/netbeans/modules/maven/options/SettingsPanel.java @@ -993,21 +993,10 @@ public class SettingsPanel extends javax.swing.JPanel { updateCheckboxes(); }//GEN-LAST:event_cbEnableIndexingActionPerformed - // short term UI memory, to select index download again when indexing - // was toggled off and on by the user - private boolean indexDownloadWasEnabled = false; - private void updateCheckboxes() { - if (!cbEnableIndexing.isSelected()) { - indexDownloadWasEnabled = cbEnableIndexDownload.isSelected(); - cbEnableIndexDownload.setSelected(false); - } else if (indexDownloadWasEnabled) { - cbEnableIndexDownload.setSelected(true); - } cbEnableIndexDownload.setEnabled(cbEnableIndexing.isSelected()); } - // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnDirectory; private javax.swing.JButton btnGoals; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists