1b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato/* 2b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * ProGuard -- shrinking, optimization, obfuscation, and preverification 3b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * of Java bytecode. 4b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * 52270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom * Copyright (c) 2002-2014 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 582270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom private final JCheckBox keepDescriptorClassesCheckBox = new JCheckBox(msg("keepDescriptorClasses")); 592270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom 60b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private final JCheckBox allowShrinkingCheckBox = new JCheckBox(msg("allowShrinking")); 61b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private final JCheckBox allowOptimizationCheckBox = new JCheckBox(msg("allowOptimization")); 62b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private final JCheckBox allowObfuscationCheckBox = new JCheckBox(msg("allowObfuscation")); 63b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 64b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 65b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private final JRadioButton[] publicRadioButtons; 66b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private final JRadioButton[] finalRadioButtons; 67b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private final JRadioButton[] abstractRadioButtons; 689f606f95f03a75961498803e24bee6799a7c0885Ying Wang private final JRadioButton[] interfaceRadioButtons; 69b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang private final JRadioButton[] annotationRadioButtons; 70b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang private final JRadioButton[] enumRadioButtons; 71b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang private final JRadioButton[] syntheticRadioButtons; 72b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 73b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private final JTextField annotationTypeTextField = new JTextField(20); 74b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private final JTextField classNameTextField = new JTextField(20); 75b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private final JTextField extendsAnnotationTypeTextField = new JTextField(20); 76b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private final JTextField extendsClassNameTextField = new JTextField(20); 77b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 78b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private final MemberSpecificationsPanel memberSpecificationsPanel; 79b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 80b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private int returnValue; 81b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 82b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 83b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato public ClassSpecificationDialog(JFrame owner, boolean fullKeepOptions) 84b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 85b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato super(owner, msg("specifyClasses"), true); 86b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato setResizable(true); 87b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 88b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create some constraints that can be reused. 89b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints constraints = new GridBagConstraints(); 90b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraints.anchor = GridBagConstraints.WEST; 91b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraints.insets = new Insets(1, 2, 1, 2); 92b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 93b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints constraintsStretch = new GridBagConstraints(); 94b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsStretch.fill = GridBagConstraints.HORIZONTAL; 95b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsStretch.weightx = 1.0; 96b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsStretch.anchor = GridBagConstraints.WEST; 97b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsStretch.insets = constraints.insets; 98b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 99b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints constraintsLast = new GridBagConstraints(); 100b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsLast.gridwidth = GridBagConstraints.REMAINDER; 101b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsLast.anchor = GridBagConstraints.WEST; 102b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsLast.insets = constraints.insets; 103b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 104b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints constraintsLastStretch = new GridBagConstraints(); 105b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsLastStretch.gridwidth = GridBagConstraints.REMAINDER; 106b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsLastStretch.fill = GridBagConstraints.HORIZONTAL; 107b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsLastStretch.weightx = 1.0; 108b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsLastStretch.anchor = GridBagConstraints.WEST; 109b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsLastStretch.insets = constraints.insets; 110b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 111b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints panelConstraints = new GridBagConstraints(); 112b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato panelConstraints.gridwidth = GridBagConstraints.REMAINDER; 113b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato panelConstraints.fill = GridBagConstraints.HORIZONTAL; 114b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato panelConstraints.weightx = 1.0; 115b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato panelConstraints.weighty = 0.0; 116b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato panelConstraints.anchor = GridBagConstraints.NORTHWEST; 117b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato panelConstraints.insets = constraints.insets; 118b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 119b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints stretchPanelConstraints = new GridBagConstraints(); 120b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato stretchPanelConstraints.gridwidth = GridBagConstraints.REMAINDER; 121b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato stretchPanelConstraints.fill = GridBagConstraints.BOTH; 122b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato stretchPanelConstraints.weightx = 1.0; 123b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato stretchPanelConstraints.weighty = 1.0; 124b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato stretchPanelConstraints.anchor = GridBagConstraints.NORTHWEST; 125b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato stretchPanelConstraints.insets = constraints.insets; 126b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 127b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints labelConstraints = new GridBagConstraints(); 128b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato labelConstraints.anchor = GridBagConstraints.CENTER; 129b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato labelConstraints.insets = new Insets(2, 10, 2, 10); 130b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 131b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints lastLabelConstraints = new GridBagConstraints(); 132b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato lastLabelConstraints.gridwidth = GridBagConstraints.REMAINDER; 133b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato lastLabelConstraints.anchor = GridBagConstraints.CENTER; 134b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato lastLabelConstraints.insets = labelConstraints.insets; 135b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 136b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints advancedButtonConstraints = new GridBagConstraints(); 137b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato advancedButtonConstraints.weightx = 1.0; 138b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato advancedButtonConstraints.weighty = 1.0; 139b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato advancedButtonConstraints.anchor = GridBagConstraints.SOUTHWEST; 140b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato advancedButtonConstraints.insets = new Insets(4, 4, 8, 4); 141b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 142b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints okButtonConstraints = new GridBagConstraints(); 143b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato okButtonConstraints.weightx = 1.0; 144b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato okButtonConstraints.weighty = 1.0; 145b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato okButtonConstraints.anchor = GridBagConstraints.SOUTHEAST; 146b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato okButtonConstraints.insets = advancedButtonConstraints.insets; 147b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 148b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints cancelButtonConstraints = new GridBagConstraints(); 149b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato cancelButtonConstraints.gridwidth = GridBagConstraints.REMAINDER; 150b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato cancelButtonConstraints.weighty = 1.0; 151b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato cancelButtonConstraints.anchor = GridBagConstraints.SOUTHEAST; 152b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato cancelButtonConstraints.insets = advancedButtonConstraints.insets; 153b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 154b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagLayout layout = new GridBagLayout(); 155b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 156b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato Border etchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.RAISED); 157b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 158b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create the comments panel. 159b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JPanel commentsPanel = new JPanel(layout); 160b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato commentsPanel.setBorder(BorderFactory.createTitledBorder(etchedBorder, 161b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato msg("comments"))); 162b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 163b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JScrollPane commentsScrollPane = new JScrollPane(commentsTextArea); 164b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato commentsScrollPane.setBorder(classNameTextField.getBorder()); 165b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 166b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato commentsPanel.add(tip(commentsScrollPane, "commentsTip"), constraintsLastStretch); 167b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 168b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create the keep option panel. 169b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato ButtonGroup keepButtonGroup = new ButtonGroup(); 170b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato keepButtonGroup.add(keepClassesAndMembersRadioButton); 171b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato keepButtonGroup.add(keepClassMembersRadioButton); 172b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato keepButtonGroup.add(keepClassesWithMembersRadioButton); 173b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 174b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JPanel keepOptionPanel = new JPanel(layout); 175b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato keepOptionPanel.setBorder(BorderFactory.createTitledBorder(etchedBorder, 176b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato msg("keepTitle"))); 177b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 178b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato keepOptionPanel.add(tip(keepClassesAndMembersRadioButton, "keepTip"), constraintsLastStretch); 179b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato keepOptionPanel.add(tip(keepClassMembersRadioButton, "keepClassMembersTip"), constraintsLastStretch); 180b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato keepOptionPanel.add(tip(keepClassesWithMembersRadioButton, "keepClassesWithMembersTip"), constraintsLastStretch); 1812270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom keepOptionPanel.add(tip(keepDescriptorClassesCheckBox, "keepDescriptorClassesTip"), constraintsLastStretch); 1822270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom 1832270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom // Create the also keep panel. 1842270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom final JPanel alsoKeepOptionPanel = new JPanel(layout); 1852270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom alsoKeepOptionPanel.setBorder(BorderFactory.createTitledBorder(etchedBorder, 1862270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom msg("alsoKeepTitle"))); 1872270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom 1882270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom alsoKeepOptionPanel.add(tip(keepDescriptorClassesCheckBox, "keepDescriptorClassesTip"), constraintsLastStretch); 189b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 190b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create the allow option panel. 191b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato final JPanel allowOptionPanel = new JPanel(layout); 192b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato allowOptionPanel.setBorder(BorderFactory.createTitledBorder(etchedBorder, 193b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato msg("allowTitle"))); 194b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 195b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato allowOptionPanel.add(tip(allowShrinkingCheckBox, "allowShrinkingTip"), constraintsLastStretch); 196b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato allowOptionPanel.add(tip(allowOptimizationCheckBox, "allowOptimizationTip"), constraintsLastStretch); 197b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato allowOptionPanel.add(tip(allowObfuscationCheckBox, "allowObfuscationTip"), constraintsLastStretch); 198b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 199b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create the access panel. 200b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JPanel accessPanel = new JPanel(layout); 201b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato accessPanel.setBorder(BorderFactory.createTitledBorder(etchedBorder, 202b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato msg("access"))); 203b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 204b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato accessPanel.add(Box.createGlue(), labelConstraints); 205b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato accessPanel.add(tip(new JLabel(msg("required")), "requiredTip"), labelConstraints); 206b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato accessPanel.add(tip(new JLabel(msg("not")), "notTip"), labelConstraints); 207b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato accessPanel.add(tip(new JLabel(msg("dontCare")), "dontCareTip"), labelConstraints); 208b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato accessPanel.add(Box.createGlue(), constraintsLastStretch); 209b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 210b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato publicRadioButtons = addRadioButtonTriplet("Public", accessPanel); 211b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato finalRadioButtons = addRadioButtonTriplet("Final", accessPanel); 212b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato abstractRadioButtons = addRadioButtonTriplet("Abstract", accessPanel); 2139f606f95f03a75961498803e24bee6799a7c0885Ying Wang interfaceRadioButtons = addRadioButtonTriplet("Interface", accessPanel); 214b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang annotationRadioButtons = addRadioButtonTriplet("Annotation", accessPanel); 215b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang enumRadioButtons = addRadioButtonTriplet("Enum", accessPanel); 216b9cc48a43ed984587c939d02fba5316bf5c0df6eYing Wang syntheticRadioButtons = addRadioButtonTriplet("Synthetic", accessPanel); 217b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 218b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create the annotation type panel. 219b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato final JPanel annotationTypePanel = new JPanel(layout); 220b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato annotationTypePanel.setBorder(BorderFactory.createTitledBorder(etchedBorder, 221b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato msg("annotation"))); 222b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 223b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato annotationTypePanel.add(tip(annotationTypeTextField, "classNameTip"), constraintsLastStretch); 224b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 225b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create the class name panel. 226b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JPanel classNamePanel = new JPanel(layout); 227b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato classNamePanel.setBorder(BorderFactory.createTitledBorder(etchedBorder, 228b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato msg("class"))); 229b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 230b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato classNamePanel.add(tip(classNameTextField, "classNameTip"), constraintsLastStretch); 231b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 232b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create the extends annotation type panel. 233b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato final JPanel extendsAnnotationTypePanel = new JPanel(layout); 234b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato extendsAnnotationTypePanel.setBorder(BorderFactory.createTitledBorder(etchedBorder, 235b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato msg("extendsImplementsAnnotation"))); 236b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 237b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato extendsAnnotationTypePanel.add(tip(extendsAnnotationTypeTextField, "classNameTip"), constraintsLastStretch); 238b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 239b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create the extends class name panel. 240b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JPanel extendsClassNamePanel = new JPanel(layout); 241b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato extendsClassNamePanel.setBorder(BorderFactory.createTitledBorder(etchedBorder, 242b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato msg("extendsImplementsClass"))); 243b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 244b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato extendsClassNamePanel.add(tip(extendsClassNameTextField, "classNameTip"), constraintsLastStretch); 245b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 246b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 247b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create the class member list panel. 248b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato memberSpecificationsPanel = new MemberSpecificationsPanel(this, fullKeepOptions); 249b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato memberSpecificationsPanel.setBorder(BorderFactory.createTitledBorder(etchedBorder, 250b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato msg("classMembers"))); 251b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 252b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create the Advanced button. 253b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato final JButton advancedButton = new JButton(msg("basic")); 254b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato advancedButton.addActionListener(new ActionListener() 255b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 256b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato public void actionPerformed(ActionEvent e) 257b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 2582270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom boolean visible = !alsoKeepOptionPanel.isVisible(); 259b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 2602270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom alsoKeepOptionPanel .setVisible(visible); 261b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato allowOptionPanel .setVisible(visible); 262b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato annotationTypePanel .setVisible(visible); 263b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato extendsAnnotationTypePanel.setVisible(visible); 264b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 265b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato advancedButton.setText(msg(visible ? "basic" : "advanced")); 266b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 267b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato pack(); 268b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 269b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato }); 270b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato advancedButton.doClick(); 271b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 272b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create the Ok button. 273b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JButton okButton = new JButton(msg("ok")); 274b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato okButton.addActionListener(new ActionListener() 275b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 276b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato public void actionPerformed(ActionEvent e) 277b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 278b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato returnValue = APPROVE_OPTION; 279b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato hide(); 280b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 281b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato }); 282b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 283b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create the Cancel button. 284b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JButton cancelButton = new JButton(msg("cancel")); 285b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato cancelButton.addActionListener(new ActionListener() 286b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 287b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato public void actionPerformed(ActionEvent e) 288b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 289b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato hide(); 290b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 291b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato }); 292b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 293b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Add all panels to the main panel. 294b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JPanel mainPanel = new JPanel(layout); 295b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato mainPanel.add(tip(commentsPanel, "commentsTip"), panelConstraints); 296b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato if (fullKeepOptions) 297b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 298b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato mainPanel.add(tip(keepOptionPanel, "keepTitleTip"), panelConstraints); 2992270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom mainPanel.add(tip(alsoKeepOptionPanel, "alsoKeepTitleTip"), panelConstraints); 300b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato mainPanel.add(tip(allowOptionPanel, "allowTitleTip"), panelConstraints); 301b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 302b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato mainPanel.add(tip(accessPanel, "accessTip"), panelConstraints); 303b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato mainPanel.add(tip(annotationTypePanel, "annotationTip"), panelConstraints); 304b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato mainPanel.add(tip(classNamePanel, "classTip"), panelConstraints); 305b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato mainPanel.add(tip(extendsAnnotationTypePanel, "extendsImplementsAnnotationTip"), panelConstraints); 306b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato mainPanel.add(tip(extendsClassNamePanel, "extendsImplementsClassTip"), panelConstraints); 307b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato mainPanel.add(tip(memberSpecificationsPanel, "classMembersTip"), stretchPanelConstraints); 308b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 309b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato mainPanel.add(tip(advancedButton, "advancedTip"), advancedButtonConstraints); 310b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato mainPanel.add(okButton, okButtonConstraints); 311b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato mainPanel.add(cancelButton, cancelButtonConstraints); 312b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 313b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato getContentPane().add(new JScrollPane(mainPanel)); 314b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 315b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 316b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 317b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato /** 318b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Adds a JLabel and three JRadioButton instances in a ButtonGroup to the 319b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * given panel with a GridBagLayout, and returns the buttons in an array. 320b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */ 321b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private JRadioButton[] addRadioButtonTriplet(String labelText, 322b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JPanel panel) 323b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 324b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints labelConstraints = new GridBagConstraints(); 325b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato labelConstraints.anchor = GridBagConstraints.WEST; 326b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato labelConstraints.insets = new Insets(2, 10, 2, 10); 327b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 328b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints buttonConstraints = new GridBagConstraints(); 329b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato buttonConstraints.insets = labelConstraints.insets; 330b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 331b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints lastGlueConstraints = new GridBagConstraints(); 332b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato lastGlueConstraints.gridwidth = GridBagConstraints.REMAINDER; 333b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato lastGlueConstraints.weightx = 1.0; 334b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 335b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create the radio buttons. 336b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JRadioButton radioButton0 = new JRadioButton(); 337b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JRadioButton radioButton1 = new JRadioButton(); 338b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JRadioButton radioButton2 = new JRadioButton(); 339b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 340b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Put them in a button group. 341b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato ButtonGroup buttonGroup = new ButtonGroup(); 342b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato buttonGroup.add(radioButton0); 343b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato buttonGroup.add(radioButton1); 344b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato buttonGroup.add(radioButton2); 345b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 346b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Add the label and the buttons to the panel. 347b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato panel.add(new JLabel(labelText), labelConstraints); 348b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato panel.add(radioButton0, buttonConstraints); 349b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato panel.add(radioButton1, buttonConstraints); 350b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato panel.add(radioButton2, buttonConstraints); 351b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato panel.add(Box.createGlue(), lastGlueConstraints); 352b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 353b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato return new JRadioButton[] 354b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 355b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato radioButton0, 356b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato radioButton1, 357b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato radioButton2 358b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato }; 359b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 360b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 361b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 362b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato /** 363b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Sets the KeepClassSpecification to be represented in this dialog. 364b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */ 365b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato public void setKeepSpecification(KeepClassSpecification keepClassSpecification) 366b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 3672270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom boolean markClasses = keepClassSpecification.markClasses; 3682270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom boolean markConditionally = keepClassSpecification.markConditionally; 3692270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom boolean markDescriptorClasses = keepClassSpecification.markDescriptorClasses; 3702270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom boolean allowShrinking = keepClassSpecification.allowShrinking; 3712270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom boolean allowOptimization = keepClassSpecification.allowOptimization; 3722270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom boolean allowObfuscation = keepClassSpecification.allowObfuscation; 373b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 374b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Figure out the proper keep radio button and set it. 375b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JRadioButton keepOptionRadioButton = 376b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato markConditionally ? keepClassesWithMembersRadioButton : 377b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato markClasses ? keepClassesAndMembersRadioButton : 378b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato keepClassMembersRadioButton; 379b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 380b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato keepOptionRadioButton.setSelected(true); 381b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 3822270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom // Set the other check boxes. 3832270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom keepDescriptorClassesCheckBox.setSelected(markDescriptorClasses); 3842270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom allowShrinkingCheckBox .setSelected(allowShrinking); 3852270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom allowOptimizationCheckBox .setSelected(allowOptimization); 3862270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom allowObfuscationCheckBox .setSelected(allowObfuscation); 387b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 388b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato setClassSpecification(keepClassSpecification); 389b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 390b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 391b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 392b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato /** 393b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Sets the ClassSpecification to be represented in this dialog. 394b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */ 395b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato public void setClassSpecification(ClassSpecification classSpecification) 396b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 397b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato String comments = classSpecification.comments; 398b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato String annotationType = classSpecification.annotationType; 399b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato String className = classSpecification.className; 400b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato String extendsAnnotationType = classSpecification.extendsAnnotationType; 401b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato String extendsClassName = classSpecification.extendsClassName; 402b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato List keepFieldOptions = classSpecification.fieldSpecifications; 403b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato List keepMethodOptions = classSpecification.methodSpecifications; 404b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 405b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Set the comments text area. 406b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato commentsTextArea.setText(comments == null ? "" : comments); 407b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 408b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Set the access radio buttons. 4092270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom setClassSpecificationRadioButtons(classSpecification, ClassConstants.ACC_PUBLIC, publicRadioButtons); 4102270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom setClassSpecificationRadioButtons(classSpecification, ClassConstants.ACC_FINAL, finalRadioButtons); 4112270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom setClassSpecificationRadioButtons(classSpecification, ClassConstants.ACC_ABSTRACT, abstractRadioButtons); 4122270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom setClassSpecificationRadioButtons(classSpecification, ClassConstants.ACC_INTERFACE, interfaceRadioButtons); 4132270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom setClassSpecificationRadioButtons(classSpecification, ClassConstants.ACC_ANNOTATTION, annotationRadioButtons); 4142270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom setClassSpecificationRadioButtons(classSpecification, ClassConstants.ACC_ENUM, enumRadioButtons); 4152270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom setClassSpecificationRadioButtons(classSpecification, ClassConstants.ACC_SYNTHETIC, syntheticRadioButtons); 416b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 417b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Set the class and annotation text fields. 418b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato annotationTypeTextField .setText(annotationType == null ? "" : ClassUtil.externalType(annotationType)); 419b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato classNameTextField .setText(className == null ? "*" : ClassUtil.externalClassName(className)); 420b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato extendsAnnotationTypeTextField.setText(extendsAnnotationType == null ? "" : ClassUtil.externalType(extendsAnnotationType)); 421b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato extendsClassNameTextField .setText(extendsClassName == null ? "" : ClassUtil.externalClassName(extendsClassName)); 422b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 423b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Set the keep class member option list. 424b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato memberSpecificationsPanel.setMemberSpecifications(keepFieldOptions, keepMethodOptions); 425b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 426b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 427b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 428b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato /** 429b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Returns the KeepClassSpecification currently represented in this dialog. 430b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */ 431b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato public KeepClassSpecification getKeepSpecification() 432b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 4332270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom boolean markClasses = !keepClassMembersRadioButton .isSelected(); 4342270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom boolean markConditionally = keepClassesWithMembersRadioButton.isSelected(); 4352270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom boolean markDescriptorClasses = keepDescriptorClassesCheckBox .isSelected(); 4362270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom boolean allowShrinking = allowShrinkingCheckBox .isSelected(); 4372270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom boolean allowOptimization = allowOptimizationCheckBox .isSelected(); 4382270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom boolean allowObfuscation = allowObfuscationCheckBox .isSelected(); 439b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 440b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato return new KeepClassSpecification(markClasses, 4412270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom markConditionally, 4422270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom markDescriptorClasses, 4432270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom allowShrinking, 4442270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom allowOptimization, 4452270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom allowObfuscation, 4462270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom getClassSpecification()); 447b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 448b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 449b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 450b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato /** 451b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Returns the ClassSpecification currently represented in this dialog. 452b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */ 453b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato public ClassSpecification getClassSpecification() 454b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 455b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato String comments = commentsTextArea.getText(); 456b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato String annotationType = annotationTypeTextField.getText(); 457b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato String className = classNameTextField.getText(); 458b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato String extendsAnnotationType = extendsAnnotationTypeTextField.getText(); 459b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato String extendsClassName = extendsClassNameTextField.getText(); 460b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 461b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato ClassSpecification classSpecification = 462b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato new ClassSpecification(comments.equals("") ? null : comments, 463b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 0, 464b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 0, 465b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato annotationType.equals("") ? null : ClassUtil.internalType(annotationType), 466b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato className.equals("") || 467b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato className.equals("*") ? null : ClassUtil.internalClassName(className), 468b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato extendsAnnotationType.equals("") ? null : ClassUtil.internalType(extendsAnnotationType), 469b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato extendsClassName.equals("") ? null : ClassUtil.internalClassName(extendsClassName)); 470b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 471b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Also get the access radio button settings. 4722270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom getClassSpecificationRadioButtons(classSpecification, ClassConstants.ACC_PUBLIC, publicRadioButtons); 4732270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom getClassSpecificationRadioButtons(classSpecification, ClassConstants.ACC_FINAL, finalRadioButtons); 4742270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom getClassSpecificationRadioButtons(classSpecification, ClassConstants.ACC_ABSTRACT, abstractRadioButtons); 4752270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom getClassSpecificationRadioButtons(classSpecification, ClassConstants.ACC_INTERFACE, interfaceRadioButtons); 4762270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom getClassSpecificationRadioButtons(classSpecification, ClassConstants.ACC_ANNOTATTION, annotationRadioButtons); 4772270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom getClassSpecificationRadioButtons(classSpecification, ClassConstants.ACC_ENUM, enumRadioButtons); 4782270795fbe0b277bfd49f40950ecaa78583175ccBrian Carlstrom getClassSpecificationRadioButtons(classSpecification, ClassConstants.ACC_SYNTHETIC, syntheticRadioButtons); 479b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 480b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Get the keep class member option lists. 481b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato classSpecification.fieldSpecifications = memberSpecificationsPanel.getMemberSpecifications(true); 482b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato classSpecification.methodSpecifications = memberSpecificationsPanel.getMemberSpecifications(false); 483b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 484b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato return classSpecification; 485b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 486b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 487b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 488b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato /** 489b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Shows this dialog. This method only returns when the dialog is closed. 490b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * 491b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * @return <code>CANCEL_OPTION</code> or <code>APPROVE_OPTION</code>, 492b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * depending on the choice of the user. 493b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */ 494b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato public int showDialog() 495b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 496b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato returnValue = CANCEL_OPTION; 497b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 498b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Open the dialog in the right place, then wait for it to be closed, 499b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // one way or another. 500b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato pack(); 501b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato setLocationRelativeTo(getOwner()); 502b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato show(); 503b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 504b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato return returnValue; 505b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 506b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 507b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 508b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato /** 509b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Sets the appropriate radio button of a given triplet, based on the access 510b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * flags of the given keep option. 511b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */ 512b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private void setClassSpecificationRadioButtons(ClassSpecification classSpecification, 513b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato int flag, 514b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JRadioButton[] radioButtons) 515b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 516b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato int index = (classSpecification.requiredSetAccessFlags & flag) != 0 ? 0 : 517b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato (classSpecification.requiredUnsetAccessFlags & flag) != 0 ? 1 : 518b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 2; 519b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato radioButtons[index].setSelected(true); 520b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 521b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 522b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 523b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato /** 524b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Updates the access flag of the given keep option, based on the given radio 525b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * button triplet. 526b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */ 527b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private void getClassSpecificationRadioButtons(ClassSpecification classSpecification, 528b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato int flag, 529b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JRadioButton[] radioButtons) 530b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 531b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato if (radioButtons[0].isSelected()) 532b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 533b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato classSpecification.requiredSetAccessFlags |= flag; 534b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 535b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato else if (radioButtons[1].isSelected()) 536b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 537b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato classSpecification.requiredUnsetAccessFlags |= flag; 538b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 539b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 540b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 541b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 542b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato /** 543b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Attaches the tool tip from the GUI resources that corresponds to the 544b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * given key, to the given component. 545b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */ 546b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private static JComponent tip(JComponent component, String messageKey) 547b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 548b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato component.setToolTipText(msg(messageKey)); 549b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 550b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato return component; 551b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 552b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 553b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 554b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato /** 555b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Returns the message from the GUI resources that corresponds to the given 556b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * key. 557b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */ 558b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private static String msg(String messageKey) 559b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 560b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato return GUIResources.getMessage(messageKey); 561b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 562b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato} 563