mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
hide non-working library and module settings actions from context menu of platform-based products (WI-4440)
This commit is contained in:
+20
@@ -47,18 +47,38 @@ public class IdeaProjectSettingsService extends ProjectSettingsService {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canOpenModuleSettings() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void openModuleSettings(final Module module) {
|
||||
ModulesConfigurator.showDialog(myProject, module.getName(), null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canOpenModuleLibrarySettings() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void openModuleLibrarySettings(final Module module) {
|
||||
ModulesConfigurator.showDialog(myProject, module.getName(), ClasspathEditor.NAME, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canOpenContentEntriesSettings() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void openContentEntriesSettings(final Module module) {
|
||||
ModulesConfigurator.showDialog(myProject, module.getName(), ContentEntriesEditor.NAME, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canOpenProjectLibrarySettings(NamedLibraryElement value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void openProjectLibrarySettings(final NamedLibraryElement element) {
|
||||
final ProjectStructureConfigurable config = ProjectStructureConfigurable.getInstance(myProject);
|
||||
ShowSettingsUtil.getInstance().editConfigurable(myProject, config, new Runnable() {
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ public abstract class AbstractModuleNode extends ProjectViewNode<Module> impleme
|
||||
}
|
||||
|
||||
public boolean canNavigate() {
|
||||
return true;
|
||||
return ProjectSettingsService.getInstance(myProject).canOpenModuleSettings();
|
||||
}
|
||||
|
||||
public boolean canNavigateToSource() {
|
||||
|
||||
+1
-1
@@ -117,7 +117,7 @@ public class LibraryGroupNode extends ProjectViewNode<LibraryGroupElement> {
|
||||
}
|
||||
|
||||
public boolean canNavigate() {
|
||||
return true;
|
||||
return ProjectSettingsService.getInstance(myProject).canOpenModuleLibrarySettings();
|
||||
}
|
||||
|
||||
public boolean canNavigateToSource() {
|
||||
|
||||
+1
-1
@@ -122,7 +122,7 @@ public class NamedLibraryElementNode extends ProjectViewNode<NamedLibraryElement
|
||||
}
|
||||
|
||||
public boolean canNavigate() {
|
||||
return true;
|
||||
return ProjectSettingsService.getInstance(myProject).canOpenProjectLibrarySettings(getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+8
-6
@@ -179,9 +179,10 @@ public class PsiDirectoryNode extends BasePsiNode<PsiDirectory> implements Navig
|
||||
VirtualFile file = getVirtualFile();
|
||||
Project project = getProject();
|
||||
|
||||
return file != null && (ProjectRootsUtil.isModuleContentRoot(file, project) ||
|
||||
ProjectRootsUtil.isSourceOrTestRoot(file, project) ||
|
||||
ProjectRootsUtil.isLibraryRoot(file, project));
|
||||
ProjectSettingsService service = ProjectSettingsService.getInstance(myProject);
|
||||
return file != null && ((ProjectRootsUtil.isModuleContentRoot(file, project) && service.canOpenModuleSettings()) ||
|
||||
(ProjectRootsUtil.isSourceOrTestRoot(file, project) && service.canOpenContentEntriesSettings()) ||
|
||||
(ProjectRootsUtil.isLibraryRoot(file, project) && service.canOpenModuleLibrarySettings()));
|
||||
}
|
||||
|
||||
public boolean canNavigateToSource() {
|
||||
@@ -193,14 +194,15 @@ public class PsiDirectoryNode extends BasePsiNode<PsiDirectory> implements Navig
|
||||
if (module != null) {
|
||||
final VirtualFile file = getVirtualFile();
|
||||
final Project project = getProject();
|
||||
ProjectSettingsService service = ProjectSettingsService.getInstance(myProject);
|
||||
if (ProjectRootsUtil.isModuleContentRoot(file, project)) {
|
||||
ProjectSettingsService.getInstance(myProject).openModuleSettings(module);
|
||||
service.openModuleSettings(module);
|
||||
}
|
||||
else if (ProjectRootsUtil.isLibraryRoot(file, project)) {
|
||||
ProjectSettingsService.getInstance(myProject).openModuleLibrarySettings(module);
|
||||
service.openModuleLibrarySettings(module);
|
||||
}
|
||||
else {
|
||||
ProjectSettingsService.getInstance(myProject).openContentEntriesSettings(module);
|
||||
service.openContentEntriesSettings(module);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+28
-6
@@ -46,15 +46,40 @@ public class ProjectSettingsService {
|
||||
public void openModuleSettings(final Module module) {
|
||||
}
|
||||
|
||||
public boolean canOpenModuleSettings() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void openModuleLibrarySettings(final Module module) {
|
||||
}
|
||||
|
||||
public boolean canOpenModuleLibrarySettings() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void openContentEntriesSettings(final Module module) {
|
||||
}
|
||||
|
||||
public boolean canOpenContentEntriesSettings() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void openProjectLibrarySettings(final NamedLibraryElement value) {
|
||||
Configurable additionalSettingsConfigurable = getLibrarySettingsConfigurable(value);
|
||||
if (additionalSettingsConfigurable != null) {
|
||||
LibraryOrderEntry entry = (LibraryOrderEntry) value.getOrderEntry();
|
||||
ShowSettingsUtil.getInstance().showSettingsDialog(entry.getOwnerModule().getProject(), additionalSettingsConfigurable);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canOpenProjectLibrarySettings(final NamedLibraryElement value) {
|
||||
return getLibrarySettingsConfigurable(value) != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Configurable getLibrarySettingsConfigurable(NamedLibraryElement value) {
|
||||
OrderEntry orderEntry = value.getOrderEntry();
|
||||
if (!(orderEntry instanceof LibraryOrderEntry)) return;
|
||||
if (!(orderEntry instanceof LibraryOrderEntry)) return null;
|
||||
LibraryOrderEntry libOrderEntry = (LibraryOrderEntry)orderEntry;
|
||||
Library lib = libOrderEntry.getLibrary();
|
||||
if (lib instanceof LibraryEx) {
|
||||
@@ -63,14 +88,11 @@ public class ProjectSettingsService {
|
||||
if (libType != null) {
|
||||
LibraryRootsComponentDescriptor libComponentDescriptor = libType.createLibraryRootsComponentDescriptor();
|
||||
if (libComponentDescriptor != null) {
|
||||
Configurable additionalSettingsConfigurable = libComponentDescriptor.getAdditionalSettingsConfigurable(project);
|
||||
if (additionalSettingsConfigurable != null) {
|
||||
ShowSettingsUtil.getInstance().showSettingsDialog(project, additionalSettingsConfigurable);
|
||||
return;
|
||||
}
|
||||
return libComponentDescriptor.getAdditionalSettingsConfigurable(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean processModulesMoved(final Module[] modules, @Nullable final ModuleGroup targetGroup) {
|
||||
|
||||
Reference in New Issue
Block a user