use of com.intellij.openapi.wm.ToolWindowManager in project intellij-community by JetBrains.
the class ExternalSystemUtil method ensureToolWindowInitialized.
public static void ensureToolWindowInitialized(@NotNull Project project, @NotNull ProjectSystemId externalSystemId) {
try {
ToolWindowManager manager = ToolWindowManager.getInstance(project);
if (!(manager instanceof ToolWindowManagerEx)) {
return;
}
ToolWindowManagerEx managerEx = (ToolWindowManagerEx) manager;
String id = externalSystemId.getReadableName();
ToolWindow window = manager.getToolWindow(id);
if (window != null) {
return;
}
ToolWindowEP[] beans = Extensions.getExtensions(ToolWindowEP.EP_NAME);
for (final ToolWindowEP bean : beans) {
if (id.equals(bean.id)) {
managerEx.initToolWindow(bean);
}
}
} catch (Exception e) {
LOG.error(String.format("Unable to initialize %s tool window", externalSystemId.getReadableName()), e);
}
}
use of com.intellij.openapi.wm.ToolWindowManager in project intellij-community by JetBrains.
the class ExternalSystemUtil method ensureToolWindowContentInitialized.
@Nullable
public static ToolWindow ensureToolWindowContentInitialized(@NotNull Project project, @NotNull ProjectSystemId externalSystemId) {
final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
if (toolWindowManager == null)
return null;
final ToolWindow toolWindow = toolWindowManager.getToolWindow(externalSystemId.getReadableName());
if (toolWindow == null)
return null;
if (toolWindow instanceof ToolWindowImpl) {
((ToolWindowImpl) toolWindow).ensureContentInitialized();
}
return toolWindow;
}
use of com.intellij.openapi.wm.ToolWindowManager in project intellij-community by JetBrains.
the class ExternalToolWindowManager method getToolWindow.
@Nullable
private static ToolWindow getToolWindow(@NotNull Project project, @NotNull ProjectSystemId externalSystemId) {
final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
if (toolWindowManager == null) {
return null;
}
ToolWindow result = toolWindowManager.getToolWindow(externalSystemId.getReadableName());
if (result instanceof ToolWindowImpl) {
((ToolWindowImpl) result).ensureContentInitialized();
}
return result;
}
use of com.intellij.openapi.wm.ToolWindowManager in project intellij-community by JetBrains.
the class RunDashboardManagerImpl method updateDashboard.
private void updateDashboard(final boolean withStructure) {
final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
toolWindowManager.invokeLater(() -> {
if (myProject.isDisposed()) {
return;
}
if (withStructure) {
boolean available = hasContent();
ToolWindow toolWindow = toolWindowManager.getToolWindow(getToolWindowId());
if (toolWindow == null) {
if (available) {
createToolWindow();
}
return;
}
boolean doShow = !toolWindow.isAvailable() && available;
toolWindow.setAvailable(available, null);
if (doShow) {
toolWindow.show(null);
}
}
if (myDashboardContent != null) {
myDashboardContent.updateContent(withStructure);
}
});
}
use of com.intellij.openapi.wm.ToolWindowManager in project intellij-community by JetBrains.
the class ProgramRunnerUtil method executeConfiguration.
public static void executeConfiguration(@NotNull final ExecutionEnvironment environment, boolean showSettings, boolean assignNewId) {
if (ExecutorRegistry.getInstance().isStarting(environment)) {
return;
}
RunnerAndConfigurationSettings runnerAndConfigurationSettings = environment.getRunnerAndConfigurationSettings();
final Project project = environment.getProject();
if (runnerAndConfigurationSettings != null) {
if (!ExecutionTargetManager.canRun(environment)) {
ExecutionUtil.handleExecutionError(environment, new ExecutionException(StringUtil.escapeXml("Cannot run '" + environment.getRunProfile().getName() + "' on '" + environment.getExecutionTarget().getDisplayName() + "'")));
return;
}
if ((!RunManagerImpl.canRunConfiguration(environment) || (showSettings && runnerAndConfigurationSettings.isEditBeforeRun())) && !DumbService.isDumb(project)) {
if (!RunDialog.editConfiguration(environment, "Edit configuration")) {
return;
}
while (!RunManagerImpl.canRunConfiguration(environment)) {
if (Messages.YES == Messages.showYesNoDialog(project, "Configuration is still incorrect. Do you want to edit it again?", "Change Configuration Settings", "Edit", "Continue Anyway", Messages.getErrorIcon())) {
if (!RunDialog.editConfiguration(environment, "Edit configuration")) {
return;
}
} else {
break;
}
}
}
ConfigurationType configurationType = runnerAndConfigurationSettings.getType();
if (configurationType != null) {
UsageTrigger.trigger("execute." + ConvertUsagesUtil.ensureProperKey(configurationType.getId()) + "." + environment.getExecutor().getId());
}
}
try {
if (assignNewId) {
environment.assignNewExecutionId();
}
if (DumbService.isDumb(project) && Registry.is("dumb.aware.run.configurations")) {
UIUtil.invokeLaterIfNeeded(() -> {
if (project.isDisposed()) {
return;
}
final String toolWindowId = ExecutionManager.getInstance(project).getContentManager().getToolWindowIdByEnvironment(environment);
ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
if (toolWindowManager.canShowNotification(toolWindowId)) {
//noinspection SSBasedInspection
toolWindowManager.notifyByBalloon(toolWindowId, MessageType.INFO, "Some actions may not work as expected if you start a Run/debug configuration while indexing is in progress.");
}
});
}
environment.getRunner().execute(environment);
} catch (ExecutionException e) {
String name = runnerAndConfigurationSettings != null ? runnerAndConfigurationSettings.getName() : null;
if (name == null) {
name = environment.getRunProfile().getName();
}
if (name == null && environment.getContentToReuse() != null) {
name = environment.getContentToReuse().getDisplayName();
}
if (name == null) {
name = "<Unknown>";
}
ExecutionUtil.handleExecutionError(project, ExecutionManager.getInstance(project).getContentManager().getToolWindowIdByEnvironment(environment), name, e);
}
}
Aggregations