📄 proguardgui.java
字号:
/* * 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.image.BufferedImage;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 = "InnerClasses,SourceFile,LineNumberTable,Deprecated,Signature,*Annotation*,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 JFileChooser configurationChooser = new JFileChooser(""); private JFileChooser fileChooser = new JFileChooser(""); private SplashPanel splashPanel; private ClassPathPanel programPanel = new ClassPathPanel(this, true); private ClassPathPanel libraryPanel = new ClassPathPanel(this, false); private KeepSpecification[] boilerplateKeep; private JCheckBox[] boilerplateKeepCheckBoxes; private JTextField[] boilerplateKeepTextFields; private KeepSpecificationsPanel additionalKeepPanel = new KeepSpecificationsPanel(this, true, false, false, false, false); private KeepSpecification[] boilerplateKeepNames; private JCheckBox[] boilerplateKeepNamesCheckBoxes; private JTextField[] boilerplateKeepNamesTextFields; private KeepSpecificationsPanel additionalKeepNamesPanel = new KeepSpecificationsPanel(this, true, false, true, false, false); private ClassSpecification[] boilerplateNoSideEffectMethods; private JCheckBox[] boilerplateNoSideEffectMethodCheckBoxes; private ClassSpecificationsPanel additionalNoSideEffectsPanel = new ClassSpecificationsPanel(this, false); private ClassSpecificationsPanel whyAreYouKeepingPanel = new ClassSpecificationsPanel(this, false); private JCheckBox shrinkCheckBox = new JCheckBox(msg("shrink")); private JCheckBox printUsageCheckBox = new JCheckBox(msg("printUsage")); private JCheckBox optimizeCheckBox = new JCheckBox(msg("optimize")); private JCheckBox allowAccessModificationCheckBox = new JCheckBox(msg("allowAccessModification")); private JLabel optimizationPassesLabel = new JLabel(msg("optimizationPasses")); private JSpinner optimizationPassesSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 9, 1)); private JCheckBox obfuscateCheckBox = new JCheckBox(msg("obfuscate")); private JCheckBox printMappingCheckBox = new JCheckBox(msg("printMapping")); private JCheckBox applyMappingCheckBox = new JCheckBox(msg("applyMapping")); private JCheckBox obfuscationDictionaryCheckBox = new JCheckBox(msg("obfuscationDictionary")); private JCheckBox overloadAggressivelyCheckBox = new JCheckBox(msg("overloadAggressively")); private JCheckBox useUniqueClassMemberNamesCheckBox = new JCheckBox(msg("useUniqueClassMemberNames")); private JCheckBox useMixedCaseClassNamesCheckBox = new JCheckBox(msg("useMixedCaseClassNames")); private JCheckBox flattenPackageHierarchyCheckBox = new JCheckBox(msg("flattenPackageHierarchy")); private JCheckBox repackageClassesCheckBox = new JCheckBox(msg("repackageClasses")); private JCheckBox keepAttributesCheckBox = new JCheckBox(msg("keepAttributes")); private JCheckBox newSourceFileAttributeCheckBox = new JCheckBox(msg("renameSourceFileAttribute")); private JCheckBox adaptResourceFileNamesCheckBox = new JCheckBox(msg("adaptResourceFileNames")); private JCheckBox adaptResourceFileContentsCheckBox = new JCheckBox(msg("adaptResourceFileContents")); private JCheckBox preverifyCheckBox = new JCheckBox(msg("preverify")); private JCheckBox microEditionCheckBox = new JCheckBox(msg("microEdition")); private JCheckBox targetCheckBox = new JCheckBox(msg("target")); private JComboBox targetComboBox = new JComboBox(ListUtil.commaSeparatedList(msg("targets")).toArray()); private JCheckBox verboseCheckBox = new JCheckBox(msg("verbose")); private JCheckBox ignoreWarningsCheckBox = new JCheckBox(msg("ignoreWarnings")); private JCheckBox warnCheckBox = new JCheckBox(msg("warn")); private JCheckBox noteCheckBox = new JCheckBox(msg("note")); private JCheckBox skipNonPublicLibraryClassesCheckBox = new JCheckBox(msg("skipNonPublicLibraryClasses")); private JCheckBox skipNonPublicLibraryClassMembersCheckBox = new JCheckBox(msg("skipNonPublicLibraryClassMembers")); private JCheckBox forceProcessingCheckBox = new JCheckBox(msg("forceProcessing")); private JCheckBox printSeedsCheckBox = new JCheckBox(msg("printSeeds")); private JCheckBox printConfigurationCheckBox = new JCheckBox(msg("printConfiguration")); private JCheckBox dumpCheckBox = new JCheckBox(msg("dump")); private JTextField printUsageTextField = new JTextField(40); private JTextField printMappingTextField = new JTextField(40); private JTextField applyMappingTextField = new JTextField(40); private JTextField obfuscationDictionaryTextField = new JTextField(40); private JTextField flattenPackageHierarchyTextField = new JTextField(40); private JTextField repackageClassesTextField = new JTextField(40); private JTextField keepAttributesTextField = new JTextField(40); private JTextField newSourceFileAttributeTextField = new JTextField(40); private JTextField adaptResourceFileNamesTextField = new JTextField(40); private JTextField adaptResourceFileContentsTextField = new JTextField(40); private JTextField printSeedsTextField = new JTextField(40); private JTextField printConfigurationTextField = new JTextField(40); private JTextField dumpTextField = new JTextField(40); private JTextArea consoleTextArea = new JTextArea(msg("processingInfo"), 3, 40); private JCheckBox reTraceVerboseCheckBox = new JCheckBox(msg("verbose")); private JTextField reTraceMappingTextField = new JTextField(40); private JTextArea stackTraceTextArea = new JTextArea(3, 40); private 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), new LinearInt(-10, 120, new SmoothTiming(500, 1000))))), new ColorSprite(new ConstantColor(Color.white), new FontSprite(new ConstantFont(new Font("sansserif", Font.BOLD, 45)), new ShadowedSprite(new ConstantInt(3), new ConstantInt(3), new ConstantDouble(0.4), new ConstantInt(1), new CompositeSprite(new Sprite[] { new TextSprite(new ConstantString(msg("shrinking")), new LinearInt(1000, 60, new SmoothTiming(1000, 2000)), new ConstantInt(70)), new TextSprite(new ConstantString(msg("optimization")), new LinearInt(1000, 400, new SmoothTiming(1500, 2500)), new ConstantInt(60)), new TextSprite(new ConstantString(msg("obfuscation")), new LinearInt(1000, 10, new SmoothTiming(2000, 3000)), new ConstantInt(145)),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -