⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 proguardgui.java

📁 j2me 混淆包,用于混淆j2me的原代码用的
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        }    }    /**     * Saves the current ProGuard configuration to the given file.     */    private void saveConfiguration(String fileName)    {        try        {            // Save the configuration file.            ConfigurationWriter writer = new ConfigurationWriter(fileName);            writer.write(getProGuardConfiguration());            writer.close();        }        catch (Exception ex)        {            JOptionPane.showMessageDialog(getContentPane(),                                          msg("cantSaveConfigurationFile", fileName),                                          msg("warning"),                                          JOptionPane.ERROR_MESSAGE);        }    }    /**     * Loads the given stack trace into the GUI.     */    private void loadStackTrace(String fileName)    {        try        {            // Read the entire stack trace file into a buffer.            File file = new File(fileName);            byte[] buffer = new byte[(int)file.length()];            InputStream inputStream = new FileInputStream(file);            inputStream.read(buffer);            inputStream.close();            // Put the stack trace in the text area.            stackTraceTextArea.setText(new String(buffer));        }        catch (IOException ex)        {            JOptionPane.showMessageDialog(getContentPane(),                                          msg("cantOpenStackTraceFile", fileName),                                          msg("warning"),                                          JOptionPane.ERROR_MESSAGE);        }    }    /**     * This ActionListener loads a ProGuard configuration file and initializes     * the GUI accordingly.     */    private class MyLoadConfigurationActionListener implements ActionListener    {        public void actionPerformed(ActionEvent e)        {            configurationChooser.setDialogTitle(msg("selectConfigurationFile"));            int returnValue = configurationChooser.showOpenDialog(ProGuardGUI.this);            if (returnValue == JFileChooser.APPROVE_OPTION)            {                File selectedFile = configurationChooser.getSelectedFile();                String fileName = selectedFile.getPath();                loadConfiguration(fileName);            }        }    }    /**     * This ActionListener saves a ProGuard configuration file based on the     * current GUI settings.     */    private class MySaveConfigurationActionListener implements ActionListener    {        public void actionPerformed(ActionEvent e)        {            configurationChooser.setDialogTitle(msg("saveConfigurationFile"));            int returnVal = configurationChooser.showSaveDialog(ProGuardGUI.this);            if (returnVal == JFileChooser.APPROVE_OPTION)            {                File selectedFile = configurationChooser.getSelectedFile();                String fileName = selectedFile.getPath();                saveConfiguration(fileName);            }        }    }    /**     * This ActionListener displays the ProGuard configuration specified by the     * current GUI settings.     */    private class MyViewConfigurationActionListener implements ActionListener    {        public void actionPerformed(ActionEvent e)        {            // Make sure System.out has not been redirected yet.            if (!systemOutRedirected)            {                consoleTextArea.setText("");                TextAreaOutputStream outputStream =                    new TextAreaOutputStream(consoleTextArea);                try                {                    // TODO: write out relative path names and path names with system                    // properties.                    // Write the configuration.                    ConfigurationWriter writer = new ConfigurationWriter(outputStream);                    writer.write(getProGuardConfiguration());                    writer.close();                }                catch (IOException ex)                {                }                // Scroll to the top of the configuration.                consoleTextArea.setCaretPosition(0);            }        }    }    /**     * This ActionListener executes ProGuard based on the current GUI settings.     */    private class MyProcessActionListener implements ActionListener    {        public void actionPerformed(ActionEvent e)        {            // Make sure System.out has not been redirected yet.            if (!systemOutRedirected)            {                systemOutRedirected = true;                // Get the informational configuration file name.                File configurationFile = configurationChooser.getSelectedFile();                String configurationFileName = configurationFile != null ?                    configurationFile.getName() :                    msg("sampleConfigurationFileName");                // Create the ProGuard thread.                Thread proGuardThread =                    new Thread(new ProGuardRunnable(consoleTextArea,                                                    getProGuardConfiguration(),                                                    configurationFileName));                // Run it.                proGuardThread.start();            }        }    }    /**     * This ActionListener loads an obfuscated stack trace from a file and puts     * it in the proper text area.     */    private class MyLoadStackTraceActionListener implements ActionListener    {        public void actionPerformed(ActionEvent e)        {            fileChooser.setDialogTitle(msg("selectStackTraceFile"));            fileChooser.setSelectedFile(null);            int returnValue = fileChooser.showOpenDialog(ProGuardGUI.this);            if (returnValue == JFileChooser.APPROVE_OPTION)            {                File selectedFile = fileChooser.getSelectedFile();                String fileName = selectedFile.getPath();                loadStackTrace(fileName);            }        }    }    /**     * This ActionListener executes ReTrace based on the current GUI settings.     */    private class MyReTraceActionListener implements ActionListener    {        public void actionPerformed(ActionEvent e)        {            // Make sure System.out has not been redirected yet.            if (!systemOutRedirected)            {                systemOutRedirected = true;                boolean verbose            = reTraceVerboseCheckBox.isSelected();                String  retraceMappingFile = reTraceMappingTextField.getText();                String  stackTrace         = stackTraceTextArea.getText();                // Create the ReTrace runnable.                Runnable reTraceRunnable = new ReTraceRunnable(reTraceTextArea,                                                               verbose,                                                               retraceMappingFile,                                                               stackTrace);                // Run it in this thread, because it won't take long anyway.                reTraceRunnable.run();            }        }    }    // Small utility methods.    /**     * Returns the message from the GUI resources that corresponds to the given     * key.     */    private String msg(String messageKey)    {         return GUIResources.getMessage(messageKey);    }    /**     * Returns the message from the GUI resources that corresponds to the given     * key and argument.     */    private String msg(String messageKey,                       Object messageArgument)    {         return GUIResources.getMessage(messageKey, new Object[] {messageArgument});    }    /**     * The main method for the ProGuard GUI.     */    public static void main(String[] args)    {        ProGuardGUI gui = new ProGuardGUI();        gui.pack();        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();        Dimension guiSize    = gui.getSize();        gui.setLocation((screenSize.width - guiSize.width)   / 2,                        (screenSize.height - guiSize.height) / 2);        gui.show();        // Start the splash animation, unless specified otherwise.        int argIndex = 0;        if (argIndex < args.length &&            NO_SPLASH_OPTION.startsWith(args[argIndex]))        {            gui.skipSplash();            argIndex++;        }        else        {            gui.startSplash();        }        // Load an initial configuration, if specified.        if (argIndex < args.length)        {            gui.loadConfiguration(args[argIndex]);            argIndex++;        }        if (argIndex < args.length)        {            System.out.println(gui.getClass().getName() + ": ignoring extra arguments [" + args[argIndex] + "...]");        }    }}

⌨️ 快捷键说明

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