Search in sources :

Example 11 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 12 with CommandProcessor

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

the class CopyClassesHandler method copyClassesImpl.

private static void copyClassesImpl(final String copyClassName, final Project project, final Map<PsiFile, PsiClass[]> classes, final HashMap<PsiFile, String> map, final Object targetDirectory, final PsiDirectory defaultTargetDirectory, final String commandName, final boolean selectInActivePanel, final boolean openInEditor) {
    final boolean[] result = new boolean[] { false };
    Runnable command = () -> {
        PsiDirectory target;
        if (targetDirectory instanceof PsiDirectory) {
            target = (PsiDirectory) targetDirectory;
        } else {
            target = WriteAction.compute(() -> ((MoveDestination) targetDirectory).getTargetDirectory(defaultTargetDirectory));
        }
        try {
            Collection<PsiFile> files = doCopyClasses(classes, map, copyClassName, target, project);
            if (files != null) {
                if (openInEditor) {
                    for (PsiFile file : files) {
                        CopyHandler.updateSelectionInActiveProjectView(file, project, selectInActivePanel);
                    }
                    EditorHelper.openFilesInEditor(files.toArray(new PsiFile[files.size()]));
                }
            }
        } catch (IncorrectOperationException ex) {
            Messages.showMessageDialog(project, ex.getMessage(), RefactoringBundle.message("error.title"), Messages.getErrorIcon());
        }
    };
    CommandProcessor processor = CommandProcessor.getInstance();
    processor.executeCommand(project, command, commandName, null);
    if (result[0]) {
        ToolWindowManager.getInstance(project).invokeLater(() -> ToolWindowManager.getInstance(project).activateEditorComponent());
    }
}
Also used : CommandProcessor(com.intellij.openapi.command.CommandProcessor) IncorrectOperationException(com.intellij.util.IncorrectOperationException)

Example 13 with CommandProcessor

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

the class TemplateManagerImpl method startTemplateWithPrefix.

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, () -> {
        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<>();
            predefinedVarValues.put(TemplateImpl.ARG, argument);
        }
        templateState.start(template, processor, predefinedVarValues);
    }, CodeInsightBundle.message("insert.code.template.command"), null);
}
Also used : CommandProcessor(com.intellij.openapi.command.CommandProcessor)

Example 14 with CommandProcessor

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

the class SearchBackAction method actionPerformed.

@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, () -> {
        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);
}
Also used : Project(com.intellij.openapi.project.Project) FileEditor(com.intellij.openapi.fileEditor.FileEditor) FindManager(com.intellij.find.FindManager) CommandProcessor(com.intellij.openapi.command.CommandProcessor)

Example 15 with CommandProcessor

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

the class ActionTracker method ignoreCurrentDocumentChange.

void ignoreCurrentDocumentChange() {
    final CommandProcessor commandProcessor = CommandProcessor.getInstance();
    if (commandProcessor.getCurrentCommand() == null)
        return;
    myIgnoreDocumentChanges = true;
    commandProcessor.addCommandListener(new CommandAdapter() {

        @Override
        public void commandFinished(CommandEvent event) {
            commandProcessor.removeCommandListener(this);
            myIgnoreDocumentChanges = false;
        }
    });
}
Also used : CommandAdapter(com.intellij.openapi.command.CommandAdapter) CommandEvent(com.intellij.openapi.command.CommandEvent) 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