IDEA-165950 National keyboard layouts support

This commit is contained in:
Denis Fokin
2017-05-17 13:53:10 +03:00
parent 302dae41ad
commit 62098dcc60
3 changed files with 14 additions and 13 deletions
@@ -67,7 +67,8 @@ public class KeyboardSettingsExternalizable implements PersistentStateComponent<
}
public static final class OptionSet {
public boolean USE_NON_ENGLISH_KEYBOARD = false;
public boolean PREFER_KEY_POSITION_OVER_CHAR_OPTION
= "true".equals(System.getProperty("com.jetbrains.use.old.keyevent.processing"));
}
private OptionSet myOptions = new OptionSet();
@@ -89,19 +90,19 @@ public class KeyboardSettingsExternalizable implements PersistentStateComponent<
@Override
public void loadState(OptionSet state) {
state.PREFER_KEY_POSITION_OVER_CHAR_OPTION
= state.PREFER_KEY_POSITION_OVER_CHAR_OPTION
|| "true".equals(System.getProperty("com.jetbrains.use.old.keyevent.processing"));
myOptions = state;
}
public boolean isUkrainianKeyboard (Component c) {
return c!=null && "uk".equals(c.getInputContext().getLocale().getLanguage());
public boolean isPreferKeyPositionOverCharOption () {
return myOptions.PREFER_KEY_POSITION_OVER_CHAR_OPTION;
}
public boolean isNonEnglishKeyboardSupportEnabled () {
return myOptions.USE_NON_ENGLISH_KEYBOARD;
}
public void setNonEnglishKeyboardSupportEnabled (boolean enabled) {
myOptions.USE_NON_ENGLISH_KEYBOARD = enabled;
public void setPreferKeyPositionOverCharOption (boolean enabled) {
myOptions.PREFER_KEY_POSITION_OVER_CHAR_OPTION = enabled;
}
}
@@ -83,7 +83,7 @@ public class KeyboardInternationalizationNotificationManager {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
final String description = event.getDescription();
if ("enable".equals(description)) {
KeyboardSettingsExternalizable.getInstance().setNonEnglishKeyboardSupportEnabled(true);
KeyboardSettingsExternalizable.getInstance().setPreferKeyPositionOverCharOption(true);
}
else if ("settings".equals(description)) {
final ShowSettingsUtil util = ShowSettingsUtil.getInstance();
@@ -87,15 +87,15 @@ public class KeymapPanel extends JPanel implements SearchableConfigurable, Confi
preferKeyPositionOverCharOption = new JCheckBox(new AbstractAction(" " + KeyMapBundle.message("prefer.key.position")) {
@Override
public void actionPerformed(ActionEvent e) {
KeyboardSettingsExternalizable.getInstance().setPreferKeyPositionOverCharOption(preferKeyPositionOverCharOption.isSelected());
VMOptions.writeOption("com.jetbrains.use.old.keyevent.processing", "=",
Boolean.toString(preferKeyPositionOverCharOption.isSelected()));
Boolean.toString(KeyboardSettingsExternalizable.getInstance().isPreferKeyPositionOverCharOption()));
ApplicationManager.getApplication().invokeLater(
() -> ApplicationManager.getApplication().restart(),
ModalityState.NON_MODAL
);
}
});
//preferKeyPositionOverCharOption.setSelected();
preferKeyPositionOverCharOption.setBorder(new EmptyBorder(0, 0, 0, 0));
keymapPanel.add(preferKeyPositionOverCharOption, BorderLayout.SOUTH);
}
@@ -438,7 +438,7 @@ public class KeymapPanel extends JPanel implements SearchableConfigurable, Confi
@Override
public void reset() {
if (preferKeyPositionOverCharOption != null) {
preferKeyPositionOverCharOption.setSelected(KeyboardSettingsExternalizable.getInstance().isNonEnglishKeyboardSupportEnabled());
preferKeyPositionOverCharOption.setSelected(KeyboardSettingsExternalizable.getInstance().isPreferKeyPositionOverCharOption());
}
myManager.reset();
}