mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup (I18N, warnings)
This commit is contained in:
+28
-28
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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,6 +18,7 @@ package com.intellij.ide.projectView.impl.nodes;
|
||||
import com.intellij.ide.projectView.PresentationData;
|
||||
import com.intellij.ide.projectView.ProjectViewNode;
|
||||
import com.intellij.ide.projectView.ViewSettings;
|
||||
import com.intellij.idea.ActionsBundle;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -32,6 +33,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public abstract class AbstractModuleNode extends ProjectViewNode<Module> implements NavigatableWithText {
|
||||
protected AbstractModuleNode(Project project, Module module, ViewSettings viewSettings) {
|
||||
@@ -40,32 +42,31 @@ public abstract class AbstractModuleNode extends ProjectViewNode<Module> impleme
|
||||
|
||||
@Override
|
||||
public void update(PresentationData presentation) {
|
||||
if (getValue().isDisposed()) {
|
||||
Module module = getValue();
|
||||
if (module == null || module.isDisposed()) {
|
||||
setValue(null);
|
||||
return;
|
||||
}
|
||||
presentation.setPresentableText(getValue().getName());
|
||||
|
||||
presentation.setPresentableText(module.getName());
|
||||
if (showModuleNameInBold()) {
|
||||
presentation.addText(getValue().getName(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
|
||||
presentation.addText(module.getName(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
|
||||
}
|
||||
|
||||
presentation.setIcon(ModuleType.get(getValue()).getIcon());
|
||||
presentation.setIcon(ModuleType.get(module).getIcon());
|
||||
|
||||
presentation.setTooltip(ModuleType.get(module).getName());
|
||||
}
|
||||
|
||||
protected boolean showModuleNameInBold() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getTestPresentation() {
|
||||
return "Module";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<VirtualFile> getRoots() {
|
||||
return Arrays.asList(ModuleRootManager.getInstance(getValue()).getContentRoots());
|
||||
Module module = getValue();
|
||||
return module != null ? Arrays.asList(ModuleRootManager.getInstance(module).getContentRoots()) : Collections.<VirtualFile>emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,24 +74,17 @@ public abstract class AbstractModuleNode extends ProjectViewNode<Module> impleme
|
||||
Module module = getValue();
|
||||
if (module == null || module.isDisposed()) return false;
|
||||
|
||||
final VirtualFile testee;
|
||||
if (file.getFileSystem() instanceof JarFileSystem) {
|
||||
testee = JarFileSystem.getInstance().getVirtualFileForJar(file);
|
||||
if (testee == null) return false;
|
||||
VirtualFile local = JarFileSystem.getInstance().getVirtualFileForJar(file);
|
||||
if (local == null) return false;
|
||||
file = local;
|
||||
}
|
||||
else {
|
||||
testee = file;
|
||||
}
|
||||
for (VirtualFile root : ModuleRootManager.getInstance(module).getContentRoots()) {
|
||||
if (VfsUtilCore.isAncestor(root, testee, false)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getToolTip() {
|
||||
final Module module = getValue();
|
||||
return ModuleType.get(module).getName();
|
||||
for (VirtualFile root : ModuleRootManager.getInstance(module).getContentRoots()) {
|
||||
if (VfsUtilCore.isAncestor(root, file, false)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -103,11 +97,17 @@ public abstract class AbstractModuleNode extends ProjectViewNode<Module> impleme
|
||||
|
||||
@Override
|
||||
public String getNavigateActionText(boolean focusEditor) {
|
||||
return "Open Module Settings";
|
||||
return ActionsBundle.message("action.ModuleSettings.navigate");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canNavigate() {
|
||||
return ProjectSettingsService.getInstance(myProject).canOpenModuleSettings() && getValue() != null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public String getTestPresentation() {
|
||||
return "Module";
|
||||
}
|
||||
}
|
||||
|
||||
+39
-31
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.ide.projectView.impl.nodes;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
@@ -22,6 +21,7 @@ import com.intellij.ide.projectView.PresentationData;
|
||||
import com.intellij.ide.projectView.ProjectViewNode;
|
||||
import com.intellij.ide.projectView.ViewSettings;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeNode;
|
||||
import com.intellij.idea.ActionsBundle;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.SdkType;
|
||||
@@ -47,16 +47,14 @@ public class NamedLibraryElementNode extends ProjectViewNode<NamedLibraryElement
|
||||
@Override
|
||||
@NotNull
|
||||
public Collection<AbstractTreeNode> getChildren() {
|
||||
final List<AbstractTreeNode> children = new ArrayList<AbstractTreeNode>();
|
||||
LibraryGroupNode.addLibraryChildren(getValue().getOrderEntry(), children, getProject(), this);
|
||||
List<AbstractTreeNode> children = new ArrayList<AbstractTreeNode>();
|
||||
NamedLibraryElement libraryElement = getValue();
|
||||
if (libraryElement != null) {
|
||||
LibraryGroupNode.addLibraryChildren(libraryElement.getOrderEntry(), children, getProject(), this);
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTestPresentation() {
|
||||
return "Library: " + getValue().getName();
|
||||
}
|
||||
|
||||
private static Icon getJdkIcon(JdkOrderEntry entry) {
|
||||
final Sdk sdk = entry.getJdk();
|
||||
if (sdk == null) {
|
||||
@@ -68,40 +66,39 @@ public class NamedLibraryElementNode extends ProjectViewNode<NamedLibraryElement
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getValue().getName();
|
||||
NamedLibraryElement library = getValue();
|
||||
return library != null ? library.getName() : "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(@NotNull VirtualFile file) {
|
||||
return orderEntryContainsFile(getValue().getOrderEntry(), file);
|
||||
}
|
||||
NamedLibraryElement library = getValue();
|
||||
if (library == null) return false;
|
||||
|
||||
private static boolean orderEntryContainsFile(LibraryOrSdkOrderEntry orderEntry, VirtualFile file) {
|
||||
for(OrderRootType rootType: OrderRootType.getAllTypes()) {
|
||||
if (containsFileInOrderType(orderEntry, rootType, file)) return true;
|
||||
for (OrderRootType rootType : OrderRootType.getAllTypes()) {
|
||||
LibraryOrSdkOrderEntry orderEntry = library.getOrderEntry();
|
||||
if (orderEntry.isValid()) {
|
||||
for (VirtualFile virtualFile : orderEntry.getRootFiles(rootType)) {
|
||||
if (VfsUtilCore.isAncestor(virtualFile, file, false)) return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean containsFileInOrderType(final LibraryOrSdkOrderEntry orderEntry, final OrderRootType orderType, final VirtualFile file) {
|
||||
if (!orderEntry.isValid()) return false;
|
||||
VirtualFile[] files = orderEntry.getRootFiles(orderType);
|
||||
for (VirtualFile virtualFile : files) {
|
||||
boolean ancestor = VfsUtilCore.isAncestor(virtualFile, file, false);
|
||||
if (ancestor) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(PresentationData presentation) {
|
||||
presentation.setPresentableText(getValue().getName());
|
||||
final OrderEntry orderEntry = getValue().getOrderEntry();
|
||||
NamedLibraryElement library = getValue();
|
||||
if (library == null) return;
|
||||
|
||||
OrderEntry orderEntry = library.getOrderEntry();
|
||||
presentation.setPresentableText(library.getName());
|
||||
Icon closedIcon = orderEntry instanceof JdkOrderEntry ? getJdkIcon((JdkOrderEntry)orderEntry) : AllIcons.Nodes.PpLibFolder;
|
||||
presentation.setIcon(closedIcon);
|
||||
if (orderEntry instanceof JdkOrderEntry) {
|
||||
final JdkOrderEntry jdkOrderEntry = (JdkOrderEntry)orderEntry;
|
||||
final Sdk projectJdk = jdkOrderEntry.getJdk();
|
||||
JdkOrderEntry jdkOrderEntry = (JdkOrderEntry)orderEntry;
|
||||
Sdk projectJdk = jdkOrderEntry.getJdk();
|
||||
if (projectJdk != null) { //jdk not specified
|
||||
final String path = projectJdk.getHomePath();
|
||||
if (path != null) {
|
||||
@@ -117,16 +114,27 @@ public class NamedLibraryElementNode extends ProjectViewNode<NamedLibraryElement
|
||||
|
||||
@Override
|
||||
public void navigate(final boolean requestFocus) {
|
||||
ProjectSettingsService.getInstance(myProject).openLibraryOrSdkSettings(getValue().getOrderEntry());
|
||||
NamedLibraryElement library = getValue();
|
||||
if (library != null) {
|
||||
ProjectSettingsService.getInstance(myProject).openLibraryOrSdkSettings(library.getOrderEntry());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canNavigate() {
|
||||
return ProjectSettingsService.getInstance(myProject).canOpenLibraryOrSdkSettings(getValue().getOrderEntry());
|
||||
NamedLibraryElement library = getValue();
|
||||
return library != null && ProjectSettingsService.getInstance(myProject).canOpenLibraryOrSdkSettings(library.getOrderEntry());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNavigateActionText(boolean focusEditor) {
|
||||
return "Open Library Settings";
|
||||
return ActionsBundle.message("action.LibrarySettings.navigate");
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public String getTestPresentation() {
|
||||
NamedLibraryElement library = getValue();
|
||||
return "Library: " + (library != null ? library.getName() : "(null)");
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -24,6 +24,7 @@ import com.intellij.ide.projectView.ViewSettings;
|
||||
import com.intellij.ide.projectView.impl.ProjectRootsUtil;
|
||||
import com.intellij.ide.projectView.impl.ProjectViewImpl;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeNode;
|
||||
import com.intellij.idea.ActionsBundle;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileTypes.FileTypeRegistry;
|
||||
import com.intellij.openapi.module.Module;
|
||||
@@ -256,10 +257,10 @@ public class PsiDirectoryNode extends BasePsiNode<PsiDirectory> implements Navig
|
||||
|
||||
if (file != null && project != null) {
|
||||
if (ProjectRootsUtil.isModuleContentRoot(file, project) || ProjectRootsUtil.isModuleSourceRoot(file, project)) {
|
||||
return "Open Module Settings";
|
||||
return ActionsBundle.message("action.ModuleSettings.navigate");
|
||||
}
|
||||
if (ProjectRootsUtil.isLibraryRoot(file, project)) {
|
||||
return "Open Library Settings";
|
||||
return ActionsBundle.message("action.LibrarySettings.navigate");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -21,6 +21,7 @@ import com.intellij.ide.projectView.PresentationData;
|
||||
import com.intellij.ide.projectView.ViewSettings;
|
||||
import com.intellij.ide.projectView.impl.ProjectRootsUtil;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeNode;
|
||||
import com.intellij.idea.ActionsBundle;
|
||||
import com.intellij.openapi.editor.colors.CodeInsightColors;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -134,10 +135,7 @@ public class PsiFileNode extends BasePsiNode<PsiFile> implements NavigatableWith
|
||||
|
||||
@Override
|
||||
public String getNavigateActionText(boolean focusEditor) {
|
||||
if (isNavigatableLibraryRoot()) {
|
||||
return "Open Library Settings";
|
||||
}
|
||||
return null;
|
||||
return isNavigatableLibraryRoot() ? ActionsBundle.message("action.LibrarySettings.navigate") : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 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.
|
||||
@@ -13,10 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.packageDependencies.ui;
|
||||
|
||||
import com.intellij.analysis.AnalysisScopeBundle;
|
||||
import com.intellij.idea.ActionsBundle;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService;
|
||||
@@ -27,7 +27,7 @@ import com.intellij.psi.PsiFile;
|
||||
import javax.swing.*;
|
||||
import java.util.Set;
|
||||
|
||||
public class ModuleNode extends PackageDependenciesNode implements NavigatableWithText{
|
||||
public class ModuleNode extends PackageDependenciesNode implements NavigatableWithText {
|
||||
private final Module myModule;
|
||||
|
||||
public ModuleNode(Module module) {
|
||||
@@ -65,6 +65,7 @@ public class ModuleNode extends PackageDependenciesNode implements NavigatableWi
|
||||
return myModule == null || myModule.isDisposed() ? super.getIcon() : ModuleType.get(myModule).getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return myModule == null ? AnalysisScopeBundle.message("unknown.node.text") : myModule.getName();
|
||||
}
|
||||
@@ -90,15 +91,14 @@ public class ModuleNode extends PackageDependenciesNode implements NavigatableWi
|
||||
if (!(o instanceof ModuleNode)) return false;
|
||||
|
||||
final ModuleNode moduleNode = (ModuleNode)o;
|
||||
|
||||
return Comparing.equal(myModule, moduleNode.myModule);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return myModule == null ? 0 : myModule.hashCode();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return myModule != null && !myModule.isDisposed();
|
||||
@@ -106,6 +106,6 @@ public class ModuleNode extends PackageDependenciesNode implements NavigatableWi
|
||||
|
||||
@Override
|
||||
public String getNavigateActionText(boolean focusEditor) {
|
||||
return "Open Module Settings";
|
||||
return ActionsBundle.message("action.ModuleSettings.navigate");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1491,3 +1491,5 @@ action.StructuralSearchPlugin.StructuralSearchAction.description=Structural Sear
|
||||
action.StructuralSearchPlugin.StructuralReplaceAction.text=Repla_ce Structurally...
|
||||
action.StructuralSearchPlugin.StructuralReplaceAction.description=Structural Replace
|
||||
|
||||
action.ModuleSettings.navigate=Open Module Settings
|
||||
action.LibrarySettings.navigate=Open Library Settings
|
||||
Reference in New Issue
Block a user