use of com.intellij.execution.ui.RunContentDescriptor in project intellij-community by JetBrains.
the class AnalyzeStacktraceUtil method addConsole.
public static RunContentDescriptor addConsole(Project project, @Nullable ConsoleFactory consoleFactory, final String tabTitle, String text, @Nullable Icon icon) {
final TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
builder.filters(Extensions.getExtensions(EP_NAME, project));
final ConsoleView consoleView = builder.getConsole();
final DefaultActionGroup toolbarActions = new DefaultActionGroup();
JComponent consoleComponent = consoleFactory != null ? consoleFactory.createConsoleComponent(consoleView, toolbarActions) : new MyConsolePanel(consoleView, toolbarActions);
final RunContentDescriptor descriptor = new RunContentDescriptor(consoleView, null, consoleComponent, tabTitle, icon) {
@Override
public boolean isContentReuseProhibited() {
return true;
}
};
final Executor executor = DefaultRunExecutor.getRunExecutorInstance();
for (AnAction action : consoleView.createConsoleActions()) {
toolbarActions.add(action);
}
final ConsoleViewImpl console = (ConsoleViewImpl) consoleView;
ConsoleViewUtil.enableReplaceActionForConsoleViewEditor(console.getEditor());
console.getEditor().getSettings().setCaretRowShown(true);
toolbarActions.add(new AnnotateStackTraceAction(console.getEditor(), console.getHyperlinks()));
toolbarActions.add(new CloseAction(executor, descriptor, project));
ExecutionManager.getInstance(project).getContentManager().showRunContent(executor, descriptor);
consoleView.allowHeavyFilters();
if (consoleFactory == null) {
printStacktrace(consoleView, text);
}
return descriptor;
}
use of com.intellij.execution.ui.RunContentDescriptor in project intellij-community by JetBrains.
the class UnscrambleDialogTest method showText.
private void showText(String unscramble) {
RunContentDescriptor descriptor = UnscrambleDialog.showUnscrambledText(null, "foo", null, getProject(), unscramble);
assertNotNull(descriptor);
Disposer.register(myFixture.getTestRootDisposable(), descriptor);
myContent = descriptor;
}
use of com.intellij.execution.ui.RunContentDescriptor in project intellij-community by JetBrains.
the class ToggleAutoTestAction method setSelected.
@Override
public void setSelected(AnActionEvent e, boolean state) {
Project project = e.getData(CommonDataKeys.PROJECT);
RunContentDescriptor descriptor = e.getData(LangDataKeys.RUN_CONTENT_DESCRIPTOR);
ExecutionEnvironment environment = e.getData(LangDataKeys.EXECUTION_ENVIRONMENT);
if (project != null && descriptor != null && environment != null) {
getAutoTestManager(project).setAutoTestEnabled(descriptor, environment, state);
}
}
use of com.intellij.execution.ui.RunContentDescriptor in project intellij-community by JetBrains.
the class XDebugSessionImpl method showSessionTab.
public void showSessionTab() {
RunContentDescriptor descriptor = getRunContentDescriptor();
ExecutionManager.getInstance(getProject()).getContentManager().showRunContent(DefaultDebugExecutor.getDebugExecutorInstance(), descriptor);
}
use of com.intellij.execution.ui.RunContentDescriptor in project intellij-community by JetBrains.
the class TreeInplaceEditor method show.
public final void show() {
LOG.assertTrue(myInplaceEditorComponent == null, "editor is not released");
final JTree tree = getTree();
tree.scrollPathToVisible(getNodePath());
final JRootPane rootPane = tree.getRootPane();
if (rootPane == null) {
return;
}
final JLayeredPane layeredPane = rootPane.getLayeredPane();
Rectangle bounds = getEditorBounds();
if (bounds == null) {
return;
}
Point layeredPanePoint = SwingUtilities.convertPoint(tree, bounds.x, bounds.y, layeredPane);
final JComponent inplaceEditorComponent = createInplaceEditorComponent();
myInplaceEditorComponent = inplaceEditorComponent;
LOG.assertTrue(inplaceEditorComponent != null);
setInplaceEditorBounds(inplaceEditorComponent, layeredPanePoint.x, layeredPanePoint.y, bounds.width, bounds.height);
layeredPane.add(inplaceEditorComponent, new Integer(250));
myRemoveActions.add(() -> layeredPane.remove(inplaceEditorComponent));
inplaceEditorComponent.validate();
inplaceEditorComponent.paintImmediately(0, 0, inplaceEditorComponent.getWidth(), inplaceEditorComponent.getHeight());
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(getPreferredFocusedComponent(), true);
});
final ComponentAdapter componentListener = new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
final Project project = getProject();
ApplicationManager.getApplication().invokeLater(() -> {
if (!isShown() || project == null || project.isDisposed()) {
return;
}
JTree tree1 = getTree();
JLayeredPane layeredPane1 = tree1.getRootPane().getLayeredPane();
Rectangle bounds1 = getEditorBounds();
if (bounds1 == null) {
return;
}
Point layeredPanePoint1 = SwingUtilities.convertPoint(tree1, bounds1.x, bounds1.y, layeredPane1);
setInplaceEditorBounds(inplaceEditorComponent, layeredPanePoint1.x, layeredPanePoint1.y, bounds1.width, bounds1.height);
inplaceEditorComponent.revalidate();
});
}
@Override
public void componentHidden(ComponentEvent e) {
cancelEditing();
}
};
final HierarchyListener hierarchyListener = e -> {
if (!tree.isShowing()) {
cancelEditing();
}
};
tree.addHierarchyListener(hierarchyListener);
tree.addComponentListener(componentListener);
rootPane.addComponentListener(componentListener);
myRemoveActions.add(() -> {
tree.removeHierarchyListener(hierarchyListener);
tree.removeComponentListener(componentListener);
rootPane.removeComponentListener(componentListener);
});
getProject().getMessageBus().connect(myDisposable).subscribe(RunContentManager.TOPIC, new RunContentWithExecutorListener() {
@Override
public void contentSelected(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor) {
cancelEditing();
}
@Override
public void contentRemoved(@Nullable RunContentDescriptor descriptor, @NotNull Executor executor) {
cancelEditing();
}
});
final JComponent editorComponent = getEditorComponent();
editorComponent.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "enterStroke");
editorComponent.getActionMap().put("enterStroke", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
doOKAction();
}
});
editorComponent.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "escapeStroke");
editorComponent.getActionMap().put("escapeStroke", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
cancelEditing();
}
});
final Toolkit defaultToolkit = Toolkit.getDefaultToolkit();
SwingUtilities.invokeLater(() -> {
if (!isShown())
return;
defaultToolkit.addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK);
});
myRemoveActions.add(() -> defaultToolkit.removeAWTEventListener(this));
onShown();
}
Aggregations