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
.openapi
.roots
.ui
.configuration
.artifacts
.actions
;
18 import com
.intellij
.openapi
.actionSystem
.AnActionEvent
;
19 import com
.intellij
.openapi
.project
.DumbAwareAction
;
20 import com
.intellij
.openapi
.roots
.ui
.configuration
.artifacts
.ArtifactEditorEx
;
21 import com
.intellij
.openapi
.roots
.ui
.configuration
.artifacts
.LayoutTreeSelection
;
22 import com
.intellij
.openapi
.roots
.ui
.configuration
.artifacts
.nodes
.PackagingElementNode
;
23 import com
.intellij
.openapi
.roots
.ui
.configuration
.artifacts
.nodes
.PackagingNodeSource
;
25 import java
.util
.Collection
;
30 public class HideContentAction
extends DumbAwareAction
{
31 private ArtifactEditorEx myArtifactEditor
;
33 public HideContentAction(ArtifactEditorEx artifactEditor
) {
34 super("Hide Content");
35 myArtifactEditor
= artifactEditor
;
39 public void update(AnActionEvent e
) {
40 final LayoutTreeSelection selection
= myArtifactEditor
.getLayoutTreeComponent().getSelection();
41 final PackagingElementNode
<?
> node
= selection
.getNodeIfSingle();
43 final Collection
<PackagingNodeSource
> sources
= node
.getNodeSources();
44 if (!sources
.isEmpty()) {
46 if (sources
.size() == 1) {
47 description
= "Hide Content of '" + sources
.iterator().next().getPresentableName() + "'";
50 description
= "Hide Content";
52 e
.getPresentation().setVisible(true);
53 e
.getPresentation().setText(description
);
57 e
.getPresentation().setVisible(false);
60 public void actionPerformed(AnActionEvent e
) {
61 final LayoutTreeSelection selection
= myArtifactEditor
.getLayoutTreeComponent().getSelection();
62 final PackagingElementNode
<?
> node
= selection
.getNodeIfSingle();
63 if (node
== null) return;
65 final Collection
<PackagingNodeSource
> sources
= node
.getNodeSources();
66 for (PackagingNodeSource source
: sources
) {
67 myArtifactEditor
.getSubstitutionParameters().doNotSubstitute(source
.getSourceElement());
68 myArtifactEditor
.getLayoutTreeComponent().getLayoutTree().addSubtreeToUpdate(source
.getSourceParentNode());