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);
}
}
}
}
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;
}
Aggregations