This repository has been archived by the owner on Jul 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from eb4j/topic/miurahr/preference-appearance
Support appearance configuration
- Loading branch information
Showing
15 changed files
with
452 additions
and
134 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* EBViewer, a dictionary viewer application. | ||
* Copyright (C) 2022 Hiroshi Miura. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.github.eb4j.ebview.core; | ||
|
||
import io.github.eb4j.ebview.data.DictionaryEntry; | ||
import io.github.eb4j.ebview.dictionary.DictionariesManager; | ||
import io.github.eb4j.ebview.gui.IMainWindow; | ||
import io.github.eb4j.ebview.gui.MainWindow; | ||
import io.github.eb4j.ebview.gui.MainWindowMenu; | ||
|
||
import javax.swing.JFrame; | ||
import javax.swing.SwingUtilities; | ||
import java.awt.Font; | ||
import java.io.File; | ||
import java.util.List; | ||
import java.util.concurrent.CopyOnWriteArrayList; | ||
|
||
public class Core { | ||
|
||
private static final List<IFontChangedListener> FONT_CHANGED_EVENT_LISTENERS = new CopyOnWriteArrayList<>(); | ||
private static DictionariesManager dictionariesManager; | ||
private static MainWindow mw; | ||
|
||
private Core() { | ||
} | ||
|
||
public static void initializeGUI(final File dictionaryDirectory, final boolean remote) { | ||
dictionariesManager = new DictionariesManager(); | ||
mw = new MainWindow(); | ||
if (dictionaryDirectory != null) { | ||
dictionariesManager.loadDictionaries(dictionaryDirectory); | ||
} | ||
if (!remote) { | ||
new MainWindowMenu(); | ||
mw.showMessage("Please add dictionaries from Dictionary menu at first."); | ||
} else { | ||
mw.showMessage("Please enter search word above input box."); | ||
} | ||
} | ||
|
||
public static void run() { | ||
mw.setVisible(true); | ||
} | ||
|
||
public static IMainWindow getMainWindow() { | ||
return mw; | ||
} | ||
public static DictionariesManager getDictionariesManager() { | ||
return dictionariesManager; | ||
} | ||
|
||
public static JFrame getApplicationFrame() { | ||
return mw.getApplicationFrame(); | ||
} | ||
|
||
/** Register listener. */ | ||
public static void registerFontChangedEventListener(final IFontChangedListener listener) { | ||
FONT_CHANGED_EVENT_LISTENERS.add(listener); | ||
} | ||
|
||
/** Unregister listener. */ | ||
public static void unregisterFontChangedEventListener(final IFontChangedListener listener) { | ||
FONT_CHANGED_EVENT_LISTENERS.remove(listener); | ||
} | ||
|
||
/** Fire event. */ | ||
public static void fireFontChanged(final Font newFont) { | ||
SwingUtilities.invokeLater(() -> { | ||
for (IFontChangedListener listener : FONT_CHANGED_EVENT_LISTENERS) { | ||
try { | ||
listener.onFontChanged(newFont); | ||
} catch (Throwable ignored) { | ||
} | ||
} | ||
}); | ||
} | ||
|
||
public static void updateDictionaryPane(final List<DictionaryEntry> entries) { | ||
mw.updateDictionaryPane(entries); | ||
} | ||
|
||
public static void moveTo(final int index) { | ||
mw.moveTo(index); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/io/github/eb4j/ebview/core/IFontChangedListener.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,25 @@ | ||
/* | ||
* EBViewer, a dictionary viewer application. | ||
* Copyright (C) 2022 Hiroshi Miura. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.github.eb4j.ebview.core; | ||
|
||
import java.awt.Font; | ||
|
||
public interface IFontChangedListener { | ||
void onFontChanged(Font newFont); | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/io/github/eb4j/ebview/dictionary/oxford/OxfordDriver.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
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
Oops, something went wrong.