Search in sources :

Example 6 with CompilerProjectExtension

use of com.intellij.openapi.roots.CompilerProjectExtension in project intellij-community by JetBrains.

the class ProjectConfigurable method apply.

@Override
public void apply() throws ConfigurationException {
    final CompilerProjectExtension compilerProjectExtension = CompilerProjectExtension.getInstance(myProject);
    assert compilerProjectExtension != null : myProject;
    if (myProjectName != null && StringUtil.isEmptyOrSpaces(myProjectName.getText())) {
        throw new ConfigurationException("Please, specify project name!");
    }
    ApplicationManager.getApplication().runWriteAction(() -> {
        // set the output path first so that handlers of RootsChanged event sent after JDK is set
        // would see the updated path
        String canonicalPath = myProjectCompilerOutput.getText();
        if (canonicalPath != null && canonicalPath.length() > 0) {
            try {
                canonicalPath = FileUtil.resolveShortWindowsName(canonicalPath);
            } catch (IOException e) {
            //file doesn't exist yet
            }
            canonicalPath = FileUtil.toSystemIndependentName(canonicalPath);
            compilerProjectExtension.setCompilerOutputUrl(VfsUtilCore.pathToUrl(canonicalPath));
        } else {
            compilerProjectExtension.setCompilerOutputPointer(null);
        }
        LanguageLevelProjectExtension extension = LanguageLevelProjectExtension.getInstance(myProject);
        LanguageLevel level = myLanguageLevelCombo.getSelectedLevel();
        if (level != null) {
            extension.setLanguageLevel(level);
        }
        extension.setDefault(myLanguageLevelCombo.isDefault());
        myProjectJdkConfigurable.apply();
        if (myProjectName != null) {
            ((ProjectEx) myProject).setProjectName(getProjectName());
            if (myDetailsComponent != null)
                myDetailsComponent.setText(getBannerSlogan());
        }
    });
}
Also used : ProjectEx(com.intellij.openapi.project.ex.ProjectEx) ConfigurationException(com.intellij.openapi.options.ConfigurationException) LanguageLevel(com.intellij.pom.java.LanguageLevel) CompilerProjectExtension(com.intellij.openapi.roots.CompilerProjectExtension) IOException(java.io.IOException) LanguageLevelProjectExtension(com.intellij.openapi.roots.LanguageLevelProjectExtension)

Aggregations

CompilerProjectExtension (com.intellij.openapi.roots.CompilerProjectExtension)6 Project (com.intellij.openapi.project.Project)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 IOException (java.io.IOException)2 Nullable (org.jetbrains.annotations.Nullable)2 WizardContext (com.intellij.ide.util.projectWizard.WizardContext)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 ProjectEx (com.intellij.openapi.project.ex.ProjectEx)1 JavaSdk (com.intellij.openapi.projectRoots.JavaSdk)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 LanguageLevelProjectExtension (com.intellij.openapi.roots.LanguageLevelProjectExtension)1 NewVirtualFile (com.intellij.openapi.vfs.newvfs.NewVirtualFile)1 VirtualFilePointer (com.intellij.openapi.vfs.pointers.VirtualFilePointer)1 LanguageLevel (com.intellij.pom.java.LanguageLevel)1 File (java.io.File)1