テキストの各行をキーと値に分離し、複数テキストファイルを読み込み、キーを突き合わせ照合し、その結果を表示するGUIユーテリティです。
修訂 | fc17f353d1b02377d0ee332359e3e65c3c7a6334 (tree) |
---|---|
時間 | 2011-10-12 23:50:11 |
作者 | seraphy <seraphy@192....> |
Commiter | seraphy |
リファクタリングとコメント
@@ -4,27 +4,45 @@ | ||
4 | 4 | */ |
5 | 5 | package textkeymatcher.entity; |
6 | 6 | |
7 | +import java.util.AbstractMap; | |
7 | 8 | import java.util.ArrayList; |
8 | 9 | import java.util.Collections; |
9 | 10 | import java.util.List; |
10 | 11 | import java.util.Map; |
12 | +import java.util.Map.Entry; | |
13 | +import java.util.Set; | |
11 | 14 | import java.util.TreeMap; |
15 | +import textkeymatcher.entity.KeyMatchedRowMap.RowKey; | |
16 | +import textkeymatcher.entity.KeyMatchedRowMap.RowValues; | |
12 | 17 | import textkeymatcher.service.KeyMatcher; |
13 | 18 | |
14 | 19 | /** |
15 | - * | |
20 | + * 各カラムデータと、キーによるマッチングを行い、キーと値リストの組にする.<br> | |
16 | 21 | * @author seraphy |
17 | 22 | */ |
18 | -public class KeyMatchedDataModel { | |
23 | +public class KeyMatchedRowMap extends AbstractMap<RowKey, RowValues> { | |
19 | 24 | |
25 | + /** | |
26 | + * データソースのコレクション.<br> | |
27 | + */ | |
20 | 28 | private ArrayList<LineDataList> lineDataLists = new ArrayList<LineDataList>(); |
21 | 29 | |
22 | 30 | |
31 | + /** | |
32 | + * 行のキー表現 | |
33 | + */ | |
23 | 34 | public static class RowKey implements Comparable<RowKey> { |
24 | 35 | |
36 | + /** | |
37 | + * キー判定方法 | |
38 | + */ | |
25 | 39 | private final KeyMatcher keyMatcher; |
26 | 40 | |
41 | + /** | |
42 | + * キーの生データ | |
43 | + */ | |
27 | 44 | private final String key; |
45 | + | |
28 | 46 | |
29 | 47 | public RowKey(KeyMatcher keyMatcher, String key) { |
30 | 48 | if (keyMatcher == null) { |
@@ -65,6 +83,10 @@ public class KeyMatchedDataModel { | ||
65 | 83 | return false; |
66 | 84 | } |
67 | 85 | |
86 | + /** | |
87 | + * キーのマッチング法に従った文字列表現 | |
88 | + * @return 文字列表現 | |
89 | + */ | |
68 | 90 | @Override |
69 | 91 | public String toString() { |
70 | 92 | return keyMatcher.getNormalize(key); |
@@ -72,14 +94,41 @@ public class KeyMatchedDataModel { | ||
72 | 94 | } |
73 | 95 | |
74 | 96 | |
97 | + /** | |
98 | + * データソースごとの値のリスト.<br> | |
99 | + */ | |
75 | 100 | public static class RowValues { |
76 | 101 | |
102 | + /** | |
103 | + * データソースごとのデータを入れる配列.<br> | |
104 | + * データソースごとに添字を指定する.<br> | |
105 | + * 単一データであれば文字列が入り、複数データであれば文字列のリストオブジェクトが入る.<br> | |
106 | + * 該当がなければ、nullとなる.<br> | |
107 | + */ | |
77 | 108 | private Object[] datas; |
78 | - | |
109 | + | |
110 | + /** | |
111 | + * データソース数を指定して構築する. | |
112 | + * @param dataWidth データソース数 | |
113 | + */ | |
79 | 114 | public RowValues(int dataWidth) { |
80 | 115 | this.datas = new Object[dataWidth]; |
81 | 116 | } |
82 | 117 | |
118 | + /** | |
119 | + * データソース数を取得する | |
120 | + * @return データソース数 | |
121 | + */ | |
122 | + public int getDataWidth() { | |
123 | + return datas.length; | |
124 | + } | |
125 | + | |
126 | + /** | |
127 | + * データソースと、値を指定してデータをセットする.<br> | |
128 | + * 同じデータソースですでにデータがある場合はリストとして追加される.<br> | |
129 | + * @param column データソース添字 | |
130 | + * @param value データ、nullは空文字として登録される | |
131 | + */ | |
83 | 132 | public void add(int column, String value) { |
84 | 133 | if (value == null) { |
85 | 134 | value = ""; |
@@ -104,6 +153,11 @@ public class KeyMatchedDataModel { | ||
104 | 153 | } |
105 | 154 | } |
106 | 155 | |
156 | + /** | |
157 | + * 各データソースの中の最大のデータ数.<br> | |
158 | + * すべてのデータソースにひとつもデータがなければ0となる.<br> | |
159 | + * @return 最大のデータ数 | |
160 | + */ | |
107 | 161 | public int getMaxCount() { |
108 | 162 | int mx = 0; |
109 | 163 | int dataWidth = datas.length; |
@@ -116,6 +170,11 @@ public class KeyMatchedDataModel { | ||
116 | 170 | return mx; |
117 | 171 | } |
118 | 172 | |
173 | + /** | |
174 | + * 指定したデータソースのデータの個数を返す. | |
175 | + * @param column 添字 | |
176 | + * @return データの個数、未登録ならば0 | |
177 | + */ | |
119 | 178 | public int getCount(int column) { |
120 | 179 | if (column < 0 || column >= datas.length) { |
121 | 180 | // 範囲外、データがないので0を返す. |
@@ -128,10 +187,21 @@ public class KeyMatchedDataModel { | ||
128 | 187 | List<String> lst = (List<String>) datas[column]; |
129 | 188 | return lst.size(); |
130 | 189 | } |
131 | - // リストでなければ単一要素なので1を返す | |
132 | - return 1; | |
190 | + // 非nullで、リストでなければ単一要素なので1を返す | |
191 | + if (data != null) { | |
192 | + return 1; | |
193 | + } | |
194 | + // nullであればデータは未設定なので0 | |
195 | + return 0; | |
133 | 196 | } |
134 | 197 | |
198 | + /** | |
199 | + * 指定したデータソースの指定した番号のデータを取り出す.<br> | |
200 | + * 範囲外、もしくはデータ未登録である場合は空文字が返される.<br> | |
201 | + * @param column データソース番号 | |
202 | + * @param rowIndex データのインデックス、getCountで得られる個数分 | |
203 | + * @return データ、無し、もしくは範囲外の場合は空文字 | |
204 | + */ | |
135 | 205 | public String get(int column, int rowIndex) { |
136 | 206 | if (column < 0 || column >= datas.length) { |
137 | 207 | return ""; |
@@ -161,8 +231,16 @@ public class KeyMatchedDataModel { | ||
161 | 231 | } |
162 | 232 | |
163 | 233 | |
234 | + /** | |
235 | + * キーの判定方法を示すキーマッチャ | |
236 | + */ | |
164 | 237 | private KeyMatcher keyMatcher = KeyMatcher.TEXT; |
165 | 238 | |
239 | + /** | |
240 | + * キーの判定方法を設定する.<br> | |
241 | + * 設定後は{@link #remap() }を呼び出して再構築しないかぎり反映されない.<br> | |
242 | + * @param keyMatcher | |
243 | + */ | |
166 | 244 | public void setKeyMatcher(KeyMatcher keyMatcher) { |
167 | 245 | if (keyMatcher == null) { |
168 | 246 | throw new IllegalArgumentException(); |
@@ -171,16 +249,28 @@ public class KeyMatchedDataModel { | ||
171 | 249 | this.keyMatcher = keyMatcher; |
172 | 250 | } |
173 | 251 | |
252 | + /** | |
253 | + * キーの判定方法を取得する. | |
254 | + * @return | |
255 | + */ | |
174 | 256 | public KeyMatcher getKeyMatcher() { |
175 | 257 | return keyMatcher; |
176 | 258 | } |
177 | 259 | |
178 | 260 | |
179 | 261 | |
262 | + /** | |
263 | + * データソース数を返す.<br> | |
264 | + * @return データソース数 | |
265 | + */ | |
180 | 266 | public int getNumOfLineDataLists() { |
181 | 267 | return lineDataLists.size(); |
182 | 268 | } |
183 | - | |
269 | + | |
270 | + /** | |
271 | + * データソースを追加する. | |
272 | + * @param lineDataList データソース | |
273 | + */ | |
184 | 274 | public void addLineDataList(LineDataList lineDataList) { |
185 | 275 | if (lineDataList == null) { |
186 | 276 | throw new IllegalArgumentException(); |
@@ -188,42 +278,44 @@ public class KeyMatchedDataModel { | ||
188 | 278 | lineDataLists.add(lineDataList); |
189 | 279 | } |
190 | 280 | |
281 | + /** | |
282 | + * データソースを削除する. | |
283 | + * @param idx データソース | |
284 | + */ | |
191 | 285 | public void removeLineDataList(int idx) { |
192 | 286 | lineDataLists.remove(idx); |
193 | 287 | } |
194 | - | |
288 | + | |
289 | + /** | |
290 | + * 指定されたインデックスのデータソースを取得する | |
291 | + * @param idx インデックス | |
292 | + * @return データソース | |
293 | + */ | |
195 | 294 | public LineDataList getLineDataList(int idx) { |
196 | 295 | return lineDataLists.get(idx); |
197 | 296 | } |
198 | - | |
297 | + | |
298 | + /** | |
299 | + * データソースのタイトルを取得する.<br> | |
300 | + * タイトル自身はデータソースが保持しているため、これはアクセスヘルパである.<br> | |
301 | + * @param columnIndex データソースのインデックス | |
302 | + * @return タイトル | |
303 | + */ | |
199 | 304 | public String getTitle(int columnIndex) { |
200 | 305 | return getLineDataList(columnIndex).getTitle(); |
201 | 306 | } |
202 | 307 | |
203 | - public int getRowCount() { | |
204 | - return rowNumMaps.size(); | |
205 | - } | |
206 | - | |
207 | - public String getKeyAt(int rowIndex) { | |
208 | - if (rowIndex < 0 || rowIndex >= rowNumMaps.size()) { | |
209 | - return null; | |
210 | - } | |
211 | - return rowNumMaps.get(rowIndex).getRowKey().toString(); | |
212 | - } | |
213 | - | |
214 | - public String getValueAt(int rowIndex, int columnIndex) { | |
215 | - if (rowIndex < 0 || rowIndex >= rowNumMaps.size()) { | |
216 | - return null; | |
217 | - } | |
218 | - RowNumMap rowNumMap = rowNumMaps.get(rowIndex); | |
219 | - RowValues rowValues = rowNumMap.getRowValues(); | |
220 | - int rowNumber = rowNumMap.getRowNumber(); | |
221 | - return rowValues.get(columnIndex, rowNumber); | |
222 | - } | |
223 | 308 | |
224 | 309 | |
310 | + /** | |
311 | + * キーと値のリストに選別されたデータ表現 | |
312 | + */ | |
225 | 313 | private Map<RowKey, RowValues> dataMap = Collections.emptyMap(); |
226 | 314 | |
315 | + | |
316 | + /** | |
317 | + * データソースをキーに従って分類しマッピングする.<br> | |
318 | + */ | |
227 | 319 | public void remap() { |
228 | 320 | TreeMap<RowKey, RowValues> map = new TreeMap<RowKey, RowValues>(); |
229 | 321 |
@@ -257,45 +349,14 @@ public class KeyMatchedDataModel { | ||
257 | 349 | this.dataMap = map; |
258 | 350 | } |
259 | 351 | |
260 | - private static class RowNumMap { | |
261 | - | |
262 | - private final RowKey rowKey; | |
263 | - | |
264 | - private final RowValues rowValues; | |
265 | - | |
266 | - private final int rowNumber; | |
267 | - | |
268 | - public RowNumMap(RowKey rowKey, RowValues rowValues, int rowNumber) { | |
269 | - this.rowKey = rowKey; | |
270 | - this.rowValues = rowValues; | |
271 | - this.rowNumber = rowNumber; | |
272 | - } | |
273 | - | |
274 | - public RowKey getRowKey() { | |
275 | - return rowKey; | |
276 | - } | |
277 | - | |
278 | - public RowValues getRowValues() { | |
279 | - return rowValues; | |
280 | - } | |
281 | - | |
282 | - public int getRowNumber() { | |
283 | - return rowNumber; | |
284 | - } | |
285 | - } | |
286 | - | |
287 | - private List<RowNumMap> rowNumMaps = Collections.emptyList(); | |
288 | 352 | |
289 | - public void renumber() { | |
290 | - ArrayList<RowNumMap> rows = new ArrayList<RowNumMap>(); | |
291 | - for (Map.Entry<RowKey, RowValues> entry : dataMap.entrySet()) { | |
292 | - RowKey rowKey = entry.getKey(); | |
293 | - RowValues rowValues = entry.getValue(); | |
294 | - int numOfRows = rowValues.getMaxCount(); | |
295 | - for (int rowNumber = 0; rowNumber < numOfRows; rowNumber++) { | |
296 | - rows.add(new RowNumMap(rowKey, rowValues, rowNumber)); | |
297 | - } | |
298 | - } | |
299 | - this.rowNumMaps = rows; | |
353 | + @Override | |
354 | + public Set<Entry<RowKey, RowValues>> entrySet() { | |
355 | + return dataMap.entrySet(); | |
356 | + } | |
357 | + | |
358 | + @Override | |
359 | + public int size() { | |
360 | + return dataMap.size(); | |
300 | 361 | } |
301 | 362 | } |
@@ -0,0 +1,189 @@ | ||
1 | +/* | |
2 | + * To change this template, choose Tools | Templates | |
3 | + * and open the template in the editor. | |
4 | + */ | |
5 | +package textkeymatcher.entity; | |
6 | + | |
7 | +import java.util.ArrayList; | |
8 | +import java.util.Collections; | |
9 | +import java.util.List; | |
10 | +import java.util.Map; | |
11 | +import javax.swing.table.AbstractTableModel; | |
12 | +import textkeymatcher.entity.KeyMatchedRowMap.RowKey; | |
13 | +import textkeymatcher.entity.KeyMatchedRowMap.RowValues; | |
14 | + | |
15 | +/** | |
16 | + * データソースをキーと値に分解し、キーごとに集約されたデータマップから、 | |
17 | + * テーブル形式のグリッド状態にデータを展開する.<br> | |
18 | + * ひとつのキーに複数の値がある場合、同じキーの行が個数分だけ展開されます.<br> | |
19 | + * 列はキーと各データソース分となります.<br> | |
20 | + * @author seraphy | |
21 | + */ | |
22 | +public class KeyMatchedRowView extends AbstractTableModel { | |
23 | + | |
24 | + /** | |
25 | + * RowKeyとRowValuesへのアクセス方法を示すオブジェクト.<br> | |
26 | + */ | |
27 | + private static class RowNumMap { | |
28 | + | |
29 | + /** | |
30 | + * キー` | |
31 | + */ | |
32 | + private final RowKey rowKey; | |
33 | + | |
34 | + /** | |
35 | + * 各データソースごとの値のセット | |
36 | + */ | |
37 | + private final RowValues rowValues; | |
38 | + | |
39 | + /** | |
40 | + * 値が複数行ある場合の行番号(0ベース) | |
41 | + * 単一であれば0となる. | |
42 | + */ | |
43 | + private final int rowNumber; | |
44 | + | |
45 | + | |
46 | + public RowNumMap(RowKey rowKey, RowValues rowValues, int rowNumber) { | |
47 | + this.rowKey = rowKey; | |
48 | + this.rowValues = rowValues; | |
49 | + this.rowNumber = rowNumber; | |
50 | + } | |
51 | + | |
52 | + public RowKey getRowKey() { | |
53 | + return rowKey; | |
54 | + } | |
55 | + | |
56 | + public RowValues getRowValues() { | |
57 | + return rowValues; | |
58 | + } | |
59 | + | |
60 | + public int getRowNumber() { | |
61 | + return rowNumber; | |
62 | + } | |
63 | + } | |
64 | + | |
65 | + | |
66 | + /** | |
67 | + * 行データのリスト.<br> | |
68 | + * 各要素に列データへのアクセス方法が格納されている.<br> | |
69 | + */ | |
70 | + private List<RowNumMap> rowNumMaps = Collections.emptyList(); | |
71 | + | |
72 | + /** | |
73 | + * 列数 | |
74 | + */ | |
75 | + private int numOfColumns; | |
76 | + | |
77 | + | |
78 | + /** | |
79 | + * 行数 | |
80 | + * @return | |
81 | + */ | |
82 | + @Override | |
83 | + public int getRowCount() { | |
84 | + return rowNumMaps.size(); | |
85 | + } | |
86 | + | |
87 | + /** | |
88 | + * 指定した行のキーデータ(キー判定方法による文字列表現)を取得します.<br> | |
89 | + * @param rowIndex 行 | |
90 | + * @return キーデータ` | |
91 | + */ | |
92 | + public String getKeyAt(int rowIndex) { | |
93 | + if (rowIndex < 0 || rowIndex >= rowNumMaps.size()) { | |
94 | + return null; | |
95 | + } | |
96 | + return rowNumMaps.get(rowIndex).getRowKey().toString(); | |
97 | + } | |
98 | + | |
99 | + /** | |
100 | + * 指定した行のデータ部を取得します.<br> | |
101 | + * @param rowIndex 行 | |
102 | + * @param columnIndex データ列 | |
103 | + * @return データ、なければ空文字 | |
104 | + */ | |
105 | + public String getDataAt(int rowIndex, int columnIndex) { | |
106 | + if (rowIndex < 0 || rowIndex >= rowNumMaps.size()) { | |
107 | + return null; | |
108 | + } | |
109 | + RowNumMap rowNumMap = rowNumMaps.get(rowIndex); | |
110 | + RowValues rowValues = rowNumMap.getRowValues(); | |
111 | + int rowNumber = rowNumMap.getRowNumber(); | |
112 | + return rowValues.get(columnIndex, rowNumber); | |
113 | + } | |
114 | + | |
115 | + /** | |
116 | + * 第一列をキー、それ以降をデータ列として1つのテーブルのカラムとしてアクセスする.<br> | |
117 | + * @param rowIndex 行 | |
118 | + * @param columnIndex 列、0はキー、それ以降はデータ列 | |
119 | + * @return キーまたはデータの文字列、該当ない場合は空文字 | |
120 | + */ | |
121 | + @Override | |
122 | + public String getValueAt(int rowIndex, int columnIndex) { | |
123 | + if (rowIndex < 0 || rowIndex >= rowNumMaps.size()) { | |
124 | + return null; | |
125 | + } | |
126 | + if (columnIndex == 0) { | |
127 | + return getKeyAt(rowIndex); | |
128 | + } | |
129 | + return getDataAt(rowIndex, columnIndex - 1); | |
130 | + } | |
131 | + | |
132 | + /** | |
133 | + * キーおよび列のデータ型.<br> | |
134 | + * すべてStringである.<br> | |
135 | + * @param i 列、0列はキー、それ以降はデータ列 | |
136 | + * @return 列のデータ形式 | |
137 | + */ | |
138 | + @Override | |
139 | + public Class<?> getColumnClass(int i) { | |
140 | + return String.class; | |
141 | + } | |
142 | + | |
143 | + /** | |
144 | + * キー列 + データ列数を返す.<br> | |
145 | + * @return 列数 | |
146 | + */ | |
147 | + @Override | |
148 | + public int getColumnCount() { | |
149 | + return 1 + numOfColumns; | |
150 | + } | |
151 | + | |
152 | + | |
153 | + /** | |
154 | + * データマップに従って、あらたしくグリッドを生成しなおします.<br> | |
155 | + * @param dataMap データマップ | |
156 | + */ | |
157 | + public void renumbering(Map<RowKey, RowValues> dataMap) { | |
158 | + if (dataMap == null) { | |
159 | + throw new IllegalArgumentException(); | |
160 | + } | |
161 | + | |
162 | + int numOfMaxColumns = 0; | |
163 | + ArrayList<RowNumMap> rows = new ArrayList<RowNumMap>(); | |
164 | + for (Map.Entry<RowKey, RowValues> entry : dataMap.entrySet()) { | |
165 | + RowKey rowKey = entry.getKey(); | |
166 | + RowValues rowValues = entry.getValue(); | |
167 | + | |
168 | + // このキーに対していくつのデータソースが存在するのか? | |
169 | + // (最大列数の決定のため) | |
170 | + int dataWidth = rowValues.getDataWidth(); | |
171 | + if (numOfMaxColumns < dataWidth) { | |
172 | + numOfMaxColumns = dataWidth; | |
173 | + } | |
174 | + | |
175 | + // このキーに対して最大何行のデータがついているか? | |
176 | + int numOfRows = rowValues.getMaxCount(); | |
177 | + | |
178 | + // 行数分だけ同じキーを繰り返す. | |
179 | + for (int rowNumber = 0; rowNumber < numOfRows; rowNumber++) { | |
180 | + rows.add(new RowNumMap(rowKey, rowValues, rowNumber)); | |
181 | + } | |
182 | + } | |
183 | + | |
184 | + this.rowNumMaps = rows; | |
185 | + this.numOfColumns = numOfMaxColumns; | |
186 | + | |
187 | + fireTableStructureChanged(); | |
188 | + } | |
189 | +} |
@@ -39,34 +39,33 @@ | ||
39 | 39 | <Layout> |
40 | 40 | <DimensionLayout dim="0"> |
41 | 41 | <Group type="103" groupAlignment="0" attributes="0"> |
42 | - <Group type="102" alignment="0" attributes="0"> | |
42 | + <Group type="102" attributes="0"> | |
43 | 43 | <EmptySpace max="-2" attributes="0"/> |
44 | 44 | <Component id="jLabel4" min="-2" max="-2" attributes="0"/> |
45 | 45 | <EmptySpace max="-2" attributes="0"/> |
46 | - <Component id="titleTextField" pref="343" max="32767" attributes="0"/> | |
46 | + <Component id="titleTextField" pref="356" max="32767" attributes="0"/> | |
47 | 47 | <EmptySpace max="-2" attributes="0"/> |
48 | 48 | </Group> |
49 | - <Component id="inputSourcePanel" alignment="0" max="32767" attributes="1"/> | |
49 | + <Component id="btnPanel" alignment="0" pref="475" max="32767" attributes="0"/> | |
50 | + <Component id="KeyValueColumnPanel" alignment="0" max="32767" attributes="0"/> | |
50 | 51 | <Component id="dataFormatPanel" alignment="0" max="32767" attributes="1"/> |
51 | - <Component id="jPanel1" alignment="0" max="32767" attributes="0"/> | |
52 | - <Component id="btnPanel" alignment="0" pref="462" max="32767" attributes="0"/> | |
52 | + <Component id="inputSourcePanel" alignment="0" max="32767" attributes="1"/> | |
53 | 53 | </Group> |
54 | 54 | </DimensionLayout> |
55 | 55 | <DimensionLayout dim="1"> |
56 | 56 | <Group type="103" groupAlignment="0" attributes="0"> |
57 | - <Group type="102" alignment="1" attributes="0"> | |
58 | - <EmptySpace max="32767" attributes="0"/> | |
57 | + <Group type="102" alignment="0" attributes="0"> | |
59 | 58 | <Group type="103" groupAlignment="3" attributes="0"> |
60 | 59 | <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/> |
61 | 60 | <Component id="titleTextField" alignment="3" min="-2" max="-2" attributes="0"/> |
62 | 61 | </Group> |
63 | - <EmptySpace type="unrelated" max="-2" attributes="0"/> | |
64 | - <Component id="inputSourcePanel" min="-2" pref="206" max="-2" attributes="0"/> | |
65 | - <EmptySpace type="unrelated" max="-2" attributes="0"/> | |
62 | + <EmptySpace max="-2" attributes="0"/> | |
63 | + <Component id="inputSourcePanel" max="32767" attributes="0"/> | |
64 | + <EmptySpace max="-2" attributes="0"/> | |
66 | 65 | <Component id="dataFormatPanel" min="-2" max="-2" attributes="0"/> |
67 | - <EmptySpace type="unrelated" max="-2" attributes="0"/> | |
68 | - <Component id="jPanel1" min="-2" max="-2" attributes="0"/> | |
69 | - <EmptySpace type="unrelated" max="-2" attributes="0"/> | |
66 | + <EmptySpace max="-2" attributes="0"/> | |
67 | + <Component id="KeyValueColumnPanel" min="-2" max="-2" attributes="0"/> | |
68 | + <EmptySpace max="-2" attributes="0"/> | |
70 | 69 | <Component id="btnPanel" min="-2" max="-2" attributes="0"/> |
71 | 70 | </Group> |
72 | 71 | </Group> |
@@ -93,7 +92,7 @@ | ||
93 | 92 | <Group type="103" groupAlignment="0" attributes="0"> |
94 | 93 | <Group type="102" alignment="1" attributes="0"> |
95 | 94 | <EmptySpace min="-2" pref="29" max="-2" attributes="0"/> |
96 | - <Component id="directTextAreaSP" pref="384" max="32767" attributes="0"/> | |
95 | + <Component id="directTextAreaSP" pref="397" max="32767" attributes="0"/> | |
97 | 96 | </Group> |
98 | 97 | <Component id="loadTextRadioButton" alignment="0" min="-2" max="-2" attributes="0"/> |
99 | 98 | <Group type="102" alignment="0" attributes="0"> |
@@ -102,9 +101,9 @@ | ||
102 | 101 | <Group type="102" alignment="0" attributes="0"> |
103 | 102 | <Component id="jLabel3" min="-2" max="-2" attributes="0"/> |
104 | 103 | <EmptySpace type="separate" max="-2" attributes="0"/> |
105 | - <Component id="charsetComboBox" pref="213" max="32767" attributes="0"/> | |
104 | + <Component id="charsetComboBox" pref="226" max="32767" attributes="0"/> | |
106 | 105 | </Group> |
107 | - <Component id="loadFileTextField" pref="300" max="32767" attributes="0"/> | |
106 | + <Component id="loadFileTextField" pref="313" max="32767" attributes="0"/> | |
108 | 107 | </Group> |
109 | 108 | <EmptySpace max="-2" attributes="0"/> |
110 | 109 | <Component id="loadFileButton" min="-2" max="-2" attributes="0"/> |
@@ -132,8 +131,8 @@ | ||
132 | 131 | <EmptySpace type="unrelated" max="-2" attributes="0"/> |
133 | 132 | <Component id="directRadioButton" min="-2" max="-2" attributes="0"/> |
134 | 133 | <EmptySpace max="-2" attributes="0"/> |
135 | - <Component id="directTextAreaSP" min="-2" pref="48" max="-2" attributes="0"/> | |
136 | - <EmptySpace pref="10" max="32767" attributes="0"/> | |
134 | + <Component id="directTextAreaSP" max="32767" attributes="0"/> | |
135 | + <EmptySpace max="32767" attributes="0"/> | |
137 | 136 | </Group> |
138 | 137 | </Group> |
139 | 138 | </DimensionLayout> |
@@ -163,6 +162,9 @@ | ||
163 | 162 | </Component> |
164 | 163 | <Component class="javax.swing.JButton" name="loadFileButton"> |
165 | 164 | <Properties> |
165 | + <Property name="action" type="javax.swing.Action" editor="org.netbeans.modules.swingapp.ActionEditor"> | |
166 | + <action class="textkeymatcher.ui.ImportDataDialog" id="onBrowseFile" methodName="onBrowseFile"/> | |
167 | + </Property> | |
166 | 168 | <Property name="text" type="java.lang.String" resourceKey="loadFileButton.text"/> |
167 | 169 | <Property name="name" type="java.lang.String" value="loadFileButton" noResource="true"/> |
168 | 170 | </Properties> |
@@ -242,14 +244,14 @@ | ||
242 | 244 | <Group type="102" alignment="0" attributes="0"> |
243 | 245 | <Component id="simpleSplitRadioButton" min="-2" max="-2" attributes="0"/> |
244 | 246 | <EmptySpace min="-2" pref="38" max="-2" attributes="0"/> |
245 | - <Component id="simpleSplitComboBox" pref="265" max="32767" attributes="0"/> | |
247 | + <Component id="simpleSplitComboBox" pref="278" max="32767" attributes="0"/> | |
246 | 248 | </Group> |
247 | 249 | <Component id="regularExpRadioButton" alignment="0" min="-2" max="-2" attributes="0"/> |
248 | 250 | </Group> |
249 | 251 | </Group> |
250 | 252 | <Group type="102" alignment="0" attributes="0"> |
251 | 253 | <EmptySpace min="-2" pref="39" max="-2" attributes="0"/> |
252 | - <Component id="regularExpTextField" pref="391" max="32767" attributes="0"/> | |
254 | + <Component id="regularExpTextField" pref="404" max="32767" attributes="0"/> | |
253 | 255 | </Group> |
254 | 256 | </Group> |
255 | 257 | <EmptySpace max="-2" attributes="0"/> |
@@ -381,16 +383,16 @@ | ||
381 | 383 | </Component> |
382 | 384 | </SubComponents> |
383 | 385 | </Container> |
384 | - <Container class="javax.swing.JPanel" name="jPanel1"> | |
386 | + <Container class="javax.swing.JPanel" name="KeyValueColumnPanel"> | |
385 | 387 | <Properties> |
386 | 388 | <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> |
387 | 389 | <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> |
388 | - <TitledBorder title="キー・データ列の指定"> | |
389 | - <Property name="titleX" resourceKey="jPanel1.border.title"/> | |
390 | + <TitledBorder title="キー・値のカラム"> | |
391 | + <Property name="titleX" resourceKey="KeyValueColumnPanel.border.title"/> | |
390 | 392 | </TitledBorder> |
391 | 393 | </Border> |
392 | 394 | </Property> |
393 | - <Property name="name" type="java.lang.String" value="jPanel1" noResource="true"/> | |
395 | + <Property name="name" type="java.lang.String" value="KeyValueColumnPanel" noResource="true"/> | |
394 | 396 | </Properties> |
395 | 397 | |
396 | 398 | <Layout> |
@@ -400,14 +402,14 @@ | ||
400 | 402 | <EmptySpace max="-2" attributes="0"/> |
401 | 403 | <Component id="jLabel1" min="-2" max="-2" attributes="0"/> |
402 | 404 | <EmptySpace type="separate" max="-2" attributes="0"/> |
403 | - <Component id="keyColumnSpinner" pref="77" max="32767" attributes="0"/> | |
404 | - <EmptySpace min="-2" pref="32" max="-2" attributes="0"/> | |
405 | - <Component id="jLabel2" min="-2" max="-2" attributes="0"/> | |
406 | - <EmptySpace type="unrelated" max="-2" attributes="0"/> | |
407 | - <Component id="valueColumnSpinner" pref="77" max="32767" attributes="0"/> | |
405 | + <Component id="keyColumnSpinner" min="-2" pref="63" max="-2" attributes="0"/> | |
408 | 406 | <EmptySpace max="-2" attributes="0"/> |
407 | + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> | |
408 | + <EmptySpace min="-2" pref="2" max="-2" attributes="0"/> | |
409 | + <Component id="valueColumnSpinner" min="-2" pref="58" max="-2" attributes="0"/> | |
410 | + <EmptySpace type="separate" max="-2" attributes="0"/> | |
409 | 411 | <Component id="fullLineCheckBox" min="-2" max="-2" attributes="0"/> |
410 | - <EmptySpace pref="36" max="32767" attributes="0"/> | |
412 | + <EmptySpace pref="104" max="32767" attributes="0"/> | |
411 | 413 | </Group> |
412 | 414 | </Group> |
413 | 415 | </DimensionLayout> |
@@ -420,8 +422,8 @@ | ||
420 | 422 | <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> |
421 | 423 | <Component id="fullLineCheckBox" alignment="3" min="-2" max="-2" attributes="0"/> |
422 | 424 | </Group> |
423 | - <Component id="valueColumnSpinner" alignment="0" min="-2" max="-2" attributes="0"/> | |
424 | 425 | <Component id="keyColumnSpinner" alignment="0" min="-2" max="-2" attributes="0"/> |
426 | + <Component id="valueColumnSpinner" alignment="0" min="-2" max="-2" attributes="0"/> | |
425 | 427 | </Group> |
426 | 428 | <EmptySpace max="32767" attributes="0"/> |
427 | 429 | </Group> |
@@ -13,6 +13,7 @@ package textkeymatcher.ui; | ||
13 | 13 | import java.awt.Component; |
14 | 14 | import java.awt.event.InputEvent; |
15 | 15 | import java.awt.event.KeyEvent; |
16 | +import java.io.File; | |
16 | 17 | import java.nio.charset.Charset; |
17 | 18 | import java.util.ArrayList; |
18 | 19 | import java.util.List; |
@@ -22,10 +23,12 @@ import javax.swing.DefaultComboBoxModel; | ||
22 | 23 | import javax.swing.DefaultListCellRenderer; |
23 | 24 | import javax.swing.InputMap; |
24 | 25 | import javax.swing.JComponent; |
26 | +import javax.swing.JFileChooser; | |
25 | 27 | import javax.swing.JList; |
26 | 28 | import javax.swing.JRootPane; |
27 | 29 | import javax.swing.KeyStroke; |
28 | 30 | import javax.swing.ListCellRenderer; |
31 | +import javax.swing.filechooser.FileFilter; | |
29 | 32 | import org.apache.commons.lang3.StringUtils; |
30 | 33 | import org.jdesktop.application.Action; |
31 | 34 | import textkeymatcher.service.PredefinedSimpleSplitCharColumnSplitter; |
@@ -131,7 +134,7 @@ public class ImportDataDialog extends javax.swing.JDialog { | ||
131 | 134 | filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 0)); |
132 | 135 | cancelButton = new javax.swing.JButton(); |
133 | 136 | importButton = new javax.swing.JButton(); |
134 | - jPanel1 = new javax.swing.JPanel(); | |
137 | + KeyValueColumnPanel = new javax.swing.JPanel(); | |
135 | 138 | jLabel1 = new javax.swing.JLabel(); |
136 | 139 | jLabel2 = new javax.swing.JLabel(); |
137 | 140 | fullLineCheckBox = new javax.swing.JCheckBox(); |
@@ -172,6 +175,8 @@ public class ImportDataDialog extends javax.swing.JDialog { | ||
172 | 175 | binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, importDataDialogModel, org.jdesktop.beansbinding.ELProperty.create("${sourceFile}"), loadFileTextField, org.jdesktop.beansbinding.BeanProperty.create("text")); |
173 | 176 | bindingGroup.addBinding(binding); |
174 | 177 | |
178 | + javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(textkeymatcher.TextKeyMatcherApp.class).getContext().getActionMap(ImportDataDialog.class, this); | |
179 | + loadFileButton.setAction(actionMap.get("onBrowseFile")); // NOI18N | |
175 | 180 | loadFileButton.setText(resourceMap.getString("loadFileButton.text")); // NOI18N |
176 | 181 | loadFileButton.setName("loadFileButton"); // NOI18N |
177 | 182 |
@@ -211,7 +216,7 @@ public class ImportDataDialog extends javax.swing.JDialog { | ||
211 | 216 | .addGroup(inputSourcePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
212 | 217 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, inputSourcePanelLayout.createSequentialGroup() |
213 | 218 | .addGap(29, 29, 29) |
214 | - .addComponent(directTextAreaSP, javax.swing.GroupLayout.DEFAULT_SIZE, 384, Short.MAX_VALUE)) | |
219 | + .addComponent(directTextAreaSP, javax.swing.GroupLayout.DEFAULT_SIZE, 397, Short.MAX_VALUE)) | |
215 | 220 | .addComponent(loadTextRadioButton) |
216 | 221 | .addGroup(inputSourcePanelLayout.createSequentialGroup() |
217 | 222 | .addGap(29, 29, 29) |
@@ -219,8 +224,8 @@ public class ImportDataDialog extends javax.swing.JDialog { | ||
219 | 224 | .addGroup(javax.swing.GroupLayout.Alignment.LEADING, inputSourcePanelLayout.createSequentialGroup() |
220 | 225 | .addComponent(jLabel3) |
221 | 226 | .addGap(18, 18, 18) |
222 | - .addComponent(charsetComboBox, 0, 213, Short.MAX_VALUE)) | |
223 | - .addComponent(loadFileTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)) | |
227 | + .addComponent(charsetComboBox, 0, 226, Short.MAX_VALUE)) | |
228 | + .addComponent(loadFileTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 313, Short.MAX_VALUE)) | |
224 | 229 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
225 | 230 | .addComponent(loadFileButton)) |
226 | 231 | .addComponent(directRadioButton)) |
@@ -241,8 +246,8 @@ public class ImportDataDialog extends javax.swing.JDialog { | ||
241 | 246 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) |
242 | 247 | .addComponent(directRadioButton) |
243 | 248 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
244 | - .addComponent(directTextAreaSP, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE) | |
245 | - .addContainerGap(10, Short.MAX_VALUE)) | |
249 | + .addComponent(directTextAreaSP) | |
250 | + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) | |
246 | 251 | ); |
247 | 252 | |
248 | 253 | dataFormatPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("dataFormatPanel.border.title"))); // NOI18N |
@@ -286,11 +291,11 @@ public class ImportDataDialog extends javax.swing.JDialog { | ||
286 | 291 | .addGroup(dataFormatPanelLayout.createSequentialGroup() |
287 | 292 | .addComponent(simpleSplitRadioButton) |
288 | 293 | .addGap(38, 38, 38) |
289 | - .addComponent(simpleSplitComboBox, 0, 265, Short.MAX_VALUE)) | |
294 | + .addComponent(simpleSplitComboBox, 0, 278, Short.MAX_VALUE)) | |
290 | 295 | .addComponent(regularExpRadioButton))) |
291 | 296 | .addGroup(dataFormatPanelLayout.createSequentialGroup() |
292 | 297 | .addGap(39, 39, 39) |
293 | - .addComponent(regularExpTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 391, Short.MAX_VALUE))) | |
298 | + .addComponent(regularExpTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE))) | |
294 | 299 | .addContainerGap()) |
295 | 300 | ); |
296 | 301 | dataFormatPanelLayout.setVerticalGroup( |
@@ -317,7 +322,6 @@ public class ImportDataDialog extends javax.swing.JDialog { | ||
317 | 322 | gridBagConstraints.weightx = 1.0; |
318 | 323 | btnPanel.add(filler1, gridBagConstraints); |
319 | 324 | |
320 | - javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(textkeymatcher.TextKeyMatcherApp.class).getContext().getActionMap(ImportDataDialog.class, this); | |
321 | 325 | cancelButton.setAction(actionMap.get("onCancel")); // NOI18N |
322 | 326 | cancelButton.setText(resourceMap.getString("cancelButton.text")); // NOI18N |
323 | 327 | cancelButton.setName("cancelButton"); // NOI18N |
@@ -334,8 +338,8 @@ public class ImportDataDialog extends javax.swing.JDialog { | ||
334 | 338 | gridBagConstraints.gridy = 0; |
335 | 339 | btnPanel.add(importButton, gridBagConstraints); |
336 | 340 | |
337 | - jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel1.border.title"))); // NOI18N | |
338 | - jPanel1.setName("jPanel1"); // NOI18N | |
341 | + KeyValueColumnPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("KeyValueColumnPanel.border.title"))); // NOI18N | |
342 | + KeyValueColumnPanel.setName("KeyValueColumnPanel"); // NOI18N | |
339 | 343 | |
340 | 344 | jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N |
341 | 345 | jLabel1.setName("jLabel1"); // NOI18N |
@@ -361,33 +365,33 @@ public class ImportDataDialog extends javax.swing.JDialog { | ||
361 | 365 | binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, importDataDialogModel, org.jdesktop.beansbinding.ELProperty.create("${valueColumn}"), valueColumnSpinner, org.jdesktop.beansbinding.BeanProperty.create("value")); |
362 | 366 | bindingGroup.addBinding(binding); |
363 | 367 | |
364 | - javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); | |
365 | - jPanel1.setLayout(jPanel1Layout); | |
366 | - jPanel1Layout.setHorizontalGroup( | |
367 | - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
368 | - .addGroup(jPanel1Layout.createSequentialGroup() | |
368 | + javax.swing.GroupLayout KeyValueColumnPanelLayout = new javax.swing.GroupLayout(KeyValueColumnPanel); | |
369 | + KeyValueColumnPanel.setLayout(KeyValueColumnPanelLayout); | |
370 | + KeyValueColumnPanelLayout.setHorizontalGroup( | |
371 | + KeyValueColumnPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
372 | + .addGroup(KeyValueColumnPanelLayout.createSequentialGroup() | |
369 | 373 | .addContainerGap() |
370 | 374 | .addComponent(jLabel1) |
371 | 375 | .addGap(18, 18, 18) |
372 | - .addComponent(keyColumnSpinner, javax.swing.GroupLayout.DEFAULT_SIZE, 77, Short.MAX_VALUE) | |
373 | - .addGap(32, 32, 32) | |
374 | - .addComponent(jLabel2) | |
375 | - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) | |
376 | - .addComponent(valueColumnSpinner, javax.swing.GroupLayout.DEFAULT_SIZE, 77, Short.MAX_VALUE) | |
376 | + .addComponent(keyColumnSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) | |
377 | 377 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
378 | + .addComponent(jLabel2) | |
379 | + .addGap(2, 2, 2) | |
380 | + .addComponent(valueColumnSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) | |
381 | + .addGap(18, 18, 18) | |
378 | 382 | .addComponent(fullLineCheckBox) |
379 | - .addContainerGap(36, Short.MAX_VALUE)) | |
383 | + .addContainerGap(104, Short.MAX_VALUE)) | |
380 | 384 | ); |
381 | - jPanel1Layout.setVerticalGroup( | |
382 | - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
383 | - .addGroup(jPanel1Layout.createSequentialGroup() | |
384 | - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
385 | - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |
385 | + KeyValueColumnPanelLayout.setVerticalGroup( | |
386 | + KeyValueColumnPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
387 | + .addGroup(KeyValueColumnPanelLayout.createSequentialGroup() | |
388 | + .addGroup(KeyValueColumnPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) | |
389 | + .addGroup(KeyValueColumnPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) | |
386 | 390 | .addComponent(jLabel1) |
387 | 391 | .addComponent(jLabel2) |
388 | 392 | .addComponent(fullLineCheckBox)) |
389 | - .addComponent(valueColumnSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | |
390 | - .addComponent(keyColumnSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) | |
393 | + .addComponent(keyColumnSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | |
394 | + .addComponent(valueColumnSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) | |
391 | 395 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) |
392 | 396 | ); |
393 | 397 |
@@ -407,27 +411,26 @@ public class ImportDataDialog extends javax.swing.JDialog { | ||
407 | 411 | .addContainerGap() |
408 | 412 | .addComponent(jLabel4) |
409 | 413 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
410 | - .addComponent(titleTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE) | |
414 | + .addComponent(titleTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 356, Short.MAX_VALUE) | |
411 | 415 | .addContainerGap()) |
412 | - .addComponent(inputSourcePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) | |
416 | + .addComponent(btnPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 475, Short.MAX_VALUE) | |
417 | + .addComponent(KeyValueColumnPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) | |
413 | 418 | .addComponent(dataFormatPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
414 | - .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) | |
415 | - .addComponent(btnPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 462, Short.MAX_VALUE) | |
419 | + .addComponent(inputSourcePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) | |
416 | 420 | ); |
417 | 421 | layout.setVerticalGroup( |
418 | 422 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
419 | - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() | |
420 | - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) | |
423 | + .addGroup(layout.createSequentialGroup() | |
421 | 424 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) |
422 | 425 | .addComponent(jLabel4) |
423 | 426 | .addComponent(titleTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) |
424 | - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) | |
425 | - .addComponent(inputSourcePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE) | |
426 | - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) | |
427 | + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
428 | + .addComponent(inputSourcePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) | |
429 | + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
427 | 430 | .addComponent(dataFormatPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) |
428 | - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) | |
429 | - .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | |
430 | - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) | |
431 | + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
432 | + .addComponent(KeyValueColumnPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) | |
433 | + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) | |
431 | 434 | .addComponent(btnPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) |
432 | 435 | ); |
433 | 436 |
@@ -504,7 +507,63 @@ public class ImportDataDialog extends javax.swing.JDialog { | ||
504 | 507 | firePropertyChange("enableAccept", old, isEnableAccept()); |
505 | 508 | } |
506 | 509 | |
510 | + | |
511 | + /** | |
512 | + * テキストファイル拡張子フィルタ | |
513 | + */ | |
514 | + private static final FileFilter TEXT_FILE_FILTER = new FileFilter() { | |
515 | + | |
516 | + @Override | |
517 | + public boolean accept(File file) { | |
518 | + if (file.isDirectory()) { | |
519 | + return true; | |
520 | + } | |
521 | + String name = file.getName(); | |
522 | + return name.toLowerCase().endsWith(".txt"); | |
523 | + } | |
524 | + | |
525 | + @Override | |
526 | + public String getDescription() { | |
527 | + return "Text (*.txt)"; | |
528 | + } | |
529 | + }; | |
530 | + | |
531 | + /** | |
532 | + * 最後に使用したディレクトリ | |
533 | + */ | |
534 | + private File lastUseDirectory; | |
535 | + | |
536 | + public File getLastUseDirectory() { | |
537 | + return lastUseDirectory; | |
538 | + } | |
539 | + | |
540 | + public void setLastUseDirectory(File lastUseDirectory) { | |
541 | + this.lastUseDirectory = lastUseDirectory; | |
542 | + } | |
543 | + | |
544 | + /** | |
545 | + * ファイルを選択する | |
546 | + */ | |
547 | + @Action | |
548 | + public void onBrowseFile() { | |
549 | + JFileChooser fileChooser = new JFileChooser(lastUseDirectory); | |
550 | + fileChooser.setAcceptAllFileFilterUsed(true); | |
551 | + fileChooser.addChoosableFileFilter(TEXT_FILE_FILTER); | |
552 | + fileChooser.setFileFilter(TEXT_FILE_FILTER); | |
553 | + int ret = fileChooser.showOpenDialog(this); | |
554 | + if (ret != JFileChooser.APPROVE_OPTION) { | |
555 | + // cancel | |
556 | + return; | |
557 | + } | |
558 | + | |
559 | + File selectedFile = fileChooser.getSelectedFile(); | |
560 | + lastUseDirectory = selectedFile.getParentFile(); | |
561 | + | |
562 | + importDataDialogModel.setSourceFile(selectedFile.getPath()); | |
563 | + } | |
564 | + | |
507 | 565 | // Variables declaration - do not modify//GEN-BEGIN:variables |
566 | + private javax.swing.JPanel KeyValueColumnPanel; | |
508 | 567 | private javax.swing.JPanel btnPanel; |
509 | 568 | private javax.swing.JButton cancelButton; |
510 | 569 | private javax.swing.JComboBox charsetComboBox; |
@@ -523,7 +582,6 @@ public class ImportDataDialog extends javax.swing.JDialog { | ||
523 | 582 | private javax.swing.JLabel jLabel2; |
524 | 583 | private javax.swing.JLabel jLabel3; |
525 | 584 | private javax.swing.JLabel jLabel4; |
526 | - private javax.swing.JPanel jPanel1; | |
527 | 585 | private javax.swing.JSpinner keyColumnSpinner; |
528 | 586 | private javax.swing.JButton loadFileButton; |
529 | 587 | private javax.swing.JTextField loadFileTextField; |
@@ -4,60 +4,34 @@ | ||
4 | 4 | */ |
5 | 5 | package textkeymatcher.ui.model; |
6 | 6 | |
7 | -import javax.swing.table.AbstractTableModel; | |
8 | -import textkeymatcher.entity.KeyMatchedDataModel; | |
7 | +import textkeymatcher.entity.KeyMatchedRowMap; | |
8 | +import textkeymatcher.entity.KeyMatchedRowView; | |
9 | 9 | import textkeymatcher.entity.LineDataList; |
10 | 10 | |
11 | 11 | /** |
12 | 12 | * |
13 | 13 | * @author seraphy |
14 | 14 | */ |
15 | -public class DataViewTableModel extends AbstractTableModel { | |
16 | - | |
17 | - private KeyMatchedDataModel dataModel = new KeyMatchedDataModel(); | |
15 | +public class DataViewTableModel extends KeyMatchedRowView { | |
18 | 16 | |
17 | + private KeyMatchedRowMap rowMap = new KeyMatchedRowMap(); | |
18 | + | |
19 | 19 | public void addLineDataList(LineDataList lineDataList) { |
20 | 20 | if (lineDataList == null) { |
21 | 21 | throw new IllegalArgumentException(); |
22 | 22 | } |
23 | - dataModel.addLineDataList(lineDataList); | |
24 | - dataModel.remap(); | |
25 | - dataModel.renumber(); | |
26 | - fireTableStructureChanged(); | |
27 | - } | |
28 | - | |
29 | - @Override | |
30 | - public int getColumnCount() { | |
31 | - return 1 + dataModel.getNumOfLineDataLists(); | |
32 | - } | |
23 | + rowMap.addLineDataList(lineDataList); | |
24 | + rowMap.remap(); | |
33 | 25 | |
34 | - @Override | |
35 | - public Class<?> getColumnClass(int i) { | |
36 | - return String.class; | |
26 | + renumbering(rowMap); | |
37 | 27 | } |
38 | - | |
28 | + | |
39 | 29 | @Override |
40 | 30 | public String getColumnName(int i) { |
41 | 31 | if (i == 0) { |
42 | 32 | return "Key"; |
43 | 33 | } |
44 | - int column = i - 1; | |
45 | - return dataModel.getTitle(column); | |
34 | + int column = i - 1; // 左端はキーカラム固定 | |
35 | + return rowMap.getTitle(column); | |
46 | 36 | } |
47 | - | |
48 | - @Override | |
49 | - public int getRowCount() { | |
50 | - return dataModel.getRowCount(); | |
51 | - } | |
52 | - | |
53 | - @Override | |
54 | - public Object getValueAt(int rowIndex, int columnIndex) { | |
55 | - if (columnIndex == 0) { | |
56 | - return dataModel.getKeyAt(rowIndex); | |
57 | - | |
58 | - } else { | |
59 | - return dataModel.getValueAt(rowIndex, columnIndex - 1); | |
60 | - } | |
61 | - } | |
62 | - | |
63 | 37 | } |
@@ -11,7 +11,7 @@ import org.jdesktop.application.AbstractBean; | ||
11 | 11 | import textkeymatcher.service.PredefinedSimpleSplitCharColumnSplitter; |
12 | 12 | |
13 | 13 | /** |
14 | - * | |
14 | + * データインポートダイアログのモデル | |
15 | 15 | * @author seraphy |
16 | 16 | */ |
17 | 17 | public class ImportDataDialogModel extends AbstractBean { |
@@ -19,9 +19,11 @@ SIMPLE_SEMICOLON_SPLIT.text=SemiColon | ||
19 | 19 | SIMPLE_ASTER_SPLIT.text=Asterisk |
20 | 20 | SINGLE_SPACE_SPLIT.text=Space |
21 | 21 | SPACES_SPLIT.text=Spaces |
22 | -jPanel1.border.title=\u30ad\u30fc\u30fb\u30c7\u30fc\u30bf\u5217\u306e\u6307\u5b9a | |
23 | -jLabel1.text=jLabel1 | |
24 | -jLabel2.text=jLabel2 | |
25 | -fullLineCheckBox.text=\u884c\u5168\u4f53 | |
26 | -jLabel3.text=jLabel3 | |
27 | -jLabel4.text=jLabel4 | |
22 | +jLabel1.text=Key | |
23 | +jLabel2.text=Data | |
24 | +fullLineCheckBox.text=Line | |
25 | +jLabel3.text=Charset | |
26 | +jLabel4.text=Name | |
27 | +KeyValueColumnPanel.border.title=Columns | |
28 | +onBrowseFile.Action.shortDescription= | |
29 | +onBrowseFile.Action.text= |
@@ -19,9 +19,11 @@ SIMPLE_SEMICOLON_SPLIT.text=\u30bb\u30df\u30b3\u30ed\u30f3\u533a\u5207\u308a | ||
19 | 19 | SIMPLE_ASTER_SPLIT.text=\u30a2\u30b9\u30bf\u30ea\u30b9\u30af\u533a\u5207\u308a |
20 | 20 | SINGLE_SPACE_SPLIT.text=\u7a7a\u767d\u533a\u5207\u308a(\u5358\u4e00\u7a7a\u767d) |
21 | 21 | SPACES_SPLIT.text=\u7a7a\u767d\u533a\u5207\u308a |
22 | -jPanel1.border.title=\u30ad\u30fc\u30fb\u30c7\u30fc\u30bf\u5217\u306e\u6307\u5b9a | |
23 | 22 | jLabel1.text=\u30ad\u30fc\u5217: |
24 | 23 | jLabel2.text=\u30c7\u30fc\u30bf\u5217: |
25 | 24 | fullLineCheckBox.text=\u884c\u5168\u4f53 |
26 | 25 | jLabel3.text=\u6587\u5b57\u30b3\u30fc\u30c9: |
27 | 26 | jLabel4.text=\u30c7\u30fc\u30bf\u5217\u540d: |
27 | +KeyValueColumnPanel.border.title=\u30ad\u30fc\u30fb\u5024\u306e\u30ab\u30e9\u30e0 | |
28 | +onBrowseFile.Action.text= | |
29 | +onBrowseFile.Action.shortDescription= |