diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/ProjectView.java b/platform/lang-impl/src/com/intellij/ide/projectView/ProjectView.java index bc4b1e44149b..fd3469cf46b6 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/ProjectView.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/ProjectView.java @@ -89,6 +89,10 @@ public abstract class ProjectView { return true; } + public boolean isShowVisibilityIcons(String paneId) { + return false; + } + public abstract boolean isShowLibraryContents(String paneId); public abstract void setShowLibraryContents(@NotNull String paneId, boolean showLibraryContents); diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/ProjectViewSettings.java b/platform/lang-impl/src/com/intellij/ide/projectView/ProjectViewSettings.java index 4684bb9feecc..96b71d4590c5 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/ProjectViewSettings.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/ProjectViewSettings.java @@ -14,6 +14,10 @@ import org.jetbrains.annotations.Nullable; public interface ProjectViewSettings extends ViewSettings { boolean isShowExcludedFiles(); + default boolean isShowVisibilityIcons() { + return false; + } + /** * If {@code true} then {@link com.intellij.ide.projectView.impl.NestingTreeStructureProvider} will modify the tree presentation * according to the rules managed by {@link com.intellij.ide.projectView.impl.ProjectViewFileNestingService}: some peer files will be @@ -26,11 +30,13 @@ public interface ProjectViewSettings extends ViewSettings { public static final ProjectViewSettings DEFAULT = new ProjectViewSettings.Immutable(null); private final boolean myShowExcludedFiles; + private final boolean myShowVisibilityIcons; private final boolean myUseFileNestingRules; public Immutable(ProjectViewSettings settings) { super(settings); myShowExcludedFiles = settings != null && settings.isShowExcludedFiles(); + myShowVisibilityIcons = settings != null && settings.isShowVisibilityIcons(); myUseFileNestingRules = settings == null || settings.isUseFileNestingRules(); } @@ -39,6 +45,11 @@ public interface ProjectViewSettings extends ViewSettings { return myShowExcludedFiles; } + @Override + public boolean isShowVisibilityIcons() { + return myShowVisibilityIcons; + } + @Override public boolean isUseFileNestingRules() { return myUseFileNestingRules; @@ -50,6 +61,7 @@ public interface ProjectViewSettings extends ViewSettings { if (!super.equals(object)) return false; ProjectViewSettings settings = (ProjectViewSettings)object; return settings.isShowExcludedFiles() == isShowExcludedFiles() && + settings.isShowVisibilityIcons() == isShowVisibilityIcons() && settings.isUseFileNestingRules() == isUseFileNestingRules(); } @@ -57,6 +69,7 @@ public interface ProjectViewSettings extends ViewSettings { public int hashCode() { int result = super.hashCode(); result = 31 * result + Boolean.hashCode(isShowExcludedFiles()); + result = 31 * result + Boolean.hashCode(isShowVisibilityIcons()); result = 31 * result + Boolean.hashCode(isUseFileNestingRules()); return result; } @@ -81,6 +94,12 @@ public interface ProjectViewSettings extends ViewSettings { return view != null && view.isShowExcludedFiles(getPaneID(view)); } + @Override + public boolean isShowVisibilityIcons() { + ProjectView view = getProjectView(); + return view != null && view.isShowVisibilityIcons(getPaneID(view)); + } + @Override public boolean isUseFileNestingRules() { ProjectViewSettings settings = getProjectViewSettings(); diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java index 2cce5c039b19..b5b7b14c7695 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewImpl.java @@ -119,6 +119,8 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo private static final boolean ourFlattenModulesDefaults = false; private final Map myShowExcludedFiles = new THashMap<>(); private static final boolean ourShowExcludedFilesDefaults = true; + private final Map myShowVisibilityIcons = new THashMap<>(); + private static final boolean ourShowVisibilityIconsDefaults = false; private final Map myShowLibraryContents = new THashMap<>(); private static final boolean ourShowLibraryContentsDefaults = true; private final Map myHideEmptyPackages = new THashMap<>(); @@ -163,6 +165,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo @NonNls private static final String ELEMENT_SHOW_MEMBERS = "showMembers"; @NonNls private static final String ELEMENT_SHOW_MODULES = "showModules"; @NonNls private static final String ELEMENT_SHOW_EXCLUDED_FILES = "showExcludedFiles"; + @NonNls private static final String ELEMENT_SHOW_VISIBILITY_ICONS = "showVisibilityIcons"; @NonNls private static final String ELEMENT_SHOW_LIBRARY_CONTENTS = "showLibraryContents"; @NonNls private static final String ELEMENT_HIDE_EMPTY_PACKAGES = "hideEmptyPackages"; @NonNls private static final String ELEMENT_COMPACT_DIRECTORIES = "compactDirectories"; @@ -712,6 +715,24 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo myActionGroup.addAction(new FoldersAlwaysOnTopAction()).setAsSecondary(true); myActionGroup.addAction(ShowExcludedFilesAction.INSTANCE).setAsSecondary(true); + myActionGroup.addAction(new PaneOptionAction(myShowVisibilityIcons, + IdeBundle.message("action.show.visibility.icons.text"), + IdeBundle.message("action.show.visibility.icons.description"), + null, ourShowVisibilityIconsDefaults) { + + @Override + public boolean isSelected(@NotNull AnActionEvent event) { + if (isGlobalOptions()) return getGlobalOptions().getShowVisibilityIcons(); + return super.isSelected(event); + } + + @Override + public void setSelected(@NotNull AnActionEvent event, boolean showVisibilityIcons) { + if (isGlobalOptions()) getGlobalOptions().setShowVisibilityIcons(showVisibilityIcons); + super.setSelected(event, showVisibilityIcons); + } + }).setAsSecondary(true); + getProjectViewPaneById(myCurrentViewId == null ? getDefaultViewId() : myCurrentViewId).addToolbarActions(myActionGroup); List titleActions = ContainerUtil.newSmartList(); @@ -1398,6 +1419,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo readOption(navigatorElement.getChild(ELEMENT_SHOW_MEMBERS), myShowMembers); readOption(navigatorElement.getChild(ELEMENT_SHOW_MODULES), myShowModules); readOption(navigatorElement.getChild(ELEMENT_SHOW_EXCLUDED_FILES), myShowExcludedFiles); + readOption(navigatorElement.getChild(ELEMENT_SHOW_VISIBILITY_ICONS), myShowVisibilityIcons); readOption(navigatorElement.getChild(ELEMENT_SHOW_LIBRARY_CONTENTS), myShowLibraryContents); readOption(navigatorElement.getChild(ELEMENT_HIDE_EMPTY_PACKAGES), myHideEmptyPackages); readOption(navigatorElement.getChild(ELEMENT_COMPACT_DIRECTORIES), myCompactDirectories); @@ -1477,6 +1499,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo writeOption(navigatorElement, myShowMembers, ELEMENT_SHOW_MEMBERS); writeOption(navigatorElement, myShowModules, ELEMENT_SHOW_MODULES); writeOption(navigatorElement, myShowExcludedFiles, ELEMENT_SHOW_EXCLUDED_FILES); + writeOption(navigatorElement, myShowVisibilityIcons, ELEMENT_SHOW_VISIBILITY_ICONS); writeOption(navigatorElement, myShowLibraryContents, ELEMENT_SHOW_LIBRARY_CONTENTS); writeOption(navigatorElement, myHideEmptyPackages, ELEMENT_HIDE_EMPTY_PACKAGES); writeOption(navigatorElement, myCompactDirectories, ELEMENT_COMPACT_DIRECTORIES); @@ -1679,6 +1702,13 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo } } + @Override + public boolean isShowVisibilityIcons(String paneId) { + return isGlobalOptions() + ? getGlobalOptions().getShowVisibilityIcons() + : getPaneOptionValue(myShowVisibilityIcons, paneId, ourShowVisibilityIconsDefaults); + } + @Override public boolean isShowLibraryContents(String paneId) { if (isGlobalOptions()) { diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewPane.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewPane.java index a6cd1031f55a..35a5616d7141 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewPane.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewPane.java @@ -229,6 +229,11 @@ public class ProjectViewPane extends AbstractProjectViewPSIPane { return ProjectView.getInstance(myProject).isShowExcludedFiles(ID); } + @Override + public boolean isShowVisibilityIcons() { + return ProjectView.getInstance(myProject).isShowVisibilityIcons(ID); + } + @Override public boolean isUseFileNestingRules() { return myUseFileNestingRules; diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewSharedSettings.kt b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewSharedSettings.kt index 504969fb4acc..68f634418a38 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewSharedSettings.kt +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/ProjectViewSharedSettings.kt @@ -18,6 +18,7 @@ class ProjectViewSharedSettings : PersistentStateComponent extends ProjectViewNode @Iconable.IconFlags protected int getIconableFlags() { - int flags = Registry.is("ide.projectView.show.visibility") ? Iconable.ICON_FLAG_VISIBILITY : 0; + int flags = 0; + ViewSettings settings = getSettings(); + if (settings instanceof ProjectViewSettings && ((ProjectViewSettings)settings).isShowVisibilityIcons()) { + flags |= Iconable.ICON_FLAG_VISIBILITY; + } if (isMarkReadOnly()) { flags |= Iconable.ICON_FLAG_READ_STATUS; } diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties index 2b91d23db2df..f6896d89f172 100644 --- a/platform/platform-resources-en/src/messages/IdeBundle.properties +++ b/platform/platform-resources-en/src/messages/IdeBundle.properties @@ -622,6 +622,8 @@ action.show.libraries.contents=Show Libraries Contents action.show.hide.library.contents=Show/Hide Library Contents action.show.excluded.files=Show Excluded Files action.show.hide.excluded.files=Show/Hide Excluded Files +action.show.visibility.icons.text=Show Visibility Icons +action.show.visibility.icons.description=Show/Hide Visibility Icons action.file.nesting.in.project.view=File Nesting... file.nesting.dialog.title=File Nesting file.nesting.feature.enabled.checkbox=&Show files with the same names as nested diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index 4ec6fc157b7f..bc735aa08de7 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -1450,9 +1450,6 @@ ide.projectView.PackageViewTreeStructure.BuildChildrenInBackground.description=T ide.structureView.StructureViewTreeStructure.BuildChildrenInBackground=false ide.structureView.StructureViewTreeStructure.BuildChildrenInBackground.description=Temporary ability to control a tree building for the Structure View pane -ide.projectView.show.visibility=false -ide.projectView.show.visibility.description=Shows visibility icon in Project View nodes - ide.icons.deferUrlResolve.description=Defer resolving URL for IDE icons ide.icons.deferUrlResolve=true