本文整理汇总了Java中com.intellij.openapi.command.CommandProcessor.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java CommandProcessor.getInstance方法的具体用法?Java CommandProcessor.getInstance怎么用?Java CommandProcessor.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.command.CommandProcessor
的用法示例。
在下文中一共展示了CommandProcessor.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
@Override
public void actionPerformed(final AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
final FileEditor editor = e.getData(PlatformDataKeys.FILE_EDITOR);
CommandProcessor commandProcessor = CommandProcessor.getInstance();
commandProcessor.executeCommand(
project, new Runnable() {
@Override
public void run() {
PsiDocumentManager.getInstance(project).commitAllDocuments();
FindManager findManager = FindManager.getInstance(project);
if(!findManager.selectNextOccurrenceWasPerformed() && findManager.findPreviousUsageInEditor(editor)) {
return;
}
FindUtil.searchBack(project, editor, e.getDataContext());
}
},
IdeBundle.message("command.find.previous"),
null
);
}
示例2: getClickConsumer
import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
public Consumer<MouseEvent> getClickConsumer() {
return new Consumer<MouseEvent>() {
public void consume(MouseEvent mouseEvent) {
final Project project = getProject();
if (project == null) return;
final Editor editor = getEditor();
if (editor == null) return;
final CommandProcessor processor = CommandProcessor.getInstance();
processor.executeCommand(
project, new Runnable() {
public void run() {
final GotoLineNumberDialog dialog = new GotoLineNumberDialog(project, editor);
dialog.show();
IdeDocumentHistory.getInstance(project).includeCurrentCommandAsNavigation();
}
},
UIBundle.message("go.to.line.command.name"),
null
);
}
};
}
示例3: navigateSelectedElement
import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
@Override
public boolean navigateSelectedElement() {
final Ref<Boolean> succeeded = new Ref<Boolean>();
final CommandProcessor commandProcessor = CommandProcessor.getInstance();
commandProcessor.executeCommand(myProject, new Runnable() {
@Override
public void run() {
succeeded.set(MyCommanderPanel.super.navigateSelectedElement());
IdeDocumentHistory.getInstance(myProject).includeCurrentCommandAsNavigation();
}
}, "Navigate", null);
if (succeeded.get()) {
close(CANCEL_EXIT_CODE);
}
return succeeded.get();
}
示例4: actionPerformed
import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
public void actionPerformed(final AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
CommandProcessor commandProcessor = CommandProcessor.getInstance();
commandProcessor.executeCommand(
project, new Runnable(){
public void run() {
final EditorWindow window = e.getData(EditorWindow.DATA_KEY);
if (window != null){
final VirtualFile[] files = window.getFiles();
for (final VirtualFile file : files) {
window.closeFile(file);
}
return;
}
FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
VirtualFile selectedFile = fileEditorManager.getSelectedFiles()[0];
VirtualFile[] openFiles = fileEditorManager.getSiblings(selectedFile);
for (final VirtualFile openFile : openFiles) {
fileEditorManager.closeFile(openFile);
}
}
}, IdeBundle.message("command.close.all.editors"), null
);
}
示例5: actionPerformed
import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
@Override
public void actionPerformed(final AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
final FileEditor editor = e.getData(PlatformDataKeys.FILE_EDITOR);
if (editor == null || project == null) return;
CommandProcessor commandProcessor = CommandProcessor.getInstance();
commandProcessor.executeCommand(
project, new Runnable() {
@Override
public void run() {
PsiDocumentManager.getInstance(project).commitAllDocuments();
IdeDocumentHistory.getInstance(project).includeCurrentCommandAsNavigation();
FindManager findManager = FindManager.getInstance(project);
if(!findManager.selectNextOccurrenceWasPerformed() && findManager.findNextUsageInEditor(editor)) {
return;
}
FindUtil.searchAgain(project, editor, e.getDataContext());
}
},
IdeBundle.message("command.find.next"),
null
);
}
示例6: openMessageViewImpl
import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
private void openMessageViewImpl() {
CommandProcessor commandProcessor = CommandProcessor.getInstance();
commandProcessor.executeCommand(myProject, new Runnable() {
@Override
public void run() {
MessageView messageView = MessageView.SERVICE.getInstance(myProject);
Content content = ContentFactory.SERVICE.getInstance().createContent(myErrorsView.getComponent(), myContentName, true);
content.putUserData(myKey, myErrorsView);
messageView.getContentManager().addContent(content);
messageView.getContentManager().setSelectedContent(content);
messageView.getContentManager().addContentManagerListener(new CloseListener(content, myContentName, myErrorsView));
removeOldContents(content);
messageView.getContentManager().addContentManagerListener(new MyContentDisposer(content, messageView, myKey));
}
}, "Open Message View", null);
ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW).activate(null);
}
示例7: openMessagesView
import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
private static void openMessagesView(@NotNull final ErrorViewPanel errorTreeView,
@NotNull final Project myProject,
@NotNull final String tabDisplayName) {
CommandProcessor commandProcessor = CommandProcessor.getInstance();
commandProcessor.executeCommand(myProject, new Runnable() {
@Override
public void run() {
final MessageView messageView = ServiceManager.getService(myProject, MessageView.class);
final Content content = ContentFactory.SERVICE.getInstance().createContent(errorTreeView, tabDisplayName, true);
messageView.getContentManager().addContent(content);
Disposer.register(content, errorTreeView);
messageView.getContentManager().setSelectedContent(content);
removeContents(content, myProject, tabDisplayName);
}
}, "Open message view", null);
}
示例8: setPreviewText
import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
public void setPreviewText(@Nonnull String text) {
final CommandProcessor processor = CommandProcessor.getInstance();
processor.executeCommand(null, () -> {
final Application application = ApplicationManager.getApplication();
application.runWriteAction(() -> {
previewDocument.replaceString(INITIAL_OFFSET, previewDocument.getTextLength(), text);
final int textLength = previewDocument.getTextLength();
final CaretModel caret = previewEditor.getCaretModel();
if (caret.getOffset() >= textLength) {
caret.moveToOffset(textLength);
}
});
}, null, null);
}
示例9: setJson
import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
public void setJson(@NotNull String json) {
final CommandProcessor processor = CommandProcessor.getInstance();
processor.executeCommand(project, () -> {
final Application application = ApplicationManager.getApplication();
application.runWriteAction(() -> {
jsonDocument.replaceString(INITIAL_OFFSET, jsonDocument.getTextLength(), json);
final int textLength = jsonDocument.getTextLength();
final CaretModel caret = jsonEditor.getCaretModel();
if (caret.getOffset() >= textLength) {
caret.moveToOffset(textLength);
}
});
}, null, null);
}
示例10: deleteCharAtCaret
import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
public static void deleteCharAtCaret(Editor editor) {
int lineNumber = editor.getCaretModel().getLogicalPosition().line;
int afterLineEnd = EditorModificationUtil.calcAfterLineEnd(editor);
Document document = editor.getDocument();
int offset = editor.getCaretModel().getOffset();
if (afterLineEnd < 0
// There is a possible case that caret is located right before the soft wrap position at the last logical line
// (popular use case with the soft wraps at the commit message dialog).
|| (offset < document.getTextLength() - 1 && editor.getSoftWrapModel().getSoftWrap(offset) != null)) {
FoldRegion region = editor.getFoldingModel().getCollapsedRegionAtOffset(offset);
if (region != null && region.shouldNeverExpand()) {
document.deleteString(region.getStartOffset(), region.getEndOffset());
editor.getCaretModel().moveToOffset(region.getStartOffset());
}
else {
document.deleteString(offset, offset + 1);
editor.getCaretModel().moveToOffset(offset);
}
return;
}
if (lineNumber + 1 >= document.getLineCount()) return;
// Do not group delete newline and other deletions.
CommandProcessor commandProcessor = CommandProcessor.getInstance();
commandProcessor.setCurrentCommandGroupId(null);
int nextLineStart = document.getLineStartOffset(lineNumber + 1);
int nextLineEnd = document.getLineEndOffset(lineNumber + 1);
if (nextLineEnd - nextLineStart > 0) {
StringBuilder buf = new StringBuilder();
StringUtil.repeatSymbol(buf, ' ', afterLineEnd);
document.insertString(getCaretLineStart(editor) + getCaretLineLength(editor), buf.toString());
nextLineStart = document.getLineStartOffset(lineNumber + 1);
}
int thisLineEnd = document.getLineEndOffset(lineNumber);
document.deleteString(thisLineEnd, nextLineStart);
}
示例11: logErrorHeader
import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
private void logErrorHeader() {
final String info = ourApplicationInfoProvider.getInfo();
if (info != null) {
myLogger.error(info);
}
if (ourCompilationTimestamp != null) {
myLogger.error("Internal version. Compiled " + ourCompilationTimestamp);
}
myLogger.error("JDK: " + System.getProperties().getProperty("java.version", "unknown"));
myLogger.error("VM: " + System.getProperties().getProperty("java.vm.name", "unknown"));
myLogger.error("Vendor: " + System.getProperties().getProperty("java.vendor", "unknown"));
myLogger.error("OS: " + System.getProperties().getProperty("os.name", "unknown"));
ApplicationImpl application = (ApplicationImpl)ApplicationManager.getApplication();
if (application != null && application.isComponentsCreated() && !application.isDisposed()) {
final String lastPreformedActionId = ourLastActionId;
if (lastPreformedActionId != null) {
myLogger.error("Last Action: " + lastPreformedActionId);
}
CommandProcessor commandProcessor = CommandProcessor.getInstance();
if (commandProcessor != null) {
final String currentCommandName = commandProcessor.getCurrentCommandName();
if (currentCommandName != null) {
myLogger.error("Current Command: " + currentCommandName);
}
}
}
}
示例12: beforeDocumentChange
import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
@Override
public void beforeDocumentChange(DocumentEvent e) {
if (myDeaf) return;
if (DumbService.isDumb(myProject)) return;
if (myInitialText == null) {
final Document document = e.getDocument();
final PsiDocumentManager documentManager = myPsiDocumentManager;
if (!documentManager.isUncommited(document)) {
final CommandProcessor processor = CommandProcessor.getInstance();
final String currentCommandName = processor.getCurrentCommandName();
if (!Comparing.strEqual(TYPING_COMMAND_NAME, currentCommandName) &&
!Comparing.strEqual(PASTE_COMMAND_NAME, currentCommandName) &&
!Comparing.strEqual("Cut", currentCommandName) &&
!Comparing.strEqual(LanguageChangeSignatureDetector.MOVE_PARAMETER, currentCommandName) &&
!Comparing.equal(EditorActionUtil.DELETE_COMMAND_GROUP, processor.getCurrentCommandGroupId())) {
return;
}
final PsiFile file = documentManager.getPsiFile(document);
if (file != null) {
final PsiElement element = file.findElementAt(e.getOffset());
if (element != null) {
final ChangeInfo info = createInitialChangeInfo(element);
if (info != null) {
final PsiElement method = info.getMethod();
final TextRange textRange = method.getTextRange();
if (document.getTextLength() <= textRange.getEndOffset()) return;
if (method instanceof PsiNameIdentifierOwner) {
myInitialName = ((PsiNameIdentifierOwner)method).getName();
}
myInitialText = document.getText(textRange);
myInitialChangeInfo = info;
}
}
}
}
}
}
示例13: execute
import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
@Override
public void execute(final Editor editor, DataContext dataContext) {
CommandProcessor processor = CommandProcessor.getInstance();
processor.executeCommand(CommonDataKeys.PROJECT.getData(dataContext), new Runnable() {
public void run() {
editor.getSelectionModel().setSelection(0, editor.getDocument().getTextLength());
}
}, IdeBundle.message("command.select.all"), null);
}
示例14: actionPerformed
import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
public void actionPerformed(AnActionEvent e) {
final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
final CommandProcessor commandProcessor = CommandProcessor.getInstance();
commandProcessor.executeCommand(
project, new Runnable(){
public void run() {
final FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(project);
manager.setCurrentWindow(manager.getPrevWindow(manager.getCurrentWindow()));
}
}, IdeBundle.message("command.go.to.prev.split"), null
);
}
示例15: actionPerformed
import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
public void actionPerformed(AnActionEvent e) {
final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
final CommandProcessor commandProcessor = CommandProcessor.getInstance();
commandProcessor.executeCommand(
project, new Runnable(){
public void run() {
final FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(project);
manager.setCurrentWindow(manager.getNextWindow(manager.getCurrentWindow()));
}
}, IdeBundle.message("command.go.to.next.split"), null
);
}