Example usage for javax.swing JMenuItem addActionListener

List of usage examples for javax.swing JMenuItem addActionListener

Introduction

In this page you can find the example usage for javax.swing JMenuItem addActionListener.

Prototype

public void addActionListener(ActionListener l) 

Source Link

Document

Adds an ActionListener to the button.

Usage

From source file:net.sourceforge.entrainer.gui.EntrainerFX.java

private JMenuItem getLoadXmlItem() {
    JMenuItem item = new JMenuItem("Load Entrainer Program");
    addMnemonic(item, KeyEvent.VK_L);
    item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            loadXml();/*w  w w.  jav  a 2  s.c om*/
        }
    });

    return item;
}

From source file:net.sourceforge.entrainer.gui.EntrainerFX.java

private JMenuItem getNewXmlItem() {
    JMenuItem item = new JMenuItem(NEW_XML_PROGRAM_MENU_NAME);
    addMnemonic(item, KeyEvent.VK_N);
    item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            newXml();//  ww w.j  ava2 s  . co  m
        }
    });

    return item;
}

From source file:net.sourceforge.entrainer.gui.EntrainerFX.java

private JMenuItem getClearXmlItem() {
    JMenuItem item = new JMenuItem("Clear Entrainer Program");
    addMnemonic(item, KeyEvent.VK_C);
    item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            clearXmlFile();/*  w ww .ja  v a2 s .c om*/
        }
    });

    return item;
}

From source file:net.sourceforge.entrainer.gui.EntrainerFX.java

private JMenuItem getSplashItem() {
    JMenuItem splashItem = new JMenuItem("Show Splash Screen");
    addMnemonic(splashItem, KeyEvent.VK_P);
    splashItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            new EntrainerFXSplash(true);
        }//w  w  w. j  a  v a 2  s  .  c o  m
    });

    return splashItem;
}

From source file:net.sourceforge.entrainer.gui.EntrainerFX.java

private JMenuItem getAboutItem() {
    JMenuItem aboutItem = new JMenuItem(ABOUT_ENTRAINER_MENU_NAME);
    addMnemonic(aboutItem, KeyEvent.VK_B);
    aboutItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            About.showAboutDialog();//from ww w . j  a v  a2s.  com
        }
    });

    return aboutItem;
}

From source file:com.adobe.aem.demomachine.gui.AemDemo.java

@SuppressWarnings({ "rawtypes", "unchecked" })
private void initialize() {

    // Initialize properties
    setDefaultProperties(AemDemoUtils//from   ww  w.  j  a v  a2  s.co  m
            .loadProperties(buildFile.getParentFile().getAbsolutePath() + File.separator + "build.properties"));
    setPersonalProperties(AemDemoUtils.loadProperties(buildFile.getParentFile().getAbsolutePath()
            + File.separator + "conf" + File.separator + "build-personal.properties"));

    // Constructing the main frame
    frameMain = new JFrame();
    frameMain.setBounds(100, 100, 700, 530);
    frameMain.getContentPane().setLayout(null);

    // Main menu bar for the Frame
    JMenuBar menuBar = new JMenuBar();

    JMenu mnAbout = new JMenu("AEM Demo Machine");
    mnAbout.setMnemonic(KeyEvent.VK_A);
    menuBar.add(mnAbout);

    JMenuItem mntmUpdates = new JMenuItem("Check for Updates");
    mntmUpdates.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmUpdates.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "demo_update");
        }
    });
    mnAbout.add(mntmUpdates);

    JMenuItem mntmDoc = new JMenuItem("Help and Documentation");
    mntmDoc.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_H, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmDoc.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.openWebpage(AemDemoUtils.getActualPropertyValue(defaultProperties, personalProperties,
                    AemDemoConstants.OPTIONS_DOCUMENTATION));
        }
    });
    mnAbout.add(mntmDoc);

    JMenuItem mntmScripts = new JMenuItem("Demo Scripts (VPN)");
    mntmScripts.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.openWebpage(AemDemoUtils.getActualPropertyValue(defaultProperties, personalProperties,
                    AemDemoConstants.OPTIONS_SCRIPTS));
        }
    });
    mnAbout.add(mntmScripts);

    JMenuItem mntmDiagnostics = new JMenuItem("Diagnostics");
    mntmDiagnostics.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Map<String, String> env = System.getenv();
            System.out.println("====== System Environment Variables ======");
            for (String envName : env.keySet()) {
                System.out.format("%s=%s%n", envName, env.get(envName));
            }
            System.out.println("====== JVM Properties ======");
            RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
            List<String> jvmArgs = runtimeMXBean.getInputArguments();
            for (String arg : jvmArgs) {
                System.out.println(arg);
            }
            System.out.println("====== Runtime Properties ======");
            Properties props = System.getProperties();
            props.list(System.out);
        }
    });
    mnAbout.add(mntmDiagnostics);

    JMenuItem mntmQuit = new JMenuItem("Quit");
    mntmQuit.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_Q, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmQuit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.exit(-1);
        }
    });
    mnAbout.add(mntmQuit);

    JMenu mnNew = new JMenu("New");
    menuBar.add(mnNew);

    // New Demo Machine
    JMenuItem mntmNewDemo = new JMenuItem("Demo Environment");
    mntmNewDemo.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmNewDemo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            if (AemDemo.this.getBuildInProgress()) {

                JOptionPane.showMessageDialog(null,
                        "A Demo Environment is currently being built. Please wait until it is finished.");

            } else {

                final AemDemoNew dialogNew = new AemDemoNew(AemDemo.this);
                dialogNew.setModal(true);
                dialogNew.setVisible(true);
                dialogNew.getDemoBuildName().requestFocus();
                ;

            }
        }
    });
    mnNew.add(mntmNewDemo);

    JMenuItem mntmNewOptions = new JMenuItem("Demo Properties");
    mntmNewOptions.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_P, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmNewOptions.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            final AemDemoOptions dialogOptions = new AemDemoOptions(AemDemo.this);
            dialogOptions.setModal(true);
            dialogOptions.setVisible(true);

        }
    });
    mnNew.add(mntmNewOptions);

    JMenu mnUpdate = new JMenu("Add-ons");
    menuBar.add(mnUpdate);

    // Sites Add-on
    JMenu mnSites = new JMenu("Sites");
    mnUpdate.add(mnSites);

    JMenuItem mntmSitesDownloadAddOn = new JMenuItem("Download Demo Add-on");
    mntmSitesDownloadAddOn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_sites");
        }
    });
    mnSites.add(mntmSitesDownloadAddOn);

    JMenuItem mntmSitesDownloadFP = new JMenuItem("Download Packages (PackageShare)");
    mntmSitesDownloadFP.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_sites_packages");
        }
    });
    mnSites.add(mntmSitesDownloadFP);

    // Assets Add-on
    JMenu mnAssets = new JMenu("Assets");
    mnUpdate.add(mnAssets);

    JMenuItem mntmAssetsDownloadAddOn = new JMenuItem("Download Demo Add-on");
    mntmAssetsDownloadAddOn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_assets");
        }
    });
    mnAssets.add(mntmAssetsDownloadAddOn);

    JMenuItem mntmAssetsDownloadFP = new JMenuItem("Download Packages (PackageShare)");
    mntmAssetsDownloadFP.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_assets_packages");
        }
    });
    mnAssets.add(mntmAssetsDownloadFP);

    // Communities Add-on
    JMenu mnCommunities = new JMenu("Communities/Livefyre");
    mnUpdate.add(mnCommunities);

    JMenuItem mntmAemCommunitiesFeaturePacks = new JMenuItem("Download Packages (PackageShare)");
    mntmAemCommunitiesFeaturePacks.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_communities_packages");
        }
    });
    mnCommunities.add(mntmAemCommunitiesFeaturePacks);

    // Forms Add-on
    JMenu mnForms = new JMenu("Forms");
    mnUpdate.add(mnForms);

    JMenuItem mntmAemFormsAddon = new JMenuItem("Download Demo Add-on");
    mntmAemFormsAddon.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_forms");
        }
    });
    mnForms.add(mntmAemFormsAddon);

    JMenuItem mntmAemFormsFP = new JMenuItem("Download Packages (PackageShare)");
    mntmAemFormsFP.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_forms_packages");
        }
    });
    mnForms.add(mntmAemFormsFP);

    // Mobile Add-on
    JMenu mnApps = new JMenu("Mobile");
    mnUpdate.add(mnApps);

    JMenuItem mntmAemAppsAddon = new JMenuItem("Download Demo Add-on");
    mntmAemAppsAddon.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_apps");
        }
    });
    mnApps.add(mntmAemAppsAddon);

    JMenuItem mntmAemApps = new JMenuItem("Download Packages (PackageShare)");
    mntmAemApps.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_apps_packages");
        }
    });
    mnApps.add(mntmAemApps);

    // Commerce Add-on
    JMenu mnCommerce = new JMenu("Commerce");
    mnUpdate.add(mnCommerce);

    JMenu mnCommerceDownload = new JMenu("Download Packages");
    mnCommerce.add(mnCommerceDownload);

    // Commerce EP
    JMenuItem mnCommerceDownloadEP = new JMenuItem("ElasticPath (PackageShare)");
    mnCommerceDownloadEP.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_commerce_ep");
        }
    });
    mnCommerceDownload.add(mnCommerceDownloadEP);

    // Commerce WebSphere
    JMenuItem mnCommerceDownloadWAS = new JMenuItem("WebSphere (PackageShare)");
    mnCommerceDownloadWAS.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_commerce_websphere");
        }
    });
    mnCommerceDownload.add(mnCommerceDownloadWAS);

    // WeRetail Add-on
    JMenu mnWeRetail = new JMenu("We-Retail");
    mnUpdate.add(mnWeRetail);

    JMenuItem mnWeRetailAddon = new JMenuItem("Download Demo Add-on");
    mnWeRetailAddon.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_weretail");
        }
    });
    mnWeRetail.add(mnWeRetailAddon);

    // Download all section
    mnUpdate.addSeparator();

    JMenuItem mntmAemDownloadAll = new JMenuItem("Download All Add-ons");
    mntmAemDownloadAll.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_all");
        }
    });
    mnUpdate.add(mntmAemDownloadAll);

    JMenu mnInfrastructure = new JMenu("Infrastructure");
    menuBar.add(mnInfrastructure);

    JMenu mnMongo = new JMenu("MongoDB");

    JMenuItem mntmInfraMongoDB = new JMenuItem("Download");
    mntmInfraMongoDB.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_mongo");
        }
    });
    mnMongo.add(mntmInfraMongoDB);

    JMenuItem mntmInfraMongoDBInstall = new JMenuItem("Install");
    mntmInfraMongoDBInstall.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "install_mongo");
        }
    });
    mnMongo.add(mntmInfraMongoDBInstall);
    mnMongo.addSeparator();

    JMenuItem mntmInfraMongoDBStart = new JMenuItem("Start");
    mntmInfraMongoDBStart.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "mongo_start");
        }
    });
    mnMongo.add(mntmInfraMongoDBStart);

    JMenuItem mntmInfraMongoDBStop = new JMenuItem("Stop");
    mntmInfraMongoDBStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "mongo_stop");
        }
    });
    mnMongo.add(mntmInfraMongoDBStop);
    mnInfrastructure.add(mnMongo);

    // SOLR options
    JMenu mnSOLR = new JMenu("SOLR");

    JMenuItem mntmInfraSOLR = new JMenuItem("Download");
    mntmInfraSOLR.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_solr");
        }
    });
    mnSOLR.add(mntmInfraSOLR);

    JMenuItem mntmInfraSOLRInstall = new JMenuItem("Install");
    mntmInfraSOLRInstall.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "install_solr");
        }
    });
    mnSOLR.add(mntmInfraSOLRInstall);
    mnSOLR.addSeparator();

    JMenuItem mntmInfraSOLRStart = new JMenuItem("Start");
    mntmInfraSOLRStart.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "solr_start");
        }
    });
    mnSOLR.add(mntmInfraSOLRStart);

    JMenuItem mntmInfraSOLRStop = new JMenuItem("Stop");
    mntmInfraSOLRStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "solr_stop");
        }
    });
    mnSOLR.add(mntmInfraSOLRStop);

    mnInfrastructure.add(mnSOLR);

    // MySQL options
    JMenu mnMySQL = new JMenu("MySQL");

    JMenuItem mntmInfraMysql = new JMenuItem("Download");
    mntmInfraMysql.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_mysql");
        }
    });
    mnMySQL.add(mntmInfraMysql);

    JMenuItem mntmInfraMysqlInstall = new JMenuItem("Install");
    mntmInfraMysqlInstall.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "install_mysql");
        }
    });
    mnMySQL.add(mntmInfraMysqlInstall);

    mnMySQL.addSeparator();

    JMenuItem mntmInfraMysqlStart = new JMenuItem("Start");
    mntmInfraMysqlStart.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "mysql_start");
        }
    });
    mnMySQL.add(mntmInfraMysqlStart);

    JMenuItem mntmInfraMysqlStop = new JMenuItem("Stop");
    mntmInfraMysqlStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "mysql_stop");
        }
    });
    mnMySQL.add(mntmInfraMysqlStop);

    mnInfrastructure.add(mnMySQL);

    // James options
    JMenu mnJames = new JMenu("James SMTP/POP");

    JMenuItem mntmInfraJames = new JMenuItem("Download");
    mntmInfraJames.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_james");
        }
    });
    mnJames.add(mntmInfraJames);

    JMenuItem mntmInfraJamesInstall = new JMenuItem("Install");
    mntmInfraJamesInstall.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "install_james");
        }
    });
    mnJames.add(mntmInfraJamesInstall);
    mnJames.addSeparator();

    JMenuItem mntmInfraJamesStart = new JMenuItem("Start");
    mntmInfraJamesStart.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "james_start");
        }
    });
    mnJames.add(mntmInfraJamesStart);

    JMenuItem mntmInfraJamesStop = new JMenuItem("Stop");
    mntmInfraJamesStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "james_stop");
        }
    });
    mnJames.add(mntmInfraJamesStop);

    mnInfrastructure.add(mnJames);

    // FFMPEPG options
    JMenu mnFFMPEG = new JMenu("FFMPEG");

    JMenuItem mntmInfraFFMPEG = new JMenuItem("Download");
    mntmInfraFFMPEG.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_ffmpeg");
        }
    });
    mnFFMPEG.add(mntmInfraFFMPEG);

    JMenuItem mntmInfraFFMPEGInstall = new JMenuItem("Install");
    mntmInfraFFMPEGInstall.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "install_ffmpeg");
        }
    });
    mnFFMPEG.add(mntmInfraFFMPEGInstall);

    mnInfrastructure.add(mnFFMPEG);

    mnInfrastructure.addSeparator();

    // InDesignServer options
    JMenu mnInDesignServer = new JMenu("InDesign Server");

    JMenuItem mntmInfraInDesignServerDownload = new JMenuItem("Download");
    mntmInfraInDesignServerDownload.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_indesignserver");
        }
    });
    mnInDesignServer.add(mntmInfraInDesignServerDownload);

    mnInDesignServer.addSeparator();

    JMenuItem mntmInfraInDesignServerStart = new JMenuItem("Start");
    mntmInfraInDesignServerStart.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "start_indesignserver");
        }
    });
    mnInDesignServer.add(mntmInfraInDesignServerStart);

    JMenuItem mntmInfraInDesignServerStop = new JMenuItem("Stop");
    mntmInfraInDesignServerStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "stop_indesignserver");
        }
    });
    mnInDesignServer.add(mntmInfraInDesignServerStop);

    mnInfrastructure.add(mnInDesignServer);

    mnInfrastructure.addSeparator();

    JMenuItem mntmInfraInstall = new JMenuItem("All in One Setup");
    mntmInfraInstall.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "infrastructure");
        }
    });
    mnInfrastructure.add(mntmInfraInstall);

    JMenu mnOther = new JMenu("Other");
    menuBar.add(mnOther);

    JMenu mntmAemDownload = new JMenu("AEM & License files (VPN)");

    JMenuItem mntmAemLoad = new JMenuItem("Download Latest AEM Load");
    mntmAemLoad.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_L, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmAemLoad.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_load");
        }
    });
    mntmAemDownload.add(mntmAemLoad);

    JMenuItem mntmAemSnapshot = new JMenuItem("Download Latest AEM Snapshot");
    mntmAemSnapshot.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_T, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmAemSnapshot.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_snapshot");
        }
    });
    mntmAemDownload.add(mntmAemSnapshot);

    JMenuItem mntmAemDownloadAEM62 = new JMenuItem("Download AEM 6.2");
    mntmAemDownloadAEM62.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_aem62");
        }
    });
    mntmAemDownload.add(mntmAemDownloadAEM62);

    JMenuItem mntmAemDownloadAEM61 = new JMenuItem("Download AEM 6.1");
    mntmAemDownloadAEM61.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_aem61");
        }
    });
    mntmAemDownload.add(mntmAemDownloadAEM61);

    JMenuItem mntmAemDownloadAEM60 = new JMenuItem("Download AEM 6.0");
    mntmAemDownloadAEM60.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_aem60");
        }
    });
    mntmAemDownload.add(mntmAemDownloadAEM60);

    JMenuItem mntmAemDownloadCQ561 = new JMenuItem("Download CQ 5.6.1");
    mntmAemDownloadCQ561.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_cq561");
        }
    });
    mntmAemDownload.add(mntmAemDownloadCQ561);

    JMenuItem mntmAemDownloadCQ56 = new JMenuItem("Download CQ 5.6");
    mntmAemDownloadCQ56.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_cq56");
        }
    });
    mntmAemDownload.add(mntmAemDownloadCQ56);

    JMenuItem mntmAemDownloadOthers = new JMenuItem("Other Releases & License files");
    mntmAemDownloadOthers.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.openWebpage(AemDemoUtils.getActualPropertyValue(defaultProperties, personalProperties,
                    AemDemoConstants.OPTIONS_DOWNLOAD));
        }
    });
    mntmAemDownload.add(mntmAemDownloadOthers);

    mnOther.add(mntmAemDownload);

    JMenuItem mntmAemHotfix = new JMenuItem("Download Latest Hotfixes (PackageShare)");
    mntmAemHotfix.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmAemHotfix.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_hotfixes_packages");
        }
    });
    mnOther.add(mntmAemHotfix);

    JMenuItem mntmAemAcs = new JMenuItem("Download Latest ACS Commons and Tools");
    mntmAemAcs.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmAemAcs.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "download_acs");
        }
    });
    mnOther.add(mntmAemAcs);

    // Adding the menu bar
    frameMain.setJMenuBar(menuBar);

    // Adding other form elements
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(24, 163, 650, 230);
    frameMain.getContentPane().add(scrollPane);

    final JTextArea textArea = new JTextArea("");
    textArea.setEditable(false);
    scrollPane.setViewportView(textArea);

    // List of demo machines available
    JScrollPane scrollDemoList = new JScrollPane();
    scrollDemoList.setBounds(24, 34, 208, 100);
    frameMain.getContentPane().add(scrollDemoList);
    listModelDemoMachines = AemDemoUtils.listDemoMachines(buildFile.getParentFile().getAbsolutePath());
    listDemoMachines = new JList(listModelDemoMachines);
    listDemoMachines.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listDemoMachines.setSelectedIndex(AemDemoUtils.getSelectedIndex(listDemoMachines,
            this.getDefaultProperties(), this.getPersonalProperties(), AemDemoConstants.OPTIONS_BUILD_DEFAULT));
    scrollDemoList.setViewportView(listDemoMachines);

    // Capturing the output stream of ANT commands
    AemDemoOutputStream out = new AemDemoOutputStream(textArea);
    System.setOut(new PrintStream(out));

    JButton btnStart = new JButton("Start");
    btnStart.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            AemDemoUtils.antTarget(AemDemo.this, "start");

        }
    });

    btnStart.setBounds(250, 29, 117, 29);
    frameMain.getContentPane().add(btnStart);

    // Set Start as the default button
    JRootPane rootPane = SwingUtilities.getRootPane(btnStart);
    rootPane.setDefaultButton(btnStart);

    JButton btnInfo = new JButton("Details");
    btnInfo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            AemDemoUtils.antTarget(AemDemo.this, "details");

        }
    });
    btnInfo.setBounds(250, 59, 117, 29);
    frameMain.getContentPane().add(btnInfo);

    // Rebuild action
    JButton btnRebuild = new JButton("Rebuild");
    btnRebuild.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            if (AemDemo.this.getBuildInProgress()) {

                JOptionPane.showMessageDialog(null,
                        "A Demo Environment is currently being built. Please wait until it is finished.");

            } else {

                final AemDemoRebuild dialogRebuild = new AemDemoRebuild(AemDemo.this);
                dialogRebuild.setModal(true);
                dialogRebuild.setVisible(true);
                dialogRebuild.getDemoBuildName().requestFocus();
                ;

            }

        }
    });

    btnRebuild.setBounds(250, 89, 117, 29);
    frameMain.getContentPane().add(btnRebuild);

    // Stop action 
    JButton btnStop = new JButton("Stop");
    btnStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            int dialogResult = JOptionPane.showConfirmDialog(null,
                    "Are you sure you really want to stop the running instances?", "Warning",
                    JOptionPane.YES_NO_OPTION);
            if (dialogResult == JOptionPane.NO_OPTION) {
                return;
            }
            AemDemoUtils.antTarget(AemDemo.this, "stop");

        }
    });
    btnStop.setBounds(500, 29, 117, 29);
    frameMain.getContentPane().add(btnStop);

    JButton btnExit = new JButton("Exit");
    btnExit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.exit(-1);
        }
    });
    btnExit.setBounds(550, 408, 117, 29);
    frameMain.getContentPane().add(btnExit);

    JButton btnClear = new JButton("Clear");
    btnClear.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            textArea.setText("");
        }
    });
    btnClear.setBounds(40, 408, 117, 29);
    frameMain.getContentPane().add(btnClear);

    JButton btnBackup = new JButton("Backup");
    btnBackup.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "backup");
        }
    });
    btnBackup.setBounds(500, 59, 117, 29);
    frameMain.getContentPane().add(btnBackup);

    JButton btnRestore = new JButton("Restore");
    btnRestore.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            AemDemoUtils.antTarget(AemDemo.this, "restore");
        }
    });
    btnRestore.setBounds(500, 89, 117, 29);
    frameMain.getContentPane().add(btnRestore);

    JButton btnDelete = new JButton("Delete");
    btnDelete.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int dialogResult = JOptionPane.showConfirmDialog(null,
                    "Are you sure you really want to permanently delete the selected demo configuration?",
                    "Warning", JOptionPane.YES_NO_OPTION);
            if (dialogResult == JOptionPane.NO_OPTION) {
                return;
            }
            AemDemoUtils.antTarget(AemDemo.this, "uninstall");
        }
    });
    btnDelete.setBounds(500, 119, 117, 29);
    frameMain.getContentPane().add(btnDelete);

    JLabel lblSelectYourDemo = new JLabel("Select your Demo Environment");
    lblSelectYourDemo.setBounds(24, 10, 219, 16);
    frameMain.getContentPane().add(lblSelectYourDemo);

    JLabel lblCommandOutput = new JLabel("Command Output");
    lblCommandOutput.setBounds(24, 143, 160, 16);
    frameMain.getContentPane().add(lblCommandOutput);

    // Initializing and launching the ticker
    String tickerOn = AemDemoUtils.getPropertyValue(buildFile, "demo.ticker");
    if (tickerOn == null || (tickerOn != null && tickerOn.equals("true"))) {
        AemDemoMarquee mp = new AemDemoMarquee(AemDemoConstants.Credits, 60);
        mp.setBounds(140, 440, 650, 30);
        frameMain.getContentPane().add(mp);
        mp.start();
    }

    // Launching the download tracker task
    AemDemoDownload aemDownload = new AemDemoDownload(AemDemo.this);
    ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
    executor.scheduleAtFixedRate(aemDownload, 0, 5, TimeUnit.SECONDS);

    // Loading up the README.md file
    String line = null;
    try {
        FileReader fileReader = new FileReader(
                buildFile.getParentFile().getAbsolutePath() + File.separator + "README.md");
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        while ((line = bufferedReader.readLine()) != null) {
            if (line.indexOf("AEM Demo Machine!") > 0) {
                line = line + " (version: " + aemDemoMachineVersion + ")";
            }
            if (!line.startsWith("Double"))
                System.out.println(line);
        }
        bufferedReader.close();
    } catch (Exception ex) {
        logger.error(ex.getMessage());
    }

}

From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java

public MainForm(final String fileToOpen) {
    Log.info("Start in editor mode");

    this.application = null;
    this.hexLayerList = null;

    initComponents();/*from ww w  .  j a v  a2 s. c  o  m*/

    final JFrame theFrame = this;

    for (final javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
        final JMenuItem landfItem = new JMenuItem(info.getName());
        landfItem.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                } catch (Exception ex) {
                    Log.error("Can't change L&F", ex);
                }
                SwingUtilities.updateComponentTreeUI(theFrame);
            }
        });
        menuLANDF.add(landfItem);
    }

    popupMenu = new JPopupMenu();
    final JMenuItem comments = new JMenuItem("Comments");
    comments.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            // open dialog for cell comment
            final CellCommentDialog commentDialog = new CellCommentDialog(theFrame,
                    "Commentaries for the cell at " + popupHex.getColumn() + "," + popupHex.getRow(),
                    cellComments.getForHex(popupHex));
            commentDialog.setVisible(true);
            final String result = commentDialog.getResult();
            if (result != null) {
                cellComments.setForHex(popupHex, result);
            }
        }
    });
    popupMenu.add(comments);

    hexMapPanelDesktop = new Desktop();
    layers = new LayerListModel(256, 128);

    try {
        this.setIconImage(ImageIO.read(this.getClass().getClassLoader()
                .getResource("com/igormaznitsa/jhexed/swing/editor/icons/logo.png")));
    } catch (Exception ex) {
        Log.error("Can't load app icon", ex);
    }

    hexMapPanel = new HexMapPanel(this.layers);
    hexMapPanel.addHexMapPanelListener(this);

    hexMapPanel.addMouseListener(this);
    hexMapPanel.addMouseMotionListener(this);
    hexMapPanel.addMouseWheelListener(this);

    this.panelMainArea.add(hexMapPanelDesktop, BorderLayout.CENTER);

    this.frameLayers = new FrameLayers(layers, hexMapPanel);
    this.frameTools = new FrameTools();
    this.frameToolOptions = new FrameToolOptions();

    hexMapPanelDesktop.addFrame(this.frameLayers);
    hexMapPanelDesktop.addFrame(this.frameTools);
    hexMapPanelDesktop.addFrame(this.frameToolOptions);

    this.frameLayers.setVisible(true);
    this.frameTools.setVisible(true);
    this.frameToolOptions.setVisible(true);

    hexMapPanelDesktop.setContentPane(hexMapPanel);

    this.dsl = new GroovyPluginBase(this, this.layers);
    this.compilerConfiguration = new CompilerConfiguration();
    this.compilerConfiguration.setScriptBaseClass(DelegatingScript.class.getName());
    this.groovyShell = new GroovyShell(this.compilerConfiguration);

    InsideApplicationBus.getInstance().addAppBusListener(this);

    loadSettings();

    resetState();

    Log.info("The MainForm created");

    registerInternalPlugins();
    registerExternalPlugins(".");

    if (fileToOpen != null) {
        Log.info("Started with parameter: " + fileToOpen);
        final File file = new File(fileToOpen);
        loadFromFile(file);
    }

    this.lookupContainer = new ObjectLookup(this, this.hexMapPanel.getHexEngine(), this,
            Log.makeApplicationLog());
    this.applicationGraphics = null;
}

From source file:edu.ku.brc.af.ui.db.JAutoCompTextField.java

protected void keyReleasedInternal(KeyEvent ev) {
    //System.out.println(ev);
    if (dbAdapter != null) {
        if (ev.getKeyCode() == JAutoCompComboBox.SEARCH_KEY) {
            /*lookup(getText());
                    //from   w  w w .  j ava  2  s  .  com
            if (!foundMatch)
            {
            setText("");
            }*/

            ActionListener al = new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    JMenuItem mi = (JMenuItem) ae.getSource();
                    int inx = 0;
                    for (PickListItemIFace pli : dbAdapter.getList()) {
                        String title = pli.getTitle();
                        if (mi.getText().equals(title)) {
                            setSelectedIndex(inx);
                            break;
                        }
                        inx++;
                    }
                    popupMenu = null;
                }
            };

            String txt = getText();

            int cnt = 0;
            for (PickListItemIFace pli : dbAdapter.getList()) {
                String title = pli.getTitle();
                if (title.length() >= txt.length() && title.startsWith(txt)) {
                    cnt++;
                }
            }

            if (cnt > 0) {
                popupMenu = new JPopupMenu();
                for (PickListItemIFace pli : dbAdapter.getList()) {
                    String title = pli.getTitle();
                    if (title.length() >= txt.length() && title.startsWith(txt)) {
                        JMenuItem mi = new JMenuItem(title);
                        setControlSize(mi);
                        popupMenu.add(mi);
                        mi.addActionListener(al);
                    }
                }
                Point location = getLocation();
                Dimension size = getSize();
                popupMenu.show(this, location.x, location.y + size.height);
            }

        } else if (ev.getKeyCode() == KeyEvent.VK_ENTER) {
            addNewItemFromTextField();

        } else if (ev.getKeyCode() == KeyEvent.VK_END)// || ev.getKeyCode() == KeyEvent.VK_SHIFT)
        {
            setSelectionStart(prevCaretPos);
            setSelectionEnd(getText().length());
        }

        /*else
        {
        char key = ev.getKeyChar();
        if (ev.getKeyCode() == KeyEvent.VK_BACK_SPACE)
        {
            String s = getText();
            if (foundMatch)
            {
                //System.out.println("len ["+s.length()+"]");
                //System.out.println(s+"["+s.substring(0, s.length()-1)+"]");
                
                setText(s.length() == 0 ? "" : s.substring(0, s.length()-1));
                        
            } else
            {
                hasChanged = true;
            }
            return;
                    
        } else if ((!(Character.isLetterOrDigit(key) || Character.isSpaceChar(key))) && 
                     ev.getKeyCode() != KeyEvent.VK_DELETE)
        {
            if (ev.getKeyCode() == KeyEvent.VK_ENTER) 
            {
                addNewItemFromTextField();
            }
            //System.out.println("Key Code "+ev.getKeyCode()+"  Pos: "+getCaretPosition()+"  Del: "+KeyEvent.VK_DELETE);
                    
            if (ev.getKeyCode() == KeyEvent.VK_END)// || ev.getKeyCode() == KeyEvent.VK_SHIFT)
            {
                setSelectionStart(prevCaretPos);
                setSelectionEnd(getText().length());
            }
            return;
                    
        } else if(ev.getKeyCode() == KeyEvent.VK_DELETE)
        {
            foundMatch = false;
            hasChanged = true;
            return;
        }
        //System.out.println("["+ev.getKeyCode()+"]["+KeyEvent.VK_DELETE+"]");
                
        caretPos = getCaretPosition();
        String text = "";
        try
        {
            text = getText(0, caretPos);
                    
        } catch (Exception ex)
        {
            edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
            edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(JAutoCompTextField.class, ex);
            ex.printStackTrace();
        }
                
        lookup(text);
        }*/
    }
}

From source file:net.chaosserver.timelord.swingui.TimelordMenu.java

/**
 * Creates the view menu./*from   w  w w  . j  av a  2  s  .co m*/
 *
 * @return the new view menu
 */
protected JMenu createViewMenu() {
    JMenuItem menuItem;
    JMenu viewMenu = new JMenu("View");
    viewMenu.setMnemonic(KeyEvent.VK_V);

    JMenu annoyanceModeMenu = new JMenu("Annoyance Mode");
    annoyanceJordanCheckbox = new JCheckBoxMenuItem("Jordan Mode");
    annoyanceJordanCheckbox.setToolTipText("For Cool People");
    annoyanceJordanCheckbox.setActionCommand(ACTION_ANNOY_JORDAN);
    annoyanceJordanCheckbox.addActionListener(this);
    annoyanceModeMenu.add(annoyanceJordanCheckbox);

    annoyanceDougCheckbox = new JCheckBoxMenuItem("Doug Mode");
    annoyanceDougCheckbox.setToolTipText("For Losers");
    annoyanceJordanCheckbox.setActionCommand(ACTION_ANNOY_DOUG);
    annoyanceDougCheckbox.addActionListener(this);
    annoyanceModeMenu.add(annoyanceDougCheckbox);

    annoyanceNoneCheckbox = new JCheckBoxMenuItem("None");
    annoyanceJordanCheckbox.setActionCommand(ACTION_ANNOY_NONE);
    annoyanceNoneCheckbox.addActionListener(this);
    annoyanceModeMenu.add(annoyanceNoneCheckbox);
    updateAnnoyanceButtons();

    viewMenu.add(annoyanceModeMenu);

    menuItem = new JMenuItem("Refresh View", KeyEvent.VK_R);
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menuItem.setActionCommand(ACTION_REFRESH_VIEW);
    menuItem.addActionListener(this);
    viewMenu.add(menuItem);

    viewMenu.addSeparator();

    menuItem = new JMenuItem("Change Start Time");
    menuItem.setActionCommand(ACTION_CHANGE_START);
    menuItem.addActionListener(this);
    viewMenu.add(menuItem);

    menuItem = new JMenuItem("Change Annoy Time");
    // currently disabled experimental functionality
    menuItem.setEnabled(false);
    menuItem.setActionCommand(ACTION_CHANGE_ANNOY);
    menuItem.addActionListener(this);
    viewMenu.add(menuItem);

    viewMenu.addSeparator();

    menuItem = new JMenuItem("Select Previous Tab", KeyEvent.VK_BRACELEFT);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BRACELEFT,
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menuItem.setActionCommand(ACTION_PREVIOUS_TAB);
    menuItem.addActionListener(this);
    viewMenu.add(menuItem);

    menuItem = new JMenuItem("Select Next Tab", KeyEvent.VK_BRACERIGHT);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BRACERIGHT,
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    menuItem.setActionCommand(ACTION_NEXT_TAB);
    menuItem.addActionListener(this);
    viewMenu.add(menuItem);

    return viewMenu;
}

From source file:edu.harvard.i2b2.previousquery.ui.QueryPreviousRunsPanel.java

private void createPopupMenu() {
    JMenuItem menuItem;

    // Create the popup menu.
    JPopupMenu popup = new JPopupMenu();

    menuItem = new JMenuItem("Rename ...");
    menuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R,
            java.awt.event.InputEvent.CTRL_MASK));
    menuItem.addActionListener(this);
    popup.add(menuItem);/*from  w w w  .j  a  v  a  2s .  com*/

    /* popup.add(new javax.swing.JSeparator()); */

    menuItem = new JMenuItem("Delete");
    menuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_D,
            java.awt.event.InputEvent.CTRL_MASK));
    menuItem.addActionListener(this);
    popup.add(menuItem);

    popup.add(new javax.swing.JSeparator());

    menuItem = new JMenuItem("Refresh All");
    menuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A,
            java.awt.event.InputEvent.CTRL_MASK));
    menuItem.addActionListener(this);
    popup.add(menuItem);

    // Add listener to the tree
    MouseListener popupListener = new PreviousRunsTreePopupListener(popup);
    jTree1.addMouseListener(popupListener);
    jTree1.addMouseMotionListener(new PreviousRunsTreeMouseMoveListener());
}