Package com.fray.evo.util

Examples of com.fray.evo.util.EcAutoUpdate


        SwingUtilities.invokeLater(new Runnable()
        {
          @Override
          public void run()
          {
            EcAutoUpdate ecUpdater = checkForUpdates();
            // Show the main window only when there are no updates
            // running
            frame.setVisible(!ecUpdater.isUpdating());
            updateFrame.dispose();
          }
        });
      }
    });
View Full Code Here


    return new Dimension(width, height);
  }

  private static EcAutoUpdate checkForUpdates()
  {
    EcAutoUpdate ecUpdater = new EcAutoUpdate(EvolutionChamber.VERSION, new EcAutoUpdate.Callback(){
      @Override
      public void checksumFailed()
      {
        JOptionPane.showMessageDialog(null, messages.getString("update.checksumFailed.message"), messages.getString("update.checksumFailed.title"), JOptionPane.ERROR_MESSAGE);
      }
     
      @Override
      public void updateCheckFailed()
      {
        JOptionPane.showMessageDialog(null, messages.getString("update.updateCheckFailed.message"), messages.getString("update.updateCheckFailed.title"), JOptionPane.WARNING_MESSAGE);
      }
    });
    if (ecUpdater.isUpdateAvailable())
    {
      JOptionPane pane = new JOptionPane(messages.getString("update.updateAvailable.message"));
      String yes = messages.getString("update.updateAvailable.yes");
      String no = messages.getString("update.updateAvailable.no");
      pane.setOptions(new String[] { yes, no });
      JDialog dialog = pane.createDialog(new JFrame(), messages.getString("update.updateAvailable.title", ecUpdater.getLatestVersion()));
      dialog.setVisible(true);

      Object selection = pane.getValue();

      if (selection.equals(yes))
      {
        JFrame updateFrame = new JFrame();
        updateFrame.setTitle(messages.getString("update.updating.title"));
        updateFrame.setResizable(false);
        ImageIcon icon = new ImageIcon(EcSwingXMain.class.getResource(iconLocation));
        updateFrame.setIconImage(icon.getImage());

        final JProgressBar updateProgress = new JProgressBar(0, 100);
        updateProgress.setValue(0);
        updateProgress.setStringPainted(true);
        updateFrame.add(updateProgress);
        updateFrame.setPreferredSize(new Dimension(200, 100));
        updateFrame.pack();
        updateFrame.setLocationRelativeTo(null);
        updateFrame.setVisible(true);
        ecUpdater.addPropertyChangeListener(new PropertyChangeListener()
        {
          public void propertyChange(PropertyChangeEvent evt)
          {
            if ("progress".equals(evt.getPropertyName()))
            {
              updateProgress.setValue((Integer) evt.getNewValue());
            }
          }
        });
        ecUpdater.setUpdating(true);
        ecUpdater.execute();
      }
    }
    return ecUpdater;
  }
View Full Code Here

TOP

Related Classes of com.fray.evo.util.EcAutoUpdate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.