proguardgui.java
来自「proguard 一个java的混淆器」· Java 代码 · 共 1,239 行 · 第 1/5 页
JAVA
1,239 行
JButton processButton = new JButton(msg("process")); processButton.addActionListener(new MyProcessActionListener()); // Create the ReTrace panel. JPanel reTraceSettingsPanel = new JPanel(layout); addBorder(reTraceSettingsPanel, "reTraceSettings"); JButton reTraceMappingBrowseButton = createBrowseButton(reTraceMappingTextField, msg("selectApplyMappingFile")); JLabel reTraceMappingLabel = new JLabel(msg("mappingFile")); reTraceMappingLabel.setForeground(reTraceVerboseCheckBox.getForeground()); reTraceSettingsPanel.add(tip(reTraceVerboseCheckBox, "verboseTip"), constraintsLastStretch); reTraceSettingsPanel.add(tip(reTraceMappingLabel, "mappingFileTip"), constraints); reTraceSettingsPanel.add(tip(reTraceMappingTextField, "inputFileTip"), constraintsStretch); reTraceSettingsPanel.add(tip(reTraceMappingBrowseButton, "selectApplyMappingFile"), constraintsLast); stackTraceTextArea.setOpaque(true); stackTraceTextArea.setEditable(true); stackTraceTextArea.setLineWrap(false); stackTraceTextArea.setWrapStyleWord(true); JScrollPane stackTraceScrollPane = new JScrollPane(stackTraceTextArea); addBorder(stackTraceScrollPane, "obfuscatedStackTrace"); reTraceTextArea.setOpaque(false); reTraceTextArea.setEditable(false); reTraceTextArea.setLineWrap(true); reTraceTextArea.setWrapStyleWord(true); JScrollPane reTraceScrollPane = new JScrollPane(reTraceTextArea); reTraceScrollPane.setBorder(new EmptyBorder(1, 1, 1, 1)); addBorder(reTraceScrollPane, "deobfuscatedStackTrace"); JPanel reTracePanel = new JPanel(layout); reTracePanel.add(reTraceSettingsPanel, panelConstraints); reTracePanel.add(tip(stackTraceScrollPane, "obfuscatedStackTraceTip"), panelConstraints); reTracePanel.add(reTraceScrollPane, stretchPanelConstraints); // Create the load button. JButton loadStackTraceButton = new JButton(msg("loadStackTrace")); loadStackTraceButton.addActionListener(new MyLoadStackTraceActionListener()); JButton reTraceButton = new JButton(msg("reTrace")); reTraceButton.addActionListener(new MyReTraceActionListener()); // Create the main tabbed pane. TabbedPane tabs = new TabbedPane(); tabs.add(msg("proGuardTab"), proGuardPanel); tabs.add(msg("inputOutputTab"), inputOutputPanel); tabs.add(msg("shrinkingTab"), shrinkingPanel); tabs.add(msg("obfuscationTab"), obfuscationPanel); tabs.add(msg("optimizationTab"), optimizationPanel); tabs.add(msg("informationTab"), optionsPanel); tabs.add(msg("processTab"), processPanel); tabs.add(msg("reTraceTab"), reTracePanel); tabs.addImage(Toolkit.getDefaultToolkit().getImage( this.getClass().getResource(TITLE_IMAGE_FILE))); // Add the bottom buttons to each panel. proGuardPanel .add(Box.createGlue(), glueConstraints); proGuardPanel .add(tip(loadButton, "loadConfigurationTip"), bottomButtonConstraints); proGuardPanel .add(createNextButton(tabs), lastBottomButtonConstraints); inputOutputPanel .add(Box.createGlue(), glueConstraints); inputOutputPanel .add(createPreviousButton(tabs), bottomButtonConstraints); inputOutputPanel .add(createNextButton(tabs), lastBottomButtonConstraints); shrinkingPanel .add(Box.createGlue(), glueConstraints); shrinkingPanel .add(createPreviousButton(tabs), bottomButtonConstraints); shrinkingPanel .add(createNextButton(tabs), lastBottomButtonConstraints); obfuscationPanel .add(Box.createGlue(), glueConstraints); obfuscationPanel .add(createPreviousButton(tabs), bottomButtonConstraints); obfuscationPanel .add(createNextButton(tabs), lastBottomButtonConstraints); optimizationPanel .add(Box.createGlue(), glueConstraints); optimizationPanel .add(createPreviousButton(tabs), bottomButtonConstraints); optimizationPanel .add(createNextButton(tabs), lastBottomButtonConstraints); optionsPanel .add(Box.createGlue(), glueConstraints); optionsPanel .add(createPreviousButton(tabs), bottomButtonConstraints); optionsPanel .add(createNextButton(tabs), lastBottomButtonConstraints); processPanel .add(Box.createGlue(), glueConstraints); processPanel .add(createPreviousButton(tabs), bottomButtonConstraints); processPanel .add(tip(viewButton, "viewConfigurationTip"), bottomButtonConstraints); processPanel .add(tip(saveButton, "saveConfigurationTip"), bottomButtonConstraints); processPanel .add(tip(processButton, "processTip"), lastBottomButtonConstraints); reTracePanel .add(Box.createGlue(), glueConstraints); reTracePanel .add(tip(loadStackTraceButton, "loadStackTraceTip"), bottomButtonConstraints); reTracePanel .add(tip(reTraceButton, "reTraceTip"), lastBottomButtonConstraints); // Initialize the GUI settings to reasonable defaults. loadConfiguration(this.getClass().getResource(DEFAULT_CONFIGURATION)); // Add the main tabs to the frame and pack it. getContentPane().add(tabs); } public void startSplash() { splashPanel.start(); } public void skipSplash() { splashPanel.stop(); } /** * Loads the boilerplate keep class options from the boilerplate file * into the boilerplate array. */ private void loadBoilerplateConfiguration() { try { // Parse the boilerplate configuration file. ConfigurationParser parser = new ConfigurationParser( this.getClass().getResource(BOILERPLATE_CONFIGURATION)); Configuration configuration = new Configuration(); try { parser.parse(configuration); // We're interested in the keep options. boilerplateKeep = extractKeepSpecifications(configuration.keep, false, false); // We're interested in the keep options. boilerplateKeepNames = extractKeepSpecifications(configuration.keep, true, false); // We're interested in the side effects options. boilerplateNoSideEffectMethods = new ClassSpecification[configuration.assumeNoSideEffects.size()]; configuration.assumeNoSideEffects.toArray(boilerplateNoSideEffectMethods); } finally { parser.close(); } } catch (Exception ex) { ex.printStackTrace(); } } /** * Returns an array containing the ClassSpecifications instances with * matching flags. */ private KeepSpecification[] extractKeepSpecifications(List keepSpecifications, boolean allowShrinking, boolean allowObfuscation) { List matches = new ArrayList(); for (int index = 0; index < keepSpecifications.size(); index++) { KeepSpecification keepSpecification = (KeepSpecification)keepSpecifications.get(index); if (keepSpecification.allowShrinking == allowShrinking && keepSpecification.allowObfuscation == allowObfuscation) { matches.add(keepSpecification); } } KeepSpecification[] matchingKeepSpecifications = new KeepSpecification[matches.size()]; matches.toArray(matchingKeepSpecifications); return matchingKeepSpecifications; } /** * Returns an array containing the ClassSpecification instances of the * given array of KeepSpecification instances. */ private ClassSpecification[] extractClassSpecifications(KeepSpecification[] keepSpecifications) { ClassSpecification[] classSpecifications = new ClassSpecification[keepSpecifications.length]; for (int index = 0; index < classSpecifications.length; index++) { classSpecifications[index] = keepSpecifications[index]; } return classSpecifications; } /** * Creates a panel with the given boiler plate class specifications. */ private void addClassSpecifications(ClassSpecification[] boilerplateClassSpecifications, JPanel classSpecificationsPanel, JCheckBox[] boilerplateCheckBoxes, JTextField[] boilerplateTextFields) { // Create some constraints that can be reused. GridBagConstraints constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(0, 4, 0, 4); 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.anchor = GridBagConstraints.NORTHWEST; panelConstraints.insets = constraints.insets; GridBagLayout layout = new GridBagLayout(); String lastPanelName = null; JPanel keepSubpanel = null; for (int index = 0; index < boilerplateClassSpecifications.length; index++) { // The panel structure is derived from the comments. String comments = boilerplateClassSpecifications[index].comments; int dashIndex = comments.indexOf('-'); int periodIndex = comments.indexOf('.', dashIndex); String panelName = comments.substring(0, dashIndex).trim(); String optionName = comments.substring(dashIndex + 1, periodIndex).replace('_', '.').trim(); String toolTip = comments.substring(periodIndex + 1); if (keepSubpanel == null || !panelName.equals(lastPanelName)) { // Create a new keep subpanel and add it. keepSubpanel = new JPanel(layout); keepSubpanel.setBorder(BorderFactory.createTitledBorder(BORDER, panelName)); classSpecificationsPanel.add(keepSubpanel, panelConstraints); lastPanelName = panelName; }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?