1b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato/* 2b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * ProGuard -- shrinking, optimization, obfuscation, and preverification 3b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * of Java bytecode. 4b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * 5b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * 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.MemberSpecification; 24b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport proguard.classfile.ClassConstants; 25b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport proguard.classfile.util.ClassUtil; 26b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport proguard.util.ListUtil; 27b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 28b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport javax.swing.*; 29b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport javax.swing.border.*; 30b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport java.awt.*; 31b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onoratoimport java.awt.event.*; 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 MemberSpecificationDialog 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 boolean isField; 53b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 54b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private final JRadioButton[] publicRadioButtons; 55b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private final JRadioButton[] privateRadioButtons; 56b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private final JRadioButton[] protectedRadioButtons; 57b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private final JRadioButton[] staticRadioButtons; 58b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private final JRadioButton[] finalRadioButtons; 59b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 60b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private JRadioButton[] volatileRadioButtons; 61b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private JRadioButton[] transientRadioButtons; 62b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 63b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private JRadioButton[] synchronizedRadioButtons; 64b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private JRadioButton[] nativeRadioButtons; 65b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private JRadioButton[] abstractRadioButtons; 66b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private JRadioButton[] strictRadioButtons; 67b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 68b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private final JTextField annotationTypeTextField = new JTextField(20); 69b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private final JTextField nameTextField = new JTextField(20); 70b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private final JTextField typeTextField = new JTextField(20); 71b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private final JTextField argumentTypesTextField = new JTextField(20); 72b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 73b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private int returnValue; 74b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 75b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 76b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato public MemberSpecificationDialog(JDialog owner, boolean isField) 77b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 78b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato super(owner, msg(isField ? "specifyFields" : "specifyMethods"), true); 79b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato setResizable(true); 80b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 81b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create some constraints that can be reused. 82b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints constraints = new GridBagConstraints(); 83b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraints.anchor = GridBagConstraints.WEST; 84b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraints.insets = new Insets(1, 2, 1, 2); 85b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 86b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints constraintsStretch = new GridBagConstraints(); 87b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsStretch.fill = GridBagConstraints.HORIZONTAL; 88b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsStretch.weightx = 1.0; 89b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsStretch.anchor = GridBagConstraints.WEST; 90b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsStretch.insets = constraints.insets; 91b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 92b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints constraintsLast = new GridBagConstraints(); 93b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsLast.gridwidth = GridBagConstraints.REMAINDER; 94b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsLast.anchor = GridBagConstraints.WEST; 95b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsLast.insets = constraints.insets; 96b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 97b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints constraintsLastStretch = new GridBagConstraints(); 98b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsLastStretch.gridwidth = GridBagConstraints.REMAINDER; 99b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsLastStretch.fill = GridBagConstraints.HORIZONTAL; 100b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsLastStretch.weightx = 1.0; 101b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsLastStretch.anchor = GridBagConstraints.WEST; 102b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato constraintsLastStretch.insets = constraints.insets; 103b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 104b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints panelConstraints = new GridBagConstraints(); 105b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato panelConstraints.gridwidth = GridBagConstraints.REMAINDER; 106b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato panelConstraints.fill = GridBagConstraints.HORIZONTAL; 107b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato panelConstraints.weightx = 1.0; 108b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato panelConstraints.weighty = 0.0; 109b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato panelConstraints.anchor = GridBagConstraints.NORTHWEST; 110b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato panelConstraints.insets = constraints.insets; 111b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 112b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints stretchPanelConstraints = new GridBagConstraints(); 113b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato stretchPanelConstraints.gridwidth = GridBagConstraints.REMAINDER; 114b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato stretchPanelConstraints.fill = GridBagConstraints.BOTH; 115b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato stretchPanelConstraints.weightx = 1.0; 116b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato stretchPanelConstraints.weighty = 1.0; 117b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato stretchPanelConstraints.anchor = GridBagConstraints.NORTHWEST; 118b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato stretchPanelConstraints.insets = constraints.insets; 119b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 120b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints labelConstraints = new GridBagConstraints(); 121b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato labelConstraints.anchor = GridBagConstraints.CENTER; 122b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato labelConstraints.insets = new Insets(2, 10, 2, 10); 123b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 124b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints lastLabelConstraints = new GridBagConstraints(); 125b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato lastLabelConstraints.gridwidth = GridBagConstraints.REMAINDER; 126b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato lastLabelConstraints.anchor = GridBagConstraints.CENTER; 127b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato lastLabelConstraints.insets = labelConstraints.insets; 128b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 129b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints advancedButtonConstraints = new GridBagConstraints(); 130b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato advancedButtonConstraints.weightx = 1.0; 131b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato advancedButtonConstraints.weighty = 1.0; 132b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato advancedButtonConstraints.anchor = GridBagConstraints.SOUTHWEST; 133b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato advancedButtonConstraints.insets = new Insets(4, 4, 8, 4); 134b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 135b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints okButtonConstraints = new GridBagConstraints(); 136b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato okButtonConstraints.weightx = 1.0; 137b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato okButtonConstraints.weighty = 1.0; 138b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato okButtonConstraints.anchor = GridBagConstraints.SOUTHEAST; 139b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato okButtonConstraints.insets = advancedButtonConstraints.insets; 140b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 141b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints cancelButtonConstraints = new GridBagConstraints(); 142b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato cancelButtonConstraints.gridwidth = GridBagConstraints.REMAINDER; 143b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato cancelButtonConstraints.weighty = 1.0; 144b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato cancelButtonConstraints.anchor = GridBagConstraints.SOUTHEAST; 145b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato cancelButtonConstraints.insets = okButtonConstraints.insets; 146b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 147b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagLayout layout = new GridBagLayout(); 148b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 149b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato Border etchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.RAISED); 150b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 151b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato this.isField = isField; 152b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 153b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create the access panel. 154b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JPanel accessPanel = new JPanel(layout); 155b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato accessPanel.setBorder(BorderFactory.createTitledBorder(etchedBorder, 156b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato msg("access"))); 157b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 158b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato accessPanel.add(Box.createGlue(), labelConstraints); 159b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato accessPanel.add(tip(new JLabel(msg("required")), "requiredTip"), labelConstraints); 160b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato accessPanel.add(tip(new JLabel(msg("not")), "notTip"), labelConstraints); 161b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato accessPanel.add(tip(new JLabel(msg("dontCare")), "dontCareTip"), labelConstraints); 162b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato accessPanel.add(Box.createGlue(), constraintsLastStretch); 163b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 164b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato publicRadioButtons = addRadioButtonTriplet("Public", accessPanel); 165b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato privateRadioButtons = addRadioButtonTriplet("Private", accessPanel); 166b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato protectedRadioButtons = addRadioButtonTriplet("Protected", accessPanel); 167b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato staticRadioButtons = addRadioButtonTriplet("Static", accessPanel); 168b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato finalRadioButtons = addRadioButtonTriplet("Final", accessPanel); 169b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 170b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato if (isField) 171b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 172b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato volatileRadioButtons = addRadioButtonTriplet("Volatile", accessPanel); 173b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato transientRadioButtons = addRadioButtonTriplet("Transient", accessPanel); 174b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 175b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato else 176b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 177b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato synchronizedRadioButtons = addRadioButtonTriplet("Synchronized", accessPanel); 178b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato nativeRadioButtons = addRadioButtonTriplet("Native", accessPanel); 179b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato abstractRadioButtons = addRadioButtonTriplet("Abstract", accessPanel); 180b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato strictRadioButtons = addRadioButtonTriplet("Strict", accessPanel); 181b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 182b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 183b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create the type panel. 184b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JPanel typePanel = new JPanel(layout); 185b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato typePanel.setBorder(BorderFactory.createTitledBorder(etchedBorder, 186b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato msg(isField ? "fieldType" : 187b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato "returnType"))); 188b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 189b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato typePanel.add(tip(typeTextField, "typeTip"), constraintsLastStretch); 190b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 191b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create the annotation type panel. 192b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato final JPanel annotationTypePanel = new JPanel(layout); 193b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato annotationTypePanel.setBorder(BorderFactory.createTitledBorder(etchedBorder, 194b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato msg("annotation"))); 195b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 196b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato annotationTypePanel.add(tip(annotationTypeTextField, "classNameTip"), constraintsLastStretch); 197b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 198b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create the name panel. 199b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JPanel namePanel = new JPanel(layout); 200b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato namePanel.setBorder(BorderFactory.createTitledBorder(etchedBorder, 201b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato msg("name"))); 202b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 203b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato namePanel.add(tip(nameTextField, isField ? "fieldNameTip" : 204b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato "methodNameTip"), constraintsLastStretch); 205b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 206b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create the arguments panel. 207b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JPanel argumentsPanel = new JPanel(layout); 208b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato argumentsPanel.setBorder(BorderFactory.createTitledBorder(etchedBorder, 209b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato msg("argumentTypes"))); 210b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 211b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato argumentsPanel.add(tip(argumentTypesTextField, "argumentTypes2Tip"), constraintsLastStretch); 212b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 213b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create the Advanced button. 214b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato final JButton advancedButton = new JButton(msg("basic")); 215b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato advancedButton.addActionListener(new ActionListener() 216b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 217b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato public void actionPerformed(ActionEvent e) 218b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 219b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato boolean visible = !annotationTypePanel.isVisible(); 220b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 221b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato annotationTypePanel.setVisible(visible); 222b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 223b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato advancedButton.setText(msg(visible ? "basic" : "advanced")); 224b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 225b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato pack(); 226b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 227b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato }); 228b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato advancedButton.doClick(); 229b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 230b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create the Ok button. 231b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JButton okButton = new JButton(msg("ok")); 232b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato okButton.addActionListener(new ActionListener() 233b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 234b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato public void actionPerformed(ActionEvent e) 235b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 236b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato returnValue = APPROVE_OPTION; 237b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato hide(); 238b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 239b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato }); 240b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 241b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create the Cancel button. 242b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JButton cancelButton = new JButton(msg("cancel")); 243b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato cancelButton.addActionListener(new ActionListener() 244b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 245b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato public void actionPerformed(ActionEvent e) 246b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 247b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato hide(); 248b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 249b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato }); 250b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 251b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Add all panels to the main panel. 252b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JPanel mainPanel = new JPanel(layout); 253b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato mainPanel.add(tip(accessPanel, "accessTip"), panelConstraints); 254b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato mainPanel.add(tip(annotationTypePanel, "annotationTip"), panelConstraints); 255b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato mainPanel.add(tip(typePanel, isField ? "fieldTypeTip" : 256b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato "returnTypeTip"), panelConstraints); 257b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato mainPanel.add(tip(namePanel, "nameTip"), panelConstraints); 258b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 259b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato if (!isField) 260b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 261b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato mainPanel.add(tip(argumentsPanel, "argumentTypesTip"), panelConstraints); 262b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 263b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 264b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato mainPanel.add(tip(advancedButton, "advancedTip"), advancedButtonConstraints); 265b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato mainPanel.add(okButton, okButtonConstraints); 266b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato mainPanel.add(cancelButton, cancelButtonConstraints); 267b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 268b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato getContentPane().add(new JScrollPane(mainPanel)); 269b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 270b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 271b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 272b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato /** 273b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Adds a JLabel and three JRadioButton instances in a ButtonGroup to the 274b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * given panel with a GridBagLayout, and returns the buttons in an array. 275b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */ 276b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private JRadioButton[] addRadioButtonTriplet(String labelText, 277b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JPanel panel) 278b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 279b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints labelConstraints = new GridBagConstraints(); 280b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato labelConstraints.anchor = GridBagConstraints.WEST; 281b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato labelConstraints.insets = new Insets(2, 10, 2, 10); 282b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 283b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints buttonConstraints = new GridBagConstraints(); 284b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato buttonConstraints.insets = labelConstraints.insets; 285b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 286b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato GridBagConstraints lastGlueConstraints = new GridBagConstraints(); 287b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato lastGlueConstraints.gridwidth = GridBagConstraints.REMAINDER; 288b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato lastGlueConstraints.weightx = 1.0; 289b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 290b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Create the radio buttons. 291b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JRadioButton radioButton0 = new JRadioButton(); 292b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JRadioButton radioButton1 = new JRadioButton(); 293b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JRadioButton radioButton2 = new JRadioButton(); 294b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 295b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Put them in a button group. 296b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato ButtonGroup buttonGroup = new ButtonGroup(); 297b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato buttonGroup.add(radioButton0); 298b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato buttonGroup.add(radioButton1); 299b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato buttonGroup.add(radioButton2); 300b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 301b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Add the label and the buttons to the panel. 302b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato panel.add(new JLabel(labelText), labelConstraints); 303b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato panel.add(radioButton0, buttonConstraints); 304b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato panel.add(radioButton1, buttonConstraints); 305b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato panel.add(radioButton2, buttonConstraints); 306b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato panel.add(Box.createGlue(), lastGlueConstraints); 307b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 308b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato return new JRadioButton[] 309b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 310b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato radioButton0, 311b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato radioButton1, 312b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato radioButton2 313b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato }; 314b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 315b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 316b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 317b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato /** 318b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Sets the MemberSpecification to be represented in this dialog. 319b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */ 320b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato public void setMemberSpecification(MemberSpecification memberSpecification) 321b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 322b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato String annotationType = memberSpecification.annotationType; 323b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato String name = memberSpecification.name; 324b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato String descriptor = memberSpecification.descriptor; 325b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 326b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Set the class name text fields. 327b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato annotationTypeTextField.setText(annotationType == null ? "" : ClassUtil.externalType(annotationType)); 328b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 329b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Set the access radio buttons. 330b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato setMemberSpecificationRadioButtons(memberSpecification, ClassConstants.INTERNAL_ACC_PUBLIC, publicRadioButtons); 331b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato setMemberSpecificationRadioButtons(memberSpecification, ClassConstants.INTERNAL_ACC_PRIVATE, privateRadioButtons); 332b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato setMemberSpecificationRadioButtons(memberSpecification, ClassConstants.INTERNAL_ACC_PROTECTED, protectedRadioButtons); 333b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato setMemberSpecificationRadioButtons(memberSpecification, ClassConstants.INTERNAL_ACC_STATIC, staticRadioButtons); 334b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato setMemberSpecificationRadioButtons(memberSpecification, ClassConstants.INTERNAL_ACC_FINAL, finalRadioButtons); 335b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato setMemberSpecificationRadioButtons(memberSpecification, ClassConstants.INTERNAL_ACC_VOLATILE, volatileRadioButtons); 336b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato setMemberSpecificationRadioButtons(memberSpecification, ClassConstants.INTERNAL_ACC_TRANSIENT, transientRadioButtons); 337b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato setMemberSpecificationRadioButtons(memberSpecification, ClassConstants.INTERNAL_ACC_SYNCHRONIZED, synchronizedRadioButtons); 338b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato setMemberSpecificationRadioButtons(memberSpecification, ClassConstants.INTERNAL_ACC_NATIVE, nativeRadioButtons); 339b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato setMemberSpecificationRadioButtons(memberSpecification, ClassConstants.INTERNAL_ACC_ABSTRACT, abstractRadioButtons); 340b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato setMemberSpecificationRadioButtons(memberSpecification, ClassConstants.INTERNAL_ACC_STRICT, strictRadioButtons); 341b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 342b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Set the class name text fields. 343b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato nameTextField.setText(name == null ? "*" : name); 344b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 345b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato if (isField) 346b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 347b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato typeTextField .setText(descriptor == null ? "***" : ClassUtil.externalType(descriptor)); 348b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 349b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato else 350b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 351b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato typeTextField .setText(descriptor == null ? "***" : ClassUtil.externalMethodReturnType(descriptor)); 352b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato argumentTypesTextField.setText(descriptor == null ? "..." : ClassUtil.externalMethodArguments(descriptor)); 353b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 354b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 355b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 356b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 357b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato /** 358b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Returns the MemberSpecification currently represented in this dialog. 359b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */ 360b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato public MemberSpecification getMemberSpecification() 361b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 362b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato String annotationType = annotationTypeTextField.getText(); 363b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato String name = nameTextField.getText(); 364b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato String type = typeTextField.getText(); 365b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato String arguments = argumentTypesTextField.getText(); 366b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 367b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Convert all class member specifications into the internal format. 368b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato annotationType = 369b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato annotationType.equals("") || 370b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato annotationType.equals("***") ? null : ClassUtil.internalType(annotationType); 371b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 372b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato if (name.equals("") || 373b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato name.equals("*")) 374b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 375b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato name = null; 376b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 377b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 378b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato if (isField) 379b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 380b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato type = 381b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato type.equals("") || 382b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato type.equals("***") ? null : ClassUtil.internalType(type); 383b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 384b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato else 385b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 386b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato if (type.equals("")) 387b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 388b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato type = ClassConstants.EXTERNAL_TYPE_VOID; 389b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 390b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 391b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato type = 392b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato type .equals("***") && 393b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato arguments.equals("...") ? null : 394b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato ClassUtil.internalMethodDescriptor(type, ListUtil.commaSeparatedList(arguments)); 395b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 396b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 397b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato MemberSpecification memberSpecification = 398b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato new MemberSpecification(0, 0, annotationType, name, type); 399b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 400b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Also get the access radio button settings. 401b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato getMemberSpecificationRadioButtons(memberSpecification, ClassConstants.INTERNAL_ACC_PUBLIC, publicRadioButtons); 402b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato getMemberSpecificationRadioButtons(memberSpecification, ClassConstants.INTERNAL_ACC_PRIVATE, privateRadioButtons); 403b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato getMemberSpecificationRadioButtons(memberSpecification, ClassConstants.INTERNAL_ACC_PROTECTED, protectedRadioButtons); 404b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato getMemberSpecificationRadioButtons(memberSpecification, ClassConstants.INTERNAL_ACC_STATIC, staticRadioButtons); 405b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato getMemberSpecificationRadioButtons(memberSpecification, ClassConstants.INTERNAL_ACC_FINAL, finalRadioButtons); 406b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato getMemberSpecificationRadioButtons(memberSpecification, ClassConstants.INTERNAL_ACC_VOLATILE, volatileRadioButtons); 407b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato getMemberSpecificationRadioButtons(memberSpecification, ClassConstants.INTERNAL_ACC_TRANSIENT, transientRadioButtons); 408b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato getMemberSpecificationRadioButtons(memberSpecification, ClassConstants.INTERNAL_ACC_SYNCHRONIZED, synchronizedRadioButtons); 409b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato getMemberSpecificationRadioButtons(memberSpecification, ClassConstants.INTERNAL_ACC_NATIVE, nativeRadioButtons); 410b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato getMemberSpecificationRadioButtons(memberSpecification, ClassConstants.INTERNAL_ACC_ABSTRACT, abstractRadioButtons); 411b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato getMemberSpecificationRadioButtons(memberSpecification, ClassConstants.INTERNAL_ACC_STRICT, strictRadioButtons); 412b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 413b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato return memberSpecification; 414b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 415b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 416b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 417b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato /** 418b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Shows this dialog. This method only returns when the dialog is closed. 419b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * 420b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * @return <code>CANCEL_OPTION</code> or <code>APPROVE_OPTION</code>, 421b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * depending on the choice of the user. 422b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */ 423b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato public int showDialog() 424b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 425b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato returnValue = CANCEL_OPTION; 426b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 427b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // Open the dialog in the right place, then wait for it to be closed, 428b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato // one way or another. 429b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato pack(); 430b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato setLocationRelativeTo(getOwner()); 431b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato show(); 432b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 433b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato return returnValue; 434b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 435b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 436b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 437b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato /** 438b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Sets the appropriate radio button of a given triplet, based on the access 439b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * flags of the given keep option. 440b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */ 441b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private void setMemberSpecificationRadioButtons(MemberSpecification memberSpecification, 442b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato int flag, 443b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JRadioButton[] radioButtons) 444b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 445b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato if (radioButtons != null) 446b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 447b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato int index = (memberSpecification.requiredSetAccessFlags & flag) != 0 ? 0 : 448b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato (memberSpecification.requiredUnsetAccessFlags & flag) != 0 ? 1 : 449b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 2; 450b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato radioButtons[index].setSelected(true); 451b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 452b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 453b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 454b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 455b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato /** 456b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Updates the access flag of the given keep option, based on the given radio 457b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * button triplet. 458b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */ 459b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private void getMemberSpecificationRadioButtons(MemberSpecification memberSpecification, 460b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato int flag, 461b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato JRadioButton[] radioButtons) 462b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 463b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato if (radioButtons != null) 464b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 465b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato if (radioButtons[0].isSelected()) 466b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 467b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato memberSpecification.requiredSetAccessFlags |= flag; 468b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 469b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato else if (radioButtons[1].isSelected()) 470b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 471b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato memberSpecification.requiredUnsetAccessFlags |= flag; 472b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 473b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 474b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 475b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 476b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 477b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato /** 478b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Attaches the tool tip from the GUI resources that corresponds to the 479b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * given key, to the given component. 480b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */ 481b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private static JComponent tip(JComponent component, String messageKey) 482b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 483b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato component.setToolTipText(msg(messageKey)); 484b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 485b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato return component; 486b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 487b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 488b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato 489b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato /** 490b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * Returns the message from the GUI resources that corresponds to the given 491b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato * key. 492b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato */ 493b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato private static String msg(String messageKey) 494b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato { 495b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato return GUIResources.getMessage(messageKey); 496b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato } 497b72c5c2e5482cf10117b2b25f642f7616b2326c3Joe Onorato} 498