@Override public void update(final AnActionEvent e) { super.update(e); Presentation presentation = e.getPresentation(); Object property = presentation.getClientProperty(CUSTOM_COMPONENT_PROPERTY); if (property instanceof JCheckBox) { JCheckBox checkBox = (JCheckBox) property; checkBox.setText(presentation.getText()); checkBox.setToolTipText(presentation.getDescription()); checkBox.setMnemonic(presentation.getMnemonic()); checkBox.setDisplayedMnemonicIndex(presentation.getDisplayedMnemonicIndex()); checkBox.setSelected(Boolean.TRUE.equals(presentation.getClientProperty(SELECTED_PROPERTY))); checkBox.setEnabled(presentation.isEnabled()); checkBox.setVisible(presentation.isVisible()); } }
private void init() { setVisible(myPresentation.isVisible()); setEnabled(myPresentation.isEnabled()); setMnemonic(myEnableMnemonics ? myPresentation.getMnemonic() : 0); setText(myPresentation.getText()); final int mnemonicIndex = myEnableMnemonics ? myPresentation.getDisplayedMnemonicIndex() : -1; if (getText() != null && mnemonicIndex >= 0 && mnemonicIndex < getText().length()) { setDisplayedMnemonicIndex(mnemonicIndex); } AnAction action = myAction.getAction(); updateIcon(action); String id = ActionManager.getInstance().getId(action); if (id != null) { setAcceleratorFromShortcuts(KeymapManager.getInstance().getActiveKeymap().getShortcuts(id)); } else { final ShortcutSet shortcutSet = action.getShortcutSet(); if (shortcutSet != null) { setAcceleratorFromShortcuts(shortcutSet.getShortcuts()); } } }