Skip to content

Commit

Permalink
Warning issued for batch mode without OCR languages installed
Browse files Browse the repository at this point in the history
  • Loading branch information
hbitteur committed Jan 15, 2025
1 parent 8292add commit 7f5f27d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 22 deletions.
4 changes: 4 additions & 0 deletions app/src/main/java/org/audiveris/omr/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.audiveris.omr.constant.ConstantSet;
import org.audiveris.omr.log.LogUtil;
import org.audiveris.omr.sheet.BookManager;
import org.audiveris.omr.text.tesseract.Languages;
import org.audiveris.omr.text.tesseract.TesseractOCR;
import org.audiveris.omr.ui.MainGui;
import org.audiveris.omr.ui.symbol.MusicFont;
Expand Down Expand Up @@ -249,6 +250,9 @@ public static void main (String[] args)
// Fix for issue #562: Disable this check when running in batch mode.
///Versions.considerPolling();

// Check OCR languages
Languages.getInstance().checkSupport();

// Check MusicFont is loaded
MusicFont.checkMusicFont();

Expand Down
44 changes: 24 additions & 20 deletions app/src/main/java/org/audiveris/omr/text/tesseract/Languages.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,24 +95,14 @@ public class Languages
//~ Instance fields ----------------------------------------------------------------------------

/** Component resources. */
private final ResourceMap resources;
private ResourceMap resources;

/** Remote data (languages, codes). */
private RemoteData remoteData;

/** The user interface to browse, select and install languages. */
private Selector selector;

//~ Constructors -------------------------------------------------------------------------------

/**
* Creates a new <code>Languages</code> object.
*/
public Languages ()
{
resources = Application.getInstance().getContext().getResourceMap(getClass());
}

//~ Methods ------------------------------------------------------------------------------------

//---------------//
Expand Down Expand Up @@ -148,17 +138,19 @@ public void checkSupport ()
logger.info(
"Installed OCR languages: {}",
installed.stream().collect(Collectors.joining(",")));
} else if (OMR.gui == null) {
logger.warn("*** No installed OCR languages ***");
} else {
// Prompt user
final String install = resources.getString("Check.install");
final String later = resources.getString("Check.later");
final String install = getResources().getString("Check.install");
final String later = getResources().getString("Check.later");
final Object[] options = { install, later };
final String message = resources.getString("Check.message");
final String message = getResources().getString("Check.message");

final int choice = JOptionPane.showOptionDialog(
OMR.gui.getFrame(),
message,
resources.getString("Check.title"),
getResources().getString("Check.title"),
JOptionPane.DEFAULT_OPTION,
JOptionPane.WARNING_MESSAGE,
null,
Expand Down Expand Up @@ -237,6 +229,18 @@ private RemoteData getRemoteData ()
return remoteData;
}

//--------------//
// getResources //
//--------------//
private ResourceMap getResources ()
{
if (resources == null) {
resources = Application.getInstance().getContext().getResourceMap(getClass());
}

return resources;
}

//-------------//
// getSelector //
//-------------//
Expand Down Expand Up @@ -281,7 +285,7 @@ private class DownloadRemoteTask
{
DownloadRemoteTask ()
{
super(OmrGui.getApplication(), resources.getString("downloadTask.message"));
super(OmrGui.getApplication(), getResources().getString("downloadTask.message"));
}

@Override
Expand Down Expand Up @@ -363,7 +367,7 @@ public class Selector
{
private final JDialog dialog;

private final String boxTip = resources.getString("box.shortDescription");
private final String boxTip = getResources().getString("box.shortDescription");

/**
* Creates a new <code>Selector</code> object.
Expand All @@ -379,9 +383,9 @@ public Selector ()

framePane.add(new JScrollPane(defineLayout()));

// Closing (via close button)
// Closing (via exit button)
JButton button = new JButton();
button.setName("closeButton");
button.setName("exitButton");
button.setAlignmentX(CENTER_ALIGNMENT);
button.addActionListener(this);
framePane.add(button);
Expand All @@ -396,7 +400,7 @@ public void windowClosing (WindowEvent e)
}
});

resources.injectComponents(dialog);
getResources().injectComponents(dialog);
dialog.pack();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ LanguagesFrame.title = Installation of OCR languages
downloadTask.message = Collecting languages from Tesseract site...
box.shortDescription = Tick this box to install the language on-the-fly

closeButton.text = Close
exitButton.text = Exit

Check.title = OCR languages
Check.message = <html>Your collection of languages is empty!\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ LanguagesFrame.title = Installation de langues OCR
downloadTask.message = Collecte des langues en cours
box.shortDescription = Cochez cette case pour installer la langue \u00e0 la vol\u00e9e

closeButton.text = Fermer
exitButton.text = Exit

Check.title = Langues OCR
Check.message = <html>Votre collection de langues est vide !\
Expand Down

0 comments on commit 7f5f27d

Please sign in to comment.