Search in sources :

Example 6 with KeymapImpl

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);
}
Also used : KeymapImpl(com.intellij.openapi.keymap.impl.KeymapImpl)

Example 7 with KeymapImpl

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;
}
Also used : KeymapImpl(com.intellij.openapi.keymap.impl.KeymapImpl) RelativePoint(com.intellij.ui.awt.RelativePoint) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

KeymapImpl (com.intellij.openapi.keymap.impl.KeymapImpl)7 NotNull (org.jetbrains.annotations.NotNull)3 ActionShortcutRestrictions (com.intellij.openapi.keymap.impl.ActionShortcutRestrictions)2 ShortcutRestrictions (com.intellij.openapi.keymap.impl.ShortcutRestrictions)2 RelativePoint (com.intellij.ui.awt.RelativePoint)2 Keymap (com.intellij.openapi.keymap.Keymap)1 KeymapManagerEx (com.intellij.openapi.keymap.ex.KeymapManagerEx)1 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)1