Search in sources :

Example 1 with CommandProcessor

use of com.intellij.openapi.command.CommandProcessor in project intellij-community by JetBrains.

the class NextSplitAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    final Project project = e.getProject();
    final CommandProcessor commandProcessor = CommandProcessor.getInstance();
    commandProcessor.executeCommand(project, () -> {
        final FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(project);
        manager.setCurrentWindow(manager.getNextWindow(manager.getCurrentWindow()));
    }, IdeBundle.message("command.go.to.next.split"), null);
}
Also used : Project(com.intellij.openapi.project.Project) CommandProcessor(com.intellij.openapi.command.CommandProcessor) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx)

Example 2 with CommandProcessor

use of com.intellij.openapi.command.CommandProcessor in project intellij-community by JetBrains.

the class CloseAllEditorsAction method actionPerformed.

public void actionPerformed(final AnActionEvent e) {
    final Project project = e.getData(CommonDataKeys.PROJECT);
    CommandProcessor commandProcessor = CommandProcessor.getInstance();
    commandProcessor.executeCommand(project, () -> {
        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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) CommandProcessor(com.intellij.openapi.command.CommandProcessor) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx) EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow)

Example 3 with CommandProcessor

use of com.intellij.openapi.command.CommandProcessor in project intellij-community by JetBrains.

the class AbstractVcsHelperImpl method openMessagesView.

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);
}
Also used : MessageView(com.intellij.ui.content.MessageView) Content(com.intellij.ui.content.Content) CommandProcessor(com.intellij.openapi.command.CommandProcessor)

Example 4 with CommandProcessor

use of com.intellij.openapi.command.CommandProcessor in project intellij-community by JetBrains.

the class DocumentTest method testModificationInsideCommandAssertion.

public void testModificationInsideCommandAssertion() {
    CommandProcessor commandProcessor = CommandProcessor.getInstance();
    assertTrue(!commandProcessor.isUndoTransparentActionInProgress() && commandProcessor.getCurrentCommand() == null);
    final Document doc = new DocumentImpl("xxx");
    mustThrow(() -> doc.insertString(1, "x"));
    mustThrow(() -> doc.deleteString(1, 2));
    mustThrow(() -> doc.replaceString(1, 2, "s"));
    WriteCommandAction.runWriteCommandAction(getProject(), () -> doc.insertString(1, "s"));
    WriteCommandAction.runWriteCommandAction(getProject(), () -> doc.deleteString(1, 2));
    WriteCommandAction.runWriteCommandAction(getProject(), () -> doc.replaceString(1, 2, "xxx"));
    WriteCommandAction.runWriteCommandAction(getProject(), () -> doc.setText("sss"));
    DocumentImpl console = new DocumentImpl("xxxx", true);
    // need no stinking command
    console.insertString(1, "s");
    console.deleteString(1, 2);
    console.replaceString(1, 2, "xxx");
    console.setText("sss");
}
Also used : CommandProcessor(com.intellij.openapi.command.CommandProcessor) DocumentImpl(com.intellij.openapi.editor.impl.DocumentImpl)

Example 5 with CommandProcessor

use of com.intellij.openapi.command.CommandProcessor in project intellij-community by JetBrains.

the class IdeaLogger method logErrorHeader.

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);
            }
        }
    }
}
Also used : ApplicationImpl(com.intellij.openapi.application.impl.ApplicationImpl) CommandProcessor(com.intellij.openapi.command.CommandProcessor)

Aggregations

CommandProcessor (com.intellij.openapi.command.CommandProcessor)22 Project (com.intellij.openapi.project.Project)8 FileEditorManagerEx (com.intellij.openapi.fileEditor.ex.FileEditorManagerEx)3 FindManager (com.intellij.find.FindManager)2 Editor (com.intellij.openapi.editor.Editor)2 FileEditor (com.intellij.openapi.fileEditor.FileEditor)2 EditorWindow (com.intellij.openapi.fileEditor.impl.EditorWindow)2 Content (com.intellij.ui.content.Content)2 MessageView (com.intellij.ui.content.MessageView)2 IncorrectOperationException (com.intellij.util.IncorrectOperationException)2 EditorGotoLineNumberDialog (com.intellij.ide.util.EditorGotoLineNumberDialog)1 GotoLineNumberDialog (com.intellij.ide.util.GotoLineNumberDialog)1 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 ApplicationImpl (com.intellij.openapi.application.impl.ApplicationImpl)1 CommandAdapter (com.intellij.openapi.command.CommandAdapter)1 CommandEvent (com.intellij.openapi.command.CommandEvent)1 Document (com.intellij.openapi.editor.Document)1 DocumentImpl (com.intellij.openapi.editor.impl.DocumentImpl)1 EditorComposite (com.intellij.openapi.fileEditor.impl.EditorComposite)1