use of com.intellij.openapi.keymap.impl.KeymapImpl in project intellij-community by JetBrains.
the class KeymapPanel method currentKeymapChanged.
private void currentKeymapChanged() {
myResetToDefault.setEnabled(false);
Keymap selectedKeymap = myEditor.getModel().getSelected();
boolean editable = selectedKeymap != null && selectedKeymap.canModify();
myDeleteButton.setEnabled(editable);
myCopyButton.setEnabled(selectedKeymap != null);
myEditor.getComboBox().setEditable(editable);
if (selectedKeymap == null) {
myActionsTree.reset(new KeymapImpl(), myQuickLists);
return;
}
Keymap parent = selectedKeymap.getParent();
if (parent == null || !selectedKeymap.canModify()) {
myBaseKeymapLabel.setText("");
} else {
myBaseKeymapLabel.setText(KeyMapBundle.message("based.on.keymap.label", parent.getPresentableName()));
if (selectedKeymap.canModify() && ((KeymapImpl) selectedKeymap).getOwnActionIds().length > 0) {
myResetToDefault.setEnabled(true);
}
}
myActionsTree.reset(selectedKeymap, myQuickLists);
}
use of com.intellij.openapi.keymap.impl.KeymapImpl in project intellij-community by JetBrains.
the class KeymapPanel method createKeymapCopyIfNeeded.
@NotNull
private Keymap createKeymapCopyIfNeeded() {
Keymap keymap = myEditor.getModel().getSelected();
assert keymap != null;
if (keymap.canModify()) {
Keymap mutable = myEditor.getMutable(keymap);
myActionsTree.setKeymap(mutable);
return mutable;
}
String newKeymapName = KeyMapBundle.message("new.keymap.name", keymap.getPresentableName());
if (!tryNewKeymapName(newKeymapName)) {
for (int i = 0; ; i++) {
newKeymapName = KeyMapBundle.message("new.indexed.keymap.name", keymap.getPresentableName(), i);
if (tryNewKeymapName(newKeymapName)) {
break;
}
}
}
KeymapImpl newKeymap = ((KeymapImpl) keymap).deriveKeymap(newKeymapName);
newKeymap.setCanModify(true);
int indexOf = myEditor.getModel().getElementIndex(keymap);
if (indexOf >= 0) {
myEditor.getModel().add(indexOf + 1, newKeymap);
} else {
myEditor.getModel().add(newKeymap);
}
myEditor.getModel().setSelectedItem(newKeymap);
currentKeymapChanged();
return newKeymap;
}
Aggregations