This repository has been archived by the owner on Mar 3, 2022. It is now read-only.
forked from chewiebug/GCViewer
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reload only after last model of a group (inside GCDocument) has finis…
…hed loading
- Loading branch information
Showing
6 changed files
with
162 additions
and
35 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
src/main/java/com/tagtraum/perf/gcviewer/ctrl/GCModelLoaderGroupTracker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package com.tagtraum.perf.gcviewer.ctrl; | ||
|
||
import java.beans.PropertyChangeEvent; | ||
import java.beans.PropertyChangeListener; | ||
import java.beans.PropertyChangeSupport; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import javax.swing.SwingWorker; | ||
|
||
/** | ||
* Helperclass to track several modelLoaders and get an event, when all loaders have finished | ||
* loading. GCModelLoaders should be added to the tracker and then be started via | ||
* {@link #execute()}. | ||
* | ||
* @author <a href="mailto:[email protected]">Joerg Wuethrich</a> | ||
* <p>created on: 02.02.2014</p> | ||
*/ | ||
public class GCModelLoaderGroupTracker implements PropertyChangeListener { | ||
private PropertyChangeSupport propertyChangeSupport; | ||
private List<GCModelLoader> loaderList = new ArrayList<GCModelLoader>(); | ||
private int finishedCount; | ||
|
||
public GCModelLoaderGroupTracker() { | ||
super(); | ||
|
||
propertyChangeSupport = new PropertyChangeSupport(this); | ||
} | ||
|
||
/** | ||
* @see PropertyChangeSupport#addPropertyChangeListener(PropertyChangeListener) | ||
*/ | ||
public void addPropertyChangeListener(PropertyChangeListener listener) { | ||
propertyChangeSupport.addPropertyChangeListener(listener); | ||
} | ||
|
||
/** | ||
* Add a <code>GCModelLoader</code> to be tracked by this tracker. | ||
* | ||
* @param loader <code>GCModelLoader</code> to be tracked by this tracker. | ||
*/ | ||
public void addGcModelLoader(GCModelLoader loader) { | ||
loader.addPropertyChangeListener(this); | ||
loaderList.add(loader); | ||
} | ||
|
||
/** | ||
* Start execution of all loaders tracked by this tracker. | ||
*/ | ||
public void execute() { | ||
for (GCModelLoader loader : loaderList) { | ||
loader.execute(); | ||
} | ||
} | ||
|
||
/** | ||
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent) | ||
*/ | ||
@Override | ||
public void propertyChange(PropertyChangeEvent evt) { | ||
if ("state".equals(evt.getPropertyName()) | ||
&& SwingWorker.StateValue.DONE == evt.getNewValue()) { | ||
|
||
++finishedCount; | ||
if (finishedCount == loaderList.size()) { | ||
propertyChangeSupport.firePropertyChange("state", | ||
SwingWorker.StateValue.STARTED, | ||
SwingWorker.StateValue.DONE); | ||
} | ||
} | ||
|
||
} | ||
|
||
/** | ||
* @see PropertyChangeSupport#removePropertyChangeListener(PropertyChangeListener) | ||
*/ | ||
public void removePropertyChangeListener(PropertyChangeListener listener) { | ||
propertyChangeSupport.removePropertyChangeListener(listener); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,18 +7,18 @@ | |
import java.io.PrintWriter; | ||
|
||
/** | ||
* TextAreaFormatter. | ||
* <p/> | ||
* Date: Oct 3, 2005 | ||
* Time: 4:50:41 PM | ||
* Formatter for a {@link LogRecord} to be displayed in a text area. | ||
* | ||
* <p>Date: Oct 3, 2005<br/> | ||
* Time: 4:50:41 PM</p> | ||
* | ||
* @author <a href="mailto:[email protected]">Hendrik Schreiber</a> | ||
*/ | ||
public class TextAreaFormatter extends Formatter { | ||
private static final String LINE_SEPARATOR = System.getProperty("line.separator"); | ||
|
||
public String format(LogRecord record) { | ||
StringBuffer sb = new StringBuffer(); | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(record.getLevel().getLocalizedName()); | ||
sb.append(" ["); | ||
final String logger = record.getSourceClassName(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters