2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com
.intellij
.slicer
;
18 import com
.intellij
.ide
.projectView
.PresentationData
;
19 import com
.intellij
.ide
.util
.treeView
.AbstractTreeNode
;
20 import com
.intellij
.openapi
.progress
.ProgressIndicator
;
21 import com
.intellij
.openapi
.project
.Project
;
22 import org
.jetbrains
.annotations
.NotNull
;
25 import java
.util
.Collection
;
26 import java
.util
.Collections
;
27 import java
.util
.List
;
32 public class SliceRootNode
extends SliceNode
{
33 private final SliceUsage myRootUsage
;
35 public SliceRootNode(@NotNull Project project
, @NotNull DuplicateMap targetEqualUsages
, final SliceUsage rootUsage
) {
36 super(project
, new SliceUsage(rootUsage
.getElement().getContainingFile(), rootUsage
.params
), targetEqualUsages
);
37 myRootUsage
= rootUsage
;
40 void switchToAllLeavesTogether(SliceUsage rootUsage
) {
41 SliceNode node
= new SliceNode(getProject(), rootUsage
, targetEqualUsages
);
42 myCachedChildren
= Collections
.singletonList(node
);
46 SliceRootNode
copy() {
47 SliceUsage newUsage
= getValue().copy();
48 SliceRootNode newNode
= new SliceRootNode(getProject(), new DuplicateMap(), newUsage
);
49 newNode
.initialized
= initialized
;
50 newNode
.duplicate
= duplicate
;
55 public Collection
<?
extends AbstractTreeNode
> getChildren() {
56 if (myCachedChildren
== null) {
57 switchToAllLeavesTogether(myRootUsage
);
59 return myCachedChildren
;
63 public List
<?
extends AbstractTreeNode
> getChildrenUnderProgress(ProgressIndicator progress
) {
64 return (List
<?
extends AbstractTreeNode
>)getChildren();
68 protected boolean shouldUpdateData() {
69 return super.shouldUpdateData();
73 protected void update(PresentationData presentation
) {
74 if (presentation
!= null) {
75 presentation
.setChanged(presentation
.isChanged() || changed
);
82 public void customizeCellRenderer(SliceUsageCellRenderer renderer
,
92 public SliceUsage
getRootUsage() {