Example usage for javax.swing.event MenuListener MenuListener

List of usage examples for javax.swing.event MenuListener MenuListener

Introduction

In this page you can find the example usage for javax.swing.event MenuListener MenuListener.

Prototype

MenuListener

Source Link

Usage

From source file:edu.ku.brc.specify.Specify.java

/**
 * Create menus/*ww w  .ja  va2s. co m*/
 */
public JMenuBar createMenus() {
    JMenuBar mb = new JMenuBar();
    JMenuItem mi;

    //--------------------------------------------------------------------
    //-- File Menu
    //--------------------------------------------------------------------

    JMenu menu = null;

    if (!UIHelper.isMacOS() || !isWorkbenchOnly) {
        menu = UIHelper.createLocalizedMenu(mb, "Specify.FILE_MENU", "Specify.FILE_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$
    }

    if (!isWorkbenchOnly) {
        // Add Menu for switching Collection
        String title = "Specify.CHANGE_COLLECTION"; //$NON-NLS-1$
        String mnu = "Specify.CHANGE_COLL_MNEU"; //$NON-NLS-1$
        changeCollectionMenuItem = UIHelper.createLocalizedMenuItem(menu, title, mnu, title, false, null);
        changeCollectionMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                if (SubPaneMgr.getInstance().aboutToShutdown()) {

                    // Actually we really need to start over
                    // "true" means that it should NOT use any cached values it can find to automatically initialize itself
                    // instead it should ask the user any questions as if it were starting over
                    restartApp(null, databaseName, userName, true, false);
                }
            }
        });

        menu.addMenuListener(new MenuListener() {
            @Override
            public void menuCanceled(MenuEvent e) {
            }

            @Override
            public void menuDeselected(MenuEvent e) {
            }

            @Override
            public void menuSelected(MenuEvent e) {
                boolean enable = Uploader.getCurrentUpload() == null
                        && ((SpecifyAppContextMgr) AppContextMgr.getInstance()).getNumOfCollectionsForUser() > 1
                        && !TaskMgr.areTasksDisabled();

                changeCollectionMenuItem.setEnabled(enable);
            }

        });
    }

    if (UIHelper.getOSType() != UIHelper.OSTYPE.MacOSX) {
        if (!UIRegistry.isMobile()) {
            menu.addSeparator();
        }
        String title = "Specify.EXIT"; //$NON-NLS-1$
        String mnu = "Specify.Exit_MNEU"; //$NON-NLS-1$
        mi = UIHelper.createLocalizedMenuItem(menu, title, mnu, title, true, null);
        if (!UIHelper.isMacOS()) {
            mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.CTRL_DOWN_MASK));
        }
        mi.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                doExit(true);
            }
        });
    }

    menu = UIRegistry.getInstance().createEditMenu();
    mb.add(menu);

    //menu = UIHelper.createMenu(mb, "EditMenu", "EditMneu");
    if (UIHelper.getOSType() != UIHelper.OSTYPE.MacOSX) {
        menu.addSeparator();
        String title = "Specify.PREFERENCES"; //$NON-NLS-1$
        String mnu = "Specify.PREFERENCES_MNEU";//$NON-NLS-1$
        mi = UIHelper.createLocalizedMenuItem(menu, title, mnu, title, false, null);
        mi.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                doPreferences();
            }
        });
        mi.setEnabled(true);
    }

    //--------------------------------------------------------------------
    //-- Data Menu
    //--------------------------------------------------------------------
    JMenu dataMenu = UIHelper.createLocalizedMenu(mb, "Specify.DATA_MENU", "Specify.DATA_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$
    ResultSetController.addMenuItems(dataMenu);
    dataMenu.addSeparator();

    // Save And New Menu Item
    Action saveAndNewAction = new AbstractAction(getResourceString("Specify.SAVE_AND_NEW")) { //$NON-NLS-1$
        public void actionPerformed(ActionEvent e) {
            FormViewObj fvo = getCurrentFVO();
            if (fvo != null) {
                fvo.setSaveAndNew(((JCheckBoxMenuItem) e.getSource()).isSelected());
            }
        }
    };
    saveAndNewAction.setEnabled(false);
    JCheckBoxMenuItem saveAndNewCBMI = new JCheckBoxMenuItem(saveAndNewAction);
    dataMenu.add(saveAndNewCBMI);
    UIRegistry.register("SaveAndNew", saveAndNewCBMI); //$NON-NLS-1$
    UIRegistry.registerAction("SaveAndNew", saveAndNewAction); //$NON-NLS-1$
    mb.add(dataMenu);

    // Configure Carry Forward
    Action configCarryForwardAction = new AbstractAction(
            getResourceString("Specify.CONFIG_CARRY_FORWARD_MENU")) { //$NON-NLS-1$
        public void actionPerformed(ActionEvent e) {
            FormViewObj fvo = getCurrentFVO();
            if (fvo != null) {
                fvo.configureCarryForward();
            }
        }
    };
    configCarryForwardAction.setEnabled(false);
    JMenuItem configCFWMI = new JMenuItem(configCarryForwardAction);
    dataMenu.add(configCFWMI);
    UIRegistry.register("ConfigCarryForward", configCFWMI); //$NON-NLS-1$
    UIRegistry.registerAction("ConfigCarryForward", configCarryForwardAction); //$NON-NLS-1$
    mb.add(dataMenu);

    //---------------------------------------
    // Carry Forward Menu Item (On / Off)
    Action carryForwardAction = new AbstractAction(getResourceString("Specify.CARRY_FORWARD_CHECKED_MENU")) { //$NON-NLS-1$
        public void actionPerformed(ActionEvent e) {
            FormViewObj fvo = getCurrentFVO();
            if (fvo != null) {
                fvo.toggleCarryForward();
                ((JCheckBoxMenuItem) e.getSource()).setSelected(fvo.isDoCarryForward());
            }
        }
    };
    carryForwardAction.setEnabled(false);
    JCheckBoxMenuItem carryForwardCBMI = new JCheckBoxMenuItem(carryForwardAction);
    dataMenu.add(carryForwardCBMI);
    UIRegistry.register("CarryForward", carryForwardCBMI); //$NON-NLS-1$
    UIRegistry.registerAction("CarryForward", carryForwardAction); //$NON-NLS-1$
    mb.add(dataMenu);

    if (!isWorkbenchOnly) {
        final String AUTO_NUM = "AutoNumbering";
        //---------------------------------------
        // AutoNumber Menu Item (On / Off)
        Action autoNumberOnOffAction = new AbstractAction(
                getResourceString("FormViewObj.SET_AUTONUMBER_ONOFF")) { //$NON-NLS-1$
            public void actionPerformed(ActionEvent e) {
                FormViewObj fvo = getCurrentFVO();
                if (fvo != null) {
                    fvo.toggleAutoNumberOnOffState();
                    ((JCheckBoxMenuItem) e.getSource()).setSelected(fvo.isAutoNumberOn());
                }
            }
        };
        autoNumberOnOffAction.setEnabled(false);
        JCheckBoxMenuItem autoNumCBMI = new JCheckBoxMenuItem(autoNumberOnOffAction);
        dataMenu.add(autoNumCBMI);
        UIRegistry.register(AUTO_NUM, autoNumCBMI); //$NON-NLS-1$
        UIRegistry.registerAction(AUTO_NUM, autoNumberOnOffAction); //$NON-NLS-1$
    }

    if (System.getProperty("user.name").equals("rods")) {
        dataMenu.addSeparator();

        AbstractAction gpxAction = new AbstractAction("GPS Data") {
            @Override
            public void actionPerformed(ActionEvent e) {
                GPXPanel.getDlgInstance().setVisible(true);
            }
        };
        JMenuItem gpxMI = new JMenuItem(gpxAction);
        dataMenu.add(gpxMI);
        UIRegistry.register("GPXDlg", gpxMI); //$NON-NLS-1$
        UIRegistry.registerAction("GPXDlg", gpxAction); //$NON-NLS-1$
    }

    mb.add(dataMenu);

    SubPaneMgr.getInstance(); // force creating of the Mgr so the menu Actions are created.

    //--------------------------------------------------------------------
    //-- System Menu
    //--------------------------------------------------------------------

    if (!isWorkbenchOnly) {
        // TODO This needs to be moved into the SystemTask, but right now there is no way
        // to ask a task for a menu.
        menu = UIHelper.createLocalizedMenu(mb, "Specify.SYSTEM_MENU", "Specify.SYSTEM_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$

        /*if (true)
        {
        menu = UIHelper.createMenu(mb, "Forms", "o");
        Action genForms = new AbstractAction()
        {
            public void actionPerformed(ActionEvent ae)
            {
                FormGenerator fg = new FormGenerator();
                fg.generateForms();
            }
        };
        mi = UIHelper.createMenuItemWithAction(menu, "Generate All Forms", "G", "", true, genForms);
        }*/
    }

    //--------------------------------------------------------------------
    //-- Tab Menu
    //--------------------------------------------------------------------
    menu = UIHelper.createLocalizedMenu(mb, "Specify.TABS_MENU", "Specify.TABS_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$

    String ttl = UIRegistry.getResourceString("Specify.SBP_CLOSE_CUR_MENU");
    String mnu = UIRegistry.getResourceString("Specify.SBP_CLOSE_CUR_MNEU");
    mi = UIHelper.createMenuItemWithAction(menu, ttl, mnu, ttl, true, getAction("CloseCurrent"));
    if (!UIHelper.isMacOS()) {
        mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK));
    }

    ttl = UIRegistry.getResourceString("Specify.SBP_CLOSE_ALL_MENU");
    mnu = UIRegistry.getResourceString("Specify.SBP_CLOSE_ALL_MNEU");
    mi = UIHelper.createMenuItemWithAction(menu, ttl, mnu, ttl, true, getAction("CloseAll"));
    if (!UIHelper.isMacOS()) {
        mi.setAccelerator(
                KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));
    }

    ttl = UIRegistry.getResourceString("Specify.SBP_CLOSE_ALLBUT_MENU");
    mnu = UIRegistry.getResourceString("Specify.SBP_CLOSE_ALLBUT_MNEU");
    mi = UIHelper.createMenuItemWithAction(menu, ttl, mnu, ttl, true, getAction("CloseAllBut"));

    menu.addSeparator();

    // Configure Task
    JMenuItem configTaskMI = new JMenuItem(getAction("ConfigureTask"));
    menu.add(configTaskMI);
    //UIRegistry.register("ConfigureTask", configTaskMI); //$NON-NLS-1$

    //--------------------------------------------------------------------
    //-- Debug Menu
    //--------------------------------------------------------------------

    boolean doDebug = AppPreferences.getLocalPrefs().getBoolean("debug.menu", false);
    if (!UIRegistry.isRelease() || doDebug) {
        menu = UIHelper.createLocalizedMenu(mb, "Specify.DEBUG_MENU", "Specify.DEBUG_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$
        String ttle = "Specify.SHOW_LOC_PREFS";//$NON-NLS-1$ 
        String mneu = "Specify.SHOW_LOC_PREF_MNEU";//$NON-NLS-1$ 
        String desc = "Specify.SHOW_LOC_PREFS";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(menu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$ 
            public void actionPerformed(ActionEvent ae) {
                openLocalPrefs();
            }
        });

        ttle = "Specify.SHOW_REM_PREFS";//$NON-NLS-1$ 
        mneu = "Specify.SHOW_REM_PREFS_MNEU";//$NON-NLS-1$ 
        desc = "Specify.SHOW_REM_PREFS";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(menu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                openRemotePrefs();
            }
        });

        menu.addSeparator();

        ttle = "Specify.CONFIG_LOGGERS";//$NON-NLS-1$ 
        mneu = "Specify.CONFIG_LOGGERS_MNEU";//$NON-NLS-1$ 
        desc = "Specify.CONFIG_LOGGER";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(menu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                final LoggerDialog dialog = new LoggerDialog(topFrame);
                UIHelper.centerAndShow(dialog);
            }
        });

        ttle = "Specify.CONFIG_DEBUG_LOGGERS";//$NON-NLS-1$ 
        mneu = "Specify.CONFIG_DEBUG_LOGGERS_MNEU";//$NON-NLS-1$ 
        desc = "Specify.CONFIG_DEBUG_LOGGER";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(menu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                DebugLoggerDialog dialog = new DebugLoggerDialog(topFrame);
                UIHelper.centerAndShow(dialog);
            }
        });

        menu.addSeparator();

        ttle = "Specify.SHOW_MEM_STATS";//$NON-NLS-1$ 
        mneu = "Specify.SHOW_MEM_STATS_MNEU";//$NON-NLS-1$ 
        desc = "Specify.SHOW_MEM_STATS";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(menu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                System.gc();
                System.runFinalization();

                // Get current size of heap in bytes
                double meg = 1024.0 * 1024.0;
                double heapSize = Runtime.getRuntime().totalMemory() / meg;

                // Get maximum size of heap in bytes. The heap cannot grow beyond this size.
                // Any attempt will result in an OutOfMemoryException.
                double heapMaxSize = Runtime.getRuntime().maxMemory() / meg;

                // Get amount of free memory within the heap in bytes. This size will increase
                // after garbage collection and decrease as new objects are created.
                double heapFreeSize = Runtime.getRuntime().freeMemory() / meg;

                UIRegistry.getStatusBar()
                        .setText(String.format("Heap Size: %7.2f    Max: %7.2f    Free: %7.2f   Used: %7.2f", //$NON-NLS-1$
                                heapSize, heapMaxSize, heapFreeSize, (heapSize - heapFreeSize)));
            }
        });

        JMenu prefsMenu = new JMenu(UIRegistry.getResourceString("Specify.PREFS_IMPORT_EXPORT")); //$NON-NLS-1$
        menu.add(prefsMenu);
        ttle = "Specify.IMPORT_MENU";//$NON-NLS-1$ 
        mneu = "Specify.IMPORT_MNEU";//$NON-NLS-1$ 
        desc = "Specify.IMPORT_PREFS";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(prefsMenu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                importPrefs();
            }
        });
        ttle = "Specify.EXPORT_MENU";//$NON-NLS-1$ 
        mneu = "Specify.EXPORT_MNEU";//$NON-NLS-1$ 
        desc = "Specify.EXPORT_PREFS";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(prefsMenu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                exportPrefs();
            }
        });

        ttle = "Associate Storage Items";//$NON-NLS-1$ 
        mneu = "A";//$NON-NLS-1$ 
        desc = "";//$NON-NLS-1$ 
        mi = UIHelper.createMenuItemWithAction(menu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                associateStorageItems();
            }
        });

        ttle = "Load GPX Points";//$NON-NLS-1$ 
        mneu = "a";//$NON-NLS-1$ 
        desc = "";//$NON-NLS-1$ 
        mi = UIHelper.createMenuItemWithAction(menu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            @SuppressWarnings("synthetic-access") //$NON-NLS-1$
            public void actionPerformed(ActionEvent ae) {
                CustomDialog dlg = GPXPanel.getDlgInstance();
                if (dlg != null) {
                    dlg.setVisible(true);
                }
            }
        });

        JCheckBoxMenuItem cbMenuItem = new JCheckBoxMenuItem("Security Activated"); //$NON-NLS-1$
        menu.add(cbMenuItem);
        cbMenuItem.setSelected(AppContextMgr.isSecurityOn());
        cbMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                boolean isSecurityOn = !SpecifyAppContextMgr.isSecurityOn();
                AppContextMgr.getInstance().setSecurity(isSecurityOn);
                ((JMenuItem) ae.getSource()).setSelected(isSecurityOn);

                JLabel secLbl = statusField.getSectionLabel(3);
                if (secLbl != null) {
                    secLbl.setIcon(IconManager.getImage(isSecurityOn ? "SecurityOn" : "SecurityOff",
                            IconManager.IconSize.Std16));
                    secLbl.setHorizontalAlignment(SwingConstants.CENTER);
                    secLbl.setToolTipText(getResourceString("Specify.SEC_" + (isSecurityOn ? "ON" : "OFF")));
                }
            }
        });

        JMenuItem sizeMenuItem = new JMenuItem("Set to " + PREFERRED_WIDTH + "x" + PREFERRED_HEIGHT); //$NON-NLS-1$
        menu.add(sizeMenuItem);
        sizeMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                topFrame.setSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
            }
        });
    }

    //----------------------------------------------------
    //-- Helper Menu
    //----------------------------------------------------

    JMenu helpMenu = UIHelper.createLocalizedMenu(mb, "Specify.HELP_MENU", "Specify.HELP_MNEU"); //$NON-NLS-1$ //$NON-NLS-2$
    HelpMgr.createHelpMenuItem(helpMenu, getResourceString("SPECIFY_HELP")); //$NON-NLS-1$
    helpMenu.addSeparator();

    String ttle = "Specify.LOG_SHOW_FILES";//$NON-NLS-1$ 
    String mneu = "Specify.LOG_SHOW_FILES_MNEU";//$NON-NLS-1$ 
    String desc = "Specify.LOG_SHOW_FILES";//$NON-NLS-1$      
    mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null);
    helpMenu.addSeparator();
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            AppBase.displaySpecifyLogFiles();
        }
    });

    ttle = "SecurityAdminTask.CHANGE_PWD_MENU"; //$NON-NLS-1$
    mneu = "SecurityAdminTask.CHANGE_PWD_MNEU"; //$NON-NLS-1$
    desc = "SecurityAdminTask.CHANGE_PWD_DESC"; //$NON-NLS-1$
    mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null);
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            SecurityAdminTask.changePassword(true);
        }
    });

    ttle = "Specify.CHECK_UPDATE";//$NON-NLS-1$ 
    mneu = "Specify.CHECK_UPDATE_MNEU";//$NON-NLS-1$ 
    desc = "Specify.CHECK_UPDATE_DESC";//$NON-NLS-1$      
    mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null);
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            checkForUpdates();
        }
    });

    ttle = "Specify.AUTO_REG";//$NON-NLS-1$ 
    mneu = "Specify.AUTO_REG_MNEU";//$NON-NLS-1$ 
    desc = "Specify.AUTO_REG_DESC";//$NON-NLS-1$      
    mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null);
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            RegisterSpecify.register(true, 0);
        }
    });

    ttle = "Specify.SA_REG";//$NON-NLS-1$ 
    mneu = "Specify.SA_REG_MNEU";//$NON-NLS-1$ 
    desc = "Specify.SA_REG_DESC";//$NON-NLS-1$      
    mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null);
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            RegisterSpecify.registerISA();
        }
    });

    ttle = "Specify.FEEDBACK";//$NON-NLS-1$ 
    mneu = "Specify.FB_MNEU";//$NON-NLS-1$ 
    desc = "Specify.FB_DESC";//$NON-NLS-1$      
    mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null);
    mi.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            FeedBackDlg feedBackDlg = new FeedBackDlg();
            feedBackDlg.sendFeedback();
        }
    });

    if (UIHelper.getOSType() != UIHelper.OSTYPE.MacOSX) {
        helpMenu.addSeparator();

        ttle = "Specify.ABOUT";//$NON-NLS-1$ 
        mneu = "Specify.ABOUTMNEU";//$NON-NLS-1$ 
        desc = "Specify.ABOUT";//$NON-NLS-1$ 
        mi = UIHelper.createLocalizedMenuItem(helpMenu, ttle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                doAbout();
            }
        });
    }
    return mb;
}

From source file:com.maxl.java.amikodesk.AMiKoDesk.java

private static void createAndShowFullGUI() {
    // Create and setup window
    final JFrame jframe = new JFrame(Constants.APP_NAME);
    jframe.setName(Constants.APP_NAME + ".main");

    int min_width = CML_OPT_WIDTH;
    int min_height = CML_OPT_HEIGHT;
    jframe.setPreferredSize(new Dimension(min_width, min_height));
    jframe.setMinimumSize(new Dimension(min_width, min_height));
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (screen.width - min_width) / 2;
    int y = (screen.height - min_height) / 2;
    jframe.setBounds(x, y, min_width, min_height);

    // Set application icon
    if (Utilities.appCustomization().equals("ywesee")) {
        ImageIcon img = new ImageIcon(Constants.AMIKO_ICON);
        jframe.setIconImage(img.getImage());
    } else if (Utilities.appCustomization().equals("desitin")) {
        ImageIcon img = new ImageIcon(Constants.DESITIN_ICON);
        jframe.setIconImage(img.getImage());
    } else if (Utilities.appCustomization().equals("meddrugs")) {
        ImageIcon img = new ImageIcon(Constants.MEDDRUGS_ICON);
        jframe.setIconImage(img.getImage());
    } else if (Utilities.appCustomization().equals("zurrose")) {
        ImageIcon img = new ImageIcon(Constants.AMIKO_ICON);
        jframe.setIconImage(img.getImage());
    }/*from  w ww  .ja v  a  2s.  c om*/

    // ------ Setup menubar ------
    JMenuBar menu_bar = new JMenuBar();
    // menu_bar.add(Box.createHorizontalGlue()); // --> aligns menu items to the right!
    // -- Menu "Datei" --
    JMenu datei_menu = new JMenu("Datei");
    if (Utilities.appLanguage().equals("fr"))
        datei_menu.setText("Fichier");
    menu_bar.add(datei_menu);
    JMenuItem print_item = new JMenuItem("Drucken...");
    JMenuItem settings_item = new JMenuItem(m_rb.getString("settings") + "...");
    JMenuItem quit_item = new JMenuItem("Beenden");
    if (Utilities.appLanguage().equals("fr")) {
        print_item.setText("Imprimer");
        quit_item.setText("Terminer");
    }
    datei_menu.add(print_item);
    datei_menu.addSeparator();
    datei_menu.add(settings_item);
    datei_menu.addSeparator();
    datei_menu.add(quit_item);

    // -- Menu "Aktualisieren" --
    JMenu update_menu = new JMenu("Aktualisieren");
    if (Utilities.appLanguage().equals("fr"))
        update_menu.setText("Mise  jour");
    menu_bar.add(update_menu);
    final JMenuItem updatedb_item = new JMenuItem("Aktualisieren via Internet...");
    updatedb_item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK));
    JMenuItem choosedb_item = new JMenuItem("Aktualisieren via Datei...");
    update_menu.add(updatedb_item);
    update_menu.add(choosedb_item);
    if (Utilities.appLanguage().equals("fr")) {
        updatedb_item.setText("Tlcharger la banque de donnes...");
        updatedb_item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK));
        choosedb_item.setText("Ajourner la banque de donnes...");
    }

    // -- Menu "Hilfe" --
    JMenu hilfe_menu = new JMenu("Hilfe");
    if (Utilities.appLanguage().equals("fr"))
        hilfe_menu.setText("Aide");
    menu_bar.add(hilfe_menu);

    JMenuItem about_item = new JMenuItem("ber " + Constants.APP_NAME + "...");
    JMenuItem ywesee_item = new JMenuItem(Constants.APP_NAME + " im Internet");
    if (Utilities.appCustomization().equals("meddrugs"))
        ywesee_item.setText("med-drugs im Internet");
    JMenuItem report_item = new JMenuItem("Error Report...");
    JMenuItem contact_item = new JMenuItem("Kontakt...");

    if (Utilities.appLanguage().equals("fr")) {
        // Extrawunsch med-drugs
        if (Utilities.appCustomization().equals("meddrugs"))
            about_item.setText(Constants.APP_NAME);
        else
            about_item.setText("A propos de " + Constants.APP_NAME + "...");
        contact_item.setText("Contact...");
        if (Utilities.appCustomization().equals("meddrugs"))
            ywesee_item.setText("med-drugs sur Internet");
        else
            ywesee_item.setText(Constants.APP_NAME + " sur Internet");
        report_item.setText("Rapport d'erreur...");
    }
    hilfe_menu.add(about_item);
    hilfe_menu.add(ywesee_item);
    hilfe_menu.addSeparator();
    hilfe_menu.add(report_item);
    hilfe_menu.addSeparator();
    hilfe_menu.add(contact_item);

    // Menu "Abonnieren" (only for ywesee)
    JMenu subscribe_menu = new JMenu("Abonnieren");
    if (Utilities.appLanguage().equals("fr"))
        subscribe_menu.setText("Abonnement");
    if (Utilities.appCustomization().equals("ywesee")) {
        menu_bar.add(subscribe_menu);
    }

    jframe.setJMenuBar(menu_bar);

    // ------ Setup toolbar ------
    JToolBar toolBar = new JToolBar("Database");
    toolBar.setPreferredSize(new Dimension(jframe.getWidth(), 64));
    final JToggleButton selectAipsButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "aips32x32_bright.png"));
    final JToggleButton selectFavoritesButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "favorites32x32_bright.png"));
    final JToggleButton selectInteractionsButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "interactions32x32_bright.png"));
    final JToggleButton selectShoppingCartButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "shoppingcart32x32_bright.png"));
    final JToggleButton selectComparisonCartButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "comparisoncart32x32_bright.png"));

    final JToggleButton list_of_buttons[] = { selectAipsButton, selectFavoritesButton, selectInteractionsButton,
            selectShoppingCartButton, selectComparisonCartButton };

    if (Utilities.appLanguage().equals("de")) {
        setupButton(selectAipsButton, "Kompendium", "aips32x32_gray.png", "aips32x32_dark.png");
        setupButton(selectFavoritesButton, "Favoriten", "favorites32x32_gray.png", "favorites32x32_dark.png");
        setupButton(selectInteractionsButton, "Interaktionen", "interactions32x32_gray.png",
                "interactions32x32_dark.png");
        setupButton(selectShoppingCartButton, "Warenkorb", "shoppingcart32x32_gray.png",
                "shoppingcart32x32_dark.png");
        setupButton(selectComparisonCartButton, "Preisvergleich", "comparisoncart32x32_gray.png",
                "comparisoncart32x32_dark.png");
    } else if (Utilities.appLanguage().equals("fr")) {
        setupButton(selectAipsButton, "Compendium", "aips32x32_gray.png", "aips32x32_dark.png");
        setupButton(selectFavoritesButton, "Favorites", "favorites32x32_gray.png", "favorites32x32_dark.png");
        setupButton(selectInteractionsButton, "Interactions", "interactions32x32_gray.png",
                "interactions32x32_dark.png");
        setupButton(selectShoppingCartButton, "Panier", "shoppingcart32x32_gray.png",
                "shoppingcart32x32_dark.png");
        setupButton(selectComparisonCartButton, "Preisvergleich", "comparisoncart32x32_gray.png",
                "comparisoncart32x32_dark.png");
    }

    // Add to toolbar and set up
    toolBar.setBackground(m_toolbar_bg);
    toolBar.add(selectAipsButton);
    toolBar.addSeparator();
    toolBar.add(selectFavoritesButton);
    toolBar.addSeparator();
    toolBar.add(selectInteractionsButton);
    if (!Utilities.appCustomization().equals("zurrose")) {
        toolBar.addSeparator();
        toolBar.add(selectShoppingCartButton);
    }
    if (Utilities.appCustomization().equals("zurrorse")) {
        toolBar.addSeparator();
        toolBar.add(selectComparisonCartButton);
    }
    toolBar.setRollover(true);
    toolBar.setFloatable(false);
    // Progress indicator (not working...)
    toolBar.addSeparator(new Dimension(32, 32));
    toolBar.add(m_progress_indicator);

    // ------ Setup settingspage ------
    final SettingsPage settingsPage = new SettingsPage(jframe, m_rb);
    // Attach observer to it
    settingsPage.addObserver(new Observer() {
        public void update(Observable o, Object arg) {
            System.out.println(arg);
            if (m_shopping_cart != null) {
                // Refresh some stuff
                m_shopping_basket.clear();
                int index = m_shopping_cart.getCartIndex();
                if (index > 0)
                    m_web_panel.saveShoppingCartWithIndex(index);
                m_web_panel.updateShoppingHtml();
            }
        }
    });

    jframe.addWindowListener(new WindowListener() {
        // Use WindowAdapter!
        @Override
        public void windowOpened(WindowEvent e) {
        }

        @Override
        public void windowClosed(WindowEvent e) {
            m_web_panel.dispose();
            Runtime.getRuntime().exit(0);
        }

        @Override
        public void windowClosing(WindowEvent e) {
            // Save shopping cart
            int index = m_shopping_cart.getCartIndex();
            if (index > 0 && m_web_panel != null)
                m_web_panel.saveShoppingCartWithIndex(index);
        }

        @Override
        public void windowIconified(WindowEvent e) {
        }

        @Override
        public void windowDeiconified(WindowEvent e) {
        }

        @Override
        public void windowActivated(WindowEvent e) {
        }

        @Override
        public void windowDeactivated(WindowEvent e) {
        }
    });
    print_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            m_web_panel.print();
        }
    });
    settings_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            settingsPage.display();
        }
    });
    quit_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            try {
                // Save shopping cart
                int index = m_shopping_cart.getCartIndex();
                if (index > 0 && m_web_panel != null)
                    m_web_panel.saveShoppingCartWithIndex(index);
                // Save settings
                WindowSaver.saveSettings();
                m_web_panel.dispose();
                Runtime.getRuntime().exit(0);
            } catch (Exception e) {
                System.out.println(e);
            }
        }
    });
    subscribe_menu.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(MenuEvent event) {
            if (Utilities.appCustomization().equals("ywesee")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(new URI(
                                "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3UM84Z6WLFKZE"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            }
        }

        @Override
        public void menuDeselected(MenuEvent event) {
            // do nothing
        }

        @Override
        public void menuCanceled(MenuEvent event) {
            // do nothing
        }
    });
    contact_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            if (Utilities.appCustomization().equals("ywesee")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        URI mail_to_uri = URI
                                .create("mailto:zdavatz@ywesee.com?subject=AmiKo%20Desktop%20Feedback");
                        Desktop.getDesktop().mail(mail_to_uri);
                    } catch (IOException e) {
                        // TODO:
                    }
                } else {
                    AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization());
                    cd.ContactDialog();
                }
            } else if (Utilities.appCustomization().equals("desitin")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        URI mail_to_uri = URI
                                .create("mailto:info@desitin.ch?subject=AmiKo%20Desktop%20Desitin%20Feedback");
                        Desktop.getDesktop().mail(mail_to_uri);
                    } catch (IOException e) {
                        // TODO:
                    }
                } else {
                    AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization());
                    cd.ContactDialog();
                }
            } else if (Utilities.appCustomization().equals("meddrugs")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        URI mail_to_uri = URI.create(
                                "mailto:med-drugs@just-medical.com?subject=med-drugs%20desktop%20Feedback");
                        Desktop.getDesktop().mail(mail_to_uri);
                    } catch (IOException e) {
                        // TODO:
                    }
                } else {
                    AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization());
                    cd.ContactDialog();
                }
            } else if (Utilities.appCustomization().equals("zurrose")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(new URI("www.zurrose.ch/amiko"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            }
        }
    });
    report_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            // Check first m_application_folder otherwise resort to
            // pre-installed report
            String report_file = m_application_data_folder + "\\" + Constants.DEFAULT_AMIKO_REPORT_BASE
                    + Utilities.appLanguage() + ".html";
            if (!(new File(report_file)).exists())
                report_file = System.getProperty("user.dir") + "/dbs/" + Constants.DEFAULT_AMIKO_REPORT_BASE
                        + Utilities.appLanguage() + ".html";
            // Open report file in browser
            if (Desktop.isDesktopSupported()) {
                try {
                    Desktop.getDesktop().browse(new File(report_file).toURI());
                } catch (IOException e) {
                    // TODO:
                }
            }
        }
    });
    ywesee_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            if (Utilities.appCustomization().equals("ywesee")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(new URI("http://www.ywesee.com/AmiKo/Desktop"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            } else if (Utilities.appCustomization().equals("desitin")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(
                                new URI("http://www.desitin.ch/produkte/arzneimittel-kompendium-apps/"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            } else if (Utilities.appCustomization().equals("meddrugs")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        if (Utilities.appLanguage().equals("de"))
                            Desktop.getDesktop().browse(new URI("http://www.med-drugs.ch"));
                        else if (Utilities.appLanguage().equals("fr"))
                            Desktop.getDesktop()
                                    .browse(new URI("http://www.med-drugs.ch/index.cfm?&newlang=fr"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            } else if (Utilities.appCustomization().equals("zurrose")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(new URI("www.zurrose.ch/amiko"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            }
        }
    });
    about_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            AmiKoDialogs ad = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization());
            ad.AboutDialog();
        }
    });

    // Container
    final Container container = jframe.getContentPane();
    container.setBackground(Color.WHITE);
    container.setLayout(new BorderLayout());

    // ==== Toolbar =====
    container.add(toolBar, BorderLayout.NORTH);

    // ==== Left panel ====
    JPanel left_panel = new JPanel();
    left_panel.setBackground(Color.WHITE);
    left_panel.setLayout(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(2, 2, 2, 2);

    // ---- Search field ----
    final SearchField searchField = new SearchField("Suche Prparat");
    if (Utilities.appLanguage().equals("fr"))
        searchField.setText("Recherche Specialit");
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(searchField, gbc);
    left_panel.add(searchField, gbc);

    // ---- Buttons ----
    // Names
    String l_title = "Prparat";
    String l_author = "Inhaberin";
    String l_atccode = "Wirkstoff / ATC Code";
    String l_regnr = "Zulassungsnummer";
    String l_ingredient = "Wirkstoff";
    String l_therapy = "Therapie";
    String l_search = "Suche";

    if (Utilities.appLanguage().equals("fr")) {
        l_title = "Spcialit";
        l_author = "Titulaire";
        l_atccode = "Principe Active / Code ATC";
        l_regnr = "Nombre Enregistration";
        l_ingredient = "Principe Active";
        l_therapy = "Thrapie";
        l_search = "Recherche";
    }

    ButtonGroup bg = new ButtonGroup();

    JToggleButton but_title = new JToggleButton(l_title);
    setupToggleButton(but_title);
    bg.add(but_title);
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_title, gbc);
    left_panel.add(but_title, gbc);

    JToggleButton but_auth = new JToggleButton(l_author);
    setupToggleButton(but_auth);
    bg.add(but_auth);
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_auth, gbc);
    left_panel.add(but_auth, gbc);

    JToggleButton but_atccode = new JToggleButton(l_atccode);
    setupToggleButton(but_atccode);
    bg.add(but_atccode);
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_atccode, gbc);
    left_panel.add(but_atccode, gbc);

    JToggleButton but_regnr = new JToggleButton(l_regnr);
    setupToggleButton(but_regnr);
    bg.add(but_regnr);
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_regnr, gbc);
    left_panel.add(but_regnr, gbc);

    JToggleButton but_therapy = new JToggleButton(l_therapy);
    setupToggleButton(but_therapy);
    bg.add(but_therapy);
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_therapy, gbc);
    left_panel.add(but_therapy, gbc);

    // ---- Card layout ----
    final CardLayout cardl = new CardLayout();
    cardl.setHgap(-4); // HACK to make things look better!!
    final JPanel p_results = new JPanel(cardl);
    m_list_titles = new ListPanel();
    m_list_auths = new ListPanel();
    m_list_regnrs = new ListPanel();
    m_list_atccodes = new ListPanel();
    m_list_ingredients = new ListPanel();
    m_list_therapies = new ListPanel();
    // Contraints
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = 1;
    gbc.gridheight = 10;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    //
    p_results.add(m_list_titles, l_title);
    p_results.add(m_list_auths, l_author);
    p_results.add(m_list_regnrs, l_regnr);
    p_results.add(m_list_atccodes, l_atccode);
    p_results.add(m_list_ingredients, l_ingredient);
    p_results.add(m_list_therapies, l_therapy);

    // --> container.add(p_results, gbc);
    left_panel.add(p_results, gbc);
    left_panel.setBorder(null);
    // First card to show
    cardl.show(p_results, l_title);

    // ==== Right panel ====
    JPanel right_panel = new JPanel();
    right_panel.setBackground(Color.WHITE);
    right_panel.setLayout(new GridBagLayout());

    // ---- Section titles ----
    m_section_titles = null;
    if (Utilities.appLanguage().equals("de")) {
        m_section_titles = new IndexPanel(SectionTitle_DE);
    } else if (Utilities.appLanguage().equals("fr")) {
        m_section_titles = new IndexPanel(SectionTitle_FR);
    }
    m_section_titles.setMinimumSize(new Dimension(150, 150));
    m_section_titles.setMaximumSize(new Dimension(320, 1000));

    // ---- Fachinformation ----
    m_web_panel = new WebPanel2();
    m_web_panel.setMinimumSize(new Dimension(320, 150));

    // Add JSplitPane on the RIGHT
    final int Divider_location = 150;
    final int Divider_size = 10;
    final JSplitPane split_pane_right = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, m_section_titles,
            m_web_panel);
    split_pane_right.setOneTouchExpandable(true);
    split_pane_right.setDividerLocation(Divider_location);
    split_pane_right.setDividerSize(Divider_size);

    // Add JSplitPane on the LEFT
    JSplitPane split_pane_left = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left_panel,
            split_pane_right /* right_panel */);
    split_pane_left.setOneTouchExpandable(true);
    split_pane_left.setDividerLocation(320); // Sets the pane divider location
    split_pane_left.setDividerSize(Divider_size);
    container.add(split_pane_left, BorderLayout.CENTER);

    // Add status bar on the bottom
    JPanel statusPanel = new JPanel();
    statusPanel.setPreferredSize(new Dimension(jframe.getWidth(), 16));
    statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS));
    container.add(statusPanel, BorderLayout.SOUTH);

    final JLabel m_status_label = new JLabel("");
    m_status_label.setHorizontalAlignment(SwingConstants.LEFT);
    statusPanel.add(m_status_label);

    // Add mouse listener
    searchField.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            searchField.setText("");
        }
    });

    final String final_title = l_title;
    final String final_author = l_author;
    final String final_atccode = l_atccode;
    final String final_regnr = l_regnr;
    final String final_therapy = l_therapy;
    final String final_search = l_search;

    // Internal class that implements switching between buttons
    final class Toggle {
        public void toggleButton(JToggleButton jbn) {
            for (int i = 0; i < list_of_buttons.length; ++i) {
                if (jbn == list_of_buttons[i])
                    list_of_buttons[i].setSelected(true);
                else
                    list_of_buttons[i].setSelected(false);
            }
        }
    }
    ;

    // ------ Add toolbar action listeners ------
    selectAipsButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            new Toggle().toggleButton(selectAipsButton);
            // Set state 'aips'
            if (!m_curr_uistate.getUseMode().equals("aips")) {
                m_curr_uistate.setUseMode("aips");
                // Show middle pane
                split_pane_right.setDividerSize(Divider_size);
                split_pane_right.setDividerLocation(Divider_location);
                m_section_titles.setVisible(true);
                //
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        m_start_time = System.currentTimeMillis();
                        m_query_str = searchField.getText();
                        int num_hits = retrieveAipsSearchResults(false);
                        m_status_label.setText(med_search.size() + " Suchresultate in "
                                + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek.");
                        //
                        if (med_index < 0 && prev_med_index >= 0)
                            med_index = prev_med_index;
                        m_web_panel.updateText();
                        if (num_hits == 0) {
                            m_web_panel.emptyPage();
                        }
                    }
                });
            }
        }
    });
    selectFavoritesButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            new Toggle().toggleButton(selectFavoritesButton);
            // Set state 'favorites'
            if (!m_curr_uistate.getUseMode().equals("favorites")) {
                m_curr_uistate.setUseMode("favorites");
                // Show middle pane
                split_pane_right.setDividerSize(Divider_size);
                split_pane_right.setDividerLocation(Divider_location);
                m_section_titles.setVisible(true);
                //
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        m_start_time = System.currentTimeMillis();
                        // m_query_str = searchField.getText();
                        // Clear the search container
                        med_search.clear();
                        for (String regnr : favorite_meds_set) {
                            List<Medication> meds = m_sqldb.searchRegNr(regnr);
                            if (!meds.isEmpty()) { // Add med database ID
                                med_search.add(meds.get(0));
                            }
                        }
                        // Sort list of meds
                        Collections.sort(med_search, new Comparator<Medication>() {
                            @Override
                            public int compare(final Medication m1, final Medication m2) {
                                return m1.getTitle().compareTo(m2.getTitle());
                            }
                        });

                        sTitle();
                        cardl.show(p_results, final_title);

                        m_status_label.setText(med_search.size() + " Suchresultate in "
                                + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek.");
                    }
                });
            }
        }
    });
    selectInteractionsButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            new Toggle().toggleButton(selectInteractionsButton);
            // Set state 'interactions'
            if (!m_curr_uistate.getUseMode().equals("interactions")) {
                m_curr_uistate.setUseMode("interactions");
                // Show middle pane
                split_pane_right.setDividerSize(Divider_size);
                split_pane_right.setDividerLocation(Divider_location);
                m_section_titles.setVisible(true);
                //
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        m_query_str = searchField.getText();
                        retrieveAipsSearchResults(false);
                        // Switch to interaction mode
                        m_web_panel.updateInteractionsCart();
                        m_web_panel.repaint();
                        m_web_panel.validate();
                    }
                });
            }
        }
    });
    selectShoppingCartButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            String email_adr = m_prefs.get("emailadresse", "");
            if (email_adr != null && email_adr.length() > 2) // Two chars is the minimum lenght for an email address
                m_preferences_ok = true;
            if (m_preferences_ok) {
                m_preferences_ok = false; // Check always
                new Toggle().toggleButton(selectShoppingCartButton);
                // Set state 'shopping'
                if (!m_curr_uistate.getUseMode().equals("shopping")) {
                    m_curr_uistate.setUseMode("shopping");
                    // Show middle pane
                    split_pane_right.setDividerSize(Divider_size);
                    split_pane_right.setDividerLocation(Divider_location);
                    m_section_titles.setVisible(true);
                    // Set right panel title
                    m_web_panel.setTitle(m_rb.getString("shoppingCart"));
                    // Switch to shopping cart
                    int index = 1;
                    if (m_shopping_cart != null) {
                        index = m_shopping_cart.getCartIndex();
                        m_web_panel.loadShoppingCartWithIndex(index);
                        // m_shopping_cart.printShoppingBasket();
                    }
                    // m_web_panel.updateShoppingHtml();
                    m_web_panel.updateListOfPackages();
                    if (m_first_pass == true) {
                        m_first_pass = false;
                        if (Utilities.appCustomization().equals("ywesee"))
                            med_search = m_sqldb.searchAuth("ibsa");
                        else if (Utilities.appCustomization().equals("desitin"))
                            med_search = m_sqldb.searchAuth("desitin");
                        sAuth();
                        cardl.show(p_results, final_author);
                    }
                }
            } else {
                selectShoppingCartButton.setSelected(false);
                settingsPage.display();
            }
        }
    });
    selectComparisonCartButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            new Toggle().toggleButton(selectComparisonCartButton);
            // Set state 'comparison'
            if (!m_curr_uistate.getUseMode().equals("comparison")) {
                m_curr_uistate.setUseMode("comparison");
                // Hide middle pane
                m_section_titles.setVisible(false);
                split_pane_right.setDividerLocation(0);
                split_pane_right.setDividerSize(0);
                //
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        m_start_time = System.currentTimeMillis();
                        // Set right panel title
                        m_web_panel.setTitle(getTitle("priceComp"));
                        if (med_index >= 0) {
                            if (med_id != null && med_index < med_id.size()) {
                                Medication m = m_sqldb.getMediWithId(med_id.get(med_index));
                                String atc_code = m.getAtcCode();
                                if (atc_code != null) {
                                    String atc = atc_code.split(";")[0];
                                    m_web_panel.fillComparisonBasket(atc);
                                    m_web_panel.updateComparisonCartHtml();
                                    // Update pane on the left
                                    retrieveAipsSearchResults(false);
                                }
                            }
                        }

                        m_status_label.setText(rose_search.size() + " Suchresultate in "
                                + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek.");
                    }
                });
            }
        }
    });

    // ------ Add keylistener to text field (type as you go feature) ------
    searchField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyTyped(KeyEvent e) { // keyReleased(KeyEvent e)
            // invokeLater potentially in the wrong place... more testing
            // required
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    if (m_curr_uistate.isLoadCart())
                        m_curr_uistate.restoreUseMode();
                    m_start_time = System.currentTimeMillis();
                    m_query_str = searchField.getText();
                    // Queries for SQLite DB
                    if (!m_query_str.isEmpty()) {
                        if (m_query_type == 0) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchTitle(m_query_str);
                            } else {
                                med_search = m_sqldb.searchTitle(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sTitle();
                            cardl.show(p_results, final_title);
                        } else if (m_query_type == 1) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchSupplier(m_query_str);
                            } else {
                                med_search = m_sqldb.searchAuth(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sAuth();
                            cardl.show(p_results, final_author);
                        } else if (m_query_type == 2) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchATC(m_query_str);
                            } else {
                                med_search = m_sqldb.searchATC(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sATC();
                            cardl.show(p_results, final_atccode);
                        } else if (m_query_type == 3) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchEan(m_query_str);
                            } else {
                                med_search = m_sqldb.searchRegNr(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sRegNr();
                            cardl.show(p_results, final_regnr);
                        } else if (m_query_type == 4) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchTherapy(m_query_str);
                            } else {
                                med_search = m_sqldb.searchApplication(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sTherapy();
                            cardl.show(p_results, final_therapy);
                        } else {
                            // do nothing
                        }
                        int num_hits = 0;
                        if (m_curr_uistate.isComparisonMode())
                            num_hits = rose_search.size();
                        else
                            num_hits = med_search.size();
                        m_status_label.setText(num_hits + " Suchresultate in "
                                + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek.");

                    }
                }
            });
        }
    });

    // Add actionlisteners
    but_title.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_title);
            m_curr_uistate.setQueryType(m_query_type = 0);
            sTitle();
            cardl.show(p_results, final_title);
        }
    });
    but_auth.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_author);
            m_curr_uistate.setQueryType(m_query_type = 1);
            sAuth();
            cardl.show(p_results, final_author);
        }
    });
    but_atccode.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_atccode);
            m_curr_uistate.setQueryType(m_query_type = 2);
            sATC();
            cardl.show(p_results, final_atccode);
        }
    });
    but_regnr.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_regnr);
            m_curr_uistate.setQueryType(m_query_type = 3);
            sRegNr();
            cardl.show(p_results, final_regnr);
        }
    });
    but_therapy.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_therapy);
            m_curr_uistate.setQueryType(m_query_type = 4);
            sTherapy();
            cardl.show(p_results, final_therapy);
        }
    });

    // Display window
    jframe.pack();
    // jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    // jframe.setAlwaysOnTop(true);
    jframe.setVisible(true);

    // Check if user has selected an alternative database
    /*
     * NOTE: 21/11/2013: This solution is put on ice. Favored is a solution
     * where the database selected by the user is saved in a default folder
     * (see variable "m_application_data_folder")
     */
    /*
     * try { WindowSaver.loadSettings(jframe); String database_path =
     * WindowSaver.getDbPath(); if (database_path!=null)
     * m_sqldb.loadDBFromPath(database_path); } catch(IOException e) {
     * e.printStackTrace(); }
     */
    // Load AIPS database
    selectAipsButton.setSelected(true);
    selectFavoritesButton.setSelected(false);
    m_curr_uistate.setUseMode("aips");
    med_search = m_sqldb.searchTitle("");
    sTitle(); // Used instead of sTitle (which is slow)
    cardl.show(p_results, final_title);

    // Add menu item listeners
    updatedb_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            if (m_mutex_update == false) {
                m_mutex_update = true;
                String db_file = m_maindb_update.doIt(jframe, Utilities.appLanguage(),
                        Utilities.appCustomization(), m_application_data_folder, m_full_db_update);
                // ... and update time
                if (m_full_db_update == true) {
                    DateTime dT = new DateTime();
                    m_prefs.put("updateTime", dT.now().toString());
                }
                //
                if (!db_file.isEmpty()) {
                    // Save db path (can't hurt)
                    WindowSaver.setDbPath(db_file);
                }
            }
        }
    });

    choosedb_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            String db_file = m_maindb_update.chooseFromFile(jframe, Utilities.appLanguage(),
                    Utilities.appCustomization(), m_application_data_folder);
            // ... and update time
            DateTime dT = new DateTime();
            m_prefs.put("updateTime", dT.now().toString());
            //
            if (!db_file.isEmpty()) {
                // Save db path (can't hurt)
                WindowSaver.setDbPath(db_file);
            }
        }
    });

    /**
     * Observers
     */
    // Attach observer to 'm_update'
    m_maindb_update.addObserver(new Observer() {
        @Override
        public void update(Observable o, Object arg) {
            System.out.println(arg);
            // Reset flag
            m_full_db_update = true;
            m_mutex_update = false;
            // Refresh some stuff after update
            loadAuthors();
            m_emailer.loadMap();
            settingsPage.load_gln_codes();
            if (m_shopping_cart != null) {
                m_shopping_cart.load_conditions();
                m_shopping_cart.load_glns();
            }
            // Empty shopping basket
            if (m_curr_uistate.isShoppingMode()) {
                m_shopping_basket.clear();
                int index = m_shopping_cart.getCartIndex();
                if (index > 0)
                    m_web_panel.saveShoppingCartWithIndex(index);
                m_web_panel.updateShoppingHtml();
            }
            if (m_curr_uistate.isComparisonMode())
                m_web_panel.setTitle(getTitle("priceComp"));
        }
    });

    // Attach observer to 'm_emailer'
    m_emailer.addObserver(new Observer() {
        @Override
        public void update(Observable o, Object arg) {
            System.out.println(arg);
            // Empty shopping basket
            m_shopping_basket.clear();
            int index = m_shopping_cart.getCartIndex();
            if (index > 0)
                m_web_panel.saveShoppingCartWithIndex(index);
            m_web_panel.updateShoppingHtml();
        }
    });

    // Attach observer to "m_comparison_cart"
    m_comparison_cart.addObserver(new Observer() {
        @Override
        public void update(Observable o, Object arg) {
            System.out.println(arg);
            m_web_panel.setTitle(getTitle("priceComp"));
            m_comparison_cart.clearUploadList();
            m_web_panel.updateComparisonCartHtml();
            new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization()).UploadDialog((String) arg);
        }
    });

    // If command line options are provided start app with a particular title or eancode
    if (commandLineOptionsProvided()) {
        if (!CML_OPT_TITLE.isEmpty())
            startAppWithTitle(but_title);
        else if (!CML_OPT_EANCODE.isEmpty())
            startAppWithEancode(but_regnr);
        else if (!CML_OPT_REGNR.isEmpty())
            startAppWithRegnr(but_regnr);
    }

    // Start timer
    Timer global_timer = new Timer();
    // Time checks all 2 minutes (120'000 milliseconds)
    global_timer.scheduleAtFixedRate(new TimerTask() {
        @Override
        public void run() {
            checkIfUpdateRequired(updatedb_item);
        }
    }, 2 * 60 * 1000, 2 * 60 * 1000);
}

From source file:org.openmicroscopy.shoola.agents.fsimporter.view.ImporterControl.java

/** Attaches listener to the window listener. */
private void attachListeners() {
    if (UIUtilities.isMacOS() && model.isMaster()) {
        try {/*from   w  ww .  j a  v  a  2  s  .  c  o  m*/
            MacOSMenuHandler handler = new MacOSMenuHandler(view);
            handler.initialize();
            view.addPropertyChangeListener(this);
        } catch (Throwable e) {
        }
    }
    view.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    view.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            model.close();
        }
    });
    JMenu menu = ImporterFactory.getWindowMenu();
    menu.addMenuListener(new MenuListener() {

        public void menuSelected(MenuEvent e) {
            Object source = e.getSource();
            if (source instanceof JMenu)
                createWindowsMenuItems((JMenu) source);
        }

        /** 
         * Required by I/F but not actually needed in our case, 
         * no-operation implementation.
         * @see MenuListener#menuCanceled(MenuEvent)
         */
        public void menuCanceled(MenuEvent e) {
        }

        /** 
         * Required by I/F but not actually needed in our case, 
         * no-operation implementation.
         * @see MenuListener#menuDeselected(MenuEvent)
         */
        public void menuDeselected(MenuEvent e) {
        }

    });

    //Listen to keyboard selection
    menu.addMenuKeyListener(new MenuKeyListener() {

        public void menuKeyReleased(MenuKeyEvent e) {
            Object source = e.getSource();
            if (source instanceof JMenu)
                createWindowsMenuItems((JMenu) source);
        }

        /** 
         * Required by I/F but not actually needed in our case, 
         * no-operation implementation.
         * @see MenuKeyListener#menuKeyPressed(MenuKeyEvent)
         */
        public void menuKeyPressed(MenuKeyEvent e) {
        }

        /** 
         * Required by I/F but not actually needed in our case, 
         * no-operation implementation.
         * @see MenuKeyListener#menuKeyTyped(MenuKeyEvent)
         */
        public void menuKeyTyped(MenuKeyEvent e) {
        }

    });
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.view.TreeViewerControl.java

/** 
 * Attaches a window listener to the view to discard the model when 
 * the user closes the window. /*from w  w w.ja v a 2s .  c  o m*/
 */
private void attachListeners() {
    if (UIUtilities.isMacOS()) {
        try {
            MacOSMenuHandler handler = new MacOSMenuHandler(view);
            handler.initialize();
            view.addPropertyChangeListener(this);
        } catch (Throwable e) {
        }
    }
    Map browsers = model.getBrowsers();
    Iterator i = browsers.values().iterator();
    Browser browser;
    while (i.hasNext()) {
        browser = (Browser) i.next();
        browser.addPropertyChangeListener(this);
        browser.addChangeListener(this);
    }
    view.addWindowFocusListener(this);
    model.addPropertyChangeListener(this);
    view.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    view.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            model.closeWindow();
        }
    });

    //
    JMenu menu = TreeViewerFactory.getWindowMenu();
    menu.addMenuListener(new MenuListener() {

        public void menuSelected(MenuEvent e) {
            Object source = e.getSource();
            if (source instanceof JMenu)
                createWindowsMenuItems((JMenu) source);
        }

        /** 
         * Required by I/F but not actually needed in our case, 
         * no-operation implementation.
         * @see MenuListener#menuCanceled(MenuEvent)
         */
        public void menuCanceled(MenuEvent e) {
        }

        /** 
         * Required by I/F but not actually needed in our case, 
         * no-operation implementation.
         * @see MenuListener#menuDeselected(MenuEvent)
         */
        public void menuDeselected(MenuEvent e) {
        }

    });

    //Listen to keyboard selection
    menu.addMenuKeyListener(new MenuKeyListener() {

        public void menuKeyReleased(MenuKeyEvent e) {
            Object source = e.getSource();
            if (source instanceof JMenu)
                createWindowsMenuItems((JMenu) source);
        }

        /** 
         * Required by I/F but not actually needed in our case, 
         * no-operation implementation.
         * @see MenuKeyListener#menuKeyPressed(MenuKeyEvent)
         */
        public void menuKeyPressed(MenuKeyEvent e) {
        }

        /** 
         * Required by I/F but not actually needed in our case, 
         * no-operation implementation.
         * @see MenuKeyListener#menuKeyTyped(MenuKeyEvent)
         */
        public void menuKeyTyped(MenuKeyEvent e) {
        }

    });
}

From source file:org.rdv.datapanel.DigitalTabularDataPanel.java

private void addColumn() {
    if (columnGroupCount == MAX_COLUMN_GROUP_COUNT) {
        return;/* w w w. j av  a 2  s.co m*/
    }

    if (columnGroupCount != 0) {
        panelBox.add(Box.createHorizontalStrut(7));
    }

    final int tableIndex = columnGroupCount;

    final DataTableModel tableModel = new DataTableModel();
    final JTable table = new JTable(tableModel);

    table.setDragEnabled(true);
    table.setName(DigitalTabularDataPanel.class.getName() + " JTable #" + Integer.toString(columnGroupCount));

    if (showThresholdCheckBoxGroup.isSelected()) {
        tableModel.setThresholdVisible(true);
    }

    if (showMinMaxCheckBoxGroup.isSelected()) {
        tableModel.setMaxMinVisible(true);

        table.getColumn("Min").setCellRenderer(doubleCellRenderer);
        table.getColumn("Max").setCellRenderer(doubleCellRenderer);
    }

    table.getColumn("Value").setCellRenderer(dataCellRenderer);

    tables.add(table);
    tableModels.add(tableModel);

    JScrollPane tableScrollPane = new JScrollPane(table);
    panelBox.add(tableScrollPane);

    // popup menu for panel
    JPopupMenu popupMenu = new JPopupMenu();

    final JMenuItem copyMenuItem = new JMenuItem("Copy");
    copyMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            TransferHandler.getCopyAction().actionPerformed(
                    new ActionEvent(table, ae.getID(), ae.getActionCommand(), ae.getWhen(), ae.getModifiers()));
        }
    });
    popupMenu.add(copyMenuItem);

    popupMenu.addSeparator();

    JMenuItem printMenuItem = new JMenuItem("Print...");
    printMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                table.print(JTable.PrintMode.FIT_WIDTH);
            } catch (PrinterException pe) {
            }
        }
    });
    popupMenu.add(printMenuItem);
    popupMenu.addSeparator();

    final JCheckBoxMenuItem showMaxMinMenuItem = new JCheckBoxMenuItem("Show min/max columns", false);
    showMaxMinMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            setMaxMinVisible(showMaxMinMenuItem.isSelected());
        }
    });
    showMinMaxCheckBoxGroup.addCheckBox(showMaxMinMenuItem);
    popupMenu.add(showMaxMinMenuItem);

    final JCheckBoxMenuItem showThresholdMenuItem = new JCheckBoxMenuItem("Show threshold columns", false);
    showThresholdMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            setThresholdVisible(showThresholdMenuItem.isSelected());
        }
    });
    showThresholdCheckBoxGroup.addCheckBox(showThresholdMenuItem);
    popupMenu.add(showThresholdMenuItem);

    popupMenu.addSeparator();

    JMenuItem blankRowMenuItem = new JMenuItem("Insert blank row");
    blankRowMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            tableModel.addBlankRow();
        }
    });
    popupMenu.add(blankRowMenuItem);

    final JMenuItem removeSelectedRowsMenuItem = new JMenuItem("Remove selected rows");
    removeSelectedRowsMenuItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            removeSelectedRows(tableIndex);
        }
    });
    popupMenu.add(removeSelectedRowsMenuItem);

    popupMenu.addSeparator();

    JMenu numberOfColumnsMenu = new JMenu("Number of columns");
    numberOfColumnsMenu.addMenuListener(new MenuListener() {
        public void menuSelected(MenuEvent me) {
            JMenu menu = (JMenu) me.getSource();
            for (int j = 0; j < MAX_COLUMN_GROUP_COUNT; j++) {
                JMenuItem menuItem = menu.getItem(j);
                boolean selected = (j == (columnGroupCount - 1));
                menuItem.setSelected(selected);
            }
        }

        public void menuDeselected(MenuEvent me) {
        }

        public void menuCanceled(MenuEvent me) {
        }
    });

    for (int i = 0; i < MAX_COLUMN_GROUP_COUNT; i++) {
        final int number = i + 1;
        JRadioButtonMenuItem item = new JRadioButtonMenuItem(Integer.toString(number));
        item.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                setNumberOfColumns(number);
            }
        });
        numberOfColumnsMenu.add(item);
    }
    popupMenu.add(numberOfColumnsMenu);

    popupMenu.addPopupMenuListener(new PopupMenuListener() {
        public void popupMenuWillBecomeVisible(PopupMenuEvent arg0) {
            boolean anyRowsSelected = table.getSelectedRowCount() > 0;
            copyMenuItem.setEnabled(anyRowsSelected);
            removeSelectedRowsMenuItem.setEnabled(anyRowsSelected);
        }

        public void popupMenuWillBecomeInvisible(PopupMenuEvent arg0) {
        }

        public void popupMenuCanceled(PopupMenuEvent arg0) {
        }
    });

    // set component popup and mouselistener to trigger it
    table.setComponentPopupMenu(popupMenu);
    tableScrollPane.setComponentPopupMenu(popupMenu);

    panelBox.revalidate();

    columnGroupCount++;

    properties.setProperty("numberOfColumns", Integer.toString(columnGroupCount));
}

From source file:org.rdv.ui.MainPanel.java

private void initMenuBar() {
    Application application = RDV.getInstance();
    ApplicationContext context = application.getContext();

    ResourceMap resourceMap = context.getResourceMap();
    String platform = resourceMap.getString("platform");
    boolean isMac = (platform != null && platform.equals("osx"));

    ActionFactory actionFactory = ActionFactory.getInstance();

    Actions actions = Actions.getInstance();
    ActionMap actionMap = context.getActionMap(actions);

    menuBar = new JMenuBar();

    JMenuItem menuItem;/*from www .  j  a  v a  2  s  . com*/

    JMenu fileMenu = new JMenu(fileAction);

    menuItem = new JMenuItem(connectAction);
    fileMenu.add(menuItem);

    menuItem = new JMenuItem(disconnectAction);
    fileMenu.add(menuItem);

    fileMenu.addSeparator();

    menuItem = new JMenuItem(loginAction);
    fileMenu.add(menuItem);

    menuItem = new JMenuItem(logoutAction);
    fileMenu.add(menuItem);

    fileMenu.addMenuListener(new MenuListener() {
        public void menuCanceled(MenuEvent arg0) {
        }

        public void menuDeselected(MenuEvent arg0) {
        }

        public void menuSelected(MenuEvent arg0) {
            if (AuthenticationManager.getInstance().getAuthentication() == null) {
                loginAction.setEnabled(true);
                logoutAction.setEnabled(false);
            } else {
                loginAction.setEnabled(false);
                logoutAction.setEnabled(true);
            }
        }
    });

    fileMenu.addSeparator();

    menuItem = new JMenuItem(loadAction);
    fileMenu.add(menuItem);

    menuItem = new JMenuItem(saveAction);
    fileMenu.add(menuItem);

    fileMenu.addSeparator();

    fileMenu.add(new JMenuItem(actionMap.get("addLocalChannel")));

    fileMenu.addSeparator();

    JMenu importSubMenu = new JMenu(importAction);

    menuItem = new JMenuItem(actionFactory.getDataImportAction());
    importSubMenu.add(menuItem);

    menuItem = new JMenuItem(actionFactory.getOpenSeesDataImportAction());
    importSubMenu.add(menuItem);

    importSubMenu.add(new JMenuItem(actionMap.get("importJPEGs")));

    fileMenu.add(importSubMenu);

    JMenu exportSubMenu = new JMenu(exportAction);

    menuItem = new JMenuItem(actionFactory.getDataExportAction());
    exportSubMenu.add(menuItem);

    menuItem = new JMenuItem(exportVideoAction);
    exportSubMenu.add(menuItem);

    fileMenu.add(exportSubMenu);

    fileMenu.addSeparator();

    menuItem = new DataViewerCheckBoxMenuItem(actionFactory.getOfflineAction());
    fileMenu.add(menuItem);

    if (!isMac) {
        menuItem = new JMenuItem(exitAction);
        fileMenu.add(menuItem);
    }

    menuBar.add(fileMenu);

    JMenu controlMenu = new JMenu(controlAction);

    menuItem = new SelectableCheckBoxMenuItem(realTimeAction);
    controlMenu.add(menuItem);

    menuItem = new SelectableCheckBoxMenuItem(playAction);
    controlMenu.add(menuItem);

    menuItem = new SelectableCheckBoxMenuItem(pauseAction);
    controlMenu.add(menuItem);

    controlMenu.addMenuListener(new MenuListener() {
        public void menuCanceled(MenuEvent arg0) {
        }

        public void menuDeselected(MenuEvent arg0) {
        }

        public void menuSelected(MenuEvent arg0) {
            int state = rbnb.getState();
            realTimeAction.setSelected(state == Player.STATE_MONITORING);
            playAction.setSelected(state == Player.STATE_PLAYING);
            pauseAction.setSelected(state == Player.STATE_STOPPED);
        }
    });

    controlMenu.addSeparator();

    menuItem = new JMenuItem(beginningAction);
    controlMenu.add(menuItem);

    menuItem = new JMenuItem(endAction);
    controlMenu.add(menuItem);

    menuItem = new JMenuItem(gotoTimeAction);
    controlMenu.add(menuItem);

    menuBar.add(controlMenu);

    controlMenu.addSeparator();

    menuItem = new JMenuItem(updateChannelListAction);
    controlMenu.add(menuItem);

    controlMenu.addSeparator();

    menuItem = new JCheckBoxMenuItem(dropDataAction);
    controlMenu.add(menuItem);

    JMenu viewMenu = new JMenu(viewAction);

    menuItem = new JCheckBoxMenuItem(showChannelListAction);
    menuItem.setSelected(true);
    viewMenu.add(menuItem);

    menuItem = new JCheckBoxMenuItem(showMetadataPanelAction);
    menuItem.setSelected(true);
    viewMenu.add(menuItem);

    menuItem = new JCheckBoxMenuItem(showControlPanelAction);
    menuItem.setSelected(true);
    viewMenu.add(menuItem);

    menuItem = new JCheckBoxMenuItem(showAudioPlayerPanelAction);
    menuItem.setSelected(false);
    viewMenu.add(menuItem);

    menuItem = new JCheckBoxMenuItem(showMarkerPanelAction);
    menuItem.setSelected(true);
    viewMenu.add(menuItem);

    viewMenu.addSeparator();

    menuItem = new JCheckBoxMenuItem(showHiddenChannelsAction);
    menuItem.setSelected(false);
    viewMenu.add(menuItem);

    menuItem = new JCheckBoxMenuItem(hideEmptyTimeAction);
    menuItem.setSelected(false);
    viewMenu.add(menuItem);

    viewMenu.addSeparator();

    menuItem = new JCheckBoxMenuItem(fullScreenAction);
    menuItem.setSelected(false);
    viewMenu.add(menuItem);

    menuBar.add(viewMenu);

    JMenu windowMenu = new JMenu(windowAction);

    List<Extension> extensions = dataPanelManager.getExtensions();
    for (final Extension extension : extensions) {
        Action action = new DataViewerAction("Add " + extension.getName(), "", KeyEvent.VK_J) {
            /** serialization version identifier */
            private static final long serialVersionUID = 36998228704476723L;

            public void actionPerformed(ActionEvent ae) {
                try {
                    dataPanelManager.createDataPanel(extension);
                } catch (Exception e) {
                    log.error("Unable to open data panel provided by extension " + extension.getName() + " ("
                            + extension.getID() + ").");
                    e.printStackTrace();
                }
            }
        };

        menuItem = new JMenuItem(action);
        windowMenu.add(menuItem);
    }

    windowMenu.addSeparator();

    menuItem = new JMenuItem(closeAllDataPanelsAction);
    windowMenu.add(menuItem);

    windowMenu.addSeparator();
    JMenu dataPanelSubMenu = new JMenu(dataPanelAction);

    ButtonGroup dataPanelLayoutGroup = new ButtonGroup();

    menuItem = new JRadioButtonMenuItem(dataPanelHorizontalLayoutAction);
    dataPanelSubMenu.add(menuItem);
    dataPanelLayoutGroup.add(menuItem);

    menuItem = new JRadioButtonMenuItem(dataPanelVerticalLayoutAction);
    menuItem.setSelected(true);
    dataPanelSubMenu.add(menuItem);
    dataPanelLayoutGroup.add(menuItem);
    windowMenu.add(dataPanelSubMenu);

    menuBar.add(windowMenu);

    JMenu helpMenu = new JMenu(helpAction);

    menuItem = new JMenuItem(usersGuideAction);
    helpMenu.add(menuItem);

    menuItem = new JMenuItem(supportAction);
    helpMenu.add(menuItem);

    menuItem = new JMenuItem(releaseNotesAction);
    helpMenu.add(menuItem);

    if (!isMac) {
        helpMenu.addSeparator();

        menuItem = new JMenuItem(aboutAction);
        helpMenu.add(menuItem);
    }

    menuBar.add(helpMenu);

    menuBar.add(Box.createHorizontalGlue());
    throbberStop = DataViewer.getIcon("icons/throbber.png");
    throbberAnim = DataViewer.getIcon("icons/throbber_anim.gif");
    throbber = new JLabel(throbberStop);
    throbber.setBorder(new EmptyBorder(0, 0, 0, 4));
    menuBar.add(throbber, BorderLayout.EAST);

    if (isMac) {
        registerMacOSXEvents();
    }

    frame.setJMenuBar(menuBar);
}

From source file:org.tinymediamanager.ui.MainWindow.java

/**
 * Create the application.//from   w  w  w.j ava 2 s .c o m
 * 
 * @param name
 *          the name
 */
public MainWindow(String name) {
    super(name);
    setName("mainWindow");
    setMinimumSize(new Dimension(1000, 700));

    instance = this;

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    JMenu mnTmm = new JMenu("tinyMediaManager");
    mnTmm.setMnemonic(KeyEvent.VK_T);
    menuBar.add(mnTmm);

    if (!Globals.isDonator()) {
        mnTmm.add(new RegisterDonatorVersionAction());
    }

    mnTmm.add(new SettingsAction());
    mnTmm.addSeparator();
    mnTmm.add(new LaunchUpdaterAction());
    mnTmm.addSeparator();
    mnTmm.add(new ExitAction());
    initialize();

    // tools menu
    JMenu tools = new JMenu(BUNDLE.getString("tmm.tools")); //$NON-NLS-1$
    tools.setMnemonic(KeyEvent.VK_O);
    tools.add(new ClearDatabaseAction());

    JMenu cache = new JMenu(BUNDLE.getString("tmm.cache")); //$NON-NLS-1$
    cache.setMnemonic(KeyEvent.VK_C);
    tools.add(cache);
    JMenuItem clearImageCache = new JMenuItem(new ClearImageCacheAction());
    clearImageCache.setMnemonic(KeyEvent.VK_I);
    cache.add(clearImageCache);

    JMenuItem rebuildImageCache = new JMenuItem(new RebuildImageCacheAction());
    rebuildImageCache.setMnemonic(KeyEvent.VK_R);
    cache.add(rebuildImageCache);

    JMenuItem tmmFolder = new JMenuItem(BUNDLE.getString("tmm.gotoinstalldir")); //$NON-NLS-1$
    tmmFolder.setMnemonic(KeyEvent.VK_I);
    tools.add(tmmFolder);
    tmmFolder.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            Path path = Paths.get(System.getProperty("user.dir"));
            try {
                // check whether this location exists
                if (Files.exists(path)) {
                    TmmUIHelper.openFile(path);
                }
            } catch (Exception ex) {
                LOGGER.error("open filemanager", ex);
                MessageManager.instance.pushMessage(new Message(MessageLevel.ERROR, path,
                        "message.erroropenfolder", new String[] { ":", ex.getLocalizedMessage() }));
            }
        }
    });

    JMenuItem tmmLogs = new JMenuItem(BUNDLE.getString("tmm.errorlogs")); //$NON-NLS-1$
    tmmLogs.setMnemonic(KeyEvent.VK_L);
    tools.add(tmmLogs);
    tmmLogs.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            JDialog logDialog = new LogDialog();
            logDialog.setLocationRelativeTo(MainWindow.getActiveInstance());
            logDialog.setVisible(true);
        }
    });

    JMenuItem tmmMessages = new JMenuItem(BUNDLE.getString("tmm.messages")); //$NON-NLS-1$
    tmmMessages.setMnemonic(KeyEvent.VK_L);
    tools.add(tmmMessages);
    tmmMessages.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            JDialog messageDialog = MessageHistoryDialog.getInstance();
            messageDialog.setVisible(true);
        }
    });

    tools.addSeparator();
    final JMenu menuWakeOnLan = new JMenu(BUNDLE.getString("tmm.wakeonlan")); //$NON-NLS-1$
    menuWakeOnLan.setMnemonic(KeyEvent.VK_W);
    menuWakeOnLan.addMenuListener(new MenuListener() {
        @Override
        public void menuCanceled(MenuEvent arg0) {
        }

        @Override
        public void menuDeselected(MenuEvent arg0) {
        }

        @Override
        public void menuSelected(MenuEvent arg0) {
            menuWakeOnLan.removeAll();
            for (final WolDevice device : Globals.settings.getWolDevices()) {
                JMenuItem item = new JMenuItem(device.getName());
                item.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent arg0) {
                        Utils.sendWakeOnLanPacket(device.getMacAddress());
                    }
                });
                menuWakeOnLan.add(item);
            }
        }
    });
    tools.add(menuWakeOnLan);

    // activate/deactivate WakeOnLan menu item
    tools.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(MenuEvent e) {
            if (Globals.settings.getWolDevices().size() > 0) {
                menuWakeOnLan.setEnabled(true);
            } else {
                menuWakeOnLan.setEnabled(false);
            }
        }

        @Override
        public void menuDeselected(MenuEvent e) {
        }

        @Override
        public void menuCanceled(MenuEvent e) {
        }
    });

    if (Globals.isDebug()) {
        final JMenu debugMenu = new JMenu("Debug"); //$NON-NLS-1$

        JMenuItem trace = new JMenuItem("set Logger to TRACE"); //$NON-NLS-1$
        trace.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
                lc.getLogger("org.tinymediamanager").setLevel(Level.TRACE);
                MessageManager.instance.pushMessage(new Message("Trace levels set!", ""));
                LOGGER.trace("if you see that, we're now on TRACE logging level ;)");
            }
        });

        debugMenu.add(trace);
        tools.add(debugMenu);
    }

    menuBar.add(tools);

    mnTmm = new JMenu(BUNDLE.getString("tmm.contact")); //$NON-NLS-1$
    mnTmm.setMnemonic(KeyEvent.VK_C);
    mnTmm.add(new FeedbackAction()).setMnemonic(KeyEvent.VK_F);
    mnTmm.add(new BugReportAction()).setMnemonic(KeyEvent.VK_B);
    menuBar.add(mnTmm);

    mnTmm = new JMenu(BUNDLE.getString("tmm.help")); //$NON-NLS-1$
    mnTmm.setMnemonic(KeyEvent.VK_H);
    menuBar.add(mnTmm);

    mnTmm.add(new WikiAction()).setMnemonic(KeyEvent.VK_W);
    mnTmm.add(new FaqAction()).setMnemonic(KeyEvent.VK_F);
    mnTmm.add(new ForumAction()).setMnemonic(KeyEvent.VK_O);
    mnTmm.addSeparator();

    mnTmm.add(new AboutAction()).setMnemonic(KeyEvent.VK_A);

    menuBar.add(Box.createGlue());

    if (!Globals.isDonator()) {
        JButton btnDonate = new JButton(new DonateAction());
        btnDonate.setBorderPainted(false);
        btnDonate.setFocusPainted(false);
        btnDonate.setContentAreaFilled(false);
        menuBar.add(btnDonate);
    }

    checkForUpdate();
}

From source file:org.tinymediamanager.ui.movies.MoviePanel.java

private void buildMenu() {
    menu.setMnemonic(KeyEvent.VK_M);

    // menu items
    JMenuItem menuItem = menu.add(actionUpdateDataSources2);
    menuItem.setMnemonic(KeyEvent.VK_U);
    menuItem.setAccelerator(/*from w  w  w  .  j  a  v a2 s  .c  o m*/
            KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    final JMenu menuUpdateDatasources = new JMenu(BUNDLE.getString("update.datasource")); //$NON-NLS-1$
    final JMenu menuFindMissingMovies = new JMenu(BUNDLE.getString("movie.findmissing")); //$NON-NLS-1$
    menuUpdateDatasources.addMenuListener(new MenuListener() {
        @Override
        public void menuCanceled(MenuEvent arg0) {
        }

        @Override
        public void menuDeselected(MenuEvent arg0) {
        }

        @Override
        public void menuSelected(MenuEvent arg0) {
            menuUpdateDatasources.removeAll();
            menuFindMissingMovies.removeAll();
            for (String ds : MovieModuleManager.MOVIE_SETTINGS.getMovieDataSource()) {
                JMenuItem item = new JMenuItem(new MovieUpdateSingleDatasourceAction(ds));
                menuUpdateDatasources.add(item);

                item = new JMenuItem(new MovieFindMissingAction(ds));
                menuFindMissingMovies.add(item);

            }
        }
    });
    menu.add(menuUpdateDatasources);

    menu.add(new MovieFindMissingAction());
    menu.add(menuFindMissingMovies);
    menu.add(new MovieCreateOfflineAction(true));

    menu.addSeparator();

    JMenu menuScrape = new JMenu(BUNDLE.getString("Button.scrape")); //$NON-NLS-1$
    menuScrape.setMnemonic(KeyEvent.VK_S);
    menuItem = menuScrape.add(actionScrape2);
    menuItem.setMnemonic(KeyEvent.VK_S);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuScrape.add(actionScrapeSelected);
    menuItem.setMnemonic(KeyEvent.VK_F);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuScrape.add(actionScrapeUnscraped);
    menuItem.setMnemonic(KeyEvent.VK_U);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_U, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuScrape.add(actionScrapeMetadataSelected);
    menuItem.setMnemonic(KeyEvent.VK_M);
    menuScrape.add(actionAssignMovieSets);
    menu.add(menuScrape);

    JMenu menuEdit = new JMenu(BUNDLE.getString("Button.edit")); //$NON-NLS-1$
    menuEdit.setMnemonic(KeyEvent.VK_E);
    menuItem = menuEdit.add(actionEditMovie2);
    menuItem.setMnemonic(KeyEvent.VK_E);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_E, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuEdit.add(actionBatchEdit);
    menuItem.setMnemonic(KeyEvent.VK_B);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuEdit.add(actionSetWatchedFlag);
    menuItem.setMnemonic(KeyEvent.VK_W);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_W, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuEdit.add(actionRename2);
    menuItem.setMnemonic(KeyEvent.VK_R);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_R, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menuEdit.add(actionRenamerPreview);
    menuItem.setMnemonic(KeyEvent.VK_P);
    menu.add(menuEdit);

    menuItem = menu.add(actionRewriteNfo);
    menuItem.setMnemonic(KeyEvent.VK_N);
    menuItem = menu.add(actionTrailerDownload);
    menuItem = menu.add(actionSearchSubtitle);
    menuItem = menu.add(actionDownloadSubtitle);

    menu.addSeparator();
    menuItem = menu.add(actionMediaInformation2);
    menuItem.setMnemonic(KeyEvent.VK_M);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_M, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menu.add(actionExport);
    menuItem.setMnemonic(KeyEvent.VK_X);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK + ActionEvent.SHIFT_MASK));
    menuItem = menu.add(actionRemove2);
    menuItem.setMnemonic(KeyEvent.VK_R);
    menuItem.setAccelerator(KeyStroke.getKeyStroke((char) KeyEvent.VK_DELETE));
    menuItem = menu.add(actionDelete2);
    menuItem.setMnemonic(KeyEvent.VK_R);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, ActionEvent.SHIFT_MASK));
    menu.addSeparator();
    menuItem = menu.add(actionSyncTrakt);
    menuItem.setMnemonic(KeyEvent.VK_T);
    menuItem = menu.add(actionSyncWatchedTrakt);
    menuItem.setMnemonic(KeyEvent.VK_W);
    menuItem = menu.add(actionSyncSelectedTrakt);

    menu.addSeparator();
    menuItem = menu.add(actionClearImageCache);
    menuItem.setMnemonic(KeyEvent.VK_C);

    // popup menu
    JPopupMenu popupMenu = new JPopupMenu();
    popupMenu.add(actionScrape2);
    popupMenu.add(actionScrapeSelected);
    popupMenu.add(actionScrapeUnscraped);
    popupMenu.add(actionScrapeMetadataSelected);
    popupMenu.add(actionAssignMovieSets);
    popupMenu.addSeparator();
    popupMenu.add(actionEditMovie2);
    popupMenu.add(actionBatchEdit);
    popupMenu.add(actionSetWatchedFlag);
    popupMenu.add(actionRewriteNfo);
    popupMenu.add(actionRename2);
    popupMenu.add(actionRenamerPreview);
    popupMenu.add(actionMediaInformation2);
    popupMenu.add(actionExport);
    popupMenu.add(actionTrailerDownload);
    popupMenu.add(actionSearchSubtitle);
    popupMenu.add(actionDownloadSubtitle);
    popupMenu.addSeparator();
    popupMenu.add(actionSyncTrakt);
    popupMenu.add(actionSyncWatchedTrakt);
    popupMenu.add(actionSyncSelectedTrakt);
    popupMenu.addSeparator();
    popupMenu.add(actionClearImageCache);
    popupMenu.addSeparator();
    popupMenu.add(actionRemove2);
    popupMenu.add(actionDelete2);

    if (Globals.isDebug()) {
        JMenu menuDebug = new JMenu("Debug"); //$NON-NLS-1$
        menuDebug.add(debugDumpMovie);
        menuDebug.addSeparator();
        menuDebug.add(new FakeTmmTaskAction("download", 1, 10));
        menuDebug.add(new FakeTmmTaskAction("download", 10, 10));
        menuDebug.add(new FakeTmmTaskAction("image", 1, 10));
        menuDebug.add(new FakeTmmTaskAction("image", 10, 10));
        menuDebug.add(new FakeTmmTaskAction("unnamed", 1, 10));
        menuDebug.add(new FakeTmmTaskAction("unnamed", 10, 10));
        popupMenu.add(menuDebug);
    }

    MouseListener mouseListener = new MovieTableMouseListener(popupMenu, table);
    table.addMouseListener(mouseListener);
}