mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
- Splash view/model renamed, moved to forge.view.swing folder
- Small fix to decouple interface from implementation - Add dispatch thread test - Updated javadoc
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -9876,8 +9876,6 @@ src/main/java/net/slightlymagic/braids/util/lambda/package-info.java svneol=nati
|
|||||||
src/main/java/net/slightlymagic/braids/util/package-info.java svneol=native#text/plain
|
src/main/java/net/slightlymagic/braids/util/package-info.java svneol=native#text/plain
|
||||||
src/main/java/net/slightlymagic/braids/util/progress_monitor/BaseProgressMonitor.java svneol=native#text/plain
|
src/main/java/net/slightlymagic/braids/util/progress_monitor/BaseProgressMonitor.java svneol=native#text/plain
|
||||||
src/main/java/net/slightlymagic/braids/util/progress_monitor/BraidsProgressMonitor.java svneol=native#text/plain
|
src/main/java/net/slightlymagic/braids/util/progress_monitor/BraidsProgressMonitor.java svneol=native#text/plain
|
||||||
src/main/java/net/slightlymagic/braids/util/progress_monitor/SplashModelProgressMonitor.java -text
|
|
||||||
src/main/java/net/slightlymagic/braids/util/progress_monitor/SplashViewProgressMonitor.java -text
|
|
||||||
src/main/java/net/slightlymagic/braids/util/progress_monitor/StderrProgressMonitor.java svneol=native#text/plain
|
src/main/java/net/slightlymagic/braids/util/progress_monitor/StderrProgressMonitor.java svneol=native#text/plain
|
||||||
src/main/java/net/slightlymagic/braids/util/progress_monitor/package-info.java svneol=native#text/plain
|
src/main/java/net/slightlymagic/braids/util/progress_monitor/package-info.java svneol=native#text/plain
|
||||||
src/main/java/net/slightlymagic/maxmtg/Predicate.java -text
|
src/main/java/net/slightlymagic/maxmtg/Predicate.java -text
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import java.util.zip.ZipFile;
|
|||||||
import net.slightlymagic.braids.util.UtilFunctions;
|
import net.slightlymagic.braids.util.UtilFunctions;
|
||||||
import net.slightlymagic.braids.util.generator.FindNonDirectoriesSkipDotDirectoriesGenerator;
|
import net.slightlymagic.braids.util.generator.FindNonDirectoriesSkipDotDirectoriesGenerator;
|
||||||
import net.slightlymagic.braids.util.generator.GeneratorFunctions;
|
import net.slightlymagic.braids.util.generator.GeneratorFunctions;
|
||||||
import net.slightlymagic.braids.util.progress_monitor.BaseProgressMonitor;
|
import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor;
|
||||||
import net.slightlymagic.braids.util.progress_monitor.StderrProgressMonitor;
|
import net.slightlymagic.braids.util.progress_monitor.StderrProgressMonitor;
|
||||||
|
|
||||||
import com.google.code.jyield.Generator;
|
import com.google.code.jyield.Generator;
|
||||||
@@ -187,7 +187,7 @@ public class CardReader
|
|||||||
|
|
||||||
// Try to retrieve card loading progress monitor model.
|
// Try to retrieve card loading progress monitor model.
|
||||||
// If no progress monitor present, output results to console.
|
// If no progress monitor present, output results to console.
|
||||||
BaseProgressMonitor monitor = null;
|
BraidsProgressMonitor monitor = null;
|
||||||
final FView view = Singletons.getView();
|
final FView view = Singletons.getView();
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
monitor = view.getCardLoadingProgressMonitor();
|
monitor = view.getCardLoadingProgressMonitor();
|
||||||
@@ -206,7 +206,9 @@ public class CardReader
|
|||||||
findNonDirsIterable = YieldUtils.toIterable(findNonDirsGen);
|
findNonDirsIterable = YieldUtils.toIterable(findNonDirsGen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(monitor!=null) {
|
||||||
monitor.setTotalUnitsThisPhase(estimatedFilesRemaining);
|
monitor.setTotalUnitsThisPhase(estimatedFilesRemaining);
|
||||||
|
}
|
||||||
|
|
||||||
for (File cardTxtFile : findNonDirsIterable) {
|
for (File cardTxtFile : findNonDirsIterable) {
|
||||||
if (!cardTxtFile.getName().endsWith(CARD_FILE_DOT_EXTENSION)) {
|
if (!cardTxtFile.getName().endsWith(CARD_FILE_DOT_EXTENSION)) {
|
||||||
|
|||||||
@@ -31,6 +31,16 @@ public class BaseProgressMonitor implements BraidsProgressMonitor {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience for
|
* Convenience for
|
||||||
|
* BaseProgressMonitor(1, 1, 2.0f, null).
|
||||||
|
*
|
||||||
|
* @see #BaseProgressMonitor(int,long,float,float[])
|
||||||
|
*/
|
||||||
|
public BaseProgressMonitor() {
|
||||||
|
this(1, 1L, 2.0f, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience for
|
||||||
* BaseProgressMonitor(numPhases, 1, 2.0f, null).
|
* BaseProgressMonitor(numPhases, 1, 2.0f, null).
|
||||||
*
|
*
|
||||||
* @see #BaseProgressMonitor(int,long,float,float[])
|
* @see #BaseProgressMonitor(int,long,float,float[])
|
||||||
@@ -300,7 +310,7 @@ public class BaseProgressMonitor implements BraidsProgressMonitor {
|
|||||||
* Subclasses must call this immediately after updating the UI, to
|
* Subclasses must call this immediately after updating the UI, to
|
||||||
* preserve the integrity of the shouldUpdateUI method.
|
* preserve the integrity of the shouldUpdateUI method.
|
||||||
*/
|
*/
|
||||||
protected void justUpdatedUI() {
|
public void justUpdatedUI() {
|
||||||
this.lastUIUpdateTime = new Date().getTime()/1000;
|
this.lastUIUpdateTime = new Date().getTime()/1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,6 +113,12 @@ public interface BraidsProgressMonitor {
|
|||||||
*/
|
*/
|
||||||
public abstract boolean shouldUpdateUI();
|
public abstract boolean shouldUpdateUI();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subclasses must call this immediately after updating the UI, to
|
||||||
|
* preserve the integrity of the shouldUpdateUI method.
|
||||||
|
*/
|
||||||
|
public abstract void justUpdatedUI();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the only way to advance the phase number.
|
* This is the only way to advance the phase number.
|
||||||
* It automatically "starts the clock" for the next phase.
|
* It automatically "starts the clock" for the next phase.
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
package net.slightlymagic.braids.util.progress_monitor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Write javadoc for this type.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class SplashModelProgressMonitor extends BaseProgressMonitor {
|
|
||||||
|
|
||||||
private SplashViewProgressMonitor currentView = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Write javadoc for Constructor.
|
|
||||||
* @param numPhases
|
|
||||||
*/
|
|
||||||
public SplashModelProgressMonitor(int numPhases) {
|
|
||||||
super(numPhases);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
/**
|
|
||||||
* @see net.slightlymagic.braids.util.progress_monitor.BaseProgressMonitor#incrementUnitsCompletedThisPhase(long)
|
|
||||||
*/
|
|
||||||
public void incrementUnitsCompletedThisPhase(long numUnits) {
|
|
||||||
super.incrementUnitsCompletedThisPhase(numUnits);
|
|
||||||
getCurrentView().incrementProgressBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCurrentView(SplashViewProgressMonitor neoView) {
|
|
||||||
currentView = neoView;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SplashViewProgressMonitor getCurrentView() {
|
|
||||||
return currentView;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,109 +0,0 @@
|
|||||||
package net.slightlymagic.braids.util.progress_monitor;
|
|
||||||
|
|
||||||
import javax.swing.JProgressBar;
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Swing component view, to be used with BaseProgressMonitor.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class SplashViewProgressMonitor extends JProgressBar {
|
|
||||||
private BaseProgressMonitor currentModel;
|
|
||||||
private double completed;
|
|
||||||
private double total;
|
|
||||||
|
|
||||||
public SplashViewProgressMonitor() {
|
|
||||||
super();
|
|
||||||
setString("");
|
|
||||||
setStringPainted(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void incrementProgressBar() {
|
|
||||||
// Update bar "stripe"
|
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
stripeUpdate();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Update bar message
|
|
||||||
// Note: shouldUpdateUI() severely retards motion
|
|
||||||
// of the preloader, so is temporarily disabled.
|
|
||||||
//if (getCurrentModel().shouldUpdateUI()) {
|
|
||||||
if ((getCurrentModel().getNumPhases() > 1)) {
|
|
||||||
displayUpdate(
|
|
||||||
"Phase " + getCurrentModel().getCurrentPhase() + ". "
|
|
||||||
//+ getUnitsCompletedSoFarThisPhase() + " units processed. "
|
|
||||||
//+ "Overall: " + getTotalPercentCompleteAsString() + "% complete, "
|
|
||||||
+ "Overall ETA in " + getCurrentModel().getRelativeETAAsString() + "."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
displayUpdate(
|
|
||||||
//"Overall: " +
|
|
||||||
getCurrentModel().getUnitsCompletedSoFarThisPhase() + " units processed; "
|
|
||||||
//+ "(" + getTotalPercentCompleteAsString() + "%); "
|
|
||||||
+ "ETA in " + getCurrentModel().getRelativeETAAsString() + "."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// getCurrentModel().justUpdatedUI();
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
if (getCurrentModel().getCurrentPhase() == getCurrentModel().getNumPhases()
|
|
||||||
&& getCurrentModel().getUnitsCompletedSoFarThisPhase() >= getCurrentModel().getTotalUnitsThisPhase())
|
|
||||||
{
|
|
||||||
displayUpdate("Done! Firing up the GUI...");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shows the message inside the progress dialog; does not always work on
|
|
||||||
* all platforms.
|
|
||||||
*
|
|
||||||
* @param message the message to display
|
|
||||||
*/
|
|
||||||
public final void displayUpdate(final String message) {
|
|
||||||
final Runnable proc = new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
setString(message);
|
|
||||||
getCurrentModel().justUpdatedUI();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (SwingUtilities.isEventDispatchThread()) {
|
|
||||||
proc.run();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
SwingUtilities.invokeLater(proc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Moves the stripe inside the progress dialog.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public final void stripeUpdate() {
|
|
||||||
completed = getCurrentModel().getUnitsCompletedSoFarThisPhase();
|
|
||||||
total = getCurrentModel().getTotalUnitsThisPhase();
|
|
||||||
|
|
||||||
setValue((int)Math.round((int)completed/total*100));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets the stripe inside the progress dialog back to zero.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public final void stripeReset() {
|
|
||||||
setValue(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCurrentModel(BaseProgressMonitor neoModel) {
|
|
||||||
currentModel = neoModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BaseProgressMonitor getCurrentModel() {
|
|
||||||
return currentModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user