public static void recordUsage(@NotNull TtyConnector ttyConnector) { UsageTrigger.trigger( TERMINAL_FEATURE + "." + (ttyConnector.toString().contains("Jsch") ? "ssh" : SystemInfo.isWindows ? "win" : SystemInfo.isMac ? "mac" : "linux")); }
private void runTriggers(Executor executor, RunnerAndConfigurationSettings configuration) { final ConfigurationType configurationType = configuration.getType(); if (configurationType != null) { UsageTrigger.trigger( "execute." + ConvertUsagesUtil.ensureProperKey(configurationType.getId()) + "." + executor.getId()); } }
@Nullable private Project generateProject( @NotNull final Project project, @NotNull final AbstractProjectSettingsStep settings) { final DirectoryProjectGenerator generator = settings.getProjectGenerator(); final File location = new File(settings.getProjectLocation()); if (!location.exists() && !location.mkdirs()) { Messages.showErrorDialog( project, "Cannot create directory '" + location + "'", "Create Project"); return null; } final VirtualFile baseDir = ApplicationManager.getApplication() .runWriteAction( new Computable<VirtualFile>() { public VirtualFile compute() { return LocalFileSystem.getInstance().refreshAndFindFileByIoFile(location); } }); LOG.assertTrue(baseDir != null, "Couldn't find '" + location + "' in VFS"); baseDir.refresh(false, true); if (baseDir.getChildren().length > 0) { int rc = Messages.showYesNoDialog( project, "The directory '" + location + "' is not empty. Would you like to create a project from existing sources instead?", "Create New Project", Messages.getQuestionIcon()); if (rc == Messages.YES) { return PlatformProjectOpenProcessor.getInstance().doOpenProject(baseDir, null, false); } } String generatorName = generator == null ? "empty" : ConvertUsagesUtil.ensureProperKey(generator.getName()); UsageTrigger.trigger("NewDirectoryProjectAction." + generatorName); GeneralSettings.getInstance().setLastProjectCreationLocation(location.getParent()); return PlatformProjectOpenProcessor.doOpenProject( baseDir, null, false, -1, new ProjectOpenedCallback() { @Override public void projectOpened(Project project, Module module) { if (generator != null) { Object projectSettings = null; if (generator instanceof PythonProjectGenerator) { projectSettings = ((PythonProjectGenerator) generator).getProjectSettings(); } else if (generator instanceof WebProjectTemplate) { projectSettings = ((WebProjectTemplate) generator).getPeer().getSettings(); } if (projectSettings instanceof PyNewProjectSettings) { ((PyNewProjectSettings) projectSettings).setSdk(settings.getSdk()); ((PyNewProjectSettings) projectSettings) .setInstallFramework(settings.installFramework()); } //noinspection unchecked generator.generateProject(project, baseDir, projectSettings, module); } } }, false); }
@Override public PsiElement[] create(String newName) throws Exception { UsageTrigger.trigger("CreateFile." + CreateFileAction.this.getClass().getSimpleName()); return super.create(newName); }
public static void executeConfiguration( @NotNull ExecutionEnvironment environment, boolean showSettings, boolean assignNewId) { if (ExecutorRegistry.getInstance().isStarting(environment)) { return; } RunnerAndConfigurationSettings runnerAndConfigurationSettings = environment.getRunnerAndConfigurationSettings(); 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())) { if (!RunDialog.editConfiguration(environment, "Edit configuration")) { return; } while (!RunManagerImpl.canRunConfiguration(environment)) { if (Messages.YES == Messages.showYesNoDialog( environment.getProject(), "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(); } 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( environment.getProject(), environment.getExecutor().getToolWindowId(), name, e); } }
@Override public void actionPerformed(@NotNull AnActionEvent e) { UsageTrigger.trigger("OpenInBrowser.default"); BaseOpenInBrowserAction.open(e, findUsingBrowser()); }