update copyright
[fedora-idea.git] / java / java-impl / src / com / intellij / javadoc / JavadocGenerationPanel.java
blob65043387f351daa7a1181fe2067d5a56c5e827cf
1 /*
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.javadoc;
18 import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
19 import com.intellij.openapi.ui.TextFieldWithBrowseButton;
20 import com.intellij.psi.PsiKeyword;
21 import com.intellij.util.ui.UIUtil;
23 import javax.swing.*;
24 import javax.swing.event.ChangeEvent;
25 import javax.swing.event.ChangeListener;
26 import java.awt.*;
27 import java.util.Dictionary;
28 import java.util.Enumeration;
29 import java.util.Hashtable;
31 final class JavadocGenerationPanel extends JPanel {
32 JPanel myPanel;
33 TextFieldWithBrowseButton myTfOutputDir;
34 JTextField myOtherOptionsField;
35 JTextField myHeapSizeField;
36 private JSlider myScopeSlider;
37 JCheckBox myHierarchy;
38 JCheckBox myNavigator;
39 JCheckBox myIndex;
40 JCheckBox mySeparateIndex;
41 JCheckBox myTagUse;
42 JCheckBox myTagAuthor;
43 JCheckBox myTagVersion;
44 JCheckBox myTagDeprecated;
45 JCheckBox myDeprecatedList;
46 JCheckBox myOpenInBrowserCheckBox;
47 JTextField myLocaleTextField;
49 JavadocGenerationPanel() {
50 myTfOutputDir.addBrowseFolderListener(JavadocBundle.message("javadoc.generate.output.directory.browse"), null, null, FileChooserDescriptorFactory.createSingleFolderDescriptor());
53 myIndex.addChangeListener(
54 new ChangeListener() {
55 public void stateChanged(ChangeEvent e) {
56 mySeparateIndex.setEnabled(myIndex.isSelected());
61 myTagDeprecated.addChangeListener(
62 new ChangeListener() {
63 public void stateChanged(ChangeEvent e) {
64 myDeprecatedList.setEnabled(myTagDeprecated.isSelected());
69 //noinspection UseOfObsoleteCollectionType
70 Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>();
71 labelTable.put(new Integer(1), new JLabel(PsiKeyword.PUBLIC));
72 labelTable.put(new Integer(2), new JLabel(PsiKeyword.PROTECTED));
73 labelTable.put(new Integer(3), new JLabel(PsiKeyword.PACKAGE));
74 labelTable.put(new Integer(4), new JLabel(PsiKeyword.PRIVATE));
76 myScopeSlider.setMaximum(4);
77 myScopeSlider.setMinimum(1);
78 myScopeSlider.setValue(1);
79 myScopeSlider.setLabelTable(labelTable);
80 myScopeSlider.putClientProperty(UIUtil.JSLIDER_ISFILLED, Boolean.TRUE);
81 myScopeSlider.setPreferredSize(new Dimension(80, 50));
82 myScopeSlider.setPaintLabels(true);
83 myScopeSlider.setSnapToTicks(true);
84 myScopeSlider.addChangeListener(new ChangeListener() {
85 public void stateChanged(ChangeEvent e) {
86 handleSlider();
88 });
91 private void handleSlider() {
92 int value = myScopeSlider.getValue();
94 Dictionary labelTable = myScopeSlider.getLabelTable();
95 for (Enumeration enumeration = labelTable.keys(); enumeration.hasMoreElements();) {
96 Integer key = (Integer)enumeration.nextElement();
97 JLabel label = (JLabel)labelTable.get(key);
98 label.setForeground(key.intValue() <= value ? Color.black : new Color(100, 100, 100));
102 void setScope(String scope) {
103 if (PsiKeyword.PUBLIC.equals(scope)) {
104 myScopeSlider.setValue(1);
106 else if (PsiKeyword.PROTECTED.equals(scope)) {
107 myScopeSlider.setValue(2);
109 else if (PsiKeyword.PRIVATE.equals(scope)) {
110 myScopeSlider.setValue(4);
112 else {
113 myScopeSlider.setValue(3);
115 handleSlider();
118 String getScope() {
119 switch (myScopeSlider.getValue()) {
120 case 1:
121 return PsiKeyword.PUBLIC;
122 case 2:
123 return PsiKeyword.PROTECTED;
124 case 3:
125 return PsiKeyword.PACKAGE;
126 case 4:
127 return PsiKeyword.PRIVATE;
128 default:
129 return null;