@Override public void apply() throws ConfigurationException { commonCompilerArguments.suppressWarnings = generateNoWarningsCheckBox.isSelected(); compilerSettings.setAdditionalArguments(additionalArgsOptionsField.getText()); compilerSettings.setScriptTemplates(scriptTemplatesField.getText()); compilerSettings.setScriptTemplatesClasspath(scriptTemplatesClasspathField.getText()); compilerSettings.setCopyJsLibraryFiles(copyRuntimeFilesCheckBox.isSelected()); compilerSettings.setOutputDirectoryForJsLibraryFiles(outputDirectory.getText()); if (compilerWorkspaceSettings != null) { compilerWorkspaceSettings.setPreciseIncrementalEnabled( enablePreciseIncrementalCheckBox.isSelected()); boolean oldEnableDaemon = compilerWorkspaceSettings.getEnableDaemon(); compilerWorkspaceSettings.setEnableDaemon(keepAliveCheckBox.isSelected()); if (keepAliveCheckBox.isSelected() != oldEnableDaemon) { PluginStartupComponent.getInstance().resetAliveFlag(); } } k2jsCompilerArguments.sourceMap = generateSourceMapsCheckBox.isSelected(); k2jsCompilerArguments.outputPrefix = StringUtil.nullize(outputPrefixFile.getText(), true); k2jsCompilerArguments.outputPostfix = StringUtil.nullize(outputPostfixFile.getText(), true); k2jsCompilerArguments.moduleKind = getSelectedModuleKind(); BuildManager.getInstance().clearState(project); }
public boolean validate() throws ConfigurationException { final String moduleName = getModuleName(); if (myCreateModuleCb.isSelected() || !myWizardContext.isCreatingNewProject()) { final String moduleFileDirectory = myModuleFileLocation.getText(); if (moduleFileDirectory.length() == 0) { throw new ConfigurationException("Enter module file location"); } if (moduleName.length() == 0) { throw new ConfigurationException("Enter a module name"); } if (!ProjectWizardUtil.createDirectoryIfNotExists( IdeBundle.message("directory.module.file"), moduleFileDirectory, myImlLocationChangedByUser)) { return false; } if (!ProjectWizardUtil.createDirectoryIfNotExists( IdeBundle.message("directory.module.content.root"), myModuleContentRoot.getText(), myContentRootChangedByUser)) { return false; } File moduleFile = new File(moduleFileDirectory, moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION); if (moduleFile.exists()) { int answer = Messages.showYesNoDialog( IdeBundle.message( "prompt.overwrite.project.file", moduleFile.getAbsolutePath(), IdeBundle.message("project.new.wizard.module.identification")), IdeBundle.message("title.file.already.exists"), Messages.getQuestionIcon()); if (answer != 0) { return false; } } } if (!myWizardContext.isCreatingNewProject()) { final Module module; final ProjectStructureConfigurable fromConfigurable = ProjectStructureConfigurable.getInstance(myWizardContext.getProject()); if (fromConfigurable != null) { module = fromConfigurable.getModulesConfig().getModule(moduleName); } else { module = ModuleManager.getInstance(myWizardContext.getProject()).findModuleByName(moduleName); } if (module != null) { throw new ConfigurationException( "Module \'" + moduleName + "\' already exist in project. Please, specify another name."); } } return !myWizardContext.isCreatingNewProject() || super.validate(); }
public void validate() throws ConfigurationException { validateExecutableIfNonEmpty("stylish", stylishPath); validateExecutableIfNonEmpty("hlint", hlintPath); // Validate ghcModPath if either it or ghcModiPath have been set. if (ghcModPath.getText().isEmpty() && !ghcModiPath.getText().isEmpty()) { throw new ConfigurationException("ghc-mod must be configured if ghc-modi is configured."); } validateExecutableIfNonEmpty("ghc-mod", ghcModPath); validateExecutableIfNonEmpty("ghc-modi", ghcModiPath); validateExecutableIfNonEmpty("hindent", hindentPath); }
@Override protected void applyEditorTo(@NotNull K2JSRunConfiguration configuration) throws ConfigurationException { K2JSConfigurationSettings settings = configuration.settings(); settings.setPageToOpenFilePath(toSystemIndependentName(htmlChooseFile.getText())); Object item = browserComboBox.getSelectedItem(); if (item instanceof BrowsersConfiguration.BrowserFamily) { settings.setBrowserFamily((BrowsersConfiguration.BrowserFamily) item); } settings.setGeneratedFilePath(toSystemIndependentName(generatedChooseFile.getText())); settings.setShouldOpenInBrowserAfterTranslation(openInBrowserCheckBox.isSelected()); }
/** If we're using ghc-mod >= 5.4, ghc-modi will be configured as `ghc-mod legacy-interactive` */ private void ghcModLegacyInteractivePreSaveHook() { // If ghc-mod is not configured or is not >= 5.4, we can't infer legacy-interactive. if (ghcModPath.getText().isEmpty() || !isGhcMod5_4(ghcModPath.getText())) return; // If ghc-modi is configured and it is not >= 5.4, leave it alone. if (!ghcModiPath.getText().isEmpty() && !isGhcMod5_4(ghcModiPath.getText())) return; // If all is good, configure ghc-modi as legacy-interactive. ghcModiPath.setText(ghcModPath.getText()); // If the current ghc-modi flags contains the `legacy-interactive` command, do not add it back. if (!ghcModiFlags.getText().contains("legacy-interactive")) { ghcModiFlags.setText(ghcModiFlags.getText() + " legacy-interactive"); } }
public GoGeneratorPeer() { mySdkPath .getButton() .addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { FileChooser.chooseFile( FileChooserDescriptorFactory.createSingleFolderDescriptor(), null, mySdkPath, null, new Consumer<VirtualFile>() { @Override public void consume(@NotNull VirtualFile file) { mySdkPath.setText(FileUtil.toSystemDependentName(file.getPath())); } }); } }); gopathPath .getButton() .addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { FileChooser.chooseFile( FileChooserDescriptorFactory.createSingleFolderDescriptor(), null, gopathPath, null, new Consumer<VirtualFile>() { @Override public void consume(@NotNull VirtualFile file) { gopathPath.setText(FileUtil.toSystemDependentName(file.getPath())); } }); } }); mySdkPath.setText(FileUtil.toSystemDependentName(GoSettings.getInstance().goRoot)); if (mySdkPath.getText().equals("")) { mySdkPath.setText(GoSdkUtil.getSysGoRootPath()); } gopathPath.setText(FileUtil.toSystemDependentName(GoSettings.getInstance().goPath)); if (gopathPath.getText().equals("")) { gopathPath.setText(GoSdkUtil.getSysGoPathPath().split(File.pathSeparator)[0]); } }
@Override public void updateDataModel() { myWizardContext.setProjectBuilder(myModuleBuilder); myWizardContext.setProjectName(myNamePathComponent.getNameValue()); myWizardContext.setProjectFileDirectory(myNamePathComponent.getPath()); myFormatPanel.updateData(myWizardContext); if (myModuleBuilder != null) { final String moduleName = getModuleName(); myModuleBuilder.setName(moduleName); myModuleBuilder.setModuleFilePath( FileUtil.toSystemIndependentName(myModuleFileLocation.getText()) + "/" + moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION); myModuleBuilder.setContentEntryPath(FileUtil.toSystemIndependentName(getModuleContentRoot())); if (myModuleBuilder instanceof TemplateModuleBuilder) { myWizardContext.setProjectStorageFormat(StorageScheme.DIRECTORY_BASED); } } if (mySettingsStep != null) { mySettingsStep.updateDataModel(); } }
@Override protected void applyEditorTo(@NotNull ErlangConsoleRunConfiguration config) throws ConfigurationException { config.setModule((Module) myModuleComboBox.getSelectedItem()); config.setWorkingDirPath(myWorkingDirPathField.getText()); config.setConsoleArgs(myConsoleArgsEditor.getText()); }
@Override protected void applyEditorTo(GoApplicationConfiguration configuration) throws ConfigurationException { if (applicationName.getText().length() == 0) throw new ConfigurationException("Please select the file to run."); if (buildBeforeRunCheckBox.isSelected() && buildDirectoryPathBrowser.getText().equals("")) { throw new ConfigurationException("Please select the directory for the executable."); } configuration.scriptName = applicationName.getText(); configuration.scriptArguments = appArguments.getText(); configuration.builderArguments = builderArguments.getText(); configuration.goBuildBeforeRun = buildBeforeRunCheckBox.isSelected(); configuration.goOutputDir = buildDirectoryPathBrowser.getText(); configuration.workingDir = workingDirectoryBrowser.getText(); }
private void updateControls() { final boolean isNameOK = myValidator.checkName(myNameField.getText()); getOKAction().setEnabled(isNameOK); if (isNameOK) { final String text = myValueField.getText().trim(); getOKAction().setEnabled(text.length() > 0 && !"/".equals(text.trim())); } }
public void updateVersion() { String pathText = pathField.getText(); if (pathText.isEmpty()) { versionField.setText(""); } else { versionField.setText(getVersion(pathText, versionParam)); } }
public void apply() { ExportToHTMLSettings exportToHTMLSettings = ExportToHTMLSettings.getInstance(myProject); if (myCanBeOpenInBrowser) { exportToHTMLSettings.OPEN_IN_BROWSER = myCbOpenInBrowser.isSelected(); } exportToHTMLSettings.OUTPUT_DIRECTORY = myTargetDirectoryField.getText(); }
public void saveState() { if (isModified() && publisher != null) { publisher.onSettingsChanged(new ToolSettings(pathField.getText(), flagsField.getText())); } for (PropertyField propertyField : propertyFields) { propertyField.saveState(); } }
@Nullable @Override protected ValidationInfo doValidate() { if (StringUtils.isBlank(myOutputFolderChooser.getText())) { return new ValidationInfo("Target path can't be blank", myOutputFolderChooser.getTextField()); } return null; }
/** * Check destination directory and set appropriate error text if there are problems * * @return true if destination components are OK. */ private boolean checkDestination() { if (myParentDirectory.getText().length() == 0 || myDirectoryName.getText().length() == 0) { setErrorText(null); setOKActionEnabled(false); return false; } File file = new File(myParentDirectory.getText(), myDirectoryName.getText()); if (file.exists()) { setErrorText(GitBundle.message("clone.destination.exists.error", file)); setOKActionEnabled(false); return false; } else if (!file.getParentFile().exists()) { setErrorText(GitBundle.message("clone.parent.missing.error", file.getParent())); setOKActionEnabled(false); return false; } return true; }
public void updateDataModel() { if (!isCreateFromTemplateMode()) { mySequence.setType(myCreateModuleCb.isSelected() ? getSelectedBuilderId() : null); } super.updateDataModel(); if (!isCreateFromTemplateMode() && myCreateModuleCb.isSelected()) { final ModuleBuilder builder = (ModuleBuilder) myMode.getModuleBuilder(); assert builder != null; final String moduleName = getModuleName(); builder.setName(moduleName); builder.setModuleFilePath( FileUtil.toSystemIndependentName(myModuleFileLocation.getText()) + "/" + moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION); builder.setContentEntryPath(FileUtil.toSystemIndependentName(myModuleContentRoot.getText())); } }
public String getValue() { String path = myValueField.getText().trim(); File file = new File(path); if (file.isAbsolute()) { try { return file.getCanonicalPath(); } catch (IOException ignored) { } } return path; }
private boolean validateModulePaths() throws ConfigurationException { final String moduleName = getModuleName(); final String moduleFileDirectory = myModuleFileLocation.getText(); if (moduleFileDirectory.length() == 0) { throw new ConfigurationException("Enter module file location"); } if (moduleName.length() == 0) { throw new ConfigurationException("Enter a module name"); } if (!ProjectWizardUtil.createDirectoryIfNotExists( IdeBundle.message("directory.module.file"), moduleFileDirectory, myImlLocationChangedByUser)) { return false; } if (!ProjectWizardUtil.createDirectoryIfNotExists( IdeBundle.message("directory.module.content.root"), myModuleContentRoot.getText(), myContentRootChangedByUser)) { return false; } File moduleFile = new File(moduleFileDirectory, moduleName + ModuleFileType.DOT_DEFAULT_EXTENSION); if (moduleFile.exists()) { int answer = Messages.showYesNoDialog( IdeBundle.message( "prompt.overwrite.project.file", moduleFile.getAbsolutePath(), IdeBundle.message("project.new.wizard.module.identification")), IdeBundle.message("title.file.already.exists"), Messages.getQuestionIcon()); if (answer != 0) { return false; } } return true; }
@Nullable @Override public ValidationInfo validate() { if (getSdkData() == null) { return new ValidationInfo(GoBundle.message("error.invalid.sdk.path", mySdkPath.getText())); } String goSdkPath = mySdkPath.getText(); GoSdkType goSdk = new GoSdkType(); if (!goSdk.isValidSdkHome(goSdkPath)) { return new ValidationInfo(GoBundle.message("error.invalid.sdk.path", mySdkPath.getText())); } GoSdkData goSdkData = GoSdkUtil.testGoogleGoSdk(goSdkPath); if (goSdkData == null) { return new ValidationInfo(GoBundle.message("error.invalid.sdk.path", mySdkPath.getText())); } goSdkData.GO_GOPATH_PATH = gopathPath.getText(); labelSdkVersion.setText(goSdkData.VERSION_MAJOR); if (goSdkData.TARGET_OS != null && goSdkData.TARGET_ARCH != null) { labelSdkTarget.setText( String.format( "%s-%s (%s, %s)", goSdkData.TARGET_OS.getName(), goSdkData.TARGET_ARCH.getName(), GoSdkUtil.getCompilerName(goSdkData.TARGET_ARCH), GoSdkUtil.getLinkerName(goSdkData.TARGET_ARCH))); } else { labelSdkTarget.setText("Unknown target"); } labelBinariesPath.setText(goSdkData.GO_BIN_PATH); return null; }
/** * Save configuration panel state into settings object * * @param settings the settings object */ public void save(@NotNull GitVcsSettings settings) { settings.getAppSettings().setPathToGit(myGitField.getText()); myVcs.checkVersion(); settings.setIdeaSsh(IDEA_SSH.equals(mySSHExecutableComboBox.getSelectedItem())); Object policyItem = myConvertTextFilesComboBox.getSelectedItem(); GitVcsSettings.ConversionPolicy conversionPolicy; if (CRLF_DO_NOT_CONVERT.equals(policyItem)) { conversionPolicy = GitVcsSettings.ConversionPolicy.NONE; } else if (CRLF_CONVERT_TO_PROJECT.equals(policyItem)) { conversionPolicy = GitVcsSettings.ConversionPolicy.CONVERT; } else if (CRLF_ASK.equals(policyItem)) { conversionPolicy = GitVcsSettings.ConversionPolicy.ASK; } else { throw new IllegalStateException("Unknown selected CRLF policy: " + policyItem); } settings.setLineSeparatorsConversion(conversionPolicy); }
public LauncherParameters getLauncherParameters() { final LauncherParameters.LauncherType launcherType = myPlayerRadioButton.isSelected() ? LauncherParameters.LauncherType.Player : myBrowserRadioButton.isSelected() ? LauncherParameters.LauncherType.Browser : LauncherParameters.LauncherType.OSDefault; final WebBrowser browser = myBrowserSelector.getSelected(); final WebBrowser notNullBrowser = browser == null ? WebBrowserManager.getInstance().getFirstBrowser(BrowserFamily.FIREFOX) : browser; final String playerPath = FileUtil.toSystemIndependentName(myPlayerTextWithBrowse.getText().trim()); final boolean isNewPlayerInstance = myNewPlayerInstanceCheckBox.isSelected(); return new LauncherParameters(launcherType, notNullBrowser, playerPath, isNewPlayerInstance); }
public Generator getModifiedObject() { if (isOK()) { if (myPane != null) { myPane.readValuesTo(myGenerator); } final String dir = StringUtils.trimToNull(myOutputFolderChooser.getText()); assert dir != null; final String url = VfsUtil.pathToUrl(dir); final VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(url); myGenerator.setOutputDir(file == null ? url : file.getUrl()); return myGenerator; } else { return null; } }
protected void doOKAction() { if (myNode != null) { if (!doSetIcon(myNode, myTextField.getText(), getContentPane())) { return; } final Object userObject = myNode.getUserObject(); if (userObject instanceof Pair) { String actionId = (String) ((Pair) userObject).first; final AnAction action = ActionManager.getInstance().getAction(actionId); final Icon icon = (Icon) ((Pair) userObject).second; action.getTemplatePresentation().setIcon(icon); action.setDefaultIcon(icon == null); editToolbarIcon(actionId, myNode); } myActionsTree.repaint(); } setCustomizationSchemaForCurrentProjects(); super.doOKAction(); }
protected void doOKAction() { final String path = FileUtil.toSystemIndependentName(myDestDirectoryField.getText()); final Project project = myDirectory.getProject(); PsiDirectory directory = ApplicationManager.getApplication() .runWriteAction( new Computable<PsiDirectory>() { public PsiDirectory compute() { try { return DirectoryUtil.mkdirs(PsiManager.getInstance(project), path); } catch (IncorrectOperationException e) { LOG.error(e); return null; } } }); if (directory == null) { Messages.showErrorDialog( project, RefactoringBundle.message("cannot.find.or.create.destination.directory"), RefactoringBundle.message("cannot.move")); return; } super.doOKAction(); final PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(directory); if (aPackage == null) { Messages.showErrorDialog( project, RefactoringBundle.message("destination.directory.does.not.correspond.to.any.package"), RefactoringBundle.message("cannot.move")); return; } final JavaRefactoringSettings refactoringSettings = JavaRefactoringSettings.getInstance(); final boolean searchInComments = isSearchInComments(); final boolean searchForTextOccurences = isSearchInNonJavaFiles(); refactoringSettings.MOVE_SEARCH_IN_COMMENTS = searchInComments; refactoringSettings.MOVE_SEARCH_FOR_TEXT = searchForTextOccurences; performRefactoring(project, directory, aPackage, searchInComments, searchForTextOccurences); }
@Nullable private PsiFile getConfigFile(@NotNull Project project) { String directoryName = myConfigFileTextFieldWithBrowseButton.getText(); if (directoryName.length() == 0) return null; directoryName = directoryName.replace(File.separatorChar, '/'); VirtualFile path = LocalFileSystem.getInstance().findFileByPath(directoryName); while (path == null && directoryName.length() > 0) { int pos = directoryName.lastIndexOf('/'); if (pos <= 0) break; directoryName = directoryName.substring(0, pos); path = LocalFileSystem.getInstance().findFileByPath(directoryName); } if (path != null) { PsiManager psiManager = PsiManager.getInstance(project); if (!path.isDirectory()) { return psiManager.findFile(path); } } return null; }
private void flushDataTo(final CompoundReferenceRenderer renderer) { // label LabelRenderer labelRenderer = null; if (myRbExpressionLabel.isSelected()) { labelRenderer = new LabelRenderer(); labelRenderer.setLabelExpression(myLabelEditor.getText()); } renderer.setLabelRenderer(labelRenderer); // children ChildrenRenderer childrenRenderer = null; if (myRbExpressionChildrenRenderer.isSelected()) { childrenRenderer = new ExpressionChildrenRenderer(); ((ExpressionChildrenRenderer) childrenRenderer) .setChildrenExpression(myChildrenEditor.getText()); ((ExpressionChildrenRenderer) childrenRenderer) .setChildrenExpandable(myChildrenExpandedEditor.getText()); } else if (myRbListChildrenRenderer.isSelected()) { childrenRenderer = new EnumerationChildrenRenderer(getTableModel().getExpressions()); } renderer.setChildrenRenderer(childrenRenderer); // classname renderer.setClassName(myClassNameField.getText()); }
protected void enableSetIconButton(ActionManager actionManager) { final TreePath selectionPath = myTree.getSelectionPath(); Object userObject = null; if (selectionPath != null) { userObject = ((DefaultMutableTreeNode) selectionPath.getLastPathComponent()).getUserObject(); if (userObject instanceof String) { final AnAction action = actionManager.getAction((String) userObject); if (action != null && action.getTemplatePresentation() != null && action.getTemplatePresentation().getIcon() != null) { mySetIconButton.setEnabled(true); return; } } } mySetIconButton.setEnabled( myTextField.getText().length() != 0 && selectionPath != null && new DefaultMutableTreeNode(selectionPath).isLeaf() && !(userObject instanceof Separator)); }
/** Test availability of the connection */ private void testConnection() { final String executable = myGitField.getText(); if (myAppSettings != null) { myAppSettings.setPathToGit(executable); } final GitVersion version; try { version = GitVersion.identifyVersion(executable); } catch (Exception e) { Messages.showErrorDialog( myProject, e.getMessage(), GitBundle.getString("find.git.error.title")); return; } if (version.isSupported()) { Messages.showInfoMessage( myProject, version.toString(), GitBundle.getString("find.git.success.title")); } else { Messages.showWarningDialog( myProject, GitBundle.message("find.git.unsupported.message", version.toString(), GitVersion.MIN), GitBundle.getString("find.git.success.title")); } }
public String getParentDirectory() { return myParentDirectory.getText(); }
@Override public void applyTo(@NotNull JstdRunSettings.Builder runSettingsBuilder) { runSettingsBuilder.setConfigFile( ObjectUtils.notNull(myConfigFileTextFieldWithBrowseButton.getText(), "")); }