use of com.intellij.ui.NonFocusableCheckBox in project kotlin by JetBrains.
the class KotlinInplaceVariableIntroducer method getCreateVarCheckBox.
@Nullable
protected final Function0<JComponent> getCreateVarCheckBox() {
if (myDoNotChangeVar)
return null;
return new Function0<JComponent>() {
@Override
public JComponent invoke() {
final JCheckBox varCheckbox = new NonFocusableCheckBox("Declare with var");
varCheckbox.setSelected(isVar);
varCheckbox.setMnemonic('v');
varCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(@NotNull ActionEvent e) {
new WriteCommandAction(myProject, getCommandName(), getCommandName()) {
@Override
protected void run(@NotNull Result result) throws Throwable {
PsiDocumentManager.getInstance(myProject).commitDocument(myEditor.getDocument());
KtPsiFactory psiFactory = new KtPsiFactory(myProject);
PsiElement keyword = varCheckbox.isSelected() ? psiFactory.createVarKeyword() : psiFactory.createValKeyword();
PsiElement valOrVar = myDeclaration instanceof KtProperty ? ((KtProperty) myDeclaration).getValOrVarKeyword() : ((KtParameter) myDeclaration).getValOrVarKeyword();
valOrVar.replace(keyword);
}
}.execute();
}
});
return varCheckbox;
}
};
}
Aggregations