use of com.intellij.execution.ui.ConsoleView in project intellij-community by JetBrains.
the class FoldLinesLikeThis method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final Editor editor = e.getData(CommonDataKeys.EDITOR);
assert editor != null;
final String selection = getSingleLineSelection(editor);
assert selection != null;
ShowSettingsUtil.getInstance().editConfigurable(editor.getProject(), new ConsoleConfigurable() {
@Override
protected boolean editFoldingsOnly() {
return true;
}
@Override
public void reset() {
super.reset();
UIUtil.invokeLaterIfNeeded(() -> addRule(selection));
}
});
final ConsoleView consoleView = e.getData(LangDataKeys.CONSOLE_VIEW);
if (consoleView instanceof ConsoleViewImpl) {
((ConsoleViewImpl) consoleView).foldImmediately();
}
}
use of com.intellij.execution.ui.ConsoleView in project intellij-community by JetBrains.
the class DaemonRespondToChangesTest method testDaemonIgnoresConsoleActivities.
public void testDaemonIgnoresConsoleActivities() throws Exception {
configureByFile(BASE_PATH + "AClass.java");
doHighlighting(HighlightSeverity.WARNING);
final ConsoleView consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(getProject()).getConsole();
//create editor
consoleView.getComponent();
consoleView.print("haha", ConsoleViewContentType.NORMAL_OUTPUT);
UIUtil.dispatchAllInvocationEvents();
try {
checkDaemonReaction(false, () -> {
consoleView.clear();
try {
// *&^ing alarm
Thread.sleep(300);
} catch (InterruptedException e) {
LOG.error(e);
}
//flush
UIUtil.dispatchAllInvocationEvents();
});
checkDaemonReaction(false, () -> {
consoleView.print("sss", ConsoleViewContentType.NORMAL_OUTPUT);
try {
// *&^ing alarm
Thread.sleep(300);
} catch (InterruptedException e) {
LOG.error(e);
}
//flush
UIUtil.dispatchAllInvocationEvents();
});
checkDaemonReaction(false, () -> {
consoleView.setOutputPaused(true);
try {
// *&^ing alarm
Thread.sleep(300);
} catch (InterruptedException e) {
LOG.error(e);
}
//flush
UIUtil.dispatchAllInvocationEvents();
});
} finally {
Disposer.dispose(consoleView);
}
}
use of com.intellij.execution.ui.ConsoleView in project intellij-community by JetBrains.
the class CommandLineState method execute.
@Override
@NotNull
public ExecutionResult execute(@NotNull final Executor executor, @NotNull final ProgramRunner runner) throws ExecutionException {
final ProcessHandler processHandler = startProcess();
final ConsoleView console = createConsole(executor);
if (console != null) {
console.attachToProcess(processHandler);
}
return new DefaultExecutionResult(console, processHandler, createActions(console, processHandler, executor));
}
use of com.intellij.execution.ui.ConsoleView in project intellij-community by JetBrains.
the class LogConsoleBase method doFilter.
private synchronized void doFilter() {
if (myDisposed) {
return;
}
final ConsoleView console = getConsoleNotNull();
console.clear();
myModel.processingStarted();
final String[] lines = myOriginalDocument != null ? myOriginalDocument.toString().split("\n") : ArrayUtil.EMPTY_STRING_ARRAY;
;
int offset = 0;
boolean caretPositioned = false;
for (String line : lines) {
final int printed = printMessageToConsole(line);
if (printed > 0) {
if (!caretPositioned) {
if (Comparing.strEqual(myLineUnderSelection, line)) {
caretPositioned = true;
offset += myLineOffset != -1 ? myLineOffset : 0;
} else {
offset += printed;
}
}
}
}
// we need this, because, document can change before actual scrolling, so offset may be already not at the end
if (caretPositioned) {
console.scrollTo(offset);
} else {
((ConsoleViewImpl) console).requestScrollingToEnd();
}
}
use of com.intellij.execution.ui.ConsoleView in project intellij-community by JetBrains.
the class LogConsoleBase method printMessageToConsole.
private int printMessageToConsole(String line) {
final ConsoleView console = getConsoleNotNull();
if (myContentPreprocessor != null) {
List<LogFragment> fragments = myContentPreprocessor.parseLogLine(line + '\n');
for (LogFragment fragment : fragments) {
ConsoleViewContentType consoleViewType = ConsoleViewContentType.getConsoleViewType(fragment.getOutputType());
if (consoleViewType != null) {
String formattedText = myFormatter.formatMessage(fragment.getText());
console.print(formattedText, consoleViewType);
}
}
return line.length() + 1;
} else {
final LogFilterModel.MyProcessingResult processingResult = myModel.processLine(line);
if (processingResult.isApplicable()) {
final Key key = processingResult.getKey();
if (key != null) {
ConsoleViewContentType type = ConsoleViewContentType.getConsoleViewType(key);
if (type != null) {
final String messagePrefix = processingResult.getMessagePrefix();
if (messagePrefix != null) {
String formattedPrefix = myFormatter.formatPrefix(messagePrefix);
console.print(formattedPrefix, type);
}
String formattedMessage = myFormatter.formatMessage(line);
console.print(formattedMessage + "\n", type);
return (messagePrefix != null ? messagePrefix.length() : 0) + line.length() + 1;
}
}
}
return 0;
}
}
Aggregations