1/*
2 * Copyright (C) 2008-2012  OMRON SOFTWARE Co., Ltd.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package jp.co.omronsoft.openwnn.JAJP;
18
19import jp.co.omronsoft.openwnn.*;
20import android.os.Bundle;
21import android.view.View;
22import android.view.Window;
23import java.util.Comparator;
24
25/**
26 * The user dictionary tool class for Japanese IME.
27 *
28 * @author Copyright (C) 2009 OMRON SOFTWARE CO., LTD.  All Rights Reserved.
29 */
30public class UserDictionaryToolsListJAJP extends UserDictionaryToolsList {
31    /**
32     * Constructor
33     */
34    public UserDictionaryToolsListJAJP() {
35        mListViewName = "jp.co.omronsoft.openwnn.JAJP.UserDictionaryToolsListJAJP";
36        mEditViewName = "jp.co.omronsoft.openwnn.JAJP.UserDictionaryToolsEditJAJP";
37        mPackageName  = "jp.co.omronsoft.openwnn";
38    }
39
40    /** @see jp.co.omronsoft.iwnnime.ml.UserDictionaryToolsList#onCreate */
41    @Override protected void onCreate(Bundle savedInstanceState) {
42        super.onCreate(savedInstanceState);
43        setTitle(R.string.user_dictionary_list_words_ja);
44    }
45
46    /** @see jp.co.omronsoft.openwnn.UserDictionaryToolsList#createUserDictionaryToolsEdit */
47    @Override protected UserDictionaryToolsEdit createUserDictionaryToolsEdit(View view1, View view2) {
48        return new UserDictionaryToolsEditJAJP(view1, view2);
49    }
50
51    /** @see jp.co.omronsoft.openwnn.UserDictionaryToolsList#sendEventToIME */
52    @Override protected boolean sendEventToIME(OpenWnnEvent ev) {
53        try {
54            return OpenWnnJAJP.getInstance().onEvent(ev);
55        } catch (Exception ex) {
56            /* do nothing if an error occurs */
57        }
58        return false;
59    }
60
61    /** @see jp.co.omronsoft.openwnn.UserDictionaryToolsList#getComparator */
62    @Override protected Comparator<WnnWord> getComparator() {
63    	return new ListComparatorJAJP();
64    }
65
66    /** Comparator class for sorting the list of Japanese user dictionary */
67    protected class ListComparatorJAJP implements Comparator<WnnWord>{
68        public int compare(WnnWord word1, WnnWord word2) {
69            return word1.stroke.compareTo(word2.stroke);
70        };
71    }
72}
73