memberspecificationdialog.java

来自「proguard 一个java的混淆器」· Java 代码 · 共 498 行 · 第 1/2 页

JAVA
498
字号
/* * ProGuard -- shrinking, optimization, obfuscation, and preverification *             of Java bytecode. * * Copyright (c) 2002-2007 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 proguard.MemberSpecification;import proguard.classfile.ClassConstants;import proguard.classfile.util.ClassUtil;import proguard.util.ListUtil;import javax.swing.*;import javax.swing.border.*;import java.awt.*;import java.awt.event.*;/** * This <code>JDialog</code> allows the user to enter a String. * * @author Eric Lafortune */final class MemberSpecificationDialog 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 final boolean isField;    private final JRadioButton[] publicRadioButtons;    private final JRadioButton[] privateRadioButtons;    private final JRadioButton[] protectedRadioButtons;    private final JRadioButton[] staticRadioButtons;    private final JRadioButton[] finalRadioButtons;    private JRadioButton[] volatileRadioButtons;    private JRadioButton[] transientRadioButtons;    private JRadioButton[] synchronizedRadioButtons;    private JRadioButton[] nativeRadioButtons;    private JRadioButton[] abstractRadioButtons;    private JRadioButton[] strictRadioButtons;    private final JTextField annotationTypeTextField = new JTextField(20);    private final JTextField nameTextField           = new JTextField(20);    private final JTextField typeTextField           = new JTextField(20);    private final JTextField argumentTypesTextField  = new JTextField(20);    private int returnValue;    public MemberSpecificationDialog(JDialog owner, boolean isField)    {        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 advancedButtonConstraints = new GridBagConstraints();        advancedButtonConstraints.weightx = 1.0;        advancedButtonConstraints.weighty = 1.0;        advancedButtonConstraints.anchor  = GridBagConstraints.SOUTHWEST;        advancedButtonConstraints.insets  = new Insets(4, 4, 8, 4);        GridBagConstraints okButtonConstraints = new GridBagConstraints();        okButtonConstraints.weightx = 1.0;        okButtonConstraints.weighty = 1.0;        okButtonConstraints.anchor  = GridBagConstraints.SOUTHEAST;        okButtonConstraints.insets  = advancedButtonConstraints.insets;        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);        this.isField = isField;        // Create the access panel.        JPanel accessPanel = new JPanel(layout);        accessPanel.setBorder(BorderFactory.createTitledBorder(etchedBorder,                                                               msg("access")));        accessPanel.add(Box.createGlue(),                                labelConstraints);        accessPanel.add(tip(new JLabel(msg("required")), "requiredTip"), labelConstraints);        accessPanel.add(tip(new JLabel(msg("not")),      "notTip"),      labelConstraints);        accessPanel.add(tip(new JLabel(msg("dontCare")), "dontCareTip"), labelConstraints);        accessPanel.add(Box.createGlue(),                                constraintsLastStretch);        publicRadioButtons    = addRadioButtonTriplet("Public",    accessPanel);        privateRadioButtons   = addRadioButtonTriplet("Private",   accessPanel);        protectedRadioButtons = addRadioButtonTriplet("Protected", accessPanel);        staticRadioButtons    = addRadioButtonTriplet("Static",    accessPanel);        finalRadioButtons     = addRadioButtonTriplet("Final",     accessPanel);        if (isField)        {            volatileRadioButtons  = addRadioButtonTriplet("Volatile",  accessPanel);            transientRadioButtons = addRadioButtonTriplet("Transient", accessPanel);        }        else        {            synchronizedRadioButtons = addRadioButtonTriplet("Synchronized", accessPanel);            nativeRadioButtons       = addRadioButtonTriplet("Native",       accessPanel);            abstractRadioButtons     = addRadioButtonTriplet("Abstract",     accessPanel);            strictRadioButtons       = addRadioButtonTriplet("Strict",       accessPanel);        }        // Create the type panel.        JPanel typePanel = new JPanel(layout);        typePanel.setBorder(BorderFactory.createTitledBorder(etchedBorder,                                                             msg(isField ? "fieldType" :                                                                           "returnType")));        typePanel.add(tip(typeTextField, "typeTip"), constraintsLastStretch);        // Create the annotation type panel.        final JPanel annotationTypePanel = new JPanel(layout);        annotationTypePanel.setBorder(BorderFactory.createTitledBorder(etchedBorder,                                                                       msg("annotation")));        annotationTypePanel.add(tip(annotationTypeTextField, "classNameTip"), constraintsLastStretch);        // Create the name panel.        JPanel namePanel = new JPanel(layout);        namePanel.setBorder(BorderFactory.createTitledBorder(etchedBorder,                                                             msg("name")));        namePanel.add(tip(nameTextField, isField ? "fieldNameTip" :                                                   "methodNameTip"), constraintsLastStretch);        // Create the arguments panel.        JPanel argumentsPanel = new JPanel(layout);        argumentsPanel.setBorder(BorderFactory.createTitledBorder(etchedBorder,                                                                  msg("argumentTypes")));        argumentsPanel.add(tip(argumentTypesTextField, "argumentTypes2Tip"), constraintsLastStretch);        // Create the Advanced button.        final JButton advancedButton = new JButton(msg("basic"));        advancedButton.addActionListener(new ActionListener()        {            public void actionPerformed(ActionEvent e)            {                boolean visible = !annotationTypePanel.isVisible();                annotationTypePanel.setVisible(visible);                advancedButton.setText(msg(visible ? "basic" : "advanced"));                pack();            }        });        advancedButton.doClick();        // Create the Ok button.        JButton okButton = new JButton(msg("ok"));        okButton.addActionListener(new ActionListener()        {            public void actionPerformed(ActionEvent e)            {                returnValue = APPROVE_OPTION;                hide();            }        });        // Create the Cancel button.        JButton cancelButton = new JButton(msg("cancel"));        cancelButton.addActionListener(new ActionListener()        {            public void actionPerformed(ActionEvent e)            {                hide();            }        });

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?