From d9f111dc4bcf908b9121c1e489ce4fc33535167f Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Mon, 5 Feb 2018 11:00:01 +0100 Subject: [PATCH] Registry feature: hide modules long names in Project View and renderers --- .../impl/nodes/PsiDirectoryNode.java | 17 ++--------------- .../ide/util/PsiElementModuleRenderer.java | 12 ++++++++++-- .../util/resources/misc/registry.properties | 6 +++++- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiDirectoryNode.java b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiDirectoryNode.java index 8ee8ae943ef7..42c1233e69f8 100644 --- a/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiDirectoryNode.java +++ b/platform/lang-impl/src/com/intellij/ide/projectView/impl/nodes/PsiDirectoryNode.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.projectView.impl.nodes; import com.intellij.ide.IconProvider; @@ -138,6 +124,7 @@ public class PsiDirectoryNode extends BasePsiNode implements Navig } private static boolean moduleNameMatchesDirectoryName(@NotNull Module module, @NotNull VirtualFile directoryFile, @NotNull ProjectFileIndex fileIndex) { + if (Registry.is("ide.hide.real.module.name")) return true; String moduleName = module.getName(); String directoryName = directoryFile.getName(); if (moduleName.equalsIgnoreCase(directoryName)) { diff --git a/platform/lang-impl/src/com/intellij/ide/util/PsiElementModuleRenderer.java b/platform/lang-impl/src/com/intellij/ide/util/PsiElementModuleRenderer.java index 437ec71592f7..56983d2f4214 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/PsiElementModuleRenderer.java +++ b/platform/lang-impl/src/com/intellij/ide/util/PsiElementModuleRenderer.java @@ -1,4 +1,4 @@ -// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.util; @@ -6,7 +6,10 @@ import com.intellij.icons.AllIcons; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleType; import com.intellij.openapi.module.ModuleUtil; +import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.roots.*; +import com.intellij.openapi.util.registry.Registry; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.JarFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; @@ -82,7 +85,12 @@ public class PsiElementModuleRenderer extends DefaultListCellRenderer{ inTestSource = fileIndex.isInTestSourceContent(vFile); } } - myText = module.getName(); + if (Registry.is("ide.show.folder.name.instead.of.module.name")) { + String path = ModuleUtilCore.getModuleDirPath(module); + myText = StringUtil.isEmpty(path) ? module.getName() : new File(path).getName(); + } else { + myText = module.getName(); + } if (inTestSource) { setIcon(AllIcons.Modules.TestSourceFolder); } diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index 0dc0aed45524..009f76108d26 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -1462,4 +1462,8 @@ animation.disabled.on.remote.desktop=false animation.disabled.on.remote.desktop.description=Allows to stop animation via RDP editor.highlight.foldings=true -editor.highlight.foldings.description=Highlight folded regions containing certain highlighters (e.g. for search results) \ No newline at end of file +editor.highlight.foldings.description=Highlight folded regions containing certain highlighters (e.g. for search results) +ide.hide.real.module.name=false +ide.hide.real.module.name.description=Removes real module name from Project View in square brackets +ide.show.folder.name.instead.of.module.name=false +ide.show.folder.name.instead.of.module.name.description=Uses module folder name instead of module name in renderers \ No newline at end of file