2 * Copyright 2000-2007 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.
17 package com
.maddyhome
.idea
.copyright
.actions
;
19 import com
.intellij
.openapi
.diagnostic
.Logger
;
20 import com
.intellij
.openapi
.project
.Project
;
21 import com
.intellij
.openapi
.roots
.ProjectFileIndex
;
22 import com
.intellij
.openapi
.roots
.ProjectRootManager
;
23 import com
.intellij
.openapi
.ui
.DialogWrapper
;
24 import com
.intellij
.openapi
.vfs
.VirtualFile
;
25 import com
.intellij
.uiDesigner
.core
.GridConstraints
;
26 import com
.intellij
.uiDesigner
.core
.GridLayoutManager
;
30 import java
.awt
.event
.ActionEvent
;
31 import java
.awt
.event
.ActionListener
;
33 public class RecursionDlg
extends DialogWrapper
35 public RecursionDlg(Project project
, VirtualFile file
)
37 super(project
, false);
39 logger
.debug("file=" + file
);
41 this.project
= project
;
49 public boolean isAll()
51 return rbAll
.isSelected();
54 public boolean includeSubdirs()
56 return cbSubdirs
.isSelected();
59 private void setupControls()
61 setTitle("Update Copyright");
63 setOKButtonText("Run");
65 ButtonGroup group
= new ButtonGroup();
69 rbFile
.setMnemonic('F');
70 rbAll
.setMnemonic('A');
71 cbSubdirs
.setMnemonic('I');
73 if (file
.isDirectory())
75 rbFile
.setText("File");
76 rbFile
.setEnabled(false);
77 rbAll
.setText("All files in " + file
.getPresentableUrl());
78 rbAll
.setSelected(true);
79 cbSubdirs
.setSelected(true);
80 cbSubdirs
.setEnabled(true);
84 VirtualFile parent
= file
.getParent();
85 rbFile
.setText("File '" + file
.getPresentableUrl() + '\'');
86 rbFile
.setSelected(true);
89 rbAll
.setText("All files in " + parent
.getPresentableUrl());
90 cbSubdirs
.setSelected(true);
91 cbSubdirs
.setEnabled(false);
95 rbAll
.setVisible(false);
96 cbSubdirs
.setVisible(false);
100 VirtualFile check
= file
;
101 if (!file
.isDirectory())
103 check
= file
.getParent();
105 ProjectRootManager prm
= ProjectRootManager
.getInstance(project
);
106 ProjectFileIndex pfi
= prm
.getFileIndex();
108 VirtualFile
[] children
= check
!= null ? check
.getChildren() : VirtualFile
.EMPTY_ARRAY
;
109 boolean hasSubdirs
= false;
110 for (int i
= 0; i
< children
.length
&& !hasSubdirs
; i
++)
112 if (children
[i
].isDirectory() && !pfi
.isIgnored(children
[i
]))
118 cbSubdirs
.setVisible(hasSubdirs
);
121 cbSubdirs
.setEnabled(false);
122 mainPanel
.remove(cbSubdirs
);
125 ActionListener listener
= new ActionListener()
127 public void actionPerformed(ActionEvent e
)
129 if (cbSubdirs
.isVisible())
131 cbSubdirs
.setEnabled(rbAll
.isSelected());
136 rbFile
.addActionListener(listener
);
137 rbAll
.addActionListener(listener
);
140 protected JComponent
createCenterPanel()
146 // GUI initializer generated by IntelliJ IDEA GUI Designer
147 // >>> IMPORTANT!! <<<
148 // DO NOT EDIT OR ADD ANY CODE HERE!
153 * Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR call it in your
156 private void $$$setupUI$$$
()
158 mainPanel
= new JPanel();
159 mainPanel
.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1));
160 rbFile
= new JRadioButton();
161 rbFile
.setText("File");
162 mainPanel
.add(rbFile
, new GridConstraints(0, 0, 1, 2, GridConstraints
.ANCHOR_WEST
, GridConstraints
.FILL_NONE
,
163 GridConstraints
.SIZEPOLICY_CAN_SHRINK
| GridConstraints
.SIZEPOLICY_CAN_GROW
,
164 GridConstraints
.SIZEPOLICY_FIXED
, null, null, null));
165 rbAll
= new JRadioButton();
166 rbAll
.setText("All");
167 mainPanel
.add(rbAll
, new GridConstraints(1, 0, 1, 2, GridConstraints
.ANCHOR_WEST
, GridConstraints
.FILL_NONE
,
168 GridConstraints
.SIZEPOLICY_CAN_SHRINK
| GridConstraints
.SIZEPOLICY_CAN_GROW
,
169 GridConstraints
.SIZEPOLICY_FIXED
, null, null, null));
170 cbSubdirs
= new JCheckBox();
171 cbSubdirs
.setText("Include subdirectories");
172 mainPanel
.add(cbSubdirs
, new GridConstraints(2, 1, 1, 1, GridConstraints
.ANCHOR_WEST
, GridConstraints
.FILL_NONE
,
173 GridConstraints
.SIZEPOLICY_CAN_SHRINK
| GridConstraints
.SIZEPOLICY_CAN_GROW
,
174 GridConstraints
.SIZEPOLICY_FIXED
, null, null, null));
175 final JLabel label1
= new JLabel();
177 mainPanel
.add(label1
, new GridConstraints(2, 0, 1, 1, GridConstraints
.ANCHOR_WEST
, GridConstraints
.FILL_NONE
,
178 GridConstraints
.SIZEPOLICY_FIXED
, GridConstraints
.SIZEPOLICY_FIXED
, null, null, null));
181 private VirtualFile file
;
182 private JPanel mainPanel
;
183 private JRadioButton rbFile
;
184 private JRadioButton rbAll
;
185 private JCheckBox cbSubdirs
;
186 private Project project
;
188 private static Logger logger
= Logger
.getInstance(RecursionDlg
.class.getName());