1b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato/*
2b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * ProGuard -- shrinking, optimization, obfuscation, and preverification
3b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *             of Java bytecode.
4b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
59f606f95f03a75961498803e24bee6799a7c0885Ying Wang * Copyright (c) 2002-2009 Eric Lafortune (eric@graphics.cornell.edu)
6b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
7b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * This program is free software; you can redistribute it and/or modify it
8b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * under the terms of the GNU General Public License as published by the Free
9b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Software Foundation; either version 2 of the License, or (at your option)
10b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * any later version.
11b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
12b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * This program is distributed in the hope that it will be useful, but WITHOUT
13b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * more details.
16b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
17b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * You should have received a copy of the GNU General Public License along
18b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * with this program; if not, write to the Free Software Foundation, Inc.,
19b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */
21b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratopackage proguard.gui;
22b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
23b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport proguard.*;
24b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport proguard.classfile.ClassConstants;
25b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport proguard.classfile.util.ClassUtil;
26b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
27b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport javax.swing.*;
28b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport javax.swing.border.*;
29b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport java.awt.*;
30b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport java.awt.event.*;
31b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport java.util.List;
32b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
33b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato/**
34b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * This <code>JDialog</code> allows the user to enter a String.
35b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato *
36b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * @author Eric Lafortune
37b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */
38b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratofinal class ClassSpecificationDialog extends JDialog
39b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato{
40b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    /**
41b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * Return value if the dialog is canceled (with the Cancel button or by
42b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * closing the dialog window).
43b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     */
44b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public static final int CANCEL_OPTION = 1;
45b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
46b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    /**
47b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * Return value if the dialog is approved (with the Ok button).
48b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     */
49b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public static final int APPROVE_OPTION = 0;
50b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
51b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
52b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final JTextArea commentsTextArea = new JTextArea(4, 20);
53b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
54b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final JRadioButton keepClassesAndMembersRadioButton  = new JRadioButton(msg("keep"));
55b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final JRadioButton keepClassMembersRadioButton       = new JRadioButton(msg("keepClassMembers"));
56b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final JRadioButton keepClassesWithMembersRadioButton = new JRadioButton(msg("keepClassesWithMembers"));
57b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
58b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final JCheckBox allowShrinkingCheckBox    = new JCheckBox(msg("allowShrinking"));
59b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final JCheckBox allowOptimizationCheckBox = new JCheckBox(msg("allowOptimization"));
60b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final JCheckBox allowObfuscationCheckBox  = new JCheckBox(msg("allowObfuscation"));
61b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
62b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
63b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final JRadioButton[] publicRadioButtons;
64b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final JRadioButton[] finalRadioButtons;
65b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final JRadioButton[] abstractRadioButtons;
66cfead78069f3dc32998dc118ee08cab3867acea2Ying Wang    private final JRadioButton[] enumRadioButtons;
679f606f95f03a75961498803e24bee6799a7c0885Ying Wang    private final JRadioButton[] annotationRadioButtons;
689f606f95f03a75961498803e24bee6799a7c0885Ying Wang    private final JRadioButton[] interfaceRadioButtons;
69b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
70b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final JTextField annotationTypeTextField        = new JTextField(20);
71b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final JTextField classNameTextField             = new JTextField(20);
72b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final JTextField extendsAnnotationTypeTextField = new JTextField(20);
73b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final JTextField extendsClassNameTextField      = new JTextField(20);
74b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
75b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private final MemberSpecificationsPanel memberSpecificationsPanel;
76b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
77b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private int returnValue;
78b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
79b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
80b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public ClassSpecificationDialog(JFrame owner, boolean fullKeepOptions)
81b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
82b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        super(owner, msg("specifyClasses"), true);
83b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        setResizable(true);
84b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
85b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Create some constraints that can be reused.
86b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        GridBagConstraints constraints = new GridBagConstraints();
87b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        constraints.anchor = GridBagConstraints.WEST;
88b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        constraints.insets = new Insets(1, 2, 1, 2);
89b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
90b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        GridBagConstraints constraintsStretch = new GridBagConstraints();
91b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        constraintsStretch.fill    = GridBagConstraints.HORIZONTAL;
92b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        constraintsStretch.weightx = 1.0;
93b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        constraintsStretch.anchor  = GridBagConstraints.WEST;
94b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        constraintsStretch.insets  = constraints.insets;
95b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
96b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        GridBagConstraints constraintsLast = new GridBagConstraints();
97b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        constraintsLast.gridwidth = GridBagConstraints.REMAINDER;
98b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        constraintsLast.anchor    = GridBagConstraints.WEST;
99b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        constraintsLast.insets    = constraints.insets;
100b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
101b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        GridBagConstraints constraintsLastStretch = new GridBagConstraints();
102b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        constraintsLastStretch.gridwidth = GridBagConstraints.REMAINDER;
103b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        constraintsLastStretch.fill      = GridBagConstraints.HORIZONTAL;
104b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        constraintsLastStretch.weightx   = 1.0;
105b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        constraintsLastStretch.anchor    = GridBagConstraints.WEST;
106b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        constraintsLastStretch.insets    = constraints.insets;
107b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
108b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        GridBagConstraints panelConstraints = new GridBagConstraints();
109b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        panelConstraints.gridwidth = GridBagConstraints.REMAINDER;
110b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        panelConstraints.fill      = GridBagConstraints.HORIZONTAL;
111b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        panelConstraints.weightx   = 1.0;
112b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        panelConstraints.weighty   = 0.0;
113b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        panelConstraints.anchor    = GridBagConstraints.NORTHWEST;
114b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        panelConstraints.insets    = constraints.insets;
115b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
116b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        GridBagConstraints stretchPanelConstraints = new GridBagConstraints();
117b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        stretchPanelConstraints.gridwidth = GridBagConstraints.REMAINDER;
118b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        stretchPanelConstraints.fill      = GridBagConstraints.BOTH;
119b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        stretchPanelConstraints.weightx   = 1.0;
120b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        stretchPanelConstraints.weighty   = 1.0;
121b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        stretchPanelConstraints.anchor    = GridBagConstraints.NORTHWEST;
122b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        stretchPanelConstraints.insets    = constraints.insets;
123b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
124b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        GridBagConstraints labelConstraints = new GridBagConstraints();
125b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        labelConstraints.anchor = GridBagConstraints.CENTER;
126b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        labelConstraints.insets = new Insets(2, 10, 2, 10);
127b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
128b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        GridBagConstraints lastLabelConstraints = new GridBagConstraints();
129b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        lastLabelConstraints.gridwidth = GridBagConstraints.REMAINDER;
130b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        lastLabelConstraints.anchor    = GridBagConstraints.CENTER;
131b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        lastLabelConstraints.insets    = labelConstraints.insets;
132b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
133b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        GridBagConstraints advancedButtonConstraints = new GridBagConstraints();
134b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        advancedButtonConstraints.weightx = 1.0;
135b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        advancedButtonConstraints.weighty = 1.0;
136b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        advancedButtonConstraints.anchor  = GridBagConstraints.SOUTHWEST;
137b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        advancedButtonConstraints.insets  = new Insets(4, 4, 8, 4);
138b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
139b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        GridBagConstraints okButtonConstraints = new GridBagConstraints();
140b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        okButtonConstraints.weightx = 1.0;
141b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        okButtonConstraints.weighty = 1.0;
142b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        okButtonConstraints.anchor  = GridBagConstraints.SOUTHEAST;
143b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        okButtonConstraints.insets  = advancedButtonConstraints.insets;
144b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
145b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        GridBagConstraints cancelButtonConstraints = new GridBagConstraints();
146b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        cancelButtonConstraints.gridwidth = GridBagConstraints.REMAINDER;
147b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        cancelButtonConstraints.weighty   = 1.0;
148b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        cancelButtonConstraints.anchor    = GridBagConstraints.SOUTHEAST;
149b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        cancelButtonConstraints.insets    = advancedButtonConstraints.insets;
150b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
151b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        GridBagLayout layout = new GridBagLayout();
152b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
153b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        Border etchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
154b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
155b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Create the comments panel.
156b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        JPanel commentsPanel = new JPanel(layout);
157b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        commentsPanel.setBorder(BorderFactory.createTitledBorder(etchedBorder,
158b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                                 msg("comments")));
159b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
160b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        JScrollPane commentsScrollPane = new JScrollPane(commentsTextArea);
161b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        commentsScrollPane.setBorder(classNameTextField.getBorder());
162b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
163b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        commentsPanel.add(tip(commentsScrollPane, "commentsTip"), constraintsLastStretch);
164b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
165b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Create the keep option panel.
166b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        ButtonGroup keepButtonGroup = new ButtonGroup();
167b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        keepButtonGroup.add(keepClassesAndMembersRadioButton);
168b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        keepButtonGroup.add(keepClassMembersRadioButton);
169b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        keepButtonGroup.add(keepClassesWithMembersRadioButton);
170b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
171b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        JPanel keepOptionPanel = new JPanel(layout);
172b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        keepOptionPanel.setBorder(BorderFactory.createTitledBorder(etchedBorder,
173b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                                   msg("keepTitle")));
174b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
175b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        keepOptionPanel.add(tip(keepClassesAndMembersRadioButton,  "keepTip"),                   constraintsLastStretch);
176b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        keepOptionPanel.add(tip(keepClassMembersRadioButton,       "keepClassMembersTip"),       constraintsLastStretch);
177b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        keepOptionPanel.add(tip(keepClassesWithMembersRadioButton, "keepClassesWithMembersTip"), constraintsLastStretch);
178b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
179b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Create the allow option panel.
180b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        final JPanel allowOptionPanel = new JPanel(layout);
181b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        allowOptionPanel.setBorder(BorderFactory.createTitledBorder(etchedBorder,
182b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                                    msg("allowTitle")));
183b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
184b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        allowOptionPanel.add(tip(allowShrinkingCheckBox,    "allowShrinkingTip"),    constraintsLastStretch);
185b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        allowOptionPanel.add(tip(allowOptimizationCheckBox, "allowOptimizationTip"), constraintsLastStretch);
186b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        allowOptionPanel.add(tip(allowObfuscationCheckBox,  "allowObfuscationTip"),  constraintsLastStretch);
187b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
188b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Create the access panel.
189b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        JPanel accessPanel = new JPanel(layout);
190b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        accessPanel.setBorder(BorderFactory.createTitledBorder(etchedBorder,
191b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                               msg("access")));
192b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
193b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        accessPanel.add(Box.createGlue(),                                labelConstraints);
194b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        accessPanel.add(tip(new JLabel(msg("required")), "requiredTip"), labelConstraints);
195b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        accessPanel.add(tip(new JLabel(msg("not")),      "notTip"),      labelConstraints);
196b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        accessPanel.add(tip(new JLabel(msg("dontCare")), "dontCareTip"), labelConstraints);
197b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        accessPanel.add(Box.createGlue(),                                constraintsLastStretch);
198b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
199b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        publicRadioButtons     = addRadioButtonTriplet("Public",     accessPanel);
200b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        finalRadioButtons      = addRadioButtonTriplet("Final",      accessPanel);
201b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        abstractRadioButtons   = addRadioButtonTriplet("Abstract",   accessPanel);
202cfead78069f3dc32998dc118ee08cab3867acea2Ying Wang        enumRadioButtons       = addRadioButtonTriplet("Enum",       accessPanel);
2039f606f95f03a75961498803e24bee6799a7c0885Ying Wang        annotationRadioButtons = addRadioButtonTriplet("Annotation", accessPanel);
2049f606f95f03a75961498803e24bee6799a7c0885Ying Wang        interfaceRadioButtons  = addRadioButtonTriplet("Interface",  accessPanel);
205b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
206b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Create the annotation type panel.
207b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        final JPanel annotationTypePanel = new JPanel(layout);
208b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        annotationTypePanel.setBorder(BorderFactory.createTitledBorder(etchedBorder,
209b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                                       msg("annotation")));
210b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
211b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        annotationTypePanel.add(tip(annotationTypeTextField, "classNameTip"), constraintsLastStretch);
212b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
213b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Create the class name panel.
214b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        JPanel classNamePanel = new JPanel(layout);
215b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        classNamePanel.setBorder(BorderFactory.createTitledBorder(etchedBorder,
216b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                                  msg("class")));
217b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
218b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        classNamePanel.add(tip(classNameTextField, "classNameTip"), constraintsLastStretch);
219b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
220b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Create the extends annotation type panel.
221b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        final JPanel extendsAnnotationTypePanel = new JPanel(layout);
222b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        extendsAnnotationTypePanel.setBorder(BorderFactory.createTitledBorder(etchedBorder,
223b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                                              msg("extendsImplementsAnnotation")));
224b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
225b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        extendsAnnotationTypePanel.add(tip(extendsAnnotationTypeTextField, "classNameTip"), constraintsLastStretch);
226b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
227b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Create the extends class name panel.
228b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        JPanel extendsClassNamePanel = new JPanel(layout);
229b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        extendsClassNamePanel.setBorder(BorderFactory.createTitledBorder(etchedBorder,
230b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                                         msg("extendsImplementsClass")));
231b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
232b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        extendsClassNamePanel.add(tip(extendsClassNameTextField, "classNameTip"), constraintsLastStretch);
233b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
234b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
235b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Create the class member list panel.
236b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        memberSpecificationsPanel = new MemberSpecificationsPanel(this, fullKeepOptions);
237b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        memberSpecificationsPanel.setBorder(BorderFactory.createTitledBorder(etchedBorder,
238b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                                             msg("classMembers")));
239b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
240b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Create the Advanced button.
241b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        final JButton advancedButton = new JButton(msg("basic"));
242b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        advancedButton.addActionListener(new ActionListener()
243b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        {
244b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            public void actionPerformed(ActionEvent e)
245b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            {
246b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                boolean visible = !allowOptionPanel.isVisible();
247b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
248b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                allowOptionPanel          .setVisible(visible);
249b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                annotationTypePanel       .setVisible(visible);
250b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                extendsAnnotationTypePanel.setVisible(visible);
251b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
252b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                advancedButton.setText(msg(visible ? "basic" : "advanced"));
253b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
254b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                pack();
255b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            }
256b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        });
257b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        advancedButton.doClick();
258b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
259b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Create the Ok button.
260b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        JButton okButton = new JButton(msg("ok"));
261b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        okButton.addActionListener(new ActionListener()
262b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        {
263b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            public void actionPerformed(ActionEvent e)
264b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            {
265b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                returnValue = APPROVE_OPTION;
266b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                hide();
267b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            }
268b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        });
269b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
270b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Create the Cancel button.
271b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        JButton cancelButton = new JButton(msg("cancel"));
272b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        cancelButton.addActionListener(new ActionListener()
273b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        {
274b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            public void actionPerformed(ActionEvent e)
275b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            {
276b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                hide();
277b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            }
278b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        });
279b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
280b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Add all panels to the main panel.
281b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        JPanel mainPanel = new JPanel(layout);
282b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        mainPanel.add(tip(commentsPanel,              "commentsTip"),                    panelConstraints);
283b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        if (fullKeepOptions)
284b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        {
285b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            mainPanel.add(tip(keepOptionPanel,        "keepTitleTip"),                   panelConstraints);
286b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            mainPanel.add(tip(allowOptionPanel,       "allowTitleTip"),                  panelConstraints);
287b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        }
288b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        mainPanel.add(tip(accessPanel,                "accessTip"),                      panelConstraints);
289b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        mainPanel.add(tip(annotationTypePanel,        "annotationTip"),                  panelConstraints);
290b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        mainPanel.add(tip(classNamePanel,             "classTip"),                       panelConstraints);
291b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        mainPanel.add(tip(extendsAnnotationTypePanel, "extendsImplementsAnnotationTip"), panelConstraints);
292b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        mainPanel.add(tip(extendsClassNamePanel,      "extendsImplementsClassTip"),      panelConstraints);
293b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        mainPanel.add(tip(memberSpecificationsPanel,  "classMembersTip"),                stretchPanelConstraints);
294b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
295b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        mainPanel.add(tip(advancedButton, "advancedTip"), advancedButtonConstraints);
296b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        mainPanel.add(okButton,                           okButtonConstraints);
297b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        mainPanel.add(cancelButton,                       cancelButtonConstraints);
298b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
299b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        getContentPane().add(new JScrollPane(mainPanel));
300b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
301b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
302b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
303b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    /**
304b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * Adds a JLabel and three JRadioButton instances in a ButtonGroup to the
305b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * given panel with a GridBagLayout, and returns the buttons in an array.
306b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     */
307b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private JRadioButton[] addRadioButtonTriplet(String labelText,
308b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                 JPanel panel)
309b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
310b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        GridBagConstraints labelConstraints = new GridBagConstraints();
311b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        labelConstraints.anchor = GridBagConstraints.WEST;
312b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        labelConstraints.insets = new Insets(2, 10, 2, 10);
313b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
314b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        GridBagConstraints buttonConstraints = new GridBagConstraints();
315b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        buttonConstraints.insets = labelConstraints.insets;
316b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
317b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        GridBagConstraints lastGlueConstraints = new GridBagConstraints();
318b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        lastGlueConstraints.gridwidth = GridBagConstraints.REMAINDER;
319b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        lastGlueConstraints.weightx   = 1.0;
320b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
321b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Create the radio buttons.
322b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        JRadioButton radioButton0 = new JRadioButton();
323b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        JRadioButton radioButton1 = new JRadioButton();
324b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        JRadioButton radioButton2 = new JRadioButton();
325b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
326b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Put them in a button group.
327b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        ButtonGroup buttonGroup = new ButtonGroup();
328b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        buttonGroup.add(radioButton0);
329b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        buttonGroup.add(radioButton1);
330b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        buttonGroup.add(radioButton2);
331b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
332b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Add the label and the buttons to the panel.
333b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        panel.add(new JLabel(labelText), labelConstraints);
334b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        panel.add(radioButton0,          buttonConstraints);
335b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        panel.add(radioButton1,          buttonConstraints);
336b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        panel.add(radioButton2,          buttonConstraints);
337b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        panel.add(Box.createGlue(),      lastGlueConstraints);
338b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
339b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new JRadioButton[]
340b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        {
341b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato             radioButton0,
342b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato             radioButton1,
343b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato             radioButton2
344b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        };
345b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
346b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
347b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
348b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    /**
349b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * Sets the KeepClassSpecification to be represented in this dialog.
350b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     */
351b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void setKeepSpecification(KeepClassSpecification keepClassSpecification)
352b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
353b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        boolean markClasses       = keepClassSpecification.markClasses;
354b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        boolean markConditionally = keepClassSpecification.markConditionally;
355b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        boolean allowShrinking    = keepClassSpecification.allowShrinking;
356b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        boolean allowOptimization = keepClassSpecification.allowOptimization;
357b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        boolean allowObfuscation  = keepClassSpecification.allowObfuscation;
358b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
359b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Figure out the proper keep radio button and set it.
360b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        JRadioButton keepOptionRadioButton =
361b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            markConditionally ? keepClassesWithMembersRadioButton :
362b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            markClasses       ? keepClassesAndMembersRadioButton  :
363b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                keepClassMembersRadioButton;
364b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
365b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        keepOptionRadioButton.setSelected(true);
366b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
367b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Set the allow radio buttons.
368b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        allowShrinkingCheckBox   .setSelected(allowShrinking);
369b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        allowOptimizationCheckBox.setSelected(allowOptimization);
370b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        allowObfuscationCheckBox .setSelected(allowObfuscation);
371b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
372b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        setClassSpecification(keepClassSpecification);
373b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
374b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
375b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
376b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    /**
377b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * Sets the ClassSpecification to be represented in this dialog.
378b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     */
379b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public void setClassSpecification(ClassSpecification classSpecification)
380b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
381b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        String comments              = classSpecification.comments;
382b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        String annotationType        = classSpecification.annotationType;
383b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        String className             = classSpecification.className;
384b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        String extendsAnnotationType = classSpecification.extendsAnnotationType;
385b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        String extendsClassName      = classSpecification.extendsClassName;
386b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        List   keepFieldOptions      = classSpecification.fieldSpecifications;
387b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        List   keepMethodOptions     = classSpecification.methodSpecifications;
388b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
389b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Set the comments text area.
390b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        commentsTextArea.setText(comments == null ? "" : comments);
391b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
392b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Set the access radio buttons.
393b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        setClassSpecificationRadioButtons(classSpecification, ClassConstants.INTERNAL_ACC_PUBLIC,      publicRadioButtons);
394b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        setClassSpecificationRadioButtons(classSpecification, ClassConstants.INTERNAL_ACC_FINAL,       finalRadioButtons);
395b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        setClassSpecificationRadioButtons(classSpecification, ClassConstants.INTERNAL_ACC_ABSTRACT,    abstractRadioButtons);
396cfead78069f3dc32998dc118ee08cab3867acea2Ying Wang        setClassSpecificationRadioButtons(classSpecification, ClassConstants.INTERNAL_ACC_ENUM,        enumRadioButtons);
3979f606f95f03a75961498803e24bee6799a7c0885Ying Wang        setClassSpecificationRadioButtons(classSpecification, ClassConstants.INTERNAL_ACC_ANNOTATTION, annotationRadioButtons);
3989f606f95f03a75961498803e24bee6799a7c0885Ying Wang        setClassSpecificationRadioButtons(classSpecification, ClassConstants.INTERNAL_ACC_INTERFACE,   interfaceRadioButtons);
399b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
400b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Set the class and annotation text fields.
401b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        annotationTypeTextField       .setText(annotationType        == null ? ""  : ClassUtil.externalType(annotationType));
402b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        classNameTextField            .setText(className             == null ? "*" : ClassUtil.externalClassName(className));
403b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        extendsAnnotationTypeTextField.setText(extendsAnnotationType == null ? ""  : ClassUtil.externalType(extendsAnnotationType));
404b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        extendsClassNameTextField     .setText(extendsClassName      == null ? ""  : ClassUtil.externalClassName(extendsClassName));
405b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
406b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Set the keep class member option list.
407b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        memberSpecificationsPanel.setMemberSpecifications(keepFieldOptions, keepMethodOptions);
408b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
409b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
410b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
411b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    /**
412b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * Returns the KeepClassSpecification currently represented in this dialog.
413b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     */
414b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public KeepClassSpecification getKeepSpecification()
415b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
416b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        boolean markClasses       = !keepClassMembersRadioButton     .isSelected();
417b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        boolean markConditionally = keepClassesWithMembersRadioButton.isSelected();
418b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        boolean allowShrinking    = allowShrinkingCheckBox           .isSelected();
419b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        boolean allowOptimization = allowOptimizationCheckBox        .isSelected();
420b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        boolean allowObfuscation  = allowObfuscationCheckBox         .isSelected();
421b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
422b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return new KeepClassSpecification(markClasses,
423b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                     markConditionally,
424b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                     allowShrinking,
425b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                     allowOptimization,
426b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                     allowObfuscation,
427b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                     getClassSpecification());
428b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
429b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
430b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
431b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    /**
432b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * Returns the ClassSpecification currently represented in this dialog.
433b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     */
434b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public ClassSpecification getClassSpecification()
435b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
436b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        String comments              = commentsTextArea.getText();
437b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        String annotationType        = annotationTypeTextField.getText();
438b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        String className             = classNameTextField.getText();
439b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        String extendsAnnotationType = extendsAnnotationTypeTextField.getText();
440b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        String extendsClassName      = extendsClassNameTextField.getText();
441b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
442b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        ClassSpecification classSpecification =
443b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            new ClassSpecification(comments.equals("")              ? null : comments,
444b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                   0,
445b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                   0,
446b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                   annotationType.equals("")        ? null : ClassUtil.internalType(annotationType),
447b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                   className.equals("") ||
448b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                   className.equals("*")            ? null : ClassUtil.internalClassName(className),
449b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                   extendsAnnotationType.equals("") ? null : ClassUtil.internalType(extendsAnnotationType),
450b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                   extendsClassName.equals("")      ? null : ClassUtil.internalClassName(extendsClassName));
451b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
452b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Also get the access radio button settings.
453b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        getClassSpecificationRadioButtons(classSpecification, ClassConstants.INTERNAL_ACC_PUBLIC,      publicRadioButtons);
454b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        getClassSpecificationRadioButtons(classSpecification, ClassConstants.INTERNAL_ACC_FINAL,       finalRadioButtons);
455b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        getClassSpecificationRadioButtons(classSpecification, ClassConstants.INTERNAL_ACC_ABSTRACT,    abstractRadioButtons);
456cfead78069f3dc32998dc118ee08cab3867acea2Ying Wang        getClassSpecificationRadioButtons(classSpecification, ClassConstants.INTERNAL_ACC_ENUM,        enumRadioButtons);
4579f606f95f03a75961498803e24bee6799a7c0885Ying Wang        getClassSpecificationRadioButtons(classSpecification, ClassConstants.INTERNAL_ACC_ANNOTATTION, annotationRadioButtons);
4589f606f95f03a75961498803e24bee6799a7c0885Ying Wang        getClassSpecificationRadioButtons(classSpecification, ClassConstants.INTERNAL_ACC_INTERFACE,   interfaceRadioButtons);
459b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
460b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Get the keep class member option lists.
461b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        classSpecification.fieldSpecifications  = memberSpecificationsPanel.getMemberSpecifications(true);
462b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        classSpecification.methodSpecifications = memberSpecificationsPanel.getMemberSpecifications(false);
463b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
464b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return classSpecification;
465b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
466b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
467b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
468b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    /**
469b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * Shows this dialog. This method only returns when the dialog is closed.
470b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     *
471b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * @return <code>CANCEL_OPTION</code> or <code>APPROVE_OPTION</code>,
472b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     *         depending on the choice of the user.
473b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     */
474b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    public int showDialog()
475b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
476b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        returnValue = CANCEL_OPTION;
477b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
478b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // Open the dialog in the right place, then wait for it to be closed,
479b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        // one way or another.
480b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        pack();
481b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        setLocationRelativeTo(getOwner());
482b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        show();
483b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
484b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return returnValue;
485b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
486b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
487b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
488b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    /**
489b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * Sets the appropriate radio button of a given triplet, based on the access
490b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * flags of the given keep option.
491b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     */
492b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private void setClassSpecificationRadioButtons(ClassSpecification classSpecification,
493b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                   int                flag,
494b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                   JRadioButton[]     radioButtons)
495b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
496b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        int index = (classSpecification.requiredSetAccessFlags   & flag) != 0 ? 0 :
497b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                    (classSpecification.requiredUnsetAccessFlags & flag) != 0 ? 1 :
498b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                                                 2;
499b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        radioButtons[index].setSelected(true);
500b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
501b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
502b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
503b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    /**
504b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * Updates the access flag of the given keep option, based on the given radio
505b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * button triplet.
506b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     */
507b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private void getClassSpecificationRadioButtons(ClassSpecification classSpecification,
508b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                   int                flag,
509b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato                                                   JRadioButton[]     radioButtons)
510b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
511b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        if      (radioButtons[0].isSelected())
512b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        {
513b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            classSpecification.requiredSetAccessFlags   |= flag;
514b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        }
515b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        else if (radioButtons[1].isSelected())
516b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        {
517b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato            classSpecification.requiredUnsetAccessFlags |= flag;
518b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        }
519b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
520b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
521b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
522b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    /**
523b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * Attaches the tool tip from the GUI resources that corresponds to the
524b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * given key, to the given component.
525b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     */
526b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private static JComponent tip(JComponent component, String messageKey)
527b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
528b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        component.setToolTipText(msg(messageKey));
529b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
530b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato        return component;
531b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
532b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
533b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato
534b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    /**
535b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * Returns the message from the GUI resources that corresponds to the given
536b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     * key.
537b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato     */
538b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    private static String msg(String messageKey)
539b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    {
540b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato         return GUIResources.getMessage(messageKey);
541b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato    }
542b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato}
543