Search in sources :

Example 1 with DirectoryProjectGenerator

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));
}
Also used : DirectoryProjectGenerator(com.intellij.platform.DirectoryProjectGenerator) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with DirectoryProjectGenerator

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;
}
Also used : DirectoryProjectGenerator(com.intellij.platform.DirectoryProjectGenerator) JBList(com.intellij.ui.components.JBList) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) AnAction(com.intellij.openapi.actionSystem.AnAction) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with DirectoryProjectGenerator

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);
}
Also used : UIUtil(com.intellij.util.ui.UIUtil) PySdkUtil(com.jetbrains.python.sdk.PySdkUtil) ActionListener(java.awt.event.ActionListener) PyFrameworkProjectGenerator(com.jetbrains.python.newProject.PyFrameworkProjectGenerator) PythonRemoteInterpreterManager(com.jetbrains.python.remote.PythonRemoteInterpreterManager) ExecutionException(com.intellij.execution.ExecutionException) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) UiNotifyConnector(com.intellij.util.ui.update.UiNotifyConnector) PyProjectSynchronizer(com.jetbrains.python.remote.PyProjectSynchronizer) ProjectManager(com.intellij.openapi.project.ProjectManager) PyPackageManager(com.jetbrains.python.packaging.PyPackageManager) Project(com.intellij.openapi.project.Project) PythonIcons(icons.PythonIcons) PythonSdkType(com.jetbrains.python.sdk.PythonSdkType) WebProjectTemplate(com.intellij.ide.util.projectWizard.WebProjectTemplate) Logger(com.intellij.openapi.diagnostic.Logger) DumbAware(com.intellij.openapi.project.DumbAware) DocumentEvent(javax.swing.event.DocumentEvent) HideableDecorator(com.intellij.ui.HideableDecorator) ProgressManager(com.intellij.openapi.progress.ProgressManager) ItemEvent(java.awt.event.ItemEvent) PyConfigurableInterpreterList(com.jetbrains.python.configuration.PyConfigurableInterpreterList) PythonProjectGenerator(com.jetbrains.python.newProject.PythonProjectGenerator) PyPackageUtil(com.jetbrains.python.packaging.PyPackageUtil) StringUtil(com.intellij.openapi.util.text.StringUtil) ValidationResult(com.intellij.facet.ui.ValidationResult) DirectoryProjectGenerator(com.intellij.platform.DirectoryProjectGenerator) PyPackage(com.jetbrains.python.packaging.PyPackage) TextAccessor(com.intellij.ui.TextAccessor) ActionEvent(java.awt.event.ActionEvent) Sdk(com.intellij.openapi.projectRoots.Sdk) SystemInfo(com.intellij.openapi.util.SystemInfo) File(java.io.File) java.awt(java.awt) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) com.intellij.openapi.ui(com.intellij.openapi.ui) NullableConsumer(com.intellij.util.NullableConsumer) ProjectSettingsStepBase(com.intellij.ide.util.projectWizard.ProjectSettingsStepBase) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) Pair(com.intellij.openapi.util.Pair) ApplicationManager(com.intellij.openapi.application.ApplicationManager) PathUtil(com.intellij.util.PathUtil) VirtualEnvProjectFilter(com.jetbrains.python.configuration.VirtualEnvProjectFilter) NotNull(org.jetbrains.annotations.NotNull) DocumentAdapter(com.intellij.ui.DocumentAdapter) javax.swing(javax.swing) Project(com.intellij.openapi.project.Project) PyFrameworkProjectGenerator(com.jetbrains.python.newProject.PyFrameworkProjectGenerator) DirectoryProjectGenerator(com.intellij.platform.DirectoryProjectGenerator) Sdk(com.intellij.openapi.projectRoots.Sdk) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with DirectoryProjectGenerator

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

Aggregations

DirectoryProjectGenerator (com.intellij.platform.DirectoryProjectGenerator)4 Nullable (org.jetbrains.annotations.Nullable)3 Project (com.intellij.openapi.project.Project)2 Sdk (com.intellij.openapi.projectRoots.Sdk)2 PythonProjectGenerator (com.jetbrains.python.newProject.PythonProjectGenerator)2 ExecutionException (com.intellij.execution.ExecutionException)1 ValidationResult (com.intellij.facet.ui.ValidationResult)1 ProjectSettingsStepBase (com.intellij.ide.util.projectWizard.ProjectSettingsStepBase)1 WebProjectTemplate (com.intellij.ide.util.projectWizard.WebProjectTemplate)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 Logger (com.intellij.openapi.diagnostic.Logger)1 ProgressManager (com.intellij.openapi.progress.ProgressManager)1 DumbAware (com.intellij.openapi.project.DumbAware)1 ProjectManager (com.intellij.openapi.project.ProjectManager)1 SdkAdditionalData (com.intellij.openapi.projectRoots.SdkAdditionalData)1 com.intellij.openapi.ui (com.intellij.openapi.ui)1 JBPopupFactory (com.intellij.openapi.ui.popup.JBPopupFactory)1