Skip to content

Commit

Permalink
Small cosmetic changes to the dialog displayed while generating a cat…
Browse files Browse the repository at this point in the history
…alog
  • Loading branch information
itimpi committed Jun 3, 2014
1 parent 03e2982 commit 71db705
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 92 deletions.
Expand Up @@ -39,8 +39,7 @@ public class CachedFile extends File {

public CachedFile(String pathname) {
super(pathname);
if (logger.isTraceEnabled())
logger.trace("new CachedFile: " + getAbsolutePath());
if (logger.isTraceEnabled()) logger.trace("new CachedFile: " + getAbsolutePath());
clearCached();
}

Expand All @@ -66,15 +65,13 @@ private void checkCachedValues() {
return;
}

if (logger.isTraceEnabled())
logger.trace("Check Cached data for " + getPath());
if (logger.isTraceEnabled()) logger.trace("Check Cached data for " + getPath());

if (!super.exists()) {
// Cached entry for non-existent file needs resetting
exists = false;
clearCached();
if (logger.isTraceEnabled())
logger.trace("File does not exist - reset to defaults");
if (logger.isTraceEnabled()) logger.trace("File does not exist - reset to defaults");
return;
}
exists = true;
Expand All @@ -84,12 +81,10 @@ private void checkCachedValues() {
long d = super.lastModified();
long l = super.length();
if ((lastModifiedChecked && (d == lastModified)) || (lengthChecked && (l != length))) {
if (logger.isTraceEnabled())
logger.trace("date/length matched - CRC assumed valid");
if (logger.isTraceEnabled()) logger.trace("date/length matched - CRC assumed valid");
crcCalced = true;
} else {
if (logger.isTraceEnabled())
logger.trace("date/length not matched - CRC needs recalculating");
if (logger.isTraceEnabled()) logger.trace("date/length not matched - CRC needs recalculating");
crc = -1;
crcCalced = false;
}
Expand All @@ -106,19 +101,6 @@ private void checkCachedValues() {
@Override
public boolean exists() {
checkCachedValues();
/*
if (!existsChecked) {
if (logger.isTraceEnabled())
logger.trace("checking exists for " + getAbsolutePath());
exists = super.exists();
existsChecked = true;
} else {
if (logger.isTraceEnabled())
logger.trace("skipping check exists for " + getAbsolutePath());
}
if (logger.isTraceEnabled())
logger.trace("exists=" + exists + ": " + getAbsolutePath());
*/
return exists;
}

Expand Down Expand Up @@ -148,19 +130,6 @@ public void clearCachedInformation() {
@Override
public long lastModified() {
checkCachedValues();
/*
if (!lastModifiedChecked) {
if (logger.isTraceEnabled())
logger.trace("checking lastModified for " + getAbsolutePath());
lastModified = super.lastModified();
lastModifiedChecked = true;
} else {
if (logger.isTraceEnabled())
logger.trace("skipping check lastModified for " + getAbsolutePath());
}
if (logger.isTraceEnabled())
logger.trace("lastMoodified=" + lastModified + ": " + getAbsolutePath());
*/
return lastModified;
}

Expand All @@ -173,19 +142,6 @@ public long lastModified() {
@Override
public long length() {
checkCachedValues();
/*
if (!lengthChecked) {
if (logger.isTraceEnabled())
logger.trace("checking length for " + getAbsolutePath());
length = super.length();
lengthChecked = true;
} else {
if (logger.isTraceEnabled())
logger.trace("skipping check length for " + getAbsolutePath());
}
if (logger.isTraceEnabled())
logger.trace("length=" + length + ": " + getAbsolutePath());
*/
return length;
}

Expand All @@ -200,8 +156,7 @@ public long getCrc() {
checkCachedValues();
if (!crcCalced)
calcCrc();
if (logger.isTraceEnabled())
logger.trace("getCrc=" + crc + ": " + getAbsolutePath());
if (logger.isTraceEnabled()) logger.trace("getCrc=" + crc + ": " + getAbsolutePath());
return crc;
}

Expand All @@ -214,8 +169,7 @@ public long getCrc() {
public void setCrc(long value) {
crc = value;
crcCalced = true;
if (logger.isTraceEnabled())
logger.trace("setCrc(" + crc + "): " + getAbsolutePath());
if (logger.isTraceEnabled()) logger.trace("setCrc(" + crc + "): " + getAbsolutePath());
}

/**
Expand Down Expand Up @@ -258,8 +212,7 @@ private void calcCrc() {
} catch (IOException e) {
// Do nothing
}
if (logger.isTraceEnabled())
logger.trace("calcCrc=" + crcCalced + " (crc=" + crc + "): " + getAbsolutePath());
if (logger.isTraceEnabled()) logger.trace("calcCrc=" + crcCalced + " (crc=" + crc + "): " + getAbsolutePath());
}

/**
Expand All @@ -277,8 +230,7 @@ public void clearCrc() {
*/
public void setTarget(boolean b) {
targetFile = b;
if (logger.isTraceEnabled())
logger.trace("setTarget(" + targetFile + "): " + getAbsolutePath());
if (logger.isTraceEnabled()) logger.trace("setTarget(" + targetFile + "): " + getAbsolutePath());
}


Expand All @@ -288,8 +240,7 @@ public void setTarget(boolean b) {
*/
public void setCached() {
cachedFileValuesChecked = false;
if (logger.isTraceEnabled())
logger.trace("setCached(" + cachedFileValuesChecked + "): " + getAbsolutePath());
if (logger.isTraceEnabled()) logger.trace("setCached(" + cachedFileValuesChecked + "): " + getAbsolutePath());
}


Expand All @@ -299,11 +250,19 @@ public void setCached() {
* @return true if cached data
*/
public boolean isCachedValidated() {
if (logger.isTraceEnabled())
logger.trace("isCachedValidated=" + cachedFileValuesChecked + ": " + getAbsolutePath());
if (logger.isTraceEnabled()) logger.trace("isCachedValidated=" + cachedFileValuesChecked + ": " + getAbsolutePath());
return cachedFileValuesChecked;
}

/**
* Return status to say whether file has changed since last run
* of calibre2opds. For backwards compatibility default is true.
*
* This method is intended to support a future optimisation where
* we try and calculate whether pages have chnged without actually
* generating them. *
* @return
*/
public boolean isChanged() {
return isChanged;
}
Expand All @@ -312,11 +271,14 @@ public boolean isChanged() {
* Set to status to say whether file has changed since last run
* of calibre2opds. For backwards compatibility default is true.
*
* This method is intended to support a future optimisation where
* we try and calculate whether pages have chnged without actually
* generating them.
*
* @param b True if it is, false otherwise
*/
public void setChanged (boolean b) {
isChanged = b;
if (logger.isTraceEnabled())
logger.trace("setChanged(" + isChanged + "): " + getAbsolutePath());
if (logger.isTraceEnabled()) logger.trace("setChanged(" + isChanged + "): " + getAbsolutePath());
}
}
Binary file added Different CSS.zip
Binary file not shown.
Expand Up @@ -168,13 +168,27 @@ private void startStage(long nb, JLabel label, String localizationKey) {
boldFont(label, true);
}

private void endStage(long milliseconds, JLabel label, JLabel time, JCheckBox ckkBox) {
private void endStage(long milliseconds, JLabel label, JLabel time, JCheckBox chkBox) {
logger.info(Localization.Main.getText("info.step.donein", milliseconds));
ckkBox.setSelected(true);
if (label.isEnabled()) chkBox.setSelected(true);
boldFont(label, false);
setTimeNow(time);
if (label.isEnabled()) setTimeNow(time);
}

/**
* Called when a stage will not be relevant to this generate run
*
* @param check
* @param label
* @param time
*/
private void disableStage(JCheckBox check, JLabel label, JLabel time) {
check.setEnabled(false);
label.setEnabled(false);
time.setEnabled(false);
}


public void startReadDatabase() {
logger.info(Localization.Main.getText("info.step.database"));
chkStarted.setSelected(true);
Expand All @@ -195,6 +209,18 @@ public void setAuthorCount(String summary){
lblAuthors.setText(lblAuthors.getText() + " (" + summary + ")");
}

public void startCreateAuthors(long nb) {
startStage(nb, lblAuthors, "info.step.authors");
}

public void endCreateAuthors(long milliseconds) {
endStage(milliseconds, lblAuthors, lblAuthorsTime, chkAuthors);
}

public void disableCreateAuthors() {
disableStage(chkAuthors, lblAuthors, lblAuthorsTime);
}

public void setSeriesCount(String summary) {
lblSeries.setText(lblSeries.getText() + " (" + summary + ")");
}
Expand All @@ -216,19 +242,7 @@ public void endCreateTags(long milliseconds) {
}

public void disableCreateTags() {
lblTags.setEnabled(false);
}

public void startCreateAuthors(long nb) {
startStage(nb, lblAuthors, "info.step.authors");
}

public void endCreateAuthors(long milliseconds) {
endStage(milliseconds, lblAuthors, lblAuthorsTime, chkAuthors);
}

public void disableCreateAuthors() {
lblAuthors.setEnabled(false);
disableStage(chkTags, lblTags, lblTagsTime);
}

public void startCreateSeries(long nb) {
Expand All @@ -244,7 +258,7 @@ public void setRecentCount(String summary){
}

public void disableCreateSeries() {
lblSeries.setEnabled(false);
disableStage(chkSeries, lblSeries, lblSeriesTime);
}

public void startCreateRecent(long nb) {
Expand All @@ -256,7 +270,7 @@ public void endCreateRecent(long milliseconds) {
}

public void disableCreateRecent() {
lblRecent.setEnabled(false);
disableStage(chkRecent, lblRecent, lblRecentTime);
}

public void startCreateRated(long nb) {
Expand All @@ -268,7 +282,7 @@ public void endCreateRated(long milliseconds) {
}

public void disableCreateRated() {
lblRated.setEnabled(false);
disableStage(chkRated, lblRated, lblRatingTime);
}

public void startCreateAllbooks(long nb) {
Expand All @@ -280,7 +294,7 @@ public void endCreateAllbooks(long milliseconds) {
}

public void disableCreateAllBooks() {
lblAllbooks.setEnabled(false);
disableStage(chkAllbooks, lblAllbooks, lblAllbooksTime);
}

public void startCreateFeaturedBooks(long nb) {
Expand All @@ -292,7 +306,7 @@ public void endCreateFeaturedBooks(long milliseconds) {
}

public void disableCreateFeaturedBooks() {
lblFeaturedBooks.setEnabled(false);
disableStage(chkFeaturedBooks, lblFeaturedBooks, lblFeaturedBooksTime);
}

public void startCreateCustomCatalogs(long nb) {
Expand All @@ -304,20 +318,19 @@ public void endCreateCustomCatalogs(long milliseconds) {
}

public void disableCreateCustomCatalogs() {
lblCustomCatalogs.setEnabled(false);
disableStage(chkCustomCatalogs, lblCustomCatalogs, lblCustomCatalogsTime);
}

public void startReprocessingEpubMetadata(long nb) {
startStage(nb, lblReprocessingEpubMetadata, "info.step.reprocessingEpubMetadata");
lblReprocessingEpubMetadataTime.setText(String.format("%tT", System.currentTimeMillis()));
}

public void endReprocessingEpubMetadata(long milliseconds) {
endStage(milliseconds, lblReprocessingEpubMetadata, lblReprocessingEpubMetadataTime, chkReprocessingEpubMetadata);
}

public void disableReprocessingEpubMetadata () {
lblReprocessingEpubMetadata.setEnabled(false);
disableStage(chkReprocessingEpubMetadata, lblReprocessingEpubMetadata, lblReprocessingEpubMetadataTime);
}

public void endCreateJavascriptDatabase(long milliseconds) {
Expand All @@ -326,11 +339,10 @@ public void endCreateJavascriptDatabase(long milliseconds) {

public void startCreateJavascriptDatabase(long nb) {
startStage(nb, lblIndex, "info.step.index");
lblIndexTime.setText(String.format("%tT", System.currentTimeMillis()));
}

public void disableCreateJavascriptDatabase() {
lblIndex.setEnabled(false);
disableStage(chkIndex, lblIndex, lblIndexTime);
}

public void setCopyLibCount(String summary){
Expand All @@ -346,7 +358,7 @@ public void endCopyLibToTarget(long milliseconds) {
}

public void disableCopyLibToTarget() {
lblCopyLibToTarget.setEnabled(false);
disableStage(chkCopyLibToTarget, lblCopyLibToTarget, lblCopyLibraryTime);
}

public void setCopyCatCount(String summary){
Expand All @@ -370,10 +382,9 @@ public void endZipCatalog(long milliseconds) {
}

public void disableZipCatalog() {
lblZipCatalog.setEnabled(false);
disableStage(chkZipCatalog, lblZipCatalog, lblZipCatalogTime);
}


public void startCreatedMainCatalog() {
startStage(100,lblFinished,"info.step.done");
}
Expand Down

0 comments on commit 71db705

Please sign in to comment.