package neembuu.release1.versioning; import java.awt.Desktop; import java.io.IOException; import java.net.URI; import java.util.logging.Level; import java.util.logging.Logger; import neembuu.release1.api.log.LoggerUtil; import neembuu.release1.api.ui.MainComponent; /** This class is used to display Update Notification window. * * @author vigneshwaran * @author Shashank */ public class NotifyUpdate extends javax.swing.JFrame { /** Creates new form NotifyUpdate */ public NotifyUpdate(MainComponent mc) { try{ setIconImage(mc.getJFrame().getIconImage()); }catch(Exception ignore){} LoggerUtil.L().info("Displaying Update Notification"); //First initialize the components initComponents(); //setIconImage(mc.getJFrame().); //Set the component relative to the main window setLocationRelativeTo(mc.getJFrame()); //Set the labels with the local language newversionLabel.setText("<html>"+ "Latest available version of NeembuuNow released on " + ": <b>" + CheckUpdate.availableDate() +"</b></html>"); currentversionLabel.setText("<html>"+ "The NeembuuNow that you are using was released on " + ": <b>" + CheckUpdate.currentDate() +"</b></html>"); clickLabel.setText("<html>"+ "Download the latest version from here " + ": <a href=http://neembuu.sourceforge.net/download>http://neembuu.com/</a></html>"); LoggerUtil.L().log(Level.INFO, "{0}Setting Editor Pane", NotifyUpdate.class.getName()); //Set the editor pane to display the newfeatures.html page. try { htmlPane.setPage("http://neembuu.sourceforge.net/newfeatures.html"); } catch (IOException ex) { Logger.getLogger(NotifyUpdate.class.getName()).log(Level.SEVERE, null, ex); } //Pack to fit the size of the new language neatly. pack(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { newversionLabel = new javax.swing.JLabel(); clickLabel = new javax.swing.JLabel(); closeButton = new javax.swing.JButton(); currentversionLabel = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); htmlPane = new javax.swing.JEditorPane(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Update notifier"); newversionLabel.setText("Latest available version of Neembuu Uploader: "); clickLabel.setText("<html>Download the latest version from here: <a href=http://neembuu.sf.net>http://neembuu.sf.net</a></html>"); clickLabel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); clickLabel.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { clickLabelMouseClicked(evt); } }); closeButton.setText("Close"); closeButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { closeButtonActionPerformed(evt); } }); currentversionLabel.setText("Your outdated Neembuu Uploader version:"); htmlPane.setEditable(false); jScrollPane1.setViewportView(htmlPane); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(closeButton, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(currentversionLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 562, Short.MAX_VALUE) .addComponent(clickLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 562, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 562, Short.MAX_VALUE) .addComponent(newversionLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 562, Short.MAX_VALUE)) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(newversionLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(currentversionLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 252, Short.MAX_VALUE) .addGap(18, 18, 18) .addComponent(clickLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(closeButton) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents /** * Closes the window * @param evt */ private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeButtonActionPerformed dispose(); }//GEN-LAST:event_closeButtonActionPerformed /** * Open the homepage when the label is clicked. * @param evt */ private void clickLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_clickLabelMouseClicked if(!Desktop.isDesktopSupported()) return; try { LoggerUtil.L().log(Level.INFO, "{0}: Link clicked.. Opening the homepage..", getClass().getName()); Desktop.getDesktop().browse(new URI("http://neembuu.sourceforge.net/download")); } catch (Exception ex) { LoggerUtil.L().severe(ex.toString()); } }//GEN-LAST:event_clickLabelMouseClicked // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel clickLabel; private javax.swing.JButton closeButton; private javax.swing.JLabel currentversionLabel; private javax.swing.JEditorPane htmlPane; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JLabel newversionLabel; // End of variables declaration//GEN-END:variables }