mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Refactoring: create instances of IdeConfigurablesGroup and ProjectConfigurablesGroup in one place.
This commit is contained in:
@@ -58,8 +58,6 @@ import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.openapi.keymap.MacKeymapUtil;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.SearchableConfigurable;
|
||||
import com.intellij.openapi.options.ex.IdeConfigurablesGroup;
|
||||
import com.intellij.openapi.options.ex.ProjectConfigurablesGroup;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.util.ProgressIndicatorBase;
|
||||
@@ -1793,8 +1791,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
|
||||
project.putUserData(ChooseByNamePopup.CHOOSE_BY_NAME_POPUP_IN_PROJECT_KEY, null);
|
||||
myActionModel = createActionModel();
|
||||
myConfigurables.clear();
|
||||
fillConfigurablesIds(null, new IdeConfigurablesGroup().getConfigurables());
|
||||
fillConfigurablesIds(null, new ProjectConfigurablesGroup(project).getConfigurables());
|
||||
fillConfigurablesIds(null, ShowSettingsUtilImpl.getConfigurables(project, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.intellij.ide.util.gotoByName;
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.actions.ApplyIntentionAction;
|
||||
import com.intellij.ide.actions.ShowSettingsUtilImpl;
|
||||
import com.intellij.ide.ui.search.ActionFromOptionDescriptorProvider;
|
||||
import com.intellij.ide.ui.search.OptionDescription;
|
||||
import com.intellij.ide.ui.search.SearchableOptionsRegistrar;
|
||||
@@ -32,8 +33,6 @@ import com.intellij.openapi.keymap.KeymapManager;
|
||||
import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.SearchableConfigurable;
|
||||
import com.intellij.openapi.options.ex.IdeConfigurablesGroup;
|
||||
import com.intellij.openapi.options.ex.ProjectConfigurablesGroup;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
@@ -103,10 +102,7 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel, C
|
||||
}
|
||||
}
|
||||
myIndex = SearchableOptionsRegistrar.getInstance();
|
||||
fillConfigurablesNames(new IdeConfigurablesGroup().getConfigurables());
|
||||
if (project != null) {
|
||||
fillConfigurablesNames(new ProjectConfigurablesGroup(project).getConfigurables());
|
||||
}
|
||||
fillConfigurablesNames(ShowSettingsUtilImpl.getConfigurables(project, true));
|
||||
}
|
||||
|
||||
private void fillConfigurablesNames(Configurable[] configurables) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,8 +28,6 @@ import com.intellij.openapi.actionSystem.ex.ActionManagerEx;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.options.ex.IdeConfigurablesGroup;
|
||||
import com.intellij.openapi.options.ex.ProjectConfigurablesGroup;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
@@ -98,8 +96,7 @@ public class MacOSApplicationProvider implements ApplicationComponent {
|
||||
}
|
||||
|
||||
if (!((ShowSettingsUtilImpl)ShowSettingsUtil.getInstance()).isAlreadyShown()) {
|
||||
ShowSettingsUtil.getInstance().showSettingsDialog(project, new ProjectConfigurablesGroup(project),
|
||||
new IdeConfigurablesGroup());
|
||||
ShowSettingsUtil.getInstance().showSettingsDialog(project, ShowSettingsUtilImpl.getConfigurableGroups(project, true));
|
||||
}
|
||||
applicationEvent.setHandled(true);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,8 +20,6 @@ import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.options.ex.IdeConfigurablesGroup;
|
||||
import com.intellij.openapi.options.ex.ProjectConfigurablesGroup;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
@@ -60,7 +58,6 @@ public class ShowSettingsAction extends AnAction implements DumbAware {
|
||||
}
|
||||
}
|
||||
});
|
||||
ShowSettingsUtil.getInstance().showSettingsDialog(project, new ProjectConfigurablesGroup(project),
|
||||
new IdeConfigurablesGroup());
|
||||
ShowSettingsUtil.getInstance().showSettingsDialog(project, ShowSettingsUtilImpl.getConfigurableGroups(project, true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,6 +29,7 @@ import com.intellij.openapi.options.newEditor.OptionsEditorDialog;
|
||||
import com.intellij.openapi.options.newEditor.PreferencesDialog;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.util.ui.update.Activatable;
|
||||
import com.intellij.util.ui.update.UiNotifyConnector;
|
||||
@@ -47,11 +48,58 @@ public class ShowSettingsUtilImpl extends ShowSettingsUtil {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ide.actions.ShowSettingsUtilImpl");
|
||||
private AtomicBoolean myShown = new AtomicBoolean(false);
|
||||
|
||||
@NotNull
|
||||
private static Project getProject(@Nullable Project project) {
|
||||
return project != null ? project : ProjectManager.getInstance().getDefaultProject();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static DialogWrapper getDialog(@Nullable Project project, @NotNull ConfigurableGroup[] groups, @Nullable Configurable toSelect) {
|
||||
return Registry.is("ide.perProjectModality")
|
||||
? new OptionsEditorDialog(getProject(project), filterEmptyGroups(groups), toSelect, true)
|
||||
: Registry.is("ide.new.preferences")
|
||||
? new PreferencesDialog(getProject(project), filterEmptyGroups(groups))
|
||||
: new OptionsEditorDialog(getProject(project), filterEmptyGroups(groups), toSelect);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ConfigurableGroup[] getConfigurableGroups(@Nullable Project project, boolean withIdeSettings) {
|
||||
return !withIdeSettings
|
||||
? new ConfigurableGroup[]{new ProjectConfigurablesGroup(getProject(project))}
|
||||
: (project == null)
|
||||
? new ConfigurableGroup[]{new IdeConfigurablesGroup()}
|
||||
: new ConfigurableGroup[]{
|
||||
new ProjectConfigurablesGroup(project),
|
||||
new IdeConfigurablesGroup()};
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Configurable[] getConfigurables(@Nullable Project project, boolean withGroupReverseOrder) {
|
||||
return getConfigurables(getConfigurableGroups(project, true), withGroupReverseOrder);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Configurable[] getConfigurables(@NotNull ConfigurableGroup[] groups, boolean withGroupReverseOrder) {
|
||||
Configurable[][] arrays = new Configurable[groups.length][];
|
||||
int length = 0;
|
||||
for (int i = 0; i < groups.length; i++) {
|
||||
arrays[i] = groups[withGroupReverseOrder ? groups.length - 1 - i : i].getConfigurables();
|
||||
length += arrays[i].length;
|
||||
}
|
||||
Configurable[] configurables = new Configurable[length];
|
||||
int offset = 0;
|
||||
for (Configurable[] array : arrays) {
|
||||
System.arraycopy(array, 0, configurables, offset, array.length);
|
||||
offset += array.length;
|
||||
}
|
||||
return configurables;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showSettingsDialog(@NotNull Project project, @NotNull ConfigurableGroup[] group) {
|
||||
try {
|
||||
myShown.set(true);
|
||||
_showSettingsDialog(project, group, null);
|
||||
getDialog(project, group, null).show();
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
@@ -61,41 +109,17 @@ public class ShowSettingsUtilImpl extends ShowSettingsUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static void _showSettingsDialog(@NotNull final Project project, @NotNull ConfigurableGroup[] group, @Nullable Configurable toSelect) {
|
||||
group = filterEmptyGroups(group);
|
||||
if (Registry.is("ide.perProjectModality")) {
|
||||
new OptionsEditorDialog(project, group, toSelect, true).show();
|
||||
} else {
|
||||
if (Registry.is("ide.new.preferences")) {
|
||||
new PreferencesDialog(project, group).show();
|
||||
} else {
|
||||
new OptionsEditorDialog(project, group, toSelect).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showSettingsDialog(@Nullable final Project project, final Class configurableClass) {
|
||||
assert Configurable.class.isAssignableFrom(configurableClass) : "Not a configurable: " + configurableClass.getName();
|
||||
|
||||
ConfigurableGroup[] groups;
|
||||
IdeConfigurablesGroup commonGroup = new IdeConfigurablesGroup();
|
||||
ProjectConfigurablesGroup projectGroup = project == null ? null : new ProjectConfigurablesGroup(project);
|
||||
if (projectGroup == null) {
|
||||
groups = new ConfigurableGroup[] {commonGroup};
|
||||
} else {
|
||||
groups = new ConfigurableGroup[] {projectGroup, commonGroup};
|
||||
}
|
||||
ConfigurableGroup[] groups = getConfigurableGroups(project, true);
|
||||
|
||||
Configurable config = findByClass(commonGroup.getConfigurables(), configurableClass);
|
||||
if (config == null && projectGroup != null) {
|
||||
config = findByClass(projectGroup.getConfigurables(), configurableClass);
|
||||
}
|
||||
Configurable config = findByClass(getConfigurables(groups, true), configurableClass);
|
||||
|
||||
assert config != null : "Cannot find configurable: " + configurableClass.getName();
|
||||
|
||||
@NotNull Project nnProject = project != null ? project : ProjectManager.getInstance().getDefaultProject();
|
||||
_showSettingsDialog(nnProject, groups, config);
|
||||
getDialog(project, groups, config).show();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -110,15 +134,9 @@ public class ShowSettingsUtilImpl extends ShowSettingsUtil {
|
||||
|
||||
@Override
|
||||
public void showSettingsDialog(@Nullable final Project project, @NotNull final String nameToSelect) {
|
||||
ConfigurableGroup[] group;
|
||||
if (project == null) {
|
||||
group = new ConfigurableGroup[]{new IdeConfigurablesGroup()};
|
||||
}
|
||||
else {
|
||||
group = new ConfigurableGroup[]{new ProjectConfigurablesGroup(project), new IdeConfigurablesGroup()};
|
||||
}
|
||||
ConfigurableGroup[] group = getConfigurableGroups(project, true);
|
||||
|
||||
Project actualProject = project != null ? project : ProjectManager.getInstance().getDefaultProject();
|
||||
Project actualProject = getProject(project);
|
||||
|
||||
group = filterEmptyGroups(group);
|
||||
|
||||
@@ -133,15 +151,9 @@ public class ShowSettingsUtilImpl extends ShowSettingsUtil {
|
||||
}
|
||||
|
||||
public static void showSettingsDialog(@Nullable Project project, final String id2Select, final String filter) {
|
||||
ConfigurableGroup[] group;
|
||||
if (project == null) {
|
||||
group = new ConfigurableGroup[]{new IdeConfigurablesGroup()};
|
||||
}
|
||||
else {
|
||||
group = new ConfigurableGroup[]{new ProjectConfigurablesGroup(project), new IdeConfigurablesGroup()};
|
||||
}
|
||||
ConfigurableGroup[] group = getConfigurableGroups(project, true);
|
||||
|
||||
Project actualProject = project != null ? project : ProjectManager.getInstance().getDefaultProject();
|
||||
Project actualProject = getProject(project);
|
||||
|
||||
group = filterEmptyGroups(group);
|
||||
final Configurable configurable2Select = findConfigurable2Select(id2Select, group);
|
||||
@@ -191,10 +203,7 @@ public class ShowSettingsUtilImpl extends ShowSettingsUtil {
|
||||
|
||||
@Override
|
||||
public void showSettingsDialog(@NotNull final Project project, final Configurable toSelect) {
|
||||
_showSettingsDialog(project, new ConfigurableGroup[]{
|
||||
new ProjectConfigurablesGroup(project),
|
||||
new IdeConfigurablesGroup()
|
||||
}, toSelect);
|
||||
getDialog(project, getConfigurableGroups(project, true), toSelect).show();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+2
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,7 +18,6 @@ package com.intellij.ide.actions;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.options.ex.ProjectConfigurablesGroup;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ex.ProjectManagerEx;
|
||||
@@ -26,6 +25,6 @@ import com.intellij.openapi.project.ex.ProjectManagerEx;
|
||||
public class TemplateProjectPropertiesAction extends AnAction implements DumbAware {
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
Project defaultProject = ProjectManagerEx.getInstanceEx().getDefaultProject();
|
||||
ShowSettingsUtil.getInstance().showSettingsDialog(defaultProject, new ProjectConfigurablesGroup(defaultProject));
|
||||
ShowSettingsUtil.getInstance().showSettingsDialog(defaultProject, ShowSettingsUtilImpl.getConfigurableGroups(defaultProject, false));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,13 +17,12 @@
|
||||
package com.intellij.ide.ui.search;
|
||||
|
||||
import com.intellij.application.options.SkipSelfSearchComponent;
|
||||
import com.intellij.ide.actions.ShowSettingsUtilImpl;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.ConfigurableGroup;
|
||||
import com.intellij.openapi.options.MasterDetails;
|
||||
import com.intellij.openapi.options.SearchableConfigurable;
|
||||
import com.intellij.openapi.options.ex.GlassPanel;
|
||||
import com.intellij.openapi.options.ex.IdeConfigurablesGroup;
|
||||
import com.intellij.openapi.options.ex.ProjectConfigurablesGroup;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
@@ -66,8 +65,7 @@ public class SearchUtil {
|
||||
}
|
||||
|
||||
public static void processProjectConfigurables(Project project, HashMap<SearchableConfigurable, TreeSet<OptionDescription>> options) {
|
||||
processConfigurables(new ProjectConfigurablesGroup(project).getConfigurables(), options);
|
||||
processConfigurables(new IdeConfigurablesGroup().getConfigurables(), options);
|
||||
processConfigurables(ShowSettingsUtilImpl.getConfigurables(project, false), options);
|
||||
}
|
||||
|
||||
private static void processConfigurables(final Configurable[] configurables,
|
||||
|
||||
Reference in New Issue
Block a user