Search in sources :

Example 1 with Plugin

use of jgnash.plugin.Plugin in project jgnash by ccavanaugh.

the class OptionDialog method initComponents.

private void initComponents() {
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    setTitle(rb.getString("Title.Options"));
    tabbedPane = new JTabbedPane();
    tabbedPane.addTab(rb.getString("Tab.Accounts"), new AccountOptions());
    tabbedPane.addTab(rb.getString("Tab.General"), new GeneralOptions(this));
    tabbedPane.addTab(rb.getString("Tab.Network"), new NetworkOptions());
    tabbedPane.addTab(rb.getString("Tab.Register"), new RegisterOptions());
    tabbedPane.addTab(rb.getString("Tab.Reminders"), new ReminderOptions());
    tabbedPane.addTab(rb.getString("Tab.Report"), new ReportOptions());
    tabbedPane.addTab(rb.getString("Tab.StartupShutdown"), new StartupOptions());
    for (final Plugin plugin : PluginFactory.getPlugins()) {
        final JPanel optionsPanel = ((SwingPlugin) plugin).getOptionsPanel();
        if (optionsPanel != null) {
            Object name = optionsPanel.getClientProperty(Plugin.OPTIONS_NAME);
            if (name != null) {
                tabbedPane.addTab((String) name, optionsPanel);
            }
        }
    }
    closeButton = new JButton(rb.getString("Button.Close"));
    closeButton.addActionListener(this);
}
Also used : JPanel(javax.swing.JPanel) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) SwingPlugin(jgnash.plugin.SwingPlugin) SwingPlugin(jgnash.plugin.SwingPlugin) Plugin(jgnash.plugin.Plugin)

Example 2 with Plugin

use of jgnash.plugin.Plugin in project jgnash by ccavanaugh.

the class MainFrame method loadPlugins.

private void loadPlugins() {
    // Only load Swing based plugins
    PluginFactory.loadPlugins(plugin -> plugin instanceof SwingPlugin);
    PluginFactory.startPlugins(Plugin.PluginPlatform.Swing);
    for (final Plugin plugin : PluginFactory.getPlugins()) {
        final JMenuItem[] menuItems = ((SwingPlugin) plugin).getMenuItems();
        if (menuItems != null) {
            for (JMenuItem menuItem : menuItems) {
                final Object precedingId = menuItem.getClientProperty(SwingPlugin.PRECEDING_MENU_IDREF);
                if (precedingId != null && precedingId instanceof String) {
                    addMenuItem((String) precedingId, menuItem);
                }
            }
        }
    }
}
Also used : SwingPlugin(jgnash.plugin.SwingPlugin) JMenuItem(javax.swing.JMenuItem) Plugin(jgnash.plugin.Plugin) SwingPlugin(jgnash.plugin.SwingPlugin)

Aggregations

Plugin (jgnash.plugin.Plugin)2 SwingPlugin (jgnash.plugin.SwingPlugin)2 JButton (javax.swing.JButton)1 JMenuItem (javax.swing.JMenuItem)1 JPanel (javax.swing.JPanel)1 JTabbedPane (javax.swing.JTabbedPane)1