OmegaT のメニューバーにフォルダーツリー参照用のメニューを追加します。
change loading plugin to new method
use loadPlugins() and unloadPlugins()
@@ -24,12 +24,17 @@ | ||
24 | 24 | public class Core { |
25 | 25 | /** Get project instance. */ |
26 | 26 | public static IProject getProject() { |
27 | - return null; | |
27 | + throw new UnsupportedOperationException("This method is only a stub."); | |
28 | 28 | } |
29 | 29 | |
30 | 30 | /** Get main window instance. */ |
31 | 31 | public static IMainWindow getMainWindow() { |
32 | - return null; | |
32 | + throw new UnsupportedOperationException("This method is only a stub."); | |
33 | 33 | } |
34 | 34 | |
35 | + /** | |
36 | + * Any plugin can call this method for say about error on loading. | |
37 | + */ | |
38 | + public static void pluginLoadingError(String errorText) { } | |
39 | + | |
35 | 40 | } |
@@ -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: 0.1 | |
5 | +Implementation-Version: 0.1 | |
6 | +Permissions: all-permissions | |
7 | +Class-Path: lib/lib-mnemonics.jar | |
8 | +OmegaT-Plugins: | |
9 | + jp.sourceforge.users.yutang.omegat.plugin.foldermenu.FolderMenu | |
2 | 10 | OmegaT-Plugin: true |
3 | - | |
4 | -Name: org.omegat.plugin.foldermenu.FolderMenu | |
5 | -OmegaT-Plugin: base | |
\ No newline at end of file |
@@ -1,7 +1,7 @@ | ||
1 | 1 | /************************************************************************** |
2 | 2 | FolderMenu - easy access to project folders from menu. |
3 | 3 | |
4 | - Copyright (C) 2013 Yu Tang | |
4 | + Copyright (C) 2013-2014 Yu Tang | |
5 | 5 | Home page: http://sourceforge.jp/users/yu-tang/ |
6 | 6 | Support center: http://sourceforge.jp/users/yu-tang/pf/ |
7 | 7 |
@@ -21,6 +21,8 @@ | ||
21 | 21 | import org.omegat.core.events.IProjectEventListener; |
22 | 22 | import org.omegat.core.events.IProjectEventListener.PROJECT_CHANGE_TYPE.*; |
23 | 23 | import jp.sourceforge.users.yutang.omegat.plugin.foldermenu.filepreview.FilePreview; |
24 | +import org.omegat.core.Core; | |
25 | +import org.omegat.util.Log; | |
24 | 26 | |
25 | 27 | /** |
26 | 28 | * easy access to project folders from menu |
@@ -29,12 +31,23 @@ | ||
29 | 31 | */ |
30 | 32 | public class FolderMenu implements IApplicationEventListener, IProjectEventListener { |
31 | 33 | |
34 | + private static FolderMenu _this = new FolderMenu(); | |
35 | + | |
32 | 36 | private MenuManager menuManager; |
33 | 37 | |
34 | - @SuppressWarnings("LeakingThisInConstructor") | |
35 | - public FolderMenu() { | |
36 | - CoreEvents.registerApplicationEventListener(this); | |
37 | - CoreEvents.registerProjectChangeListener(this); | |
38 | + public static void loadPlugins() { | |
39 | + try { | |
40 | + // Not initialize in console mode. | |
41 | + CoreEvents.registerApplicationEventListener(_this); | |
42 | + } catch (Throwable ex) { | |
43 | + String msg = ex.getMessage(); | |
44 | + Log.logErrorRB(msg); | |
45 | + Core.pluginLoadingError(msg); | |
46 | + } | |
47 | + } | |
48 | + | |
49 | + public static void unloadPlugins() { | |
50 | + // do nothing | |
38 | 51 | } |
39 | 52 | |
40 | 53 | @Override |
@@ -41,6 +54,7 @@ | ||
41 | 54 | public void onApplicationStartup() { |
42 | 55 | menuManager = new MenuManager(); |
43 | 56 | FilePreview.init(); |
57 | + CoreEvents.registerProjectChangeListener(this); | |
44 | 58 | } |
45 | 59 | |
46 | 60 | @Override |