IDEA-85169 PIEAE through ProjectViewTree.paintFileColorGutter() on pasting incomplete annotation inside another annotation

This commit is contained in:
Konstantin Bulenkov
2012-04-25 14:52:43 +02:00
parent 21661c028d
commit 1157b10583
5 changed files with 32 additions and 24 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 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.
@@ -197,7 +197,7 @@ public final class PackageViewPane extends AbstractProjectViewPSIPane {
}
protected ProjectViewTree createTree(DefaultTreeModel treeModel) {
return new ProjectViewTree(treeModel) {
return new ProjectViewTree(myProject, treeModel) {
public String toString() {
return getTitle() + " " + super.toString();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 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.
@@ -249,7 +249,7 @@ public abstract class BaseProjectViewTestCase extends TestSourceBasedTestCase {
@Override
protected ProjectViewTree createTree(DefaultTreeModel treeModel) {
return new ProjectViewTree(treeModel) {
return new ProjectViewTree(myProject, treeModel) {
@Override
public DefaultMutableTreeNode getSelectedNode() {
return null;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 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.
@@ -77,7 +77,7 @@ public class ProjectViewPane extends AbstractProjectViewPSIPane {
}
protected ProjectViewTree createTree(DefaultTreeModel treeModel) {
return new ProjectViewTree(treeModel) {
return new ProjectViewTree(myProject, treeModel) {
public String toString() {
return getTitle() + " " + super.toString();
}
@@ -21,10 +21,11 @@ import com.intellij.ide.util.treeView.AbstractTreeNode;
import com.intellij.ide.util.treeView.NodeDescriptor;
import com.intellij.ide.util.treeView.NodeRenderer;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiDirectoryContainer;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.ui.FileColorManager;
import com.intellij.ui.tabs.FileColorManagerImpl;
import org.jetbrains.annotations.Nullable;
@@ -37,8 +38,11 @@ import java.awt.*;
* @author Konstantin Bulenkov
*/
public abstract class ProjectViewTree extends DnDAwareTree {
protected ProjectViewTree(TreeModel model) {
private final Project myProject;
protected ProjectViewTree(Project project, TreeModel model) {
super(model);
myProject = project;
final NodeRenderer cellRenderer = new NodeRenderer();
cellRenderer.setOpaque(false);
@@ -49,6 +53,9 @@ public abstract class ProjectViewTree extends DnDAwareTree {
}
public abstract DefaultMutableTreeNode getSelectedNode();
public Project getProject() {
return myProject;
}
public final int getToggleClickCount() {
final DefaultMutableTreeNode selectedNode = getSelectedNode();
@@ -77,17 +84,18 @@ public abstract class ProjectViewTree extends DnDAwareTree {
final Object element = ((AbstractTreeNode)object).getValue();
if (element instanceof PsiElement) {
final PsiElement psi = (PsiElement)element;
final Project project = psi.getProject();
final PsiFile file = psi.getContainingFile();
if (!psi.isValid()) return null;
final VirtualFile file = PsiUtilCore.getVirtualFile(psi);
if (file != null) {
color = FileColorManager.getInstance(project).getFileColor(file);
color = FileColorManager.getInstance(getProject()).getFileColor(file);
} else if (psi instanceof PsiDirectory) {
color = FileColorManager.getInstance(project).getFileColor(((PsiDirectory)psi).getVirtualFile());
color = FileColorManager.getInstance(getProject()).getFileColor(((PsiDirectory)psi).getVirtualFile());
} else if (psi instanceof PsiDirectoryContainer) {
final PsiDirectory[] dirs = ((PsiDirectoryContainer)psi).getDirectories();
for (PsiDirectory dir : dirs) {
Color c = FileColorManager.getInstance(project).getFileColor(dir.getVirtualFile());
Color c = FileColorManager.getInstance(getProject()).getFileColor(dir.getVirtualFile());
if (c != null && color == null) {
color = c;
} else if (c != null && color != null) {
@@ -1,17 +1,17 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 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
* 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
* 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.
* 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.
*/
package org.jetbrains.plugins.groovy.mvc.projectView;
@@ -226,7 +226,7 @@ public class MvcProjectViewPane extends AbstractProjectViewPSIPane implements Id
}
protected ProjectViewTree createTree(final DefaultTreeModel treeModel) {
return new ProjectViewTree(treeModel) {
return new ProjectViewTree(myProject, treeModel) {
public String toString() {
return myDescriptor.getFramework().getDisplayName() + " " + super.toString();
}