Changeset 661

Show
Ignore:
Timestamp:
02/04/10 21:53:25 (3 years ago)
Author:
joerg
Message:
 
Location:
trunk/src/jlatexeditor
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/jlatexeditor/gui/StatusBar.java

    r660 r661  
    1010import java.awt.event.ActionEvent; 
    1111import java.awt.event.ActionListener; 
     12import java.awt.event.MouseEvent; 
     13import java.awt.event.MouseListener; 
    1214import java.awt.geom.Rectangle2D; 
    1315import java.io.File; 
     
    1719 * StatusBar. 
    1820 */ 
    19 public class StatusBar extends JPanel implements ActionListener { 
     21public class StatusBar extends JPanel implements ActionListener, MouseListener { 
    2022  private JLatexEditorJFrame jLatexEditor; 
    2123 
     
    2426  private JPanel left = new JPanel(); 
    2527 
    26   private boolean checkForUpdates = true; 
     28  private boolean hadException = false; 
    2729  private JLabel updatesAvailable = new JLabel("SVN updates are available."); 
     30  private CheckForUpdates updateChecker = new CheckForUpdates(); 
    2831 
    2932  private ArrayList<String> messges = new ArrayList<String>(); 
     
    4548    updatesAvailable.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(), BorderFactory.createEmptyBorder(1,3,1,3))); 
    4649    updatesAvailable.setVisible(false); 
     50    updatesAvailable.addMouseListener(this); 
    4751    center.add(updatesAvailable); 
    4852 
     
    5054    setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); 
    5155 
    52     new CheckForUpdates().start(); 
     56    updateChecker.start(); 
    5357  } 
    5458 
     
    5862  } 
    5963 
    60   public synchronized void checkForUpdates() { 
    61     if(!checkForUpdates) return; 
     64  public void checkForUpdates() { 
     65    updateChecker.check(); 
     66  } 
    6267 
     68  private synchronized void checkForUpdates_() { 
    6369    boolean hasUpdates = false; 
    6470 
     
    6672    if(!file.exists()) return; 
    6773    File dir = file.getParentFile(); 
     74    if(!new File(dir, ".svn").exists()) return; 
     75     
    6876    try { 
    6977      ArrayList<SVN.StatusResult> results = SVN.getInstance().status(dir); 
     
    7280      } 
    7381    } catch (Exception e) { 
    74       e.printStackTrace(); 
    75       checkForUpdates = false; 
     82      if(!hadException) e.printStackTrace(); 
     83      hadException = true; 
    7684    } 
    7785 
    78     System.out.println(hasUpdates); 
    79     updatesAvailable.setVisible(hasUpdates); 
     86    setUpdatesAvailableVisible(hasUpdates); 
    8087  } 
    8188 
     
    8693  public void actionPerformed(ActionEvent e) { 
    8794    checkForUpdates(); 
     95  } 
     96 
     97  public void mouseClicked(MouseEvent e) { 
     98  } 
     99 
     100  public void mousePressed(MouseEvent e) { 
     101    setUpdatesAvailableVisible(false); 
     102    jLatexEditor.actionPerformed(new ActionEvent(this, 0, "svn update")); 
     103  } 
     104 
     105  public void mouseReleased(MouseEvent e) { 
     106  } 
     107 
     108  public void mouseEntered(MouseEvent e) { 
     109  } 
     110 
     111  public void mouseExited(MouseEvent e) { 
    88112  } 
    89113 
     
    127151    } 
    128152 
     153    public synchronized void check() { 
     154      notifyAll(); 
     155    } 
     156 
    129157    public void run() { 
    130       checkForUpdates(); 
     158      while(true) { 
     159        checkForUpdates_(); 
    131160 
    132       try { 
    133         synchronized (this) { wait(120000); } 
    134       } catch (InterruptedException e) { } 
     161        try { 
     162          synchronized (this) { wait(120000); } 
     163        } catch (InterruptedException e) { } 
     164      } 
    135165    } 
    136166  } 
  • trunk/src/jlatexeditor/JLatexEditorJFrame.java

    r660 r661  
    697697      checkExternalModification(false); 
    698698      statusBar.showMessage("SVN update", builder.toString()); 
     699      statusBar.setUpdatesAvailableVisible(false); 
    699700    } else 
    700701    // svn commit 
     
    10211022 
    10221023        backgroundParser.parse(); 
     1024        statusBar.checkForUpdates(); 
    10231025      } 
    10241026      if(closeIcon.contains(e.getX() - closeIcon.getX(), e.getY() - closeIcon.getY())) {