Registry feature: hide modules long names in Project View and renderers

This commit is contained in:
Konstantin Bulenkov
2018-02-05 11:00:01 +01:00
parent d5f9284f2e
commit d9f111dc4b
3 changed files with 17 additions and 18 deletions
@@ -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<PsiDirectory> 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)) {
@@ -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);
}
@@ -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)
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