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);
}
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());
}
}
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);
}
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);
}
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;
}
});
}
Aggregations