use of com.intellij.openapi.editor.Editor in project intellij-community by JetBrains.
the class InputExpressionDialog method setModeImpl.
protected void setModeImpl(Mode mode) {
// mySettingsPanel.setVisible(mode == Mode.ADVANCED);
myForm.getEditContextButton().setVisible(mode == Mode.ADVANCED);
if (mode == Mode.ADVANCED) {
setEditor(myEditor, GridConstraints.SIZEPOLICY_WANT_GROW);
myEditor.getField().selectAll();
} else {
setEditor(myComboBox, GridConstraints.SIZEPOLICY_FIXED);
myComboBox.setModel(myModel);
myComboBox.getEditor().selectAll();
}
SwingUtilities.invokeLater(() -> {
final Editor editor = getEditor();
if (editor != null) {
editor.getContentComponent().grabFocus();
}
});
}
use of com.intellij.openapi.editor.Editor in project intellij-community by JetBrains.
the class MultilineEditor method refocus.
private void refocus() {
SwingUtilities.invokeLater(() -> {
final Editor editor = myEditorTextField.getEditor();
if (editor != null) {
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(editor.getContentComponent(), true);
});
}
myEditorTextField.selectAll();
});
}
use of com.intellij.openapi.editor.Editor in project intellij-community by JetBrains.
the class PyMainPostfixTemplate method getSurrounder.
@NotNull
@Override
protected Surrounder getSurrounder() {
return new PyStatementSurrounder() {
@Nullable
@Override
protected TextRange surroundStatement(@NotNull Project project, @NotNull Editor editor, @NotNull PsiElement[] elements) throws IncorrectOperationException {
PyIfStatement ifStatement = PyElementGenerator.getInstance(project).createFromText(LanguageLevel.forElement(elements[0]), PyIfStatement.class, "if __name__ == '__main__':\n expr");
ifStatement = (PyIfStatement) CodeStyleManager.getInstance(project).reformat(ifStatement);
final PsiElement parent = elements[0].getParent();
ifStatement = (PyIfStatement) parent.addBefore(ifStatement, elements[0]);
final PyStatementList statementList = ifStatement.getIfPart().getStatementList();
statementList.addRange(elements[0], elements[elements.length - 1]);
statementList.getFirstChild().delete();
parent.deleteChildRange(elements[0], elements[elements.length - 1]);
return TextRange.from(statementList.getTextRange().getEndOffset(), 0);
}
@Override
public String getTemplateDescription() {
return DESCR;
}
};
}
use of com.intellij.openapi.editor.Editor in project intellij-community by JetBrains.
the class PyBaseConvertCollectionLiteralIntention method findCollectionLiteralUnderCaret.
@Nullable
private static PySequenceExpression findCollectionLiteralUnderCaret(@NotNull Editor editor, @NotNull PsiFile psiFile) {
final int caretOffset = editor.getCaretModel().getOffset();
final PsiElement curElem = psiFile.findElementAt(caretOffset);
final PySequenceExpression seqExpr = PsiTreeUtil.getParentOfType(curElem, PySequenceExpression.class);
if (seqExpr != null) {
return seqExpr;
}
final PyParenthesizedExpression paren = (PyParenthesizedExpression) PsiTreeUtil.findFirstParent(curElem, element -> {
final PyParenthesizedExpression parenthesizedExpr = as(element, PyParenthesizedExpression.class);
return parenthesizedExpr != null && parenthesizedExpr.getContainedExpression() instanceof PyTupleExpression;
});
return paren != null ? ((PyTupleExpression) paren.getContainedExpression()) : null;
}
use of com.intellij.openapi.editor.Editor in project intellij-community by JetBrains.
the class XmlVcsSelectionProvider method getSelection.
@Override
public VcsSelection getSelection(VcsContext context) {
final Editor editor = context.getEditor();
if (editor == null)
return null;
PsiElement psiElement = TargetElementUtil.findTargetElement(editor, TargetElementUtil.ELEMENT_NAME_ACCEPTED);
if (psiElement == null || !psiElement.isValid()) {
return null;
}
final String actionName;
if (psiElement instanceof XmlTag) {
actionName = VcsBundle.message("action.name.show.history.for.tag");
} else if (psiElement instanceof XmlText) {
actionName = VcsBundle.message("action.name.show.history.for.text");
} else {
return null;
}
TextRange textRange = psiElement.getTextRange();
if (textRange == null) {
return null;
}
VirtualFile virtualFile = psiElement.getContainingFile().getVirtualFile();
if (virtualFile == null) {
return null;
}
if (!virtualFile.isValid()) {
return null;
}
Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
return new VcsSelection(document, textRange, actionName);
}
Aggregations