📄 classspecificationdialog.java
字号:
/* $Id: ClassSpecificationDialog.java,v 1.2 2004/08/15 12:39:30 eric Exp $ * * ProGuard -- shrinking, optimization, and obfuscation of Java class files. * * Copyright (c) 2002-2004 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */package proguard.gui;import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.*;import javax.swing.border.Border;import java.util.List;import proguard.ClassSpecification;import proguard.classfile.ClassConstants;import proguard.classfile.util.ClassUtil;/** * This <code>JDialog</code> allows the user to enter a String. * * @author Eric Lafortune */class ClassSpecificationDialog extends JDialog{ /** * Return value if the dialog is canceled (with the Cancel button or by * closing the dialog window). */ public static final int CANCEL_OPTION = 1; /** * Return value if the dialog is approved (with the Ok button). */ public static final int APPROVE_OPTION = 0; private JTextArea commentsTextArea = new JTextArea(4, 20); private JRadioButton keepClassesAndMembersRadioButton = new JRadioButton(GUIResources.getMessage("keep")); private JRadioButton keepClassMembersRadioButton = new JRadioButton(GUIResources.getMessage("keepClassMembers")); private JRadioButton keepClassesWithMembersRadioButton = new JRadioButton(GUIResources.getMessage("keepClassesWithMembers")); private JRadioButton[] publicRadioButtons; private JRadioButton[] finalRadioButtons; private JRadioButton[] interfaceRadioButtons; private JRadioButton[] abstractRadioButtons; private JTextField classNameTextField = new JTextField(20); private JTextField extendsClassNameTextField = new JTextField(20); private ClassMemberSpecificationsPanel classMembersPanel; private int returnValue; public ClassSpecificationDialog(JFrame owner, boolean fullKeepOptions) { super(owner, true); setResizable(true); // Create some constraints that can be reused. GridBagConstraints constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(1, 2, 1, 2); GridBagConstraints constraintsStretch = new GridBagConstraints(); constraintsStretch.fill = GridBagConstraints.HORIZONTAL; constraintsStretch.weightx = 1.0; constraintsStretch.anchor = GridBagConstraints.WEST; constraintsStretch.insets = constraints.insets; GridBagConstraints constraintsLast = new GridBagConstraints(); constraintsLast.gridwidth = GridBagConstraints.REMAINDER; constraintsLast.anchor = GridBagConstraints.WEST; constraintsLast.insets = constraints.insets; GridBagConstraints constraintsLastStretch = new GridBagConstraints(); constraintsLastStretch.gridwidth = GridBagConstraints.REMAINDER; constraintsLastStretch.fill = GridBagConstraints.HORIZONTAL; constraintsLastStretch.weightx = 1.0; constraintsLastStretch.anchor = GridBagConstraints.WEST; constraintsLastStretch.insets = constraints.insets; GridBagConstraints panelConstraints = new GridBagConstraints(); panelConstraints.gridwidth = GridBagConstraints.REMAINDER; panelConstraints.fill = GridBagConstraints.HORIZONTAL; panelConstraints.weightx = 1.0; panelConstraints.weighty = 0.0; panelConstraints.anchor = GridBagConstraints.NORTHWEST; panelConstraints.insets = constraints.insets; GridBagConstraints stretchPanelConstraints = new GridBagConstraints(); stretchPanelConstraints.gridwidth = GridBagConstraints.REMAINDER; stretchPanelConstraints.fill = GridBagConstraints.BOTH; stretchPanelConstraints.weightx = 1.0; stretchPanelConstraints.weighty = 1.0; stretchPanelConstraints.anchor = GridBagConstraints.NORTHWEST; stretchPanelConstraints.insets = constraints.insets; GridBagConstraints labelConstraints = new GridBagConstraints(); labelConstraints.anchor = GridBagConstraints.CENTER; labelConstraints.insets = new Insets(2, 10, 2, 10); GridBagConstraints lastLabelConstraints = new GridBagConstraints(); lastLabelConstraints.gridwidth = GridBagConstraints.REMAINDER; lastLabelConstraints.anchor = GridBagConstraints.CENTER; lastLabelConstraints.insets = labelConstraints.insets; GridBagConstraints okButtonConstraints = new GridBagConstraints(); okButtonConstraints.weightx = 1.0; okButtonConstraints.weighty = 1.0; okButtonConstraints.anchor = GridBagConstraints.SOUTHEAST; okButtonConstraints.insets = new Insets(4, 4, 8, 4); GridBagConstraints cancelButtonConstraints = new GridBagConstraints(); cancelButtonConstraints.gridwidth = GridBagConstraints.REMAINDER;; cancelButtonConstraints.weighty = 1.0; cancelButtonConstraints.anchor = GridBagConstraints.SOUTHEAST; cancelButtonConstraints.insets = okButtonConstraints.insets; GridBagLayout layout = new GridBagLayout(); Border etchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.RAISED); // Create the comments panel. JPanel commentsPanel = new JPanel(layout); commentsPanel.setBorder(BorderFactory.createTitledBorder(etchedBorder, GUIResources.getMessage("comments"))); JScrollPane commentsScrollPane = new JScrollPane(commentsTextArea); commentsScrollPane.setBorder(classNameTextField.getBorder()); commentsPanel.add(commentsScrollPane, constraintsLastStretch); // Create the keep option panel. ButtonGroup keepButtonGroup = new ButtonGroup(); keepButtonGroup.add(keepClassesAndMembersRadioButton); keepButtonGroup.add(keepClassMembersRadioButton); keepButtonGroup.add(keepClassesWithMembersRadioButton); JPanel keepOptionPanel = new JPanel(layout); keepOptionPanel.setBorder(BorderFactory.createTitledBorder(etchedBorder, GUIResources.getMessage("keepTitle"))); keepOptionPanel.add(keepClassesAndMembersRadioButton, constraintsLastStretch); keepOptionPanel.add(keepClassMembersRadioButton, constraintsLastStretch); keepOptionPanel.add(keepClassesWithMembersRadioButton, constraintsLastStretch); // Create the access panel. JPanel accessPanel = new JPanel(layout); accessPanel.setBorder(BorderFactory.createTitledBorder(etchedBorder, GUIResources.getMessage("access"))); accessPanel.add(Box.createGlue(), labelConstraints); accessPanel.add(new JLabel(GUIResources.getMessage("required")), labelConstraints); accessPanel.add(new JLabel(GUIResources.getMessage("not")), labelConstraints); accessPanel.add(new JLabel(GUIResources.getMessage("dontCare")), labelConstraints); accessPanel.add(Box.createGlue(), constraintsLastStretch); publicRadioButtons = addRadioButtonTriplet("Public", accessPanel); finalRadioButtons = addRadioButtonTriplet("Final", accessPanel); interfaceRadioButtons = addRadioButtonTriplet("Interface", accessPanel); abstractRadioButtons = addRadioButtonTriplet("Abstract", accessPanel); // Create the class name panel. JPanel classNamePanel = new JPanel(layout); classNamePanel.setBorder(BorderFactory.createTitledBorder(etchedBorder, GUIResources.getMessage("class"))); classNamePanel.add(classNameTextField, constraintsLastStretch); // Create the extends class name panel. JPanel extendsClassNamePanel = new JPanel(layout); extendsClassNamePanel.setBorder(BorderFactory.createTitledBorder(etchedBorder, GUIResources.getMessage("extendsImplementsClass"))); extendsClassNamePanel.add(extendsClassNameTextField, constraintsLastStretch); // Create the class member list panel. classMembersPanel = new ClassMemberSpecificationsPanel(this, fullKeepOptions); classMembersPanel.setBorder(BorderFactory.createTitledBorder(etchedBorder, GUIResources.getMessage("classMembers"))); // Create the Ok button. JButton okButton = new JButton(GUIResources.getMessage("ok")); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -