// Path: src/main/java/org/jmeterplugins/repository/logging/LoggingHooker.java
// public class LoggingHooker {
//     private static final org.slf4j.Logger log = LoggerFactory.getLogger(LoggingHooker.class);
//     private final PluginManager mgr;
// 
//     public LoggingHooker(PluginManager mgr) {
//         this.mgr = mgr;
//     }
// 
//     public void hook() {
//         try {
//             if (!isJMeter32orLater()) {
//                 Logger logger = LoggerFactory.getLogger("jmeter.save.SaveService");
//                 // FIXME: what to do? logger.setLogTargets(new LogTarget[]{new LoggerPanelWrapping(mgr)});
//             } else {
//                 Class<?> cls = Class.forName("org.jmeterplugins.repository.logging.LoggerAppender");
//                 Constructor<?> constructor = cls.getConstructor(String.class, PluginManager.class);
//                 constructor.newInstance("pmgr-logging-appender", mgr);
//             }
//         } catch (Throwable ex) {
//             log.error("Cannot hook into logging", ex);
//         }
//     }
// 
//     public static boolean isJMeter32orLater() {
//         try {
//             Class<?> cls = LoggingHooker.class.getClassLoader().loadClass("org.apache.jmeter.gui.logging.GuiLogEventBus");
//             if (cls != null) {
//                 return true;
//             }
//         } catch (ClassNotFoundException ex) {
//             log.debug("Class 'org.apache.jmeter.gui.logging.GuiLogEventBus' not found", ex);
//         } catch (Throwable ex) {
//             log.warn("Fail to detect JMeter version", ex);
//         }
//         return false;
//     }
// }
// 
// Path: src/main/java/org/jmeterplugins/repository/util/ComponentFinder.java
// public class ComponentFinder<T extends Component> {
//     private static final Logger log = LoggerFactory.getLogger(ComponentFinder.class);
// 
//     private final Class<T> search;
// 
//     public ComponentFinder(Class<T> cls) {
//         search = cls;
//     }
// 
//     public T findComponentIn(Container container) {
//         log.debug("Searching in " + container);
//         for (Component a : container.getComponents()) {
//             if (search.isAssignableFrom(a.getClass())) {
//                 log.debug("Found " + a);
//                 return (T) a;
//             }
// 
//             if (a instanceof Container) {
//                 T res = findComponentIn((Container) a);
//                 if (res != null) {
//                     return res;
//                 }
//             }
//         }
// 
//         return null;
//     }
// }


import org.apache.jmeter.gui.GuiPackage;
import org.apache.jmeter.gui.MainFrame;
import org.apache.jmeter.gui.util.JMeterToolBar;
import org.jmeterplugins.repository.logging.LoggingHooker;
import org.jmeterplugins.repository.util.ComponentFinder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Arrays;
package org.jmeterplugins.repository;



public class PluginManagerMenuItem extends JMenuItem implements ActionListener {
    private static final long serialVersionUID = -8708638472918746046L;
    private static final Logger log = LoggerFactory.getLogger(PluginManagerMenuItem.class);
    private static PluginManagerDialog dialog;
    private final PluginManager mgr;

    public PluginManagerMenuItem() {
        super("Plugins Manager");
        addActionListener(this);

        mgr = new PluginManager(); // don't delay startup for longer that 1 second
// Path: src/main/java/org/jmeterplugins/repository/logging/LoggingHooker.java
// public class LoggingHooker {
//     private static final org.slf4j.Logger log = LoggerFactory.getLogger(LoggingHooker.class);
//     private final PluginManager mgr;
// 
//     public LoggingHooker(PluginManager mgr) {
//         this.mgr = mgr;
//     }
// 
//     public void hook() {
//         try {
//             if (!isJMeter32orLater()) {
//                 Logger logger = LoggerFactory.getLogger("jmeter.save.SaveService");
//                 // FIXME: what to do? logger.setLogTargets(new LogTarget[]{new LoggerPanelWrapping(mgr)});
//             } else {
//                 Class<?> cls = Class.forName("org.jmeterplugins.repository.logging.LoggerAppender");
//                 Constructor<?> constructor = cls.getConstructor(String.class, PluginManager.class);
//                 constructor.newInstance("pmgr-logging-appender", mgr);
//             }
//         } catch (Throwable ex) {
//             log.error("Cannot hook into logging", ex);
//         }
//     }
// 
//     public static boolean isJMeter32orLater() {
//         try {
//             Class<?> cls = LoggingHooker.class.getClassLoader().loadClass("org.apache.jmeter.gui.logging.GuiLogEventBus");
//             if (cls != null) {
//                 return true;
//             }
//         } catch (ClassNotFoundException ex) {
//             log.debug("Class 'org.apache.jmeter.gui.logging.GuiLogEventBus' not found", ex);
//         } catch (Throwable ex) {
//             log.warn("Fail to detect JMeter version", ex);
//         }
//         return false;
//     }
// }
// 
// Path: src/main/java/org/jmeterplugins/repository/util/ComponentFinder.java
// public class ComponentFinder<T extends Component> {
//     private static final Logger log = LoggerFactory.getLogger(ComponentFinder.class);
// 
//     private final Class<T> search;
// 
//     public ComponentFinder(Class<T> cls) {
//         search = cls;
//     }
// 
//     public T findComponentIn(Container container) {
//         log.debug("Searching in " + container);
//         for (Component a : container.getComponents()) {
//             if (search.isAssignableFrom(a.getClass())) {
//                 log.debug("Found " + a);
//                 return (T) a;
//             }
// 
//             if (a instanceof Container) {
//                 T res = findComponentIn((Container) a);
//                 if (res != null) {
//                     return res;
//                 }
//             }
//         }
// 
//         return null;
//     }
// }


// Path: src/main/java/org/jmeterplugins/repository/PluginManagerMenuItem.java
import org.apache.jmeter.gui.GuiPackage;
import org.apache.jmeter.gui.MainFrame;
import org.apache.jmeter.gui.util.JMeterToolBar;
import org.jmeterplugins.repository.logging.LoggingHooker;
import org.jmeterplugins.repository.util.ComponentFinder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Arrays;

package org.jmeterplugins.repository;



public class PluginManagerMenuItem extends JMenuItem implements ActionListener {
    private static final long serialVersionUID = -8708638472918746046L;
    private static final Logger log = LoggerFactory.getLogger(PluginManagerMenuItem.class);
    private static PluginManagerDialog dialog;
    private final PluginManager mgr;

    public PluginManagerMenuItem() {
        super("Plugins Manager");
        addActionListener(this);

        mgr = new PluginManager(); // don't delay startup for longer that 1 second
        LoggingHooker hooker = new LoggingHooker(mgr);