From 47a6b39f7fa992a591db9ad060efef8c3916c838 Mon Sep 17 00:00:00 2001 From: noureen66 Date: Thu, 25 Apr 2024 19:39:58 +0200 Subject: [PATCH 1/3] Make The program compile --- {resource => src/resource}/about.png | Bin .../resource}/icons/application_split.png | Bin {resource => src/resource}/icons/application_xp.png | Bin {resource => src/resource}/icons/arrow_left.png | Bin {resource => src/resource}/icons/arrow_right.png | Bin {resource => src/resource}/icons/blank.gif | Bin {resource => src/resource}/icons/card_add.gif | Bin {resource => src/resource}/icons/card_edit.gif | Bin {resource => src/resource}/icons/card_flipped.gif | Bin {resource => src/resource}/icons/card_next.gif | Bin {resource => src/resource}/icons/card_prev.gif | Bin {resource => src/resource}/icons/card_reset.gif | Bin {resource => src/resource}/icons/category_add.gif | Bin {resource => src/resource}/icons/chart_curve.png | Bin {resource => src/resource}/icons/edit_copy.gif | Bin {resource => src/resource}/icons/edit_cut.gif | Bin {resource => src/resource}/icons/edit_paste.gif | Bin {resource => src/resource}/icons/file_new.gif | Bin {resource => src/resource}/icons/file_open.gif | Bin {resource => src/resource}/icons/file_save.gif | Bin {resource => src/resource}/icons/file_saveas.gif | Bin {resource => src/resource}/icons/find.gif | Bin {resource => src/resource}/icons/folder.gif | Bin {resource => src/resource}/icons/forcelearn.gif | Bin {resource => src/resource}/icons/learn.gif | Bin {resource => src/resource}/icons/main.png | Bin {resource => src/resource}/icons/pdf.gif | Bin {resource => src/resource}/icons/picture.png | Bin {resource => src/resource}/icons/picture_add.png | Bin .../resource}/icons/picture_and_text.png | Bin {resource => src/resource}/icons/picture_delete.png | Bin {resource => src/resource}/icons/remove.gif | Bin {resource => src/resource}/icons/rtf.png | Bin {resource => src/resource}/icons/settings.gif | Bin .../resource}/icons/state_forgotten.gif | Bin {resource => src/resource}/icons/state_no.gif | Bin {resource => src/resource}/icons/state_ok.gif | Bin {resource => src/resource}/icons/state_soon.gif | Bin {resource => src/resource}/icons/text.png | Bin {resource => src/resource}/icons/text_bold.png | Bin {resource => src/resource}/icons/text_italic.png | Bin {resource => src/resource}/icons/text_subscript.png | Bin .../resource}/icons/text_superscript.png | Bin {resource => src/resource}/icons/text_underline.png | Bin {resource => src/resource}/icons/tree.gif | Bin {resource => src/resource}/icons/warn.gif | Bin {resource => src/resource}/text/changes.txt | 0 {resource => src/resource}/text/langs.txt | 0 .../resource}/text/translation_cs.properties | 0 .../resource}/text/translation_da.properties | 0 .../resource}/text/translation_de.properties | 0 .../resource}/text/translation_en.properties | 0 .../resource}/text/translation_eo.properties | 0 .../resource}/text/translation_es.properties | 0 .../resource}/text/translation_fr.properties | 0 .../resource}/text/translation_ja.properties | 0 .../resource}/text/translation_nl.native | 0 .../resource}/text/translation_no.native | 0 .../resource}/text/translation_pl.properties | 0 .../resource}/text/translation_pt.native | 0 .../resource}/text/translation_sv.native | 0 .../resource}/text/translation_tr.properties | 0 .../resource}/text/translation_zh.properties | 0 63 files changed, 0 insertions(+), 0 deletions(-) rename {resource => src/resource}/about.png (100%) rename {resource => src/resource}/icons/application_split.png (100%) rename {resource => src/resource}/icons/application_xp.png (100%) rename {resource => src/resource}/icons/arrow_left.png (100%) rename {resource => src/resource}/icons/arrow_right.png (100%) rename {resource => src/resource}/icons/blank.gif (100%) rename {resource => src/resource}/icons/card_add.gif (100%) rename {resource => src/resource}/icons/card_edit.gif (100%) rename {resource => src/resource}/icons/card_flipped.gif (100%) rename {resource => src/resource}/icons/card_next.gif (100%) rename {resource => src/resource}/icons/card_prev.gif (100%) rename {resource => src/resource}/icons/card_reset.gif (100%) rename {resource => src/resource}/icons/category_add.gif (100%) rename {resource => src/resource}/icons/chart_curve.png (100%) rename {resource => src/resource}/icons/edit_copy.gif (100%) rename {resource => src/resource}/icons/edit_cut.gif (100%) rename {resource => src/resource}/icons/edit_paste.gif (100%) rename {resource => src/resource}/icons/file_new.gif (100%) rename {resource => src/resource}/icons/file_open.gif (100%) rename {resource => src/resource}/icons/file_save.gif (100%) rename {resource => src/resource}/icons/file_saveas.gif (100%) rename {resource => src/resource}/icons/find.gif (100%) rename {resource => src/resource}/icons/folder.gif (100%) rename {resource => src/resource}/icons/forcelearn.gif (100%) rename {resource => src/resource}/icons/learn.gif (100%) rename {resource => src/resource}/icons/main.png (100%) rename {resource => src/resource}/icons/pdf.gif (100%) rename {resource => src/resource}/icons/picture.png (100%) rename {resource => src/resource}/icons/picture_add.png (100%) rename {resource => src/resource}/icons/picture_and_text.png (100%) rename {resource => src/resource}/icons/picture_delete.png (100%) rename {resource => src/resource}/icons/remove.gif (100%) rename {resource => src/resource}/icons/rtf.png (100%) rename {resource => src/resource}/icons/settings.gif (100%) rename {resource => src/resource}/icons/state_forgotten.gif (100%) rename {resource => src/resource}/icons/state_no.gif (100%) rename {resource => src/resource}/icons/state_ok.gif (100%) rename {resource => src/resource}/icons/state_soon.gif (100%) rename {resource => src/resource}/icons/text.png (100%) rename {resource => src/resource}/icons/text_bold.png (100%) rename {resource => src/resource}/icons/text_italic.png (100%) rename {resource => src/resource}/icons/text_subscript.png (100%) rename {resource => src/resource}/icons/text_superscript.png (100%) rename {resource => src/resource}/icons/text_underline.png (100%) rename {resource => src/resource}/icons/tree.gif (100%) rename {resource => src/resource}/icons/warn.gif (100%) rename {resource => src/resource}/text/changes.txt (100%) rename {resource => src/resource}/text/langs.txt (100%) rename {resource => src/resource}/text/translation_cs.properties (100%) rename {resource => src/resource}/text/translation_da.properties (100%) rename {resource => src/resource}/text/translation_de.properties (100%) rename {resource => src/resource}/text/translation_en.properties (100%) rename {resource => src/resource}/text/translation_eo.properties (100%) rename {resource => src/resource}/text/translation_es.properties (100%) rename {resource => src/resource}/text/translation_fr.properties (100%) rename {resource => src/resource}/text/translation_ja.properties (100%) rename {resource => src/resource}/text/translation_nl.native (100%) rename {resource => src/resource}/text/translation_no.native (100%) rename {resource => src/resource}/text/translation_pl.properties (100%) rename {resource => src/resource}/text/translation_pt.native (100%) rename {resource => src/resource}/text/translation_sv.native (100%) rename {resource => src/resource}/text/translation_tr.properties (100%) rename {resource => src/resource}/text/translation_zh.properties (100%) diff --git a/resource/about.png b/src/resource/about.png similarity index 100% rename from resource/about.png rename to src/resource/about.png diff --git a/resource/icons/application_split.png b/src/resource/icons/application_split.png similarity index 100% rename from resource/icons/application_split.png rename to src/resource/icons/application_split.png diff --git a/resource/icons/application_xp.png b/src/resource/icons/application_xp.png similarity index 100% rename from resource/icons/application_xp.png rename to src/resource/icons/application_xp.png diff --git a/resource/icons/arrow_left.png b/src/resource/icons/arrow_left.png similarity index 100% rename from resource/icons/arrow_left.png rename to src/resource/icons/arrow_left.png diff --git a/resource/icons/arrow_right.png b/src/resource/icons/arrow_right.png similarity index 100% rename from resource/icons/arrow_right.png rename to src/resource/icons/arrow_right.png diff --git a/resource/icons/blank.gif b/src/resource/icons/blank.gif similarity index 100% rename from resource/icons/blank.gif rename to src/resource/icons/blank.gif diff --git a/resource/icons/card_add.gif b/src/resource/icons/card_add.gif similarity index 100% rename from resource/icons/card_add.gif rename to src/resource/icons/card_add.gif diff --git a/resource/icons/card_edit.gif b/src/resource/icons/card_edit.gif similarity index 100% rename from resource/icons/card_edit.gif rename to src/resource/icons/card_edit.gif diff --git a/resource/icons/card_flipped.gif b/src/resource/icons/card_flipped.gif similarity index 100% rename from resource/icons/card_flipped.gif rename to src/resource/icons/card_flipped.gif diff --git a/resource/icons/card_next.gif b/src/resource/icons/card_next.gif similarity index 100% rename from resource/icons/card_next.gif rename to src/resource/icons/card_next.gif diff --git a/resource/icons/card_prev.gif b/src/resource/icons/card_prev.gif similarity index 100% rename from resource/icons/card_prev.gif rename to src/resource/icons/card_prev.gif diff --git a/resource/icons/card_reset.gif b/src/resource/icons/card_reset.gif similarity index 100% rename from resource/icons/card_reset.gif rename to src/resource/icons/card_reset.gif diff --git a/resource/icons/category_add.gif b/src/resource/icons/category_add.gif similarity index 100% rename from resource/icons/category_add.gif rename to src/resource/icons/category_add.gif diff --git a/resource/icons/chart_curve.png b/src/resource/icons/chart_curve.png similarity index 100% rename from resource/icons/chart_curve.png rename to src/resource/icons/chart_curve.png diff --git a/resource/icons/edit_copy.gif b/src/resource/icons/edit_copy.gif similarity index 100% rename from resource/icons/edit_copy.gif rename to src/resource/icons/edit_copy.gif diff --git a/resource/icons/edit_cut.gif b/src/resource/icons/edit_cut.gif similarity index 100% rename from resource/icons/edit_cut.gif rename to src/resource/icons/edit_cut.gif diff --git a/resource/icons/edit_paste.gif b/src/resource/icons/edit_paste.gif similarity index 100% rename from resource/icons/edit_paste.gif rename to src/resource/icons/edit_paste.gif diff --git a/resource/icons/file_new.gif b/src/resource/icons/file_new.gif similarity index 100% rename from resource/icons/file_new.gif rename to src/resource/icons/file_new.gif diff --git a/resource/icons/file_open.gif b/src/resource/icons/file_open.gif similarity index 100% rename from resource/icons/file_open.gif rename to src/resource/icons/file_open.gif diff --git a/resource/icons/file_save.gif b/src/resource/icons/file_save.gif similarity index 100% rename from resource/icons/file_save.gif rename to src/resource/icons/file_save.gif diff --git a/resource/icons/file_saveas.gif b/src/resource/icons/file_saveas.gif similarity index 100% rename from resource/icons/file_saveas.gif rename to src/resource/icons/file_saveas.gif diff --git a/resource/icons/find.gif b/src/resource/icons/find.gif similarity index 100% rename from resource/icons/find.gif rename to src/resource/icons/find.gif diff --git a/resource/icons/folder.gif b/src/resource/icons/folder.gif similarity index 100% rename from resource/icons/folder.gif rename to src/resource/icons/folder.gif diff --git a/resource/icons/forcelearn.gif b/src/resource/icons/forcelearn.gif similarity index 100% rename from resource/icons/forcelearn.gif rename to src/resource/icons/forcelearn.gif diff --git a/resource/icons/learn.gif b/src/resource/icons/learn.gif similarity index 100% rename from resource/icons/learn.gif rename to src/resource/icons/learn.gif diff --git a/resource/icons/main.png b/src/resource/icons/main.png similarity index 100% rename from resource/icons/main.png rename to src/resource/icons/main.png diff --git a/resource/icons/pdf.gif b/src/resource/icons/pdf.gif similarity index 100% rename from resource/icons/pdf.gif rename to src/resource/icons/pdf.gif diff --git a/resource/icons/picture.png b/src/resource/icons/picture.png similarity index 100% rename from resource/icons/picture.png rename to src/resource/icons/picture.png diff --git a/resource/icons/picture_add.png b/src/resource/icons/picture_add.png similarity index 100% rename from resource/icons/picture_add.png rename to src/resource/icons/picture_add.png diff --git a/resource/icons/picture_and_text.png b/src/resource/icons/picture_and_text.png similarity index 100% rename from resource/icons/picture_and_text.png rename to src/resource/icons/picture_and_text.png diff --git a/resource/icons/picture_delete.png b/src/resource/icons/picture_delete.png similarity index 100% rename from resource/icons/picture_delete.png rename to src/resource/icons/picture_delete.png diff --git a/resource/icons/remove.gif b/src/resource/icons/remove.gif similarity index 100% rename from resource/icons/remove.gif rename to src/resource/icons/remove.gif diff --git a/resource/icons/rtf.png b/src/resource/icons/rtf.png similarity index 100% rename from resource/icons/rtf.png rename to src/resource/icons/rtf.png diff --git a/resource/icons/settings.gif b/src/resource/icons/settings.gif similarity index 100% rename from resource/icons/settings.gif rename to src/resource/icons/settings.gif diff --git a/resource/icons/state_forgotten.gif b/src/resource/icons/state_forgotten.gif similarity index 100% rename from resource/icons/state_forgotten.gif rename to src/resource/icons/state_forgotten.gif diff --git a/resource/icons/state_no.gif b/src/resource/icons/state_no.gif similarity index 100% rename from resource/icons/state_no.gif rename to src/resource/icons/state_no.gif diff --git a/resource/icons/state_ok.gif b/src/resource/icons/state_ok.gif similarity index 100% rename from resource/icons/state_ok.gif rename to src/resource/icons/state_ok.gif diff --git a/resource/icons/state_soon.gif b/src/resource/icons/state_soon.gif similarity index 100% rename from resource/icons/state_soon.gif rename to src/resource/icons/state_soon.gif diff --git a/resource/icons/text.png b/src/resource/icons/text.png similarity index 100% rename from resource/icons/text.png rename to src/resource/icons/text.png diff --git a/resource/icons/text_bold.png b/src/resource/icons/text_bold.png similarity index 100% rename from resource/icons/text_bold.png rename to src/resource/icons/text_bold.png diff --git a/resource/icons/text_italic.png b/src/resource/icons/text_italic.png similarity index 100% rename from resource/icons/text_italic.png rename to src/resource/icons/text_italic.png diff --git a/resource/icons/text_subscript.png b/src/resource/icons/text_subscript.png similarity index 100% rename from resource/icons/text_subscript.png rename to src/resource/icons/text_subscript.png diff --git a/resource/icons/text_superscript.png b/src/resource/icons/text_superscript.png similarity index 100% rename from resource/icons/text_superscript.png rename to src/resource/icons/text_superscript.png diff --git a/resource/icons/text_underline.png b/src/resource/icons/text_underline.png similarity index 100% rename from resource/icons/text_underline.png rename to src/resource/icons/text_underline.png diff --git a/resource/icons/tree.gif b/src/resource/icons/tree.gif similarity index 100% rename from resource/icons/tree.gif rename to src/resource/icons/tree.gif diff --git a/resource/icons/warn.gif b/src/resource/icons/warn.gif similarity index 100% rename from resource/icons/warn.gif rename to src/resource/icons/warn.gif diff --git a/resource/text/changes.txt b/src/resource/text/changes.txt similarity index 100% rename from resource/text/changes.txt rename to src/resource/text/changes.txt diff --git a/resource/text/langs.txt b/src/resource/text/langs.txt similarity index 100% rename from resource/text/langs.txt rename to src/resource/text/langs.txt diff --git a/resource/text/translation_cs.properties b/src/resource/text/translation_cs.properties similarity index 100% rename from resource/text/translation_cs.properties rename to src/resource/text/translation_cs.properties diff --git a/resource/text/translation_da.properties b/src/resource/text/translation_da.properties similarity index 100% rename from resource/text/translation_da.properties rename to src/resource/text/translation_da.properties diff --git a/resource/text/translation_de.properties b/src/resource/text/translation_de.properties similarity index 100% rename from resource/text/translation_de.properties rename to src/resource/text/translation_de.properties diff --git a/resource/text/translation_en.properties b/src/resource/text/translation_en.properties similarity index 100% rename from resource/text/translation_en.properties rename to src/resource/text/translation_en.properties diff --git a/resource/text/translation_eo.properties b/src/resource/text/translation_eo.properties similarity index 100% rename from resource/text/translation_eo.properties rename to src/resource/text/translation_eo.properties diff --git a/resource/text/translation_es.properties b/src/resource/text/translation_es.properties similarity index 100% rename from resource/text/translation_es.properties rename to src/resource/text/translation_es.properties diff --git a/resource/text/translation_fr.properties b/src/resource/text/translation_fr.properties similarity index 100% rename from resource/text/translation_fr.properties rename to src/resource/text/translation_fr.properties diff --git a/resource/text/translation_ja.properties b/src/resource/text/translation_ja.properties similarity index 100% rename from resource/text/translation_ja.properties rename to src/resource/text/translation_ja.properties diff --git a/resource/text/translation_nl.native b/src/resource/text/translation_nl.native similarity index 100% rename from resource/text/translation_nl.native rename to src/resource/text/translation_nl.native diff --git a/resource/text/translation_no.native b/src/resource/text/translation_no.native similarity index 100% rename from resource/text/translation_no.native rename to src/resource/text/translation_no.native diff --git a/resource/text/translation_pl.properties b/src/resource/text/translation_pl.properties similarity index 100% rename from resource/text/translation_pl.properties rename to src/resource/text/translation_pl.properties diff --git a/resource/text/translation_pt.native b/src/resource/text/translation_pt.native similarity index 100% rename from resource/text/translation_pt.native rename to src/resource/text/translation_pt.native diff --git a/resource/text/translation_sv.native b/src/resource/text/translation_sv.native similarity index 100% rename from resource/text/translation_sv.native rename to src/resource/text/translation_sv.native diff --git a/resource/text/translation_tr.properties b/src/resource/text/translation_tr.properties similarity index 100% rename from resource/text/translation_tr.properties rename to src/resource/text/translation_tr.properties diff --git a/resource/text/translation_zh.properties b/src/resource/text/translation_zh.properties similarity index 100% rename from resource/text/translation_zh.properties rename to src/resource/text/translation_zh.properties From 449903a3946d242531c3874bd7871ffb0023e13d Mon Sep 17 00:00:00 2001 From: basmala Date: Thu, 25 Apr 2024 19:57:40 +0200 Subject: [PATCH 2/3] testing the main --- src/jmemorize/core/Main.java | 415 +++++++++++++++-------------------- 1 file changed, 179 insertions(+), 236 deletions(-) diff --git a/src/jmemorize/core/Main.java b/src/jmemorize/core/Main.java index 2c6f185..1fbe127 100644 --- a/src/jmemorize/core/Main.java +++ b/src/jmemorize/core/Main.java @@ -18,6 +18,7 @@ */ package jmemorize.core; +/*basmala is testing */ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -54,408 +55,366 @@ * * @author djemili */ -public class Main extends Observable implements LearnSessionProvider, - LessonProvider, CategoryObserver -{ - public interface ProgramEndObserver - { +public class Main extends Observable implements LearnSessionProvider, + LessonProvider, CategoryObserver { + public interface ProgramEndObserver { /** - * This method is notified when the program ends. + * This method is notified when the program ends. */ public void onProgramEnd(); } - - public static final Properties PROPERTIES = new Properties(); - public static final Preferences USER_PREFS = - Preferences.userRoot().node("de/riad/jmemorize"); //$NON-NLS-1$ - private static final String PROPERTIES_PATH = - "/resource/jMemorize.properties"; //$NON-NLS-1$ + public static final Properties PROPERTIES = new Properties(); + public static final Preferences USER_PREFS = Preferences.userRoot().node("de/riad/jmemorize"); //$NON-NLS-1$ - public static final File STATS_FILE = - new File(System.getProperty("user.home")+"/.jmemorize-stats.xml"); //$NON-NLS-1$ //$NON-NLS-2$ + private static final String PROPERTIES_PATH = "/resource/jMemorize.properties"; //$NON-NLS-1$ - private RecentItems m_recentFiles = - new RecentItems(5, USER_PREFS.node("recent.files")); //$NON-NLS-1$ + public static final File STATS_FILE = new File(System.getProperty("user.home") + "/.jmemorize-stats.xml"); //$NON-NLS-1$ //$NON-NLS-2$ - private static Main m_instance; - - private MainFrame m_frame; - private Lesson m_lesson; - private LearnSettings m_learnSettings; - private LearnHistory m_globalLearnHistory; - private int m_runningSessions = 0; + private RecentItems m_recentFiles = new RecentItems(5, USER_PREFS.node("recent.files")); //$NON-NLS-1$ + + private static Main m_instance; + + private MainFrame m_frame; + private Lesson m_lesson; + private LearnSettings m_learnSettings; + private LearnHistory m_globalLearnHistory; + private int m_runningSessions = 0; // observers - private List m_lessonObservers = - new LinkedList(); - private List m_learnSessionObservers = - new LinkedList(); - private List m_programEndObservers = - new LinkedList(); - + private List m_lessonObservers = new LinkedList(); + private List m_learnSessionObservers = new LinkedList(); + private List m_programEndObservers = new LinkedList(); + // simple logging support - private static final Logger logger = Logger.getLogger("jmemorize"); - private static Throwable m_lastLoggedThrowable; - + private static final Logger logger = Logger.getLogger("jmemorize"); + private static Throwable m_lastLoggedThrowable; + /** * @return the singleton instance of Main. */ - public static Main getInstance() - { - if (m_instance == null) - { + public static Main getInstance() { + if (m_instance == null) { m_instance = new Main(); } - + return m_instance; } - - public static Date getNow() - { + + public static Date getNow() { return new Date(); } - - public static Date getTomorrow() - { + + public static Date getTomorrow() { return new Date(new Date().getTime() + Card.ONE_DAY); } - - /* (non-Javadoc) + + /* + * (non-Javadoc) * Declared in jmemorize.core.LessonProvider */ - public void createNewLesson() - { + public void createNewLesson() { ImageRepository.getInstance().clear(); setLesson(new Lesson(false)); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see jmemorize.core.LessonProvider */ - public void setLesson(Lesson lesson) - { + public void setLesson(Lesson lesson) { Lesson oldLesson = m_lesson; m_lesson = lesson; - - if (oldLesson != null) - { + + if (oldLesson != null) { fireLessonClosed(oldLesson); } - + if (m_frame != null) // TODO remove call { m_frame.setLesson(m_lesson); } - + fireLessonLoaded(m_lesson); } - /* (non-Javadoc) + /* + * (non-Javadoc) * Declared in jmemorize.core.LessonProvider */ - public void loadLesson(File file) throws IOException - { - try - { + public void loadLesson(File file) throws IOException { + try { ImageRepository.getInstance().clear(); - + Lesson lesson = new Lesson(false); XmlBuilder.loadFromXMLFile(file, lesson); lesson.setFile(file); lesson.setCanSave(false); m_recentFiles.push(file.getAbsolutePath()); - + setLesson(lesson); - //startExpirationTimer(); TODO expiration timer - } - catch (Exception e) - { + // startExpirationTimer(); TODO expiration timer + } catch (Exception e) { m_recentFiles.remove(file.getAbsolutePath()); logThrowable("Error loading lesson", e); throw new IOException(e.getMessage()); } } - - /* (non-Javadoc) + + /* + * (non-Javadoc) * Declared in jmemorize.core.LessonProvider */ - public void saveLesson(Lesson lesson, File file) throws IOException - { - try - { - File tempFile = new File(file.getAbsolutePath()+"~"); //$NON-NLS-1$ + public void saveLesson(Lesson lesson, File file) throws IOException { + try { + File tempFile = new File(file.getAbsolutePath() + "~"); //$NON-NLS-1$ XmlBuilder.saveAsXMLFile(tempFile, lesson); - + file.delete(); copyFile(tempFile, file); - + lesson.setFile(file); // note: sets file only if no exception lesson.setCanSave(false); m_recentFiles.push(file.getAbsolutePath()); - - for (LessonObserver observer : m_lessonObservers) - { + + for (LessonObserver observer : m_lessonObservers) { observer.lessonSaved(lesson); } - } - catch (Throwable t) - { + } catch (Throwable t) { throw new IOException(t.getMessage()); } } - - /* (non-Javadoc) + + /* + * (non-Javadoc) * Declared in jmemorize.core.LessonProvider */ - public Lesson getLesson() - { + public Lesson getLesson() { return m_lesson; } - /* (non-Javadoc) + /* + * (non-Javadoc) * Declared in jmemorize.core.LessonProvider */ - public RecentItems getRecentLessonFiles() - { + public RecentItems getRecentLessonFiles() { return m_recentFiles; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see jmemorize.core.LessonProvider */ - public void addLessonObserver(LessonObserver observer) - { + public void addLessonObserver(LessonObserver observer) { m_lessonObservers.add(observer); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see jmemorize.core.LessonProvider */ - public void removeLessonObserver(LessonObserver observer) - { + public void removeLessonObserver(LessonObserver observer) { m_lessonObservers.remove(observer); } - + /** * Adds a ProgramEndObserver that will be fired when this program closes. * * @param observer */ - public void addProgramEndObserver(ProgramEndObserver observer) - { + public void addProgramEndObserver(ProgramEndObserver observer) { m_programEndObservers.add(observer); } - + /** * @see #addProgramEndObserver(jmemorize.core.Main.ProgramEndObserver) */ - public void removeProgramEndObserver(ProgramEndObserver observer) - { + public void removeProgramEndObserver(ProgramEndObserver observer) { m_programEndObservers.remove(observer); } - + /** * Notifies all program end observers and exists the application. */ - public void exit() - { - for (ProgramEndObserver observer : m_programEndObservers) - { + public void exit() { + for (ProgramEndObserver observer : m_programEndObservers) { observer.onProgramEnd(); } - + System.exit(0); } - /* (non-Javadoc) + /* + * (non-Javadoc) * Declared in jmemorize.core.LearnSessionProvider */ - public void startLearnSession(LearnSettings settings, List selectedCards, - Category category,boolean learnUnlearned, boolean learnExpired) - { - LearnSession session = new DefaultLearnSession(category, settings, - selectedCards, learnUnlearned, learnExpired, this); - + public void startLearnSession(LearnSettings settings, List selectedCards, + Category category, boolean learnUnlearned, boolean learnExpired) { + LearnSession session = new DefaultLearnSession(category, settings, + selectedCards, learnUnlearned, learnExpired, this); + m_runningSessions++; - - for (LearnSessionObserver observer : m_learnSessionObservers) - { + + for (LearnSessionObserver observer : m_learnSessionObservers) { observer.sessionStarted(session); } - + // this needs to be called after notifying the observers so that they // don't miss the first card session.startLearning(); } - /* (non-Javadoc) + /* + * (non-Javadoc) * Declared in jmemorize.core.LearnSessionProvider */ - public void sessionEnded(LearnSession session) - { + public void sessionEnded(LearnSession session) { m_runningSessions--; - - if (session.isRelevant()) - { + + if (session.isRelevant()) { LearnHistory history = m_lesson.getLearnHistory(); history.addSummary( - session.getStart(), - session.getEnd(), - session.getPassedCards().size(), - session.getFailedCards().size(), - session.getSkippedCards().size(), - session.getRelearnedCards().size()); + session.getStart(), + session.getEnd(), + session.getPassedCards().size(), + session.getFailedCards().size(), + session.getSkippedCards().size(), + session.getRelearnedCards().size()); } - - for (LearnSessionObserver observer : m_learnSessionObservers) - { + + for (LearnSessionObserver observer : m_learnSessionObservers) { observer.sessionEnded(session); } } - /* (non-Javadoc) + /* + * (non-Javadoc) * Declared in jmemorize.core.LearnSessionProvider */ - public boolean isSessionRunning() - { + public boolean isSessionRunning() { return m_runningSessions > 0; } - /* (non-Javadoc) + /* + * (non-Javadoc) * Declared in jmemorize.core.LearnSessionProvider */ - public void addLearnSessionObserver(LearnSessionObserver observer) - { + public void addLearnSessionObserver(LearnSessionObserver observer) { m_learnSessionObservers.add(observer); } - /* (non-Javadoc) + /* + * (non-Javadoc) * Declared in jmemorize.core.LearnSessionProvider */ - public void removeLearnSessionObserver(LearnSessionObserver observer) - { + public void removeLearnSessionObserver(LearnSessionObserver observer) { m_learnSessionObservers.remove(observer); } /** * @return the main frame. */ - public MainFrame getFrame() - { + public MainFrame getFrame() { return m_frame; } /** * @return currently loaded learn strategy. */ - public LearnSettings getLearnSettings() - { + public LearnSettings getLearnSettings() { return m_learnSettings; } - + /** * @return the statistics for jMemorize. */ - public LearnHistory getGlobalLearnHistory() - { + public LearnHistory getGlobalLearnHistory() { return m_globalLearnHistory; } - /* (non-Javadoc) + /* + * (non-Javadoc) * Declared in jmemorize.core.CategoryObserver */ - public void onCardEvent(int type, Card card, Category category, int deck) - { + public void onCardEvent(int type, Card card, Category category, int deck) { fireLessonModified(m_lesson); } - /* (non-Javadoc) + /* + * (non-Javadoc) * Declared in jmemorize.core.CategoryObserver */ - public void onCategoryEvent(int type, Category category) - { - fireLessonModified(m_lesson); + public void onCategoryEvent(int type, Category category) { + fireLessonModified(m_lesson); } - public Main() - { + public Main() { InputStream propertyStream = null; - - try - { + + try { // TODO - make this adjustable // Note that the limit might not be enough for finer. Handler fh = new FileHandler("%t/jmemorize%g.log", 10000, 3); - fh.setLevel(Level.WARNING); + fh.setLevel(Level.WARNING); fh.setFormatter(new SimpleFormatter()); logger.addHandler(fh); URL resource = getClass().getResource(PROPERTIES_PATH); - -// PROPERTIES.load(resource.openStream()); - - if (resource != null) - { + + // PROPERTIES.load(resource.openStream()); + + if (resource != null) { propertyStream = resource.openStream(); PROPERTIES.load(propertyStream); } - } - catch (Exception e) - { + } catch (Exception e) { e.printStackTrace(); logThrowable("Initialization problem", e); - } - finally - { - try - { + } finally { + try { if (propertyStream != null) propertyStream.close(); - } - catch (IOException e) - { + } catch (IOException e) { e.printStackTrace(); logThrowable("Initialization problem", e); } } } - + /** * @return true if this is the devel version running. - * false if it is the release version. This can be used for - * new and expiremental features. + * false if it is the release version. This can be used for + * new and expiremental features. */ - public static boolean isDevel() - { + public static boolean isDevel() { String property = PROPERTIES.getProperty("project.release"); //$NON-NLS-1$ return !Boolean.valueOf(property).booleanValue(); } - + /* * Logging utilities */ - public static Logger getLogger() - { + public static Logger getLogger() { return logger; } - + // note that we cache the throwable so that we only log it the first time. // This allows us to put a catch all call to this function in ErrorDialog. // Ideally, exceptions should be logged where they are first caught, because // we have more information about the exception there. - public static void logThrowable(String msg, Throwable t) - { - if (t != null && m_lastLoggedThrowable != t) - { + public static void logThrowable(String msg, Throwable t) { + if (t != null && m_lastLoggedThrowable != t) { m_lastLoggedThrowable = t; logger.severe(msg); - + // TODO, consider writing these to the log file only once? - String java = System.getProperty("java.version"); - String os = System.getProperty("os.name"); + String java = System.getProperty("java.version"); + String os = System.getProperty("os.name"); String version = Main.PROPERTIES.getProperty("project.version"); String buildId = Main.PROPERTIES.getProperty("buildId"); - String txt = "Ver "+ version +" ("+ buildId +") - Java "+ java +" , OS "+ os; + String txt = "Ver " + version + " (" + buildId + ") - Java " + java + " , OS " + os; logger.severe(txt); StringWriter strWriter = new StringWriter(); @@ -465,78 +424,63 @@ public static void logThrowable(String msg, Throwable t) } } - public static void clearLastThrowable() - { + public static void clearLastThrowable() { m_lastLoggedThrowable = null; } - - private static void copyFile(File in, File out) throws IOException - { + + private static void copyFile(File in, File out) throws IOException { FileChannel sourceChannel = null; FileChannel destinationChannel = null; - try - { + try { sourceChannel = new FileInputStream(in).getChannel(); destinationChannel = new FileOutputStream(out).getChannel(); - + sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel); - } - finally - { + } finally { if (sourceChannel != null) sourceChannel.close(); - + if (destinationChannel != null) destinationChannel.close(); } } - private void run(File file) - { + private void run(File file) { createNewLesson(); startStats(); - + m_frame = new MainFrame(); m_learnSettings = Settings.loadStrategy(m_frame); m_frame.setVisible(true); - - if (file != null) - { + + if (file != null) { m_frame.loadLesson(file); } } - private void startStats() - { + private void startStats() { m_globalLearnHistory = new LearnHistory(STATS_FILE); } - - private void fireLessonLoaded(Lesson lesson) - { + + private void fireLessonLoaded(Lesson lesson) { lesson.getRootCategory().addObserver(this); - - for (LessonObserver observer : m_lessonObservers) - { + + for (LessonObserver observer : m_lessonObservers) { observer.lessonLoaded(lesson); } } - - private void fireLessonClosed(Lesson lesson) - { + + private void fireLessonClosed(Lesson lesson) { lesson.getRootCategory().removeObserver(this); - - for (LessonObserver observer : m_lessonObservers) - { + + for (LessonObserver observer : m_lessonObservers) { observer.lessonClosed(lesson); } } - private void fireLessonModified(Lesson lesson) - { - if (lesson.canSave()) - { - for (LessonObserver observer : m_lessonObservers) - { + private void fireLessonModified(Lesson lesson) { + if (lesson.canSave()) { + for (LessonObserver observer : m_lessonObservers) { observer.lessonModified(lesson); } } @@ -545,9 +489,8 @@ private void fireLessonModified(Lesson lesson) /** * @param args the command line arguments */ - public static void main(String args[]) - { + public static void main(String args[]) { File file = args.length >= 1 ? new File(args[0]) : null; - Main.getInstance().run(file); + Main.getInstance().run(file); } } From 46781f4a26ba88b1d77bddf3ccd1c45742dea271 Mon Sep 17 00:00:00 2001 From: Eman030 <168083776+Eman030@users.noreply.github.com> Date: Thu, 25 Apr 2024 20:09:37 +0200 Subject: [PATCH 3/3] Update Main.java --- src/jmemorize/core/Main.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/jmemorize/core/Main.java b/src/jmemorize/core/Main.java index 1fbe127..53880a7 100644 --- a/src/jmemorize/core/Main.java +++ b/src/jmemorize/core/Main.java @@ -19,6 +19,7 @@ package jmemorize.core; /*basmala is testing */ +/*Eman is testing */ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream;