use of com.intellij.openapi.util.text.TextWithMnemonic in project consulo by consulo.
the class CheckboxAction method createCustomComponent.
@Nonnull
@Override
public JComponent createCustomComponent(Presentation presentation, @Nonnull String place) {
// this component cannot be stored right here because of action system architecture:
// one action can be shown on multiple toolbars simultaneously
TextWithMnemonic textWithMnemonic = TextWithMnemonic.parse(presentation.getTextValue().getValue());
JCheckBox checkBox = new JCheckBox(textWithMnemonic.getText());
checkBox.setOpaque(false);
checkBox.setToolTipText(presentation.getDescription());
checkBox.setMnemonic(textWithMnemonic.getMnemonic());
checkBox.setDisplayedMnemonicIndex(textWithMnemonic.getMnemonicIndex());
checkBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JCheckBox checkBox = (JCheckBox) e.getSource();
ActionToolbar actionToolbar = UIUtil.getParentOfType(ActionToolbar.class, checkBox);
DataContext dataContext = actionToolbar != null ? actionToolbar.getToolbarDataContext() : DataManager.getInstance().getDataContext(checkBox);
CheckboxAction.this.actionPerformed(new AnActionEvent(null, dataContext, ActionPlaces.UNKNOWN, CheckboxAction.this.getTemplatePresentation(), ActionManager.getInstance(), 0));
}
});
return checkBox;
}
use of com.intellij.openapi.util.text.TextWithMnemonic in project consulo by consulo.
the class ActionMenuItem method updateTextAndMnemonic.
private void updateTextAndMnemonic(@Nullable LocalizeValue textValue) {
// first initialization
if (myTextValue == null) {
return;
}
if (textValue != null) {
myTextValue = textValue;
}
String value = myTextValue.getValue();
TextWithMnemonic textWithMnemonic = TextWithMnemonic.parse(value);
setText(textWithMnemonic.getText());
setDisplayedMnemonicIndex(myEnableMnemonics ? textWithMnemonic.getMnemonicIndex() : -1);
setMnemonic(myEnableMnemonics ? textWithMnemonic.getMnemonic() : 0);
}
use of com.intellij.openapi.util.text.TextWithMnemonic in project consulo by consulo.
the class ActionButton method updateTextAndMnemonic.
protected void updateTextAndMnemonic(@Nonnull LocalizeValue localizeValue) {
boolean disabledMnemonic = myPresentation.isDisabledMnemonic();
if (disabledMnemonic) {
myLastComputedText = localizeValue.getValue();
setDisplayedMnemonicIndex(-1);
} else {
TextWithMnemonic textWithMnemonic = TextWithMnemonic.parse(localizeValue.getValue());
myLastComputedText = textWithMnemonic.getText();
setDisplayedMnemonicIndex(textWithMnemonic.getMnemonicIndex());
}
}
use of com.intellij.openapi.util.text.TextWithMnemonic in project consulo by consulo.
the class ActionMenu method updateTextAndMnemonic.
private void updateTextAndMnemonic(@Nullable LocalizeValue newTextValue, boolean disableMnemonic) {
myPresentationMnemonicDisabled = disableMnemonic;
// first initialization
if (myTextValue == null) {
return;
}
if (newTextValue != null) {
myTextValue = newTextValue;
}
String value = myTextValue.getValue();
TextWithMnemonic textWithMnemonic = TextWithMnemonic.parse(value);
setText(textWithMnemonic.getText());
setDisplayedMnemonicIndex(textWithMnemonic.getMnemonicIndex());
myMnemonicUpdate = true;
try {
setMnemonic(textWithMnemonic.getMnemonic());
} finally {
myMnemonicUpdate = false;
}
}
Aggregations