OmegaT の背景に画像を表示します。
change plug-in registration
| @@ -1,5 +1,10 @@ | ||
| 1 | 1 | Manifest-Version: 1.0 |
| 2 | +Main-Class: org.omegat.Main | |
| 3 | +License: GNU Public License version 3 or later | |
| 4 | +Specification-Version: 1.0 | |
| 5 | +Implementation-Version: 0.2 | |
| 6 | +Permissions: all-permissions | |
| 7 | +Class-Path: lib/lib-mnemonics.jar | |
| 8 | +OmegaT-Plugins: | |
| 9 | + jp.sourceforge.users.yutang.omegat.plugin.moenizer.Moenizer | |
| 2 | 10 | OmegaT-Plugin: true |
| 3 | - | |
| 4 | -Name: org.omegat.plugin.moenizer.Moenizer | |
| 5 | -OmegaT-Plugin: base | |
| \ No newline at end of file |
| @@ -17,19 +17,17 @@ | ||
| 17 | 17 | package jp.sourceforge.users.yutang.omegat.plugin.moenizer; |
| 18 | 18 | |
| 19 | 19 | import java.awt.image.BufferedImage; |
| 20 | -import java.io.IOException; | |
| 21 | 20 | import java.util.concurrent.TimeUnit; |
| 22 | -import java.util.logging.Level; | |
| 23 | -import java.util.logging.Logger; | |
| 24 | 21 | import javax.swing.SwingUtilities; |
| 25 | 22 | import javax.swing.SwingWorker; |
| 23 | + | |
| 26 | 24 | import org.omegat.core.CoreEvents; |
| 27 | 25 | import org.omegat.core.events.IApplicationEventListener; |
| 28 | 26 | import org.omegat.core.events.IProjectEventListener; |
| 29 | 27 | import jp.sourceforge.users.yutang.omegat.plugin.moenizer.imageloader.IImageLoader; |
| 30 | 28 | import jp.sourceforge.users.yutang.omegat.plugin.moenizer.imageloader.ImageLoader; |
| 29 | +import org.omegat.core.Core; | |
| 31 | 30 | import org.omegat.util.Log; |
| 32 | -import org.omegat.util.StaticUtils; | |
| 33 | 31 | |
| 34 | 32 | /** |
| 35 | 33 | * allow to set background image |
| @@ -38,26 +36,43 @@ | ||
| 38 | 36 | */ |
| 39 | 37 | public class Moenizer implements IApplicationEventListener, IProjectEventListener { |
| 40 | 38 | |
| 39 | + private static boolean instantiated = false; | |
| 40 | + | |
| 41 | 41 | private IImageLoader imageLoader; |
| 42 | 42 | private MoeUI ui; |
| 43 | - | |
| 44 | - | |
| 45 | - @SuppressWarnings("LeakingThisInConstructor") | |
| 46 | - public Moenizer() { | |
| 47 | - CoreEvents.registerApplicationEventListener(this); | |
| 48 | - CoreEvents.registerProjectChangeListener(this); | |
| 49 | 43 | |
| 50 | - ui = null; | |
| 51 | - imageLoader = ImageLoader.getInstance(); | |
| 52 | - // この時点ではまだウィンドウがインスタンス化されていないので、 | |
| 53 | - // ウィンドウに対する処理は少し待つ。 | |
| 54 | - | |
| 55 | - (new SlideShow()).execute(); | |
| 44 | + public static void loadPlugins() { | |
| 45 | + try { | |
| 46 | + // Not initialize in console mode | |
| 47 | + if (!instantiated) { | |
| 48 | + CoreEvents.registerApplicationEventListener(new Moenizer()); | |
| 49 | + instantiated = true; | |
| 50 | + } else { | |
| 51 | + throw new RuntimeException("Moenizer plugin could be instantiated only once."); | |
| 52 | + } | |
| 53 | + } catch (Throwable ex) { | |
| 54 | + String msg = ex.getMessage(); | |
| 55 | + Log.logErrorRB(msg); | |
| 56 | + Core.pluginLoadingError(msg); | |
| 57 | + } | |
| 58 | + } | |
| 59 | + | |
| 60 | + public static void unloadPlugins() { | |
| 61 | + // do nothing | |
| 56 | 62 | } |
| 57 | 63 | |
| 58 | 64 | @Override |
| 59 | 65 | public void onApplicationStartup() { |
| 60 | 66 | try { |
| 67 | + CoreEvents.registerProjectChangeListener(this); | |
| 68 | + | |
| 69 | + ui = null; | |
| 70 | + imageLoader = ImageLoader.getInstance(); | |
| 71 | + // この時点ではまだウィンドウがインスタンス化されていないので、 | |
| 72 | + // ウィンドウに対する処理は少し待つ。 | |
| 73 | + | |
| 74 | + (new SlideShow()).execute(); | |
| 75 | + | |
| 61 | 76 | ui = MoeUI.getMoeUI(); |
| 62 | 77 | |
| 63 | 78 | // この時点でコンポーネントの透過設定をしても反映されない(タイミング?)。 |