Changeset 15928
- Timestamp:
- 07/17/08 16:56:31 (5 years ago)
- Location:
- platform/eclipse/sabotter/trunk/jp.xet.sabotter.eclipse/src/jp/xet/sabotter/eclipse
- Files:
-
- 6 modified
-
preferences/PreferenceKeys.java (modified) (1 diff)
-
preferences/SabotterPreference.java (modified) (1 diff)
-
preferences/SabotterPreferenceImpl.java (modified) (1 diff)
-
preferences/SabotterPreferenceInitializer.java (modified) (1 diff)
-
preferences/SabotterPreferencePage.java (modified) (6 diffs)
-
views/SabotterView.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
platform/eclipse/sabotter/trunk/jp.xet.sabotter.eclipse/src/jp/xet/sabotter/eclipse/preferences/PreferenceKeys.java
r15645 r15928 120 120 public static final String SABOTTER_STATE = "TAB_STATE"; 121 121 122 /** モールス信号ネタを扱うかどうか */ 123 public static final String IS_AVAILABLE_MORSE = "IS_AVAILABLE_MORSE"; 124 122 125 } -
platform/eclipse/sabotter/trunk/jp.xet.sabotter.eclipse/src/jp/xet/sabotter/eclipse/preferences/SabotterPreference.java
r15645 r15928 252 252 public BalloonDispayType getBalloonDisplayType(); 253 253 254 /** 255 * モールス信号形式を扱うかどうか 256 * @return 扱うとき true 257 */ 258 public boolean isMorseAvailable(); 259 254 260 } -
platform/eclipse/sabotter/trunk/jp.xet.sabotter.eclipse/src/jp/xet/sabotter/eclipse/preferences/SabotterPreferenceImpl.java
r15645 r15928 307 307 } 308 308 309 /** 310 * {@inheritDoc} 311 */ 312 public boolean isMorseAvailable() { 313 return ps.getBoolean(PreferenceKeys.IS_AVAILABLE_MORSE); 314 } 315 309 316 } -
platform/eclipse/sabotter/trunk/jp.xet.sabotter.eclipse/src/jp/xet/sabotter/eclipse/preferences/SabotterPreferenceInitializer.java
r15645 r15928 37 37 38 38 preferences.setDefault(PreferenceKeys.BALLOON_DISPLAY_TYPE, BalloonDispayType.ALL.toString()); 39 preferences.setDefault(PreferenceKeys.IS_AVAILABLE_MORSE, false); 40 39 41 // FIXME 暫定的に設定を一度にここで入れるようにしてある 40 42 preferences.setDefault(WassrService.SERVICE_ID + PreferenceKeys.USERID, -
platform/eclipse/sabotter/trunk/jp.xet.sabotter.eclipse/src/jp/xet/sabotter/eclipse/preferences/SabotterPreferencePage.java
r15645 r15928 41 41 private Button chkUnreadManagement; 42 42 43 private Button chkAvailableMorse; 44 43 45 private Button radInternalBrowser; 44 46 … … 137 139 chkUnreadManagement.setText(Messages.label_unread_management); 138 140 141 chkAvailableMorse = new Button(other, SWT.CHECK); 142 gd = new GridData(GridData.FILL_HORIZONTAL); 143 gd.horizontalSpan = 3; 144 chkAvailableMorse.setLayoutData(gd); 145 chkAvailableMorse.setText("Use Morse bit. This value reflesh on reboot."); // RESOURCE 146 139 147 setCurrentValueToControls(); 140 148 … … 189 197 190 198 chkUnreadManagement.setSelection(ps.getBoolean(PreferenceKeys.UNREAD_MANAGEMENT)); 199 200 chkAvailableMorse.setSelection(ps.getBoolean(PreferenceKeys.IS_AVAILABLE_MORSE)); 191 201 192 202 radInternalBrowser.setSelection(ps.getBoolean(PreferenceKeys.INTERNAL_BROWSER) == true); … … 203 213 ps.setValue(PreferenceKeys.INTERNAL_BROWSER, true); 204 214 ps.setValue(PreferenceKeys.BALLOON_DISPLAY_TYPE, BalloonDispayType.ALL.toString()); 215 216 ps.setValue(PreferenceKeys.IS_AVAILABLE_MORSE, false); 205 217 } 206 218 … … 218 230 219 231 int balloonDisplayTypeIndex = cmbBalloonDispayType.getSelectionIndex(); 220 ps.setValue(PreferenceKeys.BALLOON_DISPLAY_TYPE, BalloonDispayType.values()[balloonDisplayTypeIndex].toString()); 232 ps 233 .setValue(PreferenceKeys.BALLOON_DISPLAY_TYPE, BalloonDispayType.values()[balloonDisplayTypeIndex] 234 .toString()); 221 235 222 236 int maxEntries = sclMaxEntries.getSelection(); … … 228 242 boolean useInternalBrowser = radInternalBrowser.getSelection(); 229 243 ps.setValue(PreferenceKeys.INTERNAL_BROWSER, useInternalBrowser); 244 245 ps.setValue(PreferenceKeys.IS_AVAILABLE_MORSE, chkAvailableMorse.getSelection()); 230 246 } 231 247 -
platform/eclipse/sabotter/trunk/jp.xet.sabotter.eclipse/src/jp/xet/sabotter/eclipse/views/SabotterView.java
r15850 r15928 465 465 } else { 466 466 detailImage.setImage(labelProvider.getImage(miniblogEntry)); 467 detailMessage.setText(labelProvider.getText(miniblogEntry)); 467 if (pref.isMorseAvailable()) { 468 if (cmbMorse.getSelectionIndex() == 0) { //無変換 469 detailMessage.setText(labelProvider.getText(miniblogEntry)); 470 } else if (cmbMorse.getSelectionIndex() == 1) { //英字変換 471 detailMessage.setText(morseDecode(reverseAlphaMap, labelProvider.getText(miniblogEntry))); 472 } else { //カナ変換 473 detailMessage.setText(morseDecode(reverseKanaMap, labelProvider.getText(miniblogEntry))); 474 } 475 } else { 476 detailMessage.setText(labelProvider.getText(miniblogEntry)); 477 } 468 478 } 469 479 } … … 718 728 }); 719 729 } 730 if (pref.isMorseAvailable()) { 731 Label label = new Label(inputArea, SWT.NONE); 732 label.setText("モールス形式"); 733 734 cmbMorse = new Combo(inputArea, SWT.BORDER | SWT.READ_ONLY); 735 cmbMorse.add("無変換"); // RESOURCE 736 cmbMorse.add("英語"); //RESOURCE 737 cmbMorse.add("カナ"); //RESOURCE 738 cmbService.setText("モールス形式");// RESOURCE 739 } 720 740 } 721 741 … … 820 840 private void sendMessage() { 821 841 String statusText = txtMessage.getText(); 842 if (pref.isMorseAvailable()) { 843 if (cmbMorse.getSelectionIndex() == 0) { //無変換 844 //do nothing 845 } else if (cmbMorse.getSelectionIndex() == 1) { //英字変換 846 statusText = morseEncode(alphaMap, statusText.toUpperCase()); 847 } else { //カナ変換 848 statusText = morseEncode(kanaMap, statusText); 849 } 850 } 822 851 try { 823 852 String serviceId = null; … … 933 962 return txtMessage; 934 963 } 964 965 966 private Combo cmbMorse; 967 968 private static Map<String, String> kanaMap = new HashMap<String, String>(); 969 970 private static Map<String, String> reverseKanaMap = new HashMap<String, String>(); 971 972 private static Map<String, String> alphaMap = new HashMap<String, String>(); 973 974 private static Map<String, String> reverseAlphaMap = new HashMap<String, String>(); 975 static { 976 kanaMap.put("イ", "・-"); 977 kanaMap.put("ノ", "・・--"); 978 kanaMap.put("ロ", "・-・-"); 979 kanaMap.put("オ", "・-・・・"); 980 kanaMap.put("ハ", "-・・・"); 981 kanaMap.put("ク", "・・・-"); 982 kanaMap.put("ニ", "-・-・"); 983 kanaMap.put("ヤ", "・--"); 984 kanaMap.put("ホ ", "-・・"); 985 kanaMap.put("マ", "-・・-"); 986 kanaMap.put("ヘ", "・"); 987 kanaMap.put("ケ", "-・--"); 988 kanaMap.put("ト", "・・-・・"); 989 kanaMap.put("フ", "--・・"); 990 kanaMap.put("チ", "・・-・"); 991 kanaMap.put("コ", "----"); 992 kanaMap.put("リ", "--・"); 993 kanaMap.put("エ", "-・---"); 994 kanaMap.put("ヌ", "・・・・"); 995 kanaMap.put("テ", "・-・--"); 996 kanaMap.put("ル", "-・--・"); 997 kanaMap.put("ア", "--・--"); 998 kanaMap.put("ヲ", "・---"); 999 kanaMap.put("サ", "-・-・-"); 1000 kanaMap.put("ワ", "-・-"); 1001 kanaMap.put("キ", "-・-・・"); 1002 kanaMap.put("カ", "・-・・"); 1003 kanaMap.put("ユ", "-・・--"); 1004 kanaMap.put("ヨ", "--"); 1005 kanaMap.put("メ", "-・・・-"); 1006 kanaMap.put("タ", "-・"); 1007 kanaMap.put("ミ", "・・-・-"); 1008 kanaMap.put("レ", "---"); 1009 kanaMap.put("シ", "--・-・"); 1010 kanaMap.put("ソ", "---・"); 1011 kanaMap.put("ヱ", "・--・・"); 1012 kanaMap.put("ツ", "・--・"); 1013 kanaMap.put("ヒ", "--・・-"); 1014 kanaMap.put("ネ", "--・-"); 1015 kanaMap.put("モ", "-・・-・"); 1016 kanaMap.put("ナ", "・-・"); 1017 kanaMap.put("セ", "・---・"); 1018 kanaMap.put("ラ", "・・・"); 1019 kanaMap.put("ス", "---・-"); 1020 kanaMap.put("ム", "-"); 1021 kanaMap.put("ン", "・-・-・"); 1022 kanaMap.put("ウ ", "・・-"); 1023 kanaMap.put(" ゛", "・・"); 1024 kanaMap.put("ヰ", "・-・・-"); 1025 kanaMap.put(" ゜", "・・--・"); 1026 kanaMap.put("ー", "・--・- "); 1027 kanaMap.put("、", "・-・-・- "); 1028 kanaMap.put("」", "・-・-・・ "); 1029 kanaMap.put("(", "-・--・-"); 1030 kanaMap.put(" )", "・-・・-・"); 1031 kanaMap.put(" ", " "); 1032 1033 for (String key : kanaMap.keySet()) { 1034 reverseKanaMap.put(kanaMap.get(key), key); 1035 } 1036 1037 alphaMap.put("A", "・-"); 1038 alphaMap.put("N", "-・"); 1039 alphaMap.put("B", "-・・・"); 1040 alphaMap.put("O", "---"); 1041 alphaMap.put("C", "-・-・"); 1042 alphaMap.put("P", "・--・"); 1043 alphaMap.put("D", "-・・"); 1044 alphaMap.put("Q", "--・-"); 1045 alphaMap.put("E", "・"); 1046 alphaMap.put("R", "・-・"); 1047 alphaMap.put("F", "・・-・"); 1048 alphaMap.put("S", "・・・"); 1049 alphaMap.put("G", "--・"); 1050 alphaMap.put("T", "-"); 1051 alphaMap.put("H", "・・・・"); 1052 alphaMap.put("U", "・・-"); 1053 alphaMap.put("I", "・・"); 1054 alphaMap.put("V", "・・・-"); 1055 alphaMap.put("J", "・---"); 1056 alphaMap.put("W", "・--"); 1057 alphaMap.put("K", "-・-"); 1058 alphaMap.put("X", "-・・-"); 1059 alphaMap.put("L", "・-・・"); 1060 alphaMap.put("Y", "-・--"); 1061 alphaMap.put("M", "--"); 1062 alphaMap.put("Z", "--・・"); 1063 alphaMap.put("1", "・----"); 1064 alphaMap.put("2", "・・---"); 1065 alphaMap.put("3", "・・・--"); 1066 alphaMap.put("4", "・・・・-"); 1067 alphaMap.put("5", "・・・・・"); 1068 alphaMap.put("6", "-・・・・"); 1069 alphaMap.put("7", "--・・・"); 1070 alphaMap.put("8", "---・・"); 1071 alphaMap.put("9", "----・"); 1072 alphaMap.put("0", "-----"); 1073 alphaMap.put(" ", " "); 1074 1075 for (String key : alphaMap.keySet()) { 1076 reverseAlphaMap.put(alphaMap.get(key), key); 1077 } 1078 } 1079 1080 1081 private String morseEncode(Map<String, String> map, String text) { 1082 StringBuilder sb = new StringBuilder(); 1083 for (int i = 0; i < text.length(); i++) { 1084 String str = new String(new char[] { 1085 text.charAt(i) 1086 }); 1087 if (map.containsKey(str)) { 1088 sb.append(map.get(str)); 1089 sb.append(" "); 1090 } else { 1091 sb.append(str); 1092 } 1093 } 1094 return sb.toString(); 1095 } 1096 1097 private String morseDecode(Map<String, String> map, String text) { 1098 StringBuilder sb = new StringBuilder(); 1099 for (String str : text.split(" ")) { 1100 if (map.containsKey(str)) { 1101 sb.append(map.get(str)); 1102 } else { 1103 sb.append(str); 1104 } 1105 } 1106 return sb.toString(); 1107 } 935 1108 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)