Example usage for com.intellij.openapi.wm ToolWindowId RUN

List of usage examples for com.intellij.openapi.wm ToolWindowId RUN

Introduction

In this page you can find the example usage for com.intellij.openapi.wm ToolWindowId RUN.

Prototype

String RUN

To view the source code for com.intellij.openapi.wm ToolWindowId RUN.

Click Source Link

Usage

From source file:com.headwire.aem.tooling.intellij.communication.ServerConnectionManager.java

License:Apache License

public void publishBundle(@NotNull final DataContext dataContext, final @NotNull Module module) {
    messageManager.sendInfoNotification("deploy.module.prepare", module);
    InputStream contents = null;// www.  j a v a 2 s  .  c  om
    // Check if this is a OSGi Bundle
    final UnifiedModule unifiedModule = module.getUnifiedModule();
    if (unifiedModule.isOSGiBundle()) {
        try {
            updateModuleStatus(module, ServerConfiguration.SynchronizationStatus.updating);
            boolean localBuildDoneSuccessfully = true;
            //AS TODO: This should be isBuildLocally instead as we can now build both with Maven or Locally if Facet is specified
            if (module.getParent().isBuildWithMaven() && module.getUnifiedModule().isMavenBased()) {
                localBuildDoneSuccessfully = false;
                List<String> goals = MavenDataKeys.MAVEN_GOALS.getData(dataContext);
                if (goals == null) {
                    goals = new ArrayList<String>();
                }
                if (goals.isEmpty()) {
                    //                        goals.add("package");
                    // If a module depends on anoher Maven module then we need to have it installed into the local repo
                    goals.add("install");
                }
                messageManager.sendInfoNotification("deploy.module.maven.goals", goals);
                final MavenProjectsManager projectsManager = MavenActionUtil.getProjectsManager(dataContext);
                if (projectsManager == null) {
                    messageManager.showAlert("Maven Failure",
                            "Could not find Maven Project Manager, need to build manually");
                } else {
                    final ToolWindow tw = ToolWindowManager.getInstance(module.getProject())
                            .getToolWindow(ToolWindowId.RUN);
                    final boolean isShown = tw != null && tw.isVisible();
                    String workingDirectory = unifiedModule.getModuleDirectory();
                    MavenExplicitProfiles explicitProfiles = projectsManager.getExplicitProfiles();
                    final MavenRunnerParameters params = new MavenRunnerParameters(true, workingDirectory,
                            goals, explicitProfiles.getEnabledProfiles(),
                            explicitProfiles.getDisabledProfiles());
                    // This Monitor is used to know when the Maven build is done
                    RunExecutionMonitor rem = RunExecutionMonitor.getInstance(myProject);
                    // We need to tell the Monitor that we are going to start a Maven Build so that the Countdown Latch
                    // is ready
                    rem.startMavenBuild();
                    try {
                        ApplicationManager.getApplication().invokeLater(new Runnable() {
                            @Override
                            public void run() {
                                try {
                                    MavenRunConfigurationType.runConfiguration(module.getProject(), params,
                                            null);
                                } catch (RuntimeException e) {
                                    // Ignore it
                                    String message = e.getMessage();
                                }
                                if (isShown) {
                                    tw.hide(null);
                                }
                            }
                        }, ModalityState.NON_MODAL);
                    } catch (IllegalStateException e) {
                        if (firstRun) {
                            firstRun = false;
                            messageManager.showAlert("deploy.module.maven.first.run.failure");
                        }
                    } catch (RuntimeException e) {
                        messageManager.sendDebugNotification("debug.maven.build.failed.unexpected", e);
                    }
                    // Now we can wait for the process to end
                    switch (RunExecutionMonitor.getInstance(myProject).waitFor()) {
                    case done:
                        messageManager.sendInfoNotification("deploy.module.maven.done");
                        localBuildDoneSuccessfully = true;
                        break;
                    case timedOut:
                        messageManager.sendInfoNotification("deploy.module.maven.timedout");
                        messageManager.showAlert("deploy.module.maven.timedout");
                        break;
                    case interrupted:
                        messageManager.sendInfoNotification("deploy.module.maven.interrupted");
                        messageManager.showAlert("deploy.module.maven.interrupted");
                        break;
                    }
                }
            } else if (!module.getUnifiedModule().isMavenBased()) {
                // Compile the IntelliJ way
                final CompilerManager compilerManager = CompilerManager.getInstance(myProject);
                final CompileScope moduleScope = compilerManager
                        .createModuleCompileScope(module.getUnifiedModule().getModule(), true);
                WaitableRunner<AtomicBoolean> runner = new WaitableRunner<AtomicBoolean>(
                        new AtomicBoolean(false)) {
                    @Override
                    public void run() {
                        compilerManager.make(moduleScope, new CompileStatusNotification() {
                            public void finished(boolean aborted, int errors, int warnings,
                                    CompileContext compileContext) {
                                getResponse().set(!aborted && errors == 0);
                            }
                        });
                    }
                };
                runAndWait(runner);
                //                    final CountDownLatch waiter = new CountDownLatch(1);
                //                    final AtomicBoolean checker = new AtomicBoolean(false);
                //                    ApplicationManager.getApplication().invokeLater(
                //                        new Runnable() {
                //                            public void run() {
                //                            }
                //                        }
                //                    );
                //                    try {
                //                        waiter.await();
                //                    } catch(InterruptedException e) {
                //                        //AS TODO: Show Info Notification and Alert
                //                    }
                localBuildDoneSuccessfully = runner.getResponse().get();
            }
            if (localBuildDoneSuccessfully) {
                File buildDirectory = new File(module.getUnifiedModule().getBuildDirectoryPath());
                if (buildDirectory.exists() && buildDirectory.isDirectory()) {
                    File buildFile = new File(buildDirectory, module.getUnifiedModule().getBuildFileName());
                    messageManager.sendDebugNotification("debug.build.file.name", buildFile.toURL());
                    if (buildFile.exists()) {
                        //AS TODO: This looks like OSGi Symbolic Name to be used here
                        EmbeddedArtifact bundle = new EmbeddedArtifact(module.getSymbolicName(),
                                module.getVersion(), buildFile.toURL());
                        contents = bundle.openInputStream();
                        obtainSGiClient().installBundle(contents, bundle.getName());
                        module.setStatus(ServerConfiguration.SynchronizationStatus.upToDate);
                    } else {
                        messageManager.showAlertWithArguments("deploy.module.maven.missing.build.file",
                                buildFile.getAbsolutePath());
                    }
                }
                updateModuleStatus(module, ServerConfiguration.SynchronizationStatus.upToDate);
                messageManager.sendInfoNotification("deploy.module.success", module);
            }
        } catch (MalformedURLException e) {
            module.setStatus(ServerConfiguration.SynchronizationStatus.failed);
            messageManager.sendErrorNotification("deploy.module.failed.bad.url", e);
            updateModuleStatus(module, ServerConfiguration.SynchronizationStatus.failed);
        } catch (OsgiClientException e) {
            module.setStatus(ServerConfiguration.SynchronizationStatus.failed);
            messageManager.sendErrorNotification("deploy.module.failed.client", e);
            updateModuleStatus(module, ServerConfiguration.SynchronizationStatus.failed);
        } catch (IOException e) {
            module.setStatus(ServerConfiguration.SynchronizationStatus.failed);
            messageManager.sendErrorNotification("deploy.module.failed.io", e);
            updateModuleStatus(module, ServerConfiguration.SynchronizationStatus.failed);
        } finally {
            IOUtils.closeQuietly(contents);
        }
    } else {
        messageManager.sendNotification("deploy.module.unsupported.maven.packaging", NotificationType.WARNING);
    }
}

From source file:com.intellij.execution.executors.DefaultRunExecutor.java

License:Apache License

@Override
public String getToolWindowId() {
    return ToolWindowId.RUN;
}

From source file:com.intellij.execution.junit.TestPackage.java

License:Apache License

@Override
protected void notifyByBalloon(JUnitRunningModel model, boolean started,
        final JUnitConsoleProperties consoleProperties) {
    if (myFoundTests) {
        super.notifyByBalloon(model, started, consoleProperties);
    } else {/*from   w  w  w .j a  va2  s .  co  m*/
        final String packageName = myConfiguration.getPackage();
        if (packageName == null)
            return;
        final Project project = myConfiguration.getProject();
        final PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage(packageName);
        if (aPackage == null)
            return;
        final Module module = myConfiguration.getConfigurationModule().getModule();
        if (module == null)
            return;
        final Set<Module> modulesWithPackage = new HashSet<Module>();
        final PsiDirectory[] directories = aPackage.getDirectories();
        for (PsiDirectory directory : directories) {
            final Module currentModule = ModuleUtil.findModuleForFile(directory.getVirtualFile(), project);
            if (module != currentModule && currentModule != null) {
                modulesWithPackage.add(currentModule);
            }
        }
        if (!modulesWithPackage.isEmpty()) {
            final String testRunDebugId = consoleProperties.isDebug() ? ToolWindowId.DEBUG : ToolWindowId.RUN;
            final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
            final Function<Module, String> moduleNameRef = new Function<Module, String>() {
                @Override
                public String fun(Module module) {
                    final String moduleName = module.getName();
                    return "<a href=\"" + moduleName + "\">" + moduleName + "</a>";
                }
            };
            String message = "Tests were not found in module \"" + module.getName() + "\".\n" + "Use ";
            if (modulesWithPackage.size() == 1) {
                message += "module \"" + moduleNameRef.fun(modulesWithPackage.iterator().next()) + "\" ";
            } else {
                message += "one of\n" + StringUtil.join(modulesWithPackage, moduleNameRef, "\n") + "\n";
            }
            message += "instead";
            toolWindowManager.notifyByBalloon(testRunDebugId, MessageType.WARNING, message, null,
                    new ResetConfigurationModuleAdapter(project, consoleProperties, toolWindowManager,
                            testRunDebugId));
        }
    }
}

From source file:com.intellij.execution.testframework.ResetConfigurationModuleAdapter.java

License:Apache License

public static <T extends ModuleBasedConfiguration<JavaRunConfigurationModule> & CommonJavaRunConfigurationParameters> boolean tryWithAnotherModule(
        T configuration, boolean isDebug) {
    final String packageName = configuration.getPackage();
    if (packageName == null)
        return false;
    final Project project = configuration.getProject();
    final PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage(packageName);
    if (aPackage == null)
        return false;
    final Module module = configuration.getConfigurationModule().getModule();
    if (module == null)
        return false;
    final Set<Module> modulesWithPackage = new HashSet<Module>();
    final PsiDirectory[] directories = aPackage.getDirectories();
    for (PsiDirectory directory : directories) {
        final Module currentModule = ModuleUtilCore.findModuleForFile(directory.getVirtualFile(), project);
        if (module != currentModule && currentModule != null) {
            modulesWithPackage.add(currentModule);
        }//  ww  w  . j a v  a  2 s .  co  m
    }
    if (!modulesWithPackage.isEmpty()) {
        final String testRunDebugId = isDebug ? ToolWindowId.DEBUG : ToolWindowId.RUN;
        final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
        final Function<Module, String> moduleNameRef = module1 -> {
            final String moduleName = module1.getName();
            return "<a href=\"" + moduleName + "\">" + moduleName + "</a>";
        };
        String message = "Tests were not found in module \"" + module.getName() + "\".\n" + "Use ";
        if (modulesWithPackage.size() == 1) {
            message += "module \"" + moduleNameRef.fun(modulesWithPackage.iterator().next()) + "\" ";
        } else {
            message += "one of\n" + StringUtil.join(modulesWithPackage, moduleNameRef, "\n") + "\n";
        }
        message += "instead";
        toolWindowManager.notifyByBalloon(testRunDebugId, MessageType.WARNING, message, null,
                new ResetConfigurationModuleAdapter(configuration, project, isDebug, toolWindowManager,
                        testRunDebugId));
        return true;
    }
    return false;
}

From source file:com.intellij.execution.testframework.sm.runner.ui.SMTRunnerNotificationsHandler.java

License:Apache License

private void notify(final String msg, final MessageType type, final SMTestProxy.SMRootTestProxy testsRoot) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            final Project project = myConsoleProperties.getProject();
            if (project.isDisposed()) {
                return;
            }/*from ww w  . ja va 2  s  .  c o  m*/

            if (myConsoleProperties == null) {
                return;
            }
            final String testRunDebugId = myConsoleProperties.isDebug() ? ToolWindowId.DEBUG : ToolWindowId.RUN;
            final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
            if (!Comparing.strEqual(toolWindowManager.getActiveToolWindowId(), testRunDebugId)) {
                toolWindowManager.notifyByBalloon(testRunDebugId, type, msg, null, null);
            }
            TestsUIUtil.NOTIFICATION_GROUP.createNotification(msg, type).notify(project);
            SystemNotifications.getInstance().notify("TestRunner", msg,
                    TestsUIUtil.getTestShortSummary(testsRoot));
        }
    });
}

From source file:com.intellij.execution.testframework.TestsUIUtil.java

License:Apache License

public static void notifyByBalloon(@NotNull final Project project, boolean started,
        final AbstractTestProxy root, final TestConsoleProperties properties, @Nullable final String comment) {
    if (project.isDisposed())
        return;/*from  ww  w .  j av a2 s  . c  o  m*/
    if (properties == null)
        return;

    final String testRunDebugId = properties.isDebug() ? ToolWindowId.DEBUG : ToolWindowId.RUN;
    final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);

    String title;
    String text;
    String balloonText;
    MessageType type;
    TestResultPresentation testResultPresentation = new TestResultPresentation(root, started, comment)
            .getPresentation();
    type = testResultPresentation.getType();
    balloonText = testResultPresentation.getBalloonText();
    title = testResultPresentation.getTitle();
    text = testResultPresentation.getText();

    if (!Comparing.strEqual(toolWindowManager.getActiveToolWindowId(), testRunDebugId)) {
        toolWindowManager.notifyByBalloon(testRunDebugId, type, balloonText, null, null);
    }

    NOTIFICATION_GROUP.createNotification(balloonText, type).notify(project);
    SystemNotifications.getInstance().notify("TestRunner", title, text);
}

From source file:io.flutter.actions.RunProfileFlutterApp.java

License:Open Source License

public RunProfileFlutterApp() {
    super(TEXT, TEXT_DETAIL_MSG_KEY, DESCRIPTION, AllIcons.Actions.Execute, FlutterLaunchMode.PROFILE,
            ToolWindowId.RUN);
}

From source file:io.flutter.actions.RunReleaseFlutterApp.java

License:Open Source License

public RunReleaseFlutterApp() {
    super(TEXT, TEXT_DETAIL_MSG_KEY, DESCRIPTION, AllIcons.Actions.Execute, FlutterLaunchMode.RELEASE,
            ToolWindowId.RUN);
}

From source file:io.flutter.run.FlutterReloadManager.java

License:Open Source License

private Notification showRunNotification(@NotNull FlutterApp app, @Nullable String title,
        @NotNull String content, boolean isError) {
    final String toolWindowId = app.getMode() == RunMode.DEBUG ? ToolWindowId.DEBUG : ToolWindowId.RUN;
    final NotificationGroup notificationGroup = getNotificationGroup(toolWindowId);
    final Notification notification;
    if (title == null) {
        notification = notificationGroup.createNotification(content,
                isError ? NotificationType.ERROR : NotificationType.INFORMATION);
    } else {// ww  w  . jav a  2  s. c o m
        notification = notificationGroup.createNotification(title, content,
                isError ? NotificationType.ERROR : NotificationType.INFORMATION, null);
    }
    notification.setIcon(FlutterIcons.Flutter);
    notification.notify(myProject);

    lastNotification = notification;

    return notification;
}

From source file:io.flutter.run.FlutterReloadManager.java

License:Open Source License

private void removeRunNotifications(FlutterApp app) {
    final String toolWindowId = app.getMode() == RunMode.DEBUG ? ToolWindowId.DEBUG : ToolWindowId.RUN;
    final Balloon balloon = ToolWindowManager.getInstance(myProject).getToolWindowBalloon(toolWindowId);
    if (balloon != null) {
        balloon.hide();//from www  .ja  va2 s  .  c o m
    }
}