本文整理汇总了Java中com.intellij.openapi.command.CommandProcessor.executeCommand方法的典型用法代码示例。如果您正苦于以下问题:Java CommandProcessor.executeCommand方法的具体用法?Java CommandProcessor.executeCommand怎么用?Java CommandProcessor.executeCommand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.command.CommandProcessor
的用法示例。
在下文中一共展示了CommandProcessor.executeCommand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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
);
}
};
}
示例2: 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
);
}
示例3: openMessagesView
import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
public void openMessagesView(final VcsErrorViewPanel errorTreeView, final String tabDisplayName) {
CommandProcessor commandProcessor = CommandProcessor.getInstance();
commandProcessor.executeCommand(myProject, new Runnable() {
public void run() {
final MessageView messageView = MessageView.SERVICE.getInstance(myProject);
messageView.runWhenInitialized(new Runnable() {
public void run() {
final Content content =
ContentFactory.SERVICE.getInstance().createContent(errorTreeView, tabDisplayName, true);
messageView.getContentManager().addContent(content);
Disposer.register(content, errorTreeView);
messageView.getContentManager().setSelectedContent(content);
removeContents(content, tabDisplayName);
ToolWindowManager.getInstance(myProject).getToolWindow(ToolWindowId.MESSAGES_WINDOW).activate(null);
}
});
}
}, VcsBundle.message("command.name.open.error.message.view"), null);
}
示例4: startTemplateWithPrefix
import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
public void startTemplateWithPrefix(final Editor editor,
final TemplateImpl template,
final int templateStart,
@Nullable final PairProcessor<String, String> processor,
@Nullable final String argument) {
final int caretOffset = editor.getCaretModel().getOffset();
final TemplateState templateState = initTemplateState(editor);
CommandProcessor commandProcessor = CommandProcessor.getInstance();
commandProcessor.executeCommand(myProject, new Runnable() {
@Override
public void run() {
editor.getDocument().deleteString(templateStart, caretOffset);
editor.getCaretModel().moveToOffset(templateStart);
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
editor.getSelectionModel().removeSelection();
Map<String, String> predefinedVarValues = null;
if (argument != null) {
predefinedVarValues = new HashMap<String, String>();
predefinedVarValues.put(TemplateImpl.ARG, argument);
}
templateState.start(template, processor, predefinedVarValues);
}
}, CodeInsightBundle.message("insert.code.template.command"), null);
}
示例5: 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);
}
示例6: 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
);
}
示例7: 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
);
}
示例8: 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();
}
示例9: openMessageView
import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
private void openMessageView() {
CommandProcessor commandProcessor = CommandProcessor.getInstance();
commandProcessor.executeCommand(
myProject, new Runnable() {
@Override
public void run() {
MessageView messageView = MessageView.SERVICE.getInstance(myProject);
final Content content = ContentFactory.SERVICE.getInstance().createContent(myErrorsView.getComponent(), CONTENT_NAME, true);
content.putUserData(KEY, myErrorsView);
messageView.getContentManager().addContent(content);
messageView.getContentManager().setSelectedContent(content);
messageView.getContentManager().addContentManagerListener(new CloseListener(content, messageView.getContentManager()));
removeCompileContents(content);
messageView.getContentManager().addContentManagerListener(new MyContentDisposer(content, messageView));
}
},
XmlBundle.message("validate.xml.open.message.view.command.name"),
null
);
}
示例10: 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);
}
示例11: 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);
}
示例12: 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);
}
示例13: actionPerformed
import com.intellij.openapi.command.CommandProcessor; //导入方法依赖的package包/类
public void actionPerformed(final AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
final CommandProcessor commandProcessor = CommandProcessor.getInstance();
commandProcessor.executeCommand(
project, new Runnable(){
public void run() {
final ArrayList<Pair<EditorComposite, EditorWindow>> filesToClose = getFilesToClose (e);
for (int i = 0; i != filesToClose.size (); ++ i) {
final Pair<EditorComposite, EditorWindow> we = filesToClose.get(i);
we.getSecond ().closeFile (we.getFirst ().getFile ());
}
}
}, IdeBundle.message("command.close.all.unmodified.editors"), null
);
}
示例14: 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);
}
示例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.getPrevWindow(manager.getCurrentWindow()));
}
}, IdeBundle.message("command.go.to.prev.split"), null
);
}