/** {@inheritDoc} */ @Override public Runner launchRunner() { CurrentProject currentProject = appContext.getCurrentProject(); if (currentProject == null) { throw new IllegalStateException( "Can't launch runner for current project. Current project is absent..."); } int ram = DEFAULT.getValue(); RunnersDescriptor runnersDescriptor = currentProject.getProjectDescription().getRunners(); String defaultRunner = runnersDescriptor.getDefault(); if (!EnvironmentIdValidator.isValid(defaultRunner)) { defaultRunner = URL.encode(defaultRunner); } RunnerConfiguration defaultConfigs = runnersDescriptor.getConfigs().get(defaultRunner); if (defaultRunner != null && defaultConfigs != null) { ram = defaultConfigs.getRam(); } RunOptions runOptions = dtoFactory .createDto(RunOptions.class) .withSkipBuild(Boolean.valueOf(currentProject.getAttributeValue("runner:skipBuild"))) .withEnvironmentId(defaultRunner) .withMemorySize(ram); Environment environment = chooseRunnerAction.selectEnvironment(); if (environment != null) { if (defaultRunner != null && defaultRunner.equals(environment.getId())) { Runner runner = modelsFactory.createRunner(runOptions); if (defaultRunner.startsWith(PROJECT_PREFIX)) { runner.setScope(PROJECT); } return launchRunner(runner); } runOptions = runOptions .withOptions(environment.getOptions()) .withMemorySize(environment.getRam()) .withEnvironmentId(environment.getId()); Runner runner = modelsFactory.createRunner(runOptions, environment.getScope(), environment.getName()); if (environment.getId().startsWith(PROJECT_PREFIX)) { runner.setScope(PROJECT); } return launchRunner(runner); } Runner runner = modelsFactory.createRunner(runOptions); if (defaultRunner != null && defaultRunner.startsWith(PROJECT_PREFIX)) { runner.setScope(PROJECT); } return launchRunner(modelsFactory.createRunner(runOptions)); }
/** {@inheritDoc} */ @Override public void onRunButtonClicked() { if (State.TEMPLATE.equals(panelState.getState())) { RunOptions runOptions = dtoFactory .createDto(RunOptions.class) .withOptions(selectedEnvironment.getOptions()) .withEnvironmentId(selectedEnvironment.getId()) .withMemorySize(selectedEnvironment.getRam()); Runner runner = modelsFactory.createRunner( runOptions, selectedEnvironment.getScope(), selectedEnvironment.getName()); if (PROJECT.equals(selectedEnvironment.getScope())) { runner.setScope(PROJECT); } launchRunner(runner); } else { launchRunner(); } }
@Before public void setUp() { when(appContext.getCurrentProject()).thenReturn(currentProject); when(environment.getScope()).thenReturn(SYSTEM); when(environment.getPath()).thenReturn(TEXT); when(environment.getName()).thenReturn(TEXT); when(environment.getType()).thenReturn(TEXT); when(environment.getRam()).thenReturn(MB_500.getValue()); when(currentProject.getCurrentTree()).thenReturn(treeStructure); when(currentProject.getProjectDescription()).thenReturn(descriptor); when(fileTypeRegistry.getFileTypeByFile(file)).thenReturn(fileType); when(editorProvider.getEditor()).thenReturn(editor); when(editor.getEditorInput()).thenReturn(editorInput); when(editorInput.getFile()).thenReturn(file); presenter = new DummyPanelProperties(view, appContext); }