@Nullable
[fedora-idea.git] / lang-impl / src / com / intellij / ide / projectView / impl / nodes / AbstractModuleNode.java
blob192e75d66f9f013a2fd4bfd9568783b9b0fa540a
1 /*
2 * Copyright (c) 2004 JetBrains s.r.o. All Rights Reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
8 * -Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
11 * -Redistribution in binary form must reproduct the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the distribution.
15 * Neither the name of JetBrains or IntelliJ IDEA
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * This software is provided "AS IS," without a warranty of any kind. ALL
20 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
21 * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
22 * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. JETBRAINS AND ITS LICENSORS SHALL NOT
23 * BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT
24 * OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR ITS
25 * DERIVATIVES. IN NO EVENT WILL JETBRAINS OR ITS LICENSORS BE LIABLE FOR ANY LOST
26 * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
27 * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
28 * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN
29 * IF JETBRAINS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 package com.intellij.ide.projectView.impl.nodes;
34 import com.intellij.ide.projectView.PresentationData;
35 import com.intellij.ide.projectView.ProjectViewNode;
36 import com.intellij.ide.projectView.ViewSettings;
37 import com.intellij.openapi.module.Module;
38 import com.intellij.openapi.module.ModuleUtil;
39 import com.intellij.openapi.project.Project;
40 import com.intellij.openapi.roots.ui.configuration.ProjectSettingsService;
41 import com.intellij.openapi.vfs.VirtualFile;
42 import org.jetbrains.annotations.NotNull;
44 public abstract class AbstractModuleNode extends ProjectViewNode<Module> {
45 protected AbstractModuleNode(Project project, Module module, ViewSettings viewSettings) {
46 super(project, module, viewSettings);
49 public void update(PresentationData presentation) {
50 if (getValue().isDisposed()) {
51 setValue(null);
52 return;
54 presentation.setPresentableText(getValue().getName());
55 presentation.setOpenIcon(getValue().getModuleType().getNodeIcon(true));
56 presentation.setClosedIcon(getValue().getModuleType().getNodeIcon(false));
60 public String getTestPresentation() {
61 return "Module";
64 public boolean contains(@NotNull VirtualFile file) {
65 Module module = getValue();
66 return module != null && !module.isDisposed() &&
67 (ModuleUtil.moduleContainsFile(module, file, false) || ModuleUtil.moduleContainsFile(module, file, true));
70 public String getToolTip() {
71 final Module module = getValue();
72 return module.getModuleType().getName();
75 public void navigate(final boolean requestFocus) {
76 ProjectSettingsService.getInstance(myProject).openModuleSettings(getValue());
79 public boolean canNavigate() {
80 return true;
83 public boolean canNavigateToSource() {
84 return false;