Search in sources :

Example 1 with JadxPlugin

use of jadx.api.plugins.JadxPlugin in project jadx by skylot.

the class JadxSettingsWindow method makePluginOptionsGroup.

private SettingsGroup makePluginOptionsGroup() {
    SettingsGroup pluginsGroup = new SettingsGroup(NLS.str("preferences.plugins"));
    JadxPluginManager pluginManager = mainWindow.getWrapper().getDecompiler().getPluginManager();
    for (JadxPlugin plugin : pluginManager.getAllPlugins()) {
        if (!(plugin instanceof JadxPluginOptions)) {
            continue;
        }
        JadxPluginInfo pluginInfo = plugin.getPluginInfo();
        JadxPluginOptions optPlugin = (JadxPluginOptions) plugin;
        for (OptionDescription opt : optPlugin.getOptionsDescriptions()) {
            String title = "[" + pluginInfo.getPluginId() + "]  " + opt.description();
            if (opt.values().isEmpty()) {
                JTextField textField = new JTextField();
                textField.getDocument().addDocumentListener(new DocumentUpdateListener(event -> {
                    settings.getPluginOptions().put(opt.name(), textField.getText());
                    needReload();
                }));
                pluginsGroup.addRow(title, textField);
            } else {
                String curValue = settings.getPluginOptions().get(opt.name());
                JComboBox<String> combo = new JComboBox<>(opt.values().toArray(new String[0]));
                combo.setSelectedItem(curValue != null ? curValue : opt.defaultValue());
                combo.addActionListener(e -> {
                    settings.getPluginOptions().put(opt.name(), ((String) combo.getSelectedItem()));
                    needReload();
                });
                pluginsGroup.addRow(title, combo);
            }
        }
    }
    return pluginsGroup;
}
Also used : JsonObject(com.google.gson.JsonObject) Arrays(java.util.Arrays) DocumentListener(javax.swing.event.DocumentListener) JDialog(javax.swing.JDialog) EditorTheme(jadx.gui.ui.codearea.EditorTheme) LafManager(jadx.gui.utils.LafManager) LoggerFactory(org.slf4j.LoggerFactory) GraphicsEnvironment(java.awt.GraphicsEnvironment) GsonBuilder(com.google.gson.GsonBuilder) CommentsLevel(jadx.api.CommentsLevel) MouseAdapter(java.awt.event.MouseAdapter) ChangeListener(javax.swing.event.ChangeListener) BorderLayout(java.awt.BorderLayout) JComboBox(javax.swing.JComboBox) OptionDescription(jadx.api.plugins.options.OptionDescription) Clipboard(java.awt.datatransfer.Clipboard) KeyStroke(javax.swing.KeyStroke) ScrollPaneConstants(javax.swing.ScrollPaneConstants) ChangeEvent(javax.swing.event.ChangeEvent) ItemEvent(java.awt.event.ItemEvent) Font(java.awt.Font) Collection(java.util.Collection) Set(java.util.Set) BorderFactory(javax.swing.BorderFactory) GridBagConstraints(java.awt.GridBagConstraints) Component(java.awt.Component) Box(javax.swing.Box) JFontChooser(say.swing.JFontChooser) Dimension(java.awt.Dimension) JadxArgs(jadx.api.JadxArgs) JadxPlugin(jadx.api.plugins.JadxPlugin) JadxPluginInfo(jadx.api.plugins.JadxPluginInfo) AbstractAction(javax.swing.AbstractAction) JCheckBox(javax.swing.JCheckBox) DocumentUpdateListener(jadx.gui.utils.ui.DocumentUpdateListener) GridBagLayout(java.awt.GridBagLayout) MainWindow(jadx.gui.ui.MainWindow) JPanel(javax.swing.JPanel) WindowConstants(javax.swing.WindowConstants) Toolkit(java.awt.Toolkit) Insets(java.awt.Insets) JadxPluginManager(jadx.api.plugins.JadxPluginManager) JTextField(javax.swing.JTextField) SpinnerNumberModel(javax.swing.SpinnerNumberModel) NLS(jadx.gui.utils.NLS) SwingConstants(javax.swing.SwingConstants) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) SwingUtilities(javax.swing.SwingUtilities) UiUtils(jadx.gui.utils.UiUtils) JadxPluginOptions(jadx.api.plugins.options.JadxPluginOptions) StringSelection(java.awt.datatransfer.StringSelection) Container(java.awt.Container) DocumentEvent(javax.swing.event.DocumentEvent) BoxLayout(javax.swing.BoxLayout) JComponent(javax.swing.JComponent) JButton(javax.swing.JButton) JSpinner(javax.swing.JSpinner) Logger(org.slf4j.Logger) JOptionPane(javax.swing.JOptionPane) ActionEvent(java.awt.event.ActionEvent) MouseEvent(java.awt.event.MouseEvent) JScrollPane(javax.swing.JScrollPane) DeobfuscationMapFileMode(jadx.api.args.DeobfuscationMapFileMode) LangLocale(jadx.gui.utils.LangLocale) JLabel(javax.swing.JLabel) UseKotlinMethodsForVarNames(jadx.api.JadxArgs.UseKotlinMethodsForVarNames) InputMap(javax.swing.InputMap) Collections(java.util.Collections) FontUtils(jadx.gui.utils.FontUtils) DocumentUpdateListener(jadx.gui.utils.ui.DocumentUpdateListener) JadxPluginOptions(jadx.api.plugins.options.JadxPluginOptions) OptionDescription(jadx.api.plugins.options.OptionDescription) JComboBox(javax.swing.JComboBox) JadxPlugin(jadx.api.plugins.JadxPlugin) JadxPluginInfo(jadx.api.plugins.JadxPluginInfo) JadxPluginManager(jadx.api.plugins.JadxPluginManager) JTextField(javax.swing.JTextField)

Example 2 with JadxPlugin

use of jadx.api.plugins.JadxPlugin in project jadx by skylot.

the class JCommanderWrapper method appendPluginOptions.

private String appendPluginOptions(int maxNamesLen) {
    StringBuilder sb = new StringBuilder();
    JadxPluginManager pluginManager = new JadxPluginManager();
    pluginManager.load();
    int k = 1;
    for (JadxPlugin plugin : pluginManager.getAllPlugins()) {
        if (plugin instanceof JadxPluginOptions) {
            if (appendPlugin(((JadxPluginOptions) plugin), sb, maxNamesLen, k)) {
                k++;
            }
        }
    }
    if (sb.length() == 0) {
        return "";
    }
    return "\nPlugin options (-P<name>=<value>):" + sb;
}
Also used : JadxPluginOptions(jadx.api.plugins.options.JadxPluginOptions) JadxPlugin(jadx.api.plugins.JadxPlugin) JadxPluginManager(jadx.api.plugins.JadxPluginManager)

Aggregations

JadxPlugin (jadx.api.plugins.JadxPlugin)2 JadxPluginManager (jadx.api.plugins.JadxPluginManager)2 JadxPluginOptions (jadx.api.plugins.options.JadxPluginOptions)2 GsonBuilder (com.google.gson.GsonBuilder)1 JsonObject (com.google.gson.JsonObject)1 CommentsLevel (jadx.api.CommentsLevel)1 JadxArgs (jadx.api.JadxArgs)1 UseKotlinMethodsForVarNames (jadx.api.JadxArgs.UseKotlinMethodsForVarNames)1 DeobfuscationMapFileMode (jadx.api.args.DeobfuscationMapFileMode)1 JadxPluginInfo (jadx.api.plugins.JadxPluginInfo)1 OptionDescription (jadx.api.plugins.options.OptionDescription)1 MainWindow (jadx.gui.ui.MainWindow)1 EditorTheme (jadx.gui.ui.codearea.EditorTheme)1 FontUtils (jadx.gui.utils.FontUtils)1 LafManager (jadx.gui.utils.LafManager)1 LangLocale (jadx.gui.utils.LangLocale)1 NLS (jadx.gui.utils.NLS)1 UiUtils (jadx.gui.utils.UiUtils)1 DocumentUpdateListener (jadx.gui.utils.ui.DocumentUpdateListener)1 BorderLayout (java.awt.BorderLayout)1