proguardgui.java
来自「proguard 一个java的混淆器」· Java 代码 · 共 1,239 行 · 第 1/5 页
JAVA
1,239 行
/* * 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.*;import proguard.classfile.util.ClassUtil;import proguard.gui.splash.*;import proguard.util.ListUtil;import javax.swing.*;import javax.swing.border.*;import java.awt.*;import java.awt.event.*;import java.io.*;import java.net.URL;import java.util.*;import java.util.List;/** * GUI for configuring and executing ProGuard and ReTrace. * * @author Eric Lafortune */public class ProGuardGUI extends JFrame{ private static final String NO_SPLASH_OPTION = "-nosplash"; private static final String TITLE_IMAGE_FILE = "vtitle.gif"; private static final String BOILERPLATE_CONFIGURATION = "boilerplate.pro"; private static final String DEFAULT_CONFIGURATION = "default.pro"; private static final String KEEP_ATTRIBUTE_DEFAULT = "Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,LocalVariable*Table,*Annotation*,Synthetic,EnclosingMethod"; private static final String SOURCE_FILE_ATTRIBUTE_DEFAULT = "SourceFile"; private static final String ADAPT_RESOURCE_FILE_NAMES_DEFAULT = "**.properties"; private static final String ADAPT_RESOURCE_FILE_CONTENTS_DEFAULT = "**.properties,META-INF/MANIFEST.MF"; private static final Border BORDER = BorderFactory.createEtchedBorder(EtchedBorder.RAISED); static boolean systemOutRedirected; private final JFileChooser configurationChooser = new JFileChooser(""); private final JFileChooser fileChooser = new JFileChooser(""); private final SplashPanel splashPanel; private final ClassPathPanel programPanel = new ClassPathPanel(this, true); private final ClassPathPanel libraryPanel = new ClassPathPanel(this, false); private KeepSpecification[] boilerplateKeep; private final JCheckBox[] boilerplateKeepCheckBoxes; private final JTextField[] boilerplateKeepTextFields; private final KeepSpecificationsPanel additionalKeepPanel = new KeepSpecificationsPanel(this, true, false, false, false, false); private KeepSpecification[] boilerplateKeepNames; private final JCheckBox[] boilerplateKeepNamesCheckBoxes; private final JTextField[] boilerplateKeepNamesTextFields; private final KeepSpecificationsPanel additionalKeepNamesPanel = new KeepSpecificationsPanel(this, true, false, true, false, false); private ClassSpecification[] boilerplateNoSideEffectMethods; private final JCheckBox[] boilerplateNoSideEffectMethodCheckBoxes; private final ClassSpecificationsPanel additionalNoSideEffectsPanel = new ClassSpecificationsPanel(this, false); private final ClassSpecificationsPanel whyAreYouKeepingPanel = new ClassSpecificationsPanel(this, false); private final JCheckBox shrinkCheckBox = new JCheckBox(msg("shrink")); private final JCheckBox printUsageCheckBox = new JCheckBox(msg("printUsage")); private final JCheckBox optimizeCheckBox = new JCheckBox(msg("optimize")); private final JCheckBox allowAccessModificationCheckBox = new JCheckBox(msg("allowAccessModification")); private final JLabel optimizationPassesLabel = new JLabel(msg("optimizationPasses")); private final JSpinner optimizationPassesSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 9, 1)); private final JCheckBox obfuscateCheckBox = new JCheckBox(msg("obfuscate")); private final JCheckBox printMappingCheckBox = new JCheckBox(msg("printMapping")); private final JCheckBox applyMappingCheckBox = new JCheckBox(msg("applyMapping")); private final JCheckBox obfuscationDictionaryCheckBox = new JCheckBox(msg("obfuscationDictionary")); private final JCheckBox overloadAggressivelyCheckBox = new JCheckBox(msg("overloadAggressively")); private final JCheckBox useUniqueClassMemberNamesCheckBox = new JCheckBox(msg("useUniqueClassMemberNames")); private final JCheckBox useMixedCaseClassNamesCheckBox = new JCheckBox(msg("useMixedCaseClassNames")); private final JCheckBox flattenPackageHierarchyCheckBox = new JCheckBox(msg("flattenPackageHierarchy")); private final JCheckBox repackageClassesCheckBox = new JCheckBox(msg("repackageClasses")); private final JCheckBox keepAttributesCheckBox = new JCheckBox(msg("keepAttributes")); private final JCheckBox newSourceFileAttributeCheckBox = new JCheckBox(msg("renameSourceFileAttribute")); private final JCheckBox adaptResourceFileNamesCheckBox = new JCheckBox(msg("adaptResourceFileNames")); private final JCheckBox adaptResourceFileContentsCheckBox = new JCheckBox(msg("adaptResourceFileContents")); private final JCheckBox preverifyCheckBox = new JCheckBox(msg("preverify")); private final JCheckBox microEditionCheckBox = new JCheckBox(msg("microEdition")); private final JCheckBox targetCheckBox = new JCheckBox(msg("target")); private final JComboBox targetComboBox = new JComboBox(ListUtil.commaSeparatedList(msg("targets")).toArray()); private final JCheckBox verboseCheckBox = new JCheckBox(msg("verbose")); private final JCheckBox ignoreWarningsCheckBox = new JCheckBox(msg("ignoreWarnings")); private final JCheckBox warnCheckBox = new JCheckBox(msg("warn")); private final JCheckBox noteCheckBox = new JCheckBox(msg("note")); private final JCheckBox skipNonPublicLibraryClassesCheckBox = new JCheckBox(msg("skipNonPublicLibraryClasses")); private final JCheckBox skipNonPublicLibraryClassMembersCheckBox = new JCheckBox(msg("skipNonPublicLibraryClassMembers")); private final JCheckBox forceProcessingCheckBox = new JCheckBox(msg("forceProcessing")); private final JCheckBox printSeedsCheckBox = new JCheckBox(msg("printSeeds")); private final JCheckBox printConfigurationCheckBox = new JCheckBox(msg("printConfiguration")); private final JCheckBox dumpCheckBox = new JCheckBox(msg("dump")); private final JTextField printUsageTextField = new JTextField(40); private final JTextField printMappingTextField = new JTextField(40); private final JTextField applyMappingTextField = new JTextField(40); private final JTextField obfuscationDictionaryTextField = new JTextField(40); private final JTextField flattenPackageHierarchyTextField = new JTextField(40); private final JTextField repackageClassesTextField = new JTextField(40); private final JTextField keepAttributesTextField = new JTextField(40); private final JTextField newSourceFileAttributeTextField = new JTextField(40); private final JTextField adaptResourceFileNamesTextField = new JTextField(40); private final JTextField adaptResourceFileContentsTextField = new JTextField(40); private final JTextField printSeedsTextField = new JTextField(40); private final JTextField printConfigurationTextField = new JTextField(40); private final JTextField dumpTextField = new JTextField(40); private final JTextArea consoleTextArea = new JTextArea(msg("processingInfo"), 3, 40); private final JCheckBox reTraceVerboseCheckBox = new JCheckBox(msg("verbose")); private final JTextField reTraceMappingTextField = new JTextField(40); private final JTextArea stackTraceTextArea = new JTextArea(3, 40); private final JTextArea reTraceTextArea = new JTextArea(msg("reTraceInfo"), 3, 40); /** * Creates a new ProGuardGUI. */ public ProGuardGUI() { setTitle("ProGuard"); setDefaultCloseOperation(EXIT_ON_CLOSE); // Create some constraints that can be reused. GridBagConstraints constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(0, 4, 0, 4); 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 splashPanelConstraints = new GridBagConstraints(); splashPanelConstraints.gridwidth = GridBagConstraints.REMAINDER; splashPanelConstraints.fill = GridBagConstraints.BOTH; splashPanelConstraints.weightx = 1.0; splashPanelConstraints.weighty = 0.02; splashPanelConstraints.anchor = GridBagConstraints.NORTHWEST; //splashPanelConstraints.insets = constraints.insets; GridBagConstraints welcomeTextAreaConstraints = new GridBagConstraints(); welcomeTextAreaConstraints.gridwidth = GridBagConstraints.REMAINDER; welcomeTextAreaConstraints.fill = GridBagConstraints.NONE; welcomeTextAreaConstraints.weightx = 1.0; welcomeTextAreaConstraints.weighty = 0.01; welcomeTextAreaConstraints.anchor = GridBagConstraints.CENTER;//NORTHWEST; welcomeTextAreaConstraints.insets = new Insets(20, 40, 20, 40); GridBagConstraints panelConstraints = new GridBagConstraints(); panelConstraints.gridwidth = GridBagConstraints.REMAINDER; panelConstraints.fill = GridBagConstraints.HORIZONTAL; panelConstraints.weightx = 1.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 glueConstraints = new GridBagConstraints(); glueConstraints.fill = GridBagConstraints.BOTH; glueConstraints.weightx = 0.01; glueConstraints.weighty = 0.01; glueConstraints.anchor = GridBagConstraints.NORTHWEST; glueConstraints.insets = constraints.insets; GridBagConstraints bottomButtonConstraints = new GridBagConstraints(); bottomButtonConstraints.anchor = GridBagConstraints.SOUTHEAST; bottomButtonConstraints.insets = new Insets(2, 2, 4, 6); bottomButtonConstraints.ipadx = 10; bottomButtonConstraints.ipady = 2; GridBagConstraints lastBottomButtonConstraints = new GridBagConstraints(); lastBottomButtonConstraints.gridwidth = GridBagConstraints.REMAINDER; lastBottomButtonConstraints.anchor = GridBagConstraints.SOUTHEAST; lastBottomButtonConstraints.insets = bottomButtonConstraints.insets; lastBottomButtonConstraints.ipadx = bottomButtonConstraints.ipadx; lastBottomButtonConstraints.ipady = bottomButtonConstraints.ipady; // Leave room for a growBox on Mac OS X. if (System.getProperty("os.name").toLowerCase().startsWith("mac os x")) { lastBottomButtonConstraints.insets = new Insets(2, 2, 4, 6 + 16); } GridBagLayout layout = new GridBagLayout(); configurationChooser.addChoosableFileFilter( new ExtensionFileFilter(msg("proExtension"), new String[] { ".pro" })); // Create the opening panel. Sprite splash = new CompositeSprite(new Sprite[] { new ColorSprite(new ConstantColor(Color.gray), new FontSprite(new ConstantFont(new Font("sansserif", Font.BOLD, 90)), new TextSprite(new ConstantString("ProGuard"), new ConstantInt(160),
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?