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.EN;
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 English IME.
27 *
28 * @author Copyright (C) 2009 OMRON SOFTWARE CO., LTD.  All Rights Reserved.
29 */
30public class UserDictionaryToolsListEN extends UserDictionaryToolsList {
31    /**
32     * Constructor
33     */
34    public UserDictionaryToolsListEN() {
35        if (OpenWnnEN.getInstance() == null) {
36            new OpenWnnEN(this);
37        }
38        mListViewName = "jp.co.omronsoft.openwnn.EN.UserDictionaryToolsListEN";
39        mEditViewName = "jp.co.omronsoft.openwnn.EN.UserDictionaryToolsEditEN";
40        mPackageName  = "jp.co.omronsoft.openwnn";
41    }
42
43    /** @see jp.co.omronsoft.iwnnime.ml.UserDictionaryToolsList#onCreate */
44    @Override protected void onCreate(Bundle savedInstanceState) {
45        super.onCreate(savedInstanceState);
46        setTitle(R.string.user_dictionary_list_words_en);
47    }
48
49    /** @see jp.co.omronsoft.openwnn.UserDictionaryToolsList#createUserDictionaryToolsEdit */
50    @Override protected UserDictionaryToolsEdit createUserDictionaryToolsEdit(View view1, View view2) {
51        return new UserDictionaryToolsEditEN(view1, view2);
52    }
53
54    /** @see jp.co.omronsoft.openwnn.UserDictionaryToolsList#sendEventToIME */
55    @Override protected boolean sendEventToIME(OpenWnnEvent ev) {
56        try {
57            return OpenWnnEN.getInstance().onEvent(ev);
58        } catch (Exception ex) {
59            /* do nothing if an error occurs */
60        }
61        return false;
62    }
63
64    /** @see jp.co.omronsoft.openwnn.UserDictionaryToolsList#getComparator */
65    @Override protected Comparator<WnnWord> getComparator() {
66    	return new ListComparatorEN();
67    }
68
69    /** Comparator class for sorting the list of English user dictionary */
70    protected class ListComparatorEN implements Comparator<WnnWord>{
71        public int compare(WnnWord word1, WnnWord word2) {
72            return word1.stroke.compareTo(word2.stroke);
73        };
74    }
75}
76