OmegaT の背景に画像を表示します。
設定ダイアログを追加
@@ -22,6 +22,7 @@ | ||
22 | 22 | import javax.swing.JMenu; |
23 | 23 | import javax.swing.JMenuItem; |
24 | 24 | import org.omegat.core.Core; |
25 | +import org.omegat.util.gui.UIThreadsUtil; | |
25 | 26 | import org.omegat.util.Log; |
26 | 27 | import org.openide.awt.Mnemonics; |
27 | 28 |
@@ -66,9 +67,9 @@ | ||
66 | 67 | // Logging user action |
67 | 68 | Log.logInfoRB("LOG_MENU_CLICK", ACTION_COMMAND_NAME); |
68 | 69 | |
69 | - // run action | |
70 | + // execute action | |
70 | 71 | if (runner != null) { |
71 | - runner.run(); | |
72 | + UIThreadsUtil.executeInSwingThread(runner); | |
72 | 73 | } |
73 | 74 | } |
74 | 75 |
@@ -105,7 +105,7 @@ | ||
105 | 105 | return ret != null ? (Boolean) ret : defaultValue; |
106 | 106 | } |
107 | 107 | |
108 | - public Set<ConfigObject> getProviderConfigs() { | |
108 | + public Set<ConfigObject> getSortedConfigs() { | |
109 | 109 | return sortedConfigs; |
110 | 110 | } |
111 | 111 |
@@ -30,8 +30,14 @@ | ||
30 | 30 | MOENIZER_MENU_LABEL, |
31 | 31 | MOENIZER_MENU_TOOLTIP, |
32 | 32 | |
33 | + // settings dialog | |
34 | + DIALOG_TITLE, | |
35 | + | |
33 | 36 | // for error |
34 | - ERROR_FILE_HAS_NO_ASSOC | |
37 | + ERROR_FILE_HAS_NO_ASSOC, | |
38 | + | |
39 | + // version | |
40 | + CURRENT_VERSION | |
35 | 41 | } |
36 | 42 | |
37 | 43 | private static final ResourceBundle bundle; |
@@ -16,6 +16,8 @@ | ||
16 | 16 | |
17 | 17 | package jp.sourceforge.users.yutang.omegat.plugin.moenizer; |
18 | 18 | |
19 | +import groovy.util.ConfigObject; | |
20 | +import java.util.Set; | |
19 | 21 | import javax.swing.SwingUtilities; |
20 | 22 | import org.omegat.core.Core; |
21 | 23 | import org.omegat.core.CoreEvents; |
@@ -61,7 +63,12 @@ | ||
61 | 63 | try { |
62 | 64 | config = new MoeConfig(MoeUtil.getMoeConfigFile()); |
63 | 65 | ui = MoeUI.getInstance(); |
64 | - menu = new MenuHandler(null); | |
66 | + menu = new MenuHandler(new Runnable() { | |
67 | + @Override | |
68 | + public void run() { | |
69 | + showSettingDialog(); | |
70 | + } | |
71 | + }); | |
65 | 72 | themeChanger = new ThemeChanger(ui); |
66 | 73 | themeChanger.setTheme(config.getCurrentConfig()); |
67 | 74 |
@@ -86,4 +93,19 @@ | ||
86 | 93 | // not used. |
87 | 94 | } |
88 | 95 | |
96 | + private void showSettingDialog() { | |
97 | + //@@TODO 前処理 -- 自動保存中断など | |
98 | + Set<ConfigObject> sortedConfigs = config.getSortedConfigs(); | |
99 | + MoeConfigEditDialog dialog = new MoeConfigEditDialog(sortedConfigs, themeChanger); | |
100 | + dialog.setSize(400, 200); //@@TODO remain size | |
101 | + dialog.setLocationRelativeTo(null); // positioning at the center of the screen | |
102 | + dialog.setVisible(true); | |
103 | + onConfigUpdate(); | |
104 | + //@@TODO 後処理 -- 自動保存再開など | |
105 | + } | |
106 | + | |
107 | + private void onConfigUpdate() { | |
108 | + Log.log("-- onConfigUpdate()"); //@@TODO 要・実装 | |
109 | + } | |
110 | + | |
89 | 111 | } |
@@ -0,0 +1,82 @@ | ||
1 | +/* | |
2 | + * To change this license header, choose License Headers in Project Properties. | |
3 | + * To change this template file, choose Tools | Templates | |
4 | + * and open the template in the editor. | |
5 | + */ | |
6 | + | |
7 | +package jp.sourceforge.users.yutang.omegat.plugin.moenizer; | |
8 | + | |
9 | +import groovy.util.ConfigObject; | |
10 | +import java.util.Set; | |
11 | +import org.omegat.core.Core; | |
12 | +import org.omegat.util.StaticUtils; | |
13 | + | |
14 | +/** | |
15 | + * | |
16 | + * @author Yu-Tang | |
17 | + */ | |
18 | +public class MoeConfigEditDialog extends javax.swing.JDialog { | |
19 | + | |
20 | + private final Set<ConfigObject> sortedConfigs; | |
21 | + private final ThemeChanger themeChanger; | |
22 | + | |
23 | + /** | |
24 | + * Creates new form MoeConfigEditDialog | |
25 | + * @param sortedConfigs | |
26 | + * @param themeChanger | |
27 | + */ | |
28 | + public MoeConfigEditDialog(Set<ConfigObject> sortedConfigs, ThemeChanger themeChanger) { | |
29 | + super(Core.getMainWindow().getApplicationFrame(), true); | |
30 | + this.sortedConfigs = sortedConfigs; | |
31 | + this.themeChanger = themeChanger; | |
32 | + initComponents(); | |
33 | + initUI(); | |
34 | + } | |
35 | + | |
36 | + private void initUI() { | |
37 | + this.setTitle(StaticUtils.format(L10n.get(L10n.Key.DIALOG_TITLE), | |
38 | + L10n.get(L10n.Key.CURRENT_VERSION))); | |
39 | + } | |
40 | + | |
41 | + /** | |
42 | + * This method is called from within the constructor to initialize the form. | |
43 | + * WARNING: Do NOT modify this code. The content of this method is always | |
44 | + * regenerated by the Form Editor. | |
45 | + */ | |
46 | + @SuppressWarnings("unchecked") | |
47 | + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | |
48 | + private void initComponents() { | |
49 | + | |
50 | + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); | |
51 | + | |
52 | + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); | |
53 | + getContentPane().setLayout(layout); | |
54 | + layout.setHorizontalGroup( | |
55 | + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
56 | + .addGap(0, 400, Short.MAX_VALUE) | |
57 | + ); | |
58 | + layout.setVerticalGroup( | |
59 | + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
60 | + .addGap(0, 300, Short.MAX_VALUE) | |
61 | + ); | |
62 | + | |
63 | + pack(); | |
64 | + }// </editor-fold>//GEN-END:initComponents | |
65 | + | |
66 | + /* | |
67 | + java.awt.EventQueue.invokeLater(new Runnable() { | |
68 | + public void run() { | |
69 | + MoeConfigEditDialog dialog = new MoeConfigEditDialog(new javax.swing.JFrame(), true); | |
70 | + dialog.addWindowListener(new java.awt.event.WindowAdapter() { | |
71 | + @Override | |
72 | + public void windowClosing(java.awt.event.WindowEvent e) { | |
73 | + System.exit(0); | |
74 | + } | |
75 | + }); | |
76 | + dialog.setVisible(true); | |
77 | + } | |
78 | + });*/ | |
79 | + | |
80 | + // Variables declaration - do not modify//GEN-BEGIN:variables | |
81 | + // End of variables declaration//GEN-END:variables | |
82 | +} |