Search in sources :

Example 1 with PyNewProjectSettings

use of com.jetbrains.python.newProject.PyNewProjectSettings in project intellij-community by JetBrains.

the class PythonGenerateProjectCallback method consume.

@Override
public void consume(@Nullable ProjectSettingsStepBase step) {
    if (!(step instanceof ProjectSpecificSettingsStep))
        return;
    final ProjectSpecificSettingsStep settingsStep = (ProjectSpecificSettingsStep) step;
    final DirectoryProjectGenerator generator = settingsStep.getProjectGenerator();
    Sdk sdk = settingsStep.getSdk();
    if (sdk instanceof PyDetectedSdk) {
        sdk = addDetectedSdk(settingsStep, sdk);
    }
    if (generator instanceof PythonProjectGenerator) {
        final BooleanFunction<PythonProjectGenerator> beforeProjectGenerated = ((PythonProjectGenerator) generator).beforeProjectGenerated(sdk);
        if (beforeProjectGenerated != null) {
            final boolean result = beforeProjectGenerated.fun((PythonProjectGenerator) generator);
            if (!result) {
                Messages.showWarningDialog("Project can not be generated", "Error in Project Generation");
                return;
            }
        }
    }
    final Project newProject = generateProject(settingsStep);
    if (generator instanceof PythonProjectGenerator && sdk == null && newProject != null) {
        final PyNewProjectSettings settings = (PyNewProjectSettings) ((PythonProjectGenerator) generator).getProjectSettings();
        ((PythonProjectGenerator) generator).createAndAddVirtualEnv(newProject, settings);
        sdk = settings.getSdk();
    }
    if (newProject != null && generator instanceof PythonProjectGenerator) {
        SdkConfigurationUtil.setDirectoryProjectSdk(newProject, sdk);
        final List<Sdk> sdks = PythonSdkType.getAllSdks();
        for (Sdk s : sdks) {
            final SdkAdditionalData additionalData = s.getSdkAdditionalData();
            if (additionalData instanceof PythonSdkAdditionalData) {
                ((PythonSdkAdditionalData) additionalData).reassociateWithCreatedProject(newProject);
            }
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) PyNewProjectSettings(com.jetbrains.python.newProject.PyNewProjectSettings) PythonProjectGenerator(com.jetbrains.python.newProject.PythonProjectGenerator) DirectoryProjectGenerator(com.intellij.platform.DirectoryProjectGenerator) PythonSdkAdditionalData(com.jetbrains.python.sdk.PythonSdkAdditionalData) PyDetectedSdk(com.jetbrains.python.sdk.PyDetectedSdk) Sdk(com.intellij.openapi.projectRoots.Sdk) PyDetectedSdk(com.jetbrains.python.sdk.PyDetectedSdk) PythonSdkAdditionalData(com.jetbrains.python.sdk.PythonSdkAdditionalData) SdkAdditionalData(com.intellij.openapi.projectRoots.SdkAdditionalData)

Example 2 with PyNewProjectSettings

use of com.jetbrains.python.newProject.PyNewProjectSettings in project intellij-community by JetBrains.

the class PythonGenerateProjectCallback method computeProjectSettings.

public static Object computeProjectSettings(DirectoryProjectGenerator<?> generator, final ProjectSpecificSettingsStep settings) {
    Object projectSettings = null;
    if (generator instanceof PythonProjectGenerator) {
        final PythonProjectGenerator<?> projectGenerator = (PythonProjectGenerator<?>) generator;
        projectSettings = projectGenerator.getProjectSettings();
    } else if (generator instanceof WebProjectTemplate) {
        projectSettings = ((WebProjectTemplate<?>) generator).getPeer().getSettings();
    }
    if (projectSettings instanceof PyNewProjectSettings) {
        final PyNewProjectSettings newProjectSettings = (PyNewProjectSettings) projectSettings;
        newProjectSettings.setSdk(settings.getSdk());
        newProjectSettings.setInstallFramework(settings.installFramework());
        newProjectSettings.setRemotePath(settings.getRemotePath());
    }
    return projectSettings;
}
Also used : PyNewProjectSettings(com.jetbrains.python.newProject.PyNewProjectSettings) PythonProjectGenerator(com.jetbrains.python.newProject.PythonProjectGenerator) WebProjectTemplate(com.intellij.ide.util.projectWizard.WebProjectTemplate)

Aggregations

PyNewProjectSettings (com.jetbrains.python.newProject.PyNewProjectSettings)2 PythonProjectGenerator (com.jetbrains.python.newProject.PythonProjectGenerator)2 WebProjectTemplate (com.intellij.ide.util.projectWizard.WebProjectTemplate)1 Project (com.intellij.openapi.project.Project)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 SdkAdditionalData (com.intellij.openapi.projectRoots.SdkAdditionalData)1 DirectoryProjectGenerator (com.intellij.platform.DirectoryProjectGenerator)1 PyDetectedSdk (com.jetbrains.python.sdk.PyDetectedSdk)1 PythonSdkAdditionalData (com.jetbrains.python.sdk.PythonSdkAdditionalData)1