Revision: 3794
Author: [email protected]
Date: Tue Jul 27 15:32:19 2010
Log: Improved the painting of the progress bar to reduce the amount of flickering it does.

Synchronized the modification of the list of progress bars to prevent co-modification exceptions when making a large number of persists.
http://code.google.com/p/power-architect/source/detail?r=3794

Modified:
/trunk/src/main/java/ca/sqlpower/architect/enterprise/NetworkConflictResolver.java
 /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectStatusBar.java

=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/enterprise/NetworkConflictResolver.java Tue Jul 27 14:11:45 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/enterprise/NetworkConflictResolver.java Tue Jul 27 15:32:19 2010
@@ -194,6 +194,7 @@
                             } catch (InterruptedException e) {
                                 throw new RuntimeException(e);
                             }
+ if (finalMonitor.isCancelled() || finalMonitor.isFinished()) break;
                             finalMonitor.incrementProgress();
finalMonitor.setMessage("Working on " + finalMonitor.getProgress() +
                                     " of " + finalMonitor.getJobSize());
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectStatusBar.java Tue Jul 27 14:11:45 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectStatusBar.java Tue Jul 27 15:32:19 2010
@@ -127,8 +127,8 @@
                 Graphics bufferG = buffer.getGraphics();
                 bufferG = progressBarPanel.getGraphics();

-                g.setColor(progressBarPanel.getBackground());
- g.fillRect(getX(), 0, getWidth(), progressBarPanel.getHeight());
+                bufferG.setColor(progressBarPanel.getBackground());
+ bufferG.fillRect(getX(), 0, getWidth(), progressBarPanel.getHeight());
                 bufferG.drawImage(PROGRESS_BAR_ICON.getImage(), getX(), 0,
                         (int) (getWidth() * getProgress() / getJobSize()),
                         progressBarPanel.getHeight(), null);
@@ -210,7 +210,7 @@
     }

     @Override
-    public MonitorableImpl createProgressMonitor() {
+    public synchronized MonitorableImpl createProgressMonitor() {
ArchitectStatusProgressBar newBar = new ArchitectStatusProgressBar();
         progressBars.add(newBar);
         resizeProgressBars();
@@ -220,7 +220,7 @@
     /**
      * Call to clear a progress bar off of the status bar.
      */
-    private void removeProgressBar(ArchitectStatusProgressBar bar) {
+ private synchronized void removeProgressBar(ArchitectStatusProgressBar bar) {
         progressBars.remove(bar);
         resizeProgressBars();
     }

Reply via email to