Search in sources :

Example 1 with ResultList

use of org.concord.energy3d.agents.ResultList in project energy3d by concord-consortium.

the class MainFrame method getHelpMenu.

private JMenu getHelpMenu() {
    if (helpMenu == null) {
        helpMenu = new JMenu("Help");
        helpMenu.addMenuListener(new MenuListener() {

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

            @Override
            public void menuDeselected(final MenuEvent e) {
            }

            @Override
            public void menuSelected(final MenuEvent e) {
            }
        });
        // User data and models
        final JMenu userHistoryMenu = new JMenu("View My History");
        helpMenu.add(userHistoryMenu);
        helpMenu.addSeparator();
        final JMenu userEventsMenu = new JMenu("Events");
        userHistoryMenu.add(userEventsMenu);
        JMenuItem mi = new JMenuItem("Event String");
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                new EventString().showGui();
            }
        });
        userEventsMenu.add(mi);
        mi = new JMenuItem("Event Time Series");
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                new EventTimeSeries().showGui();
            }
        });
        userEventsMenu.add(mi);
        mi = new JMenuItem("Event Frequency");
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                new EventFrequency().showGui();
            }
        });
        userEventsMenu.add(mi);
        final JMenu userResultsMenu = new JMenu("Results");
        userHistoryMenu.add(userResultsMenu);
        mi = new JMenuItem("Analysis Results");
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                new ResultList().showGui();
            }
        });
        userResultsMenu.add(mi);
        if (!Config.isMac()) {
            helpMenu.add(getPreferencesMenuItem());
        }
        helpMenu.add(getRecoveryMenuItem());
        // the automatic updater can fail sometimes. This provides an independent check.
        final JMenuItem miUpdate = new JMenuItem("Check Update...");
        helpMenu.add(miUpdate);
        miUpdate.setEnabled(!Config.isWebStart() && !Config.isEclipse());
        miUpdate.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                File jarFile = null;
                try {
                    jarFile = new File(MainApplication.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
                } catch (final URISyntaxException e1) {
                    e1.printStackTrace();
                    JOptionPane.showMessageDialog(instance, e1.getMessage(), "URL Error (local energy3d.jar)", JOptionPane.ERROR_MESSAGE);
                    return;
                }
                if (!jarFile.toString().endsWith("energy3d.jar")) {
                    return;
                }
                final long localLastModified = jarFile.lastModified();
                new SwingWorker<Void, Void>() {

                    URLConnection connection = null;

                    String msg = null;

                    long remoteLastModified;

                    @Override
                    protected Void doInBackground() throws Exception {
                        try {
                            connection = new URL("http://energy.concord.org/energy3d/update/energy3d.jar").openConnection();
                            remoteLastModified = connection.getLastModified();
                        } catch (final Exception e1) {
                            e1.printStackTrace();
                            msg = e1.getMessage();
                        }
                        return null;
                    }

                    @Override
                    protected void done() {
                        if (connection == null) {
                            JOptionPane.showMessageDialog(instance, msg, "URL Error (remote energy3d.jar)", JOptionPane.ERROR_MESSAGE);
                        } else {
                            if (remoteLastModified <= localLastModified) {
                                JOptionPane.showMessageDialog(instance, "Your software is up to date.", "Update Status", JOptionPane.INFORMATION_MESSAGE);
                            } else {
                                JOptionPane.showMessageDialog(instance, "<html>Your software is out of date. But for some reason, it cannot update itself.<br>Please go to http://energy3d.concord.org to download and reinstall the latest version.</html>", "Update Status", JOptionPane.INFORMATION_MESSAGE);
                                Util.openBrowser("http://energy3d.concord.org");
                            }
                        }
                    }
                }.execute();
            }
        });
        helpMenu.addSeparator();
        // Energy3D web pages
        mi = new JMenuItem("Visit Virtual Solar Grid...");
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                Util.openBrowser("http://energy.concord.org/energy3d/vsg/syw.html");
            }
        });
        helpMenu.add(mi);
        mi = new JMenuItem("View Building Examples...");
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                Util.openBrowser("http://energy.concord.org/energy3d/styles.html");
            }
        });
        helpMenu.add(mi);
        mi = new JMenuItem("View User Work...");
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                Util.openBrowser("http://energy.concord.org/energy3d/models.html");
            }
        });
        helpMenu.add(mi);
        helpMenu.addSeparator();
        mi = new JMenuItem("Visit User Forum...");
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                Util.openBrowser("https://energy.concord.org/energy3d/forum/");
            }
        });
        helpMenu.add(mi);
        mi = new JMenuItem("Visit Home Page...");
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                Util.openBrowser("http://energy3d.concord.org");
            }
        });
        helpMenu.add(mi);
        mi = new JMenuItem("Contact Us...");
        mi.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(final ActionEvent e) {
                Util.openBrowser("http://energy.concord.org/energy3d/contact.html");
            }
        });
        helpMenu.add(mi);
        if (!Config.isMac()) {
            helpMenu.add(getAboutMenuItem());
        }
    }
    return helpMenu;
}
Also used : ResultList(org.concord.energy3d.agents.ResultList) MenuListener(javax.swing.event.MenuListener) ActionEvent(java.awt.event.ActionEvent) EventString(org.concord.energy3d.agents.EventString) URISyntaxException(java.net.URISyntaxException) EventString(org.concord.energy3d.agents.EventString) URLConnection(java.net.URLConnection) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) MalformedURLException(java.net.MalformedURLException) EventTimeSeries(org.concord.energy3d.agents.EventTimeSeries) ActionListener(java.awt.event.ActionListener) EventFrequency(org.concord.energy3d.agents.EventFrequency) SwingWorker(javax.swing.SwingWorker) JMenuItem(javax.swing.JMenuItem) File(java.io.File) JMenu(javax.swing.JMenu) MenuEvent(javax.swing.event.MenuEvent) MainApplication(org.concord.energy3d.MainApplication)

Aggregations

ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 URLConnection (java.net.URLConnection)1 JMenu (javax.swing.JMenu)1 JMenuItem (javax.swing.JMenuItem)1 SwingWorker (javax.swing.SwingWorker)1 MenuEvent (javax.swing.event.MenuEvent)1 MenuListener (javax.swing.event.MenuListener)1 MainApplication (org.concord.energy3d.MainApplication)1 EventFrequency (org.concord.energy3d.agents.EventFrequency)1 EventString (org.concord.energy3d.agents.EventString)1 EventTimeSeries (org.concord.energy3d.agents.EventTimeSeries)1 ResultList (org.concord.energy3d.agents.ResultList)1