use of com.intellij.platform.DirectoryProjectGenerator in project intellij-community by JetBrains.
the class PythonGenerateProjectCallback method generateProject.
@Nullable
private static Project generateProject(@NotNull final ProjectSettingsStepBase settings) {
final DirectoryProjectGenerator generator = settings.getProjectGenerator();
final String location = FileUtil.expandUserHome(settings.getProjectLocation());
return AbstractNewProjectStep.doGenerateProject(ProjectManager.getInstance().getDefaultProject(), location, generator, file -> computeProjectSettings(generator, (ProjectSpecificSettingsStep) settings));
}
use of com.intellij.platform.DirectoryProjectGenerator in project intellij-community by JetBrains.
the class AbstractNewProjectDialog method createCenterPanel.
@Nullable
@Override
protected JComponent createCenterPanel() {
DirectoryProjectGenerator[] generators = Extensions.getExtensions(DirectoryProjectGenerator.EP_NAME);
setTitle(generators.length == 0 ? "Create Project" : "New Project");
DefaultActionGroup root = createRootStep();
Disposer.register(getDisposable(), () -> root.removeAll());
Pair<JPanel, JBList> pair = FlatWelcomeFrame.createActionGroupPanel(root, getRootPane(), null, getDisposable());
JPanel component = pair.first;
new AnAction() {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
close(CANCEL_EXIT_CODE);
}
}.registerCustomShortcutSet(KeyEvent.VK_ESCAPE, 0, component);
myPair = pair;
UiNotifyConnector.doWhenFirstShown(myPair.second, () -> ScrollingUtil.ensureSelectionExists(myPair.second));
FlatWelcomeFrame.installQuickSearch(pair.second);
return component;
}
use of com.intellij.platform.DirectoryProjectGenerator in project intellij-community by JetBrains.
the class ProjectSpecificSettingsStep method createInterpreterCombo.
@NotNull
private LabeledComponent<PythonSdkChooserCombo> createInterpreterCombo() {
final Project project = ProjectManager.getInstance().getDefaultProject();
final List<Sdk> sdks = PyConfigurableInterpreterList.getInstance(project).getAllPythonSdks();
VirtualEnvProjectFilter.removeAllAssociated(sdks);
Sdk compatibleSdk = sdks.isEmpty() ? null : sdks.iterator().next();
DirectoryProjectGenerator generator = getProjectGenerator();
if (generator instanceof PyFrameworkProjectGenerator && !((PyFrameworkProjectGenerator) generator).supportsPython3()) {
if (compatibleSdk != null && PythonSdkType.getLanguageLevelForSdk(compatibleSdk).isPy3K()) {
Sdk python2Sdk = PythonSdkType.findPython2Sdk(sdks);
if (python2Sdk != null) {
compatibleSdk = python2Sdk;
}
}
}
final Sdk preferred = compatibleSdk;
mySdkCombo = new PythonSdkChooserCombo(project, sdks, sdk -> sdk == preferred);
if (SystemInfo.isMac && !UIUtil.isUnderDarcula()) {
mySdkCombo.putClientProperty("JButton.buttonType", null);
}
mySdkCombo.setButtonIcon(PythonIcons.Python.InterpreterGear);
return LabeledComponent.create(mySdkCombo, "Interpreter", BorderLayout.WEST);
}
use of com.intellij.platform.DirectoryProjectGenerator 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);
}
}
}
}
Aggregations