use of com.intellij.openapi.projectRoots.SdkAdditionalData 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.intellij.openapi.projectRoots.SdkAdditionalData in project intellij-community by JetBrains.
the class PyRemotePackageManagerImpl method getHelperPath.
@Nullable
@Override
protected String getHelperPath(String helper) throws ExecutionException {
final Sdk sdk = getSdk();
final SdkAdditionalData sdkData = sdk.getSdkAdditionalData();
if (sdkData instanceof PyRemoteSdkAdditionalDataBase) {
final PyRemoteSdkAdditionalDataBase remoteSdkData = (PyRemoteSdkAdditionalDataBase) sdkData;
try {
String helpersPath;
if (CaseCollector.useRemoteCredentials(remoteSdkData)) {
final RemoteSdkCredentials remoteSdkCredentials = remoteSdkData.getRemoteSdkCredentials(false);
helpersPath = remoteSdkCredentials.getHelpersPath();
} else {
helpersPath = remoteSdkData.getHelpersPath();
}
if (!StringUtil.isEmpty(helpersPath)) {
return new RemoteFile(helpersPath, helper).getPath();
} else {
return null;
}
} catch (InterruptedException e) {
LOG.error(e);
} catch (ExecutionException e) {
throw analyzeException(e, helper, Collections.<String>emptyList());
}
}
return null;
}
use of com.intellij.openapi.projectRoots.SdkAdditionalData in project intellij-community by JetBrains.
the class PyRemoteProcessStarter method doStartRemoteProcess.
protected PyRemoteProcessHandlerBase doStartRemoteProcess(@NotNull Sdk sdk, @NotNull final GeneralCommandLine commandLine, @NotNull final PythonRemoteInterpreterManager manager, @Nullable final Project project, @Nullable PyRemotePathMapper pathMapper) throws ExecutionException {
SdkAdditionalData data = sdk.getSdkAdditionalData();
assert data instanceof PyRemoteSdkAdditionalDataBase;
final PyRemoteSdkAdditionalDataBase pyRemoteSdkAdditionalDataBase = (PyRemoteSdkAdditionalDataBase) data;
final PyRemotePathMapper extendedPathMapper = manager.setupMappings(project, pyRemoteSdkAdditionalDataBase, pathMapper);
try {
return PyRemoteProcessStarterManagerUtil.getManager(pyRemoteSdkAdditionalDataBase).startRemoteProcess(project, commandLine, manager, pyRemoteSdkAdditionalDataBase, extendedPathMapper);
} catch (InterruptedException e) {
throw new ExecutionException(e);
}
}
use of com.intellij.openapi.projectRoots.SdkAdditionalData in project intellij-community by JetBrains.
the class PyStudyDirectoryProjectGenerator method createAndAddVirtualEnv.
public void createAndAddVirtualEnv(Project project, PyNewProjectSettings settings) {
final ProjectSdksModel model = PyConfigurableInterpreterList.getInstance(project).getModel();
final String baseSdk = getBaseSdk(project);
if (baseSdk != null) {
final PyPackageManager packageManager = PyPackageManager.getInstance(new PyDetectedSdk(baseSdk));
try {
final String path = packageManager.createVirtualEnv(project.getBasePath() + "/.idea/VirtualEnvironment", false);
AbstractCreateVirtualEnvDialog.setupVirtualEnvSdk(path, true, new AbstractCreateVirtualEnvDialog.VirtualEnvCallback() {
@Override
public void virtualEnvCreated(Sdk createdSdk, boolean associateWithProject) {
settings.setSdk(createdSdk);
model.addSdk(createdSdk);
try {
model.apply();
} catch (ConfigurationException exception) {
LOG.error("Error adding created virtual env " + exception.getMessage());
}
if (associateWithProject) {
SdkAdditionalData additionalData = createdSdk.getSdkAdditionalData();
if (additionalData == null) {
additionalData = new PythonSdkAdditionalData(PythonSdkFlavor.getFlavor(createdSdk.getHomePath()));
((ProjectJdkImpl) createdSdk).setSdkAdditionalData(additionalData);
}
((PythonSdkAdditionalData) additionalData).associateWithNewProject();
}
}
});
} catch (ExecutionException e) {
LOG.warn("Failed to create virtual env " + e.getMessage());
}
}
}
use of com.intellij.openapi.projectRoots.SdkAdditionalData in project intellij-plugins by JetBrains.
the class Flexmojos3ImporterTest method checkFlexmojosSdkClasspath.
private static void checkFlexmojosSdkClasspath(final String sdkVersion, final String[] expectedPaths) {
final Sdk sdk = ProjectJdkTable.getInstance().findJdk("Flexmojos SDK " + sdkVersion);
assertNotNull(sdk);
assertInstanceOf(sdk.getSdkType(), FlexmojosSdkType.class);
final SdkAdditionalData additionalData = sdk.getSdkAdditionalData();
assertInstanceOf(additionalData, FlexmojosSdkAdditionalData.class);
final Collection<String> classpath = ((FlexmojosSdkAdditionalData) additionalData).getFlexCompilerClasspath();
assertSameElements(classpath, expectedPaths);
}
Aggregations