Search in sources :

Example 21 with ProjectManagerEx

use of com.intellij.openapi.project.ex.ProjectManagerEx in project Aspose.BarCode-for-Java by aspose-barcode.

the class AsposeMavenModuleBuilderHelper method copyMavenConfigurationFiles.

private void copyMavenConfigurationFiles(VirtualFile pom) {
    try {
        String projectPath = project.getBasePath();
        final File workingDir = new File(getAsposeMavenWorkSpace());
        String projectModulefile = projectPath + File.separator + project.getName() + ".iml";
        String projectIdea_compiler_xml = projectPath + File.separator + ".idea" + File.separator + "compiler.xml";
        String projectIdea_misc_xml = projectPath + File.separator + ".idea" + File.separator + "misc.xml";
        VirtualFile vf_projectIdea_misc_xml = LocalFileSystem.getInstance().findFileByPath(projectIdea_misc_xml);
        FileUtil.copy(new File(workingDir, intelliJMavenFiles.get(0)), new File(projectModulefile));
        FileUtil.copy(new File(workingDir, intelliJMavenFiles.get(1)), new File(projectIdea_compiler_xml));
        addMavenConfiguration(vf_projectIdea_misc_xml, projectIdea_misc_xml);
        ProjectManagerEx pm = ProjectManagerEx.getInstanceEx();
        pm.reloadProject(project);
        EditorHelper.openInEditor(getPsiFile(project, pom));
    } catch (IOException e) {
        showError(project, e);
        return;
    } catch (Throwable e) {
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFile(com.intellij.psi.PsiFile) ProjectManagerEx(com.intellij.openapi.project.ex.ProjectManagerEx)

Example 22 with ProjectManagerEx

use of com.intellij.openapi.project.ex.ProjectManagerEx in project Aspose.Cells-for-Java by aspose-cells.

the class AsposeMavenModuleBuilderHelper method copyMavenConfigurationFiles.

private void copyMavenConfigurationFiles(VirtualFile pom) {
    try {
        String projectPath = project.getBasePath();
        final File workingDir = new File(getAsposeMavenWorkSpace());
        String projectModulefile = projectPath + File.separator + project.getName() + ".iml";
        String projectIdea_compiler_xml = projectPath + File.separator + ".idea" + File.separator + "compiler.xml";
        String projectIdea_misc_xml = projectPath + File.separator + ".idea" + File.separator + "misc.xml";
        VirtualFile vf_projectIdea_misc_xml = LocalFileSystem.getInstance().findFileByPath(projectIdea_misc_xml);
        FileUtil.copy(new File(workingDir, intelliJMavenFiles.get(0)), new File(projectModulefile));
        FileUtil.copy(new File(workingDir, intelliJMavenFiles.get(1)), new File(projectIdea_compiler_xml));
        addMavenConfiguration(vf_projectIdea_misc_xml, projectIdea_misc_xml);
        ProjectManagerEx pm = ProjectManagerEx.getInstanceEx();
        pm.reloadProject(project);
        EditorHelper.openInEditor(getPsiFile(project, pom));
    } catch (IOException e) {
        showError(project, e);
        return;
    } catch (Throwable e) {
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFile(com.intellij.psi.PsiFile) ProjectManagerEx(com.intellij.openapi.project.ex.ProjectManagerEx)

Example 23 with ProjectManagerEx

use of com.intellij.openapi.project.ex.ProjectManagerEx in project intellij by bazelbuild.

the class BlazeProjectCreator method doCreate.

@Nullable
private Project doCreate() throws IOException {
    final ProjectManagerEx projectManager = ProjectManagerEx.getInstanceEx();
    final String projectFilePath = wizardContext.getProjectFileDirectory();
    try {
        File projectDir = new File(projectFilePath).getParentFile();
        LOG.assertTrue(projectDir != null, "Cannot create project in '" + projectFilePath + "': no parent file exists");
        FileUtil.ensureExists(projectDir);
        if (wizardContext.getProjectStorageFormat() == StorageScheme.DIRECTORY_BASED) {
            final File ideaDir = new File(projectFilePath, Project.DIRECTORY_STORE_FOLDER);
            FileUtil.ensureExists(ideaDir);
        }
        String name = wizardContext.getProjectName();
        Project newProject = projectBuilder.createProject(name, projectFilePath);
        if (newProject == null) {
            return null;
        }
        if (!ApplicationManager.getApplication().isUnitTestMode()) {
            newProject.save();
        }
        if (!projectBuilder.validate(null, newProject)) {
            return null;
        }
        projectBuilder.commit(newProject, null, ModulesProvider.EMPTY_MODULES_PROVIDER);
        StartupManager.getInstance(newProject).registerPostStartupActivity(() -> {
            // ensure the dialog is shown after all startup activities are done
            // noinspection SSBasedInspection
            SwingUtilities.invokeLater(() -> {
                if (newProject.isDisposed() || ApplicationManager.getApplication().isUnitTestMode()) {
                    return;
                }
                ApplicationManager.getApplication().invokeLater(() -> {
                    if (newProject.isDisposed()) {
                        return;
                    }
                    final ToolWindow toolWindow = ToolWindowManager.getInstance(newProject).getToolWindow(ToolWindowId.PROJECT_VIEW);
                    if (toolWindow != null) {
                        toolWindow.activate(null);
                    }
                }, ModalityState.NON_MODAL);
            });
        });
        ProjectUtil.updateLastProjectLocation(projectFilePath);
        if (WindowManager.getInstance().isFullScreenSupportedInCurrentOS()) {
            IdeFocusManager instance = IdeFocusManager.findInstance();
            IdeFrame lastFocusedFrame = instance.getLastFocusedFrame();
            if (lastFocusedFrame instanceof IdeFrameEx) {
                boolean fullScreen = ((IdeFrameEx) lastFocusedFrame).isInFullScreen();
                if (fullScreen) {
                    newProject.putUserData(IdeFrameImpl.SHOULD_OPEN_IN_FULL_SCREEN, Boolean.TRUE);
                }
            }
        }
        projectManager.openProject(newProject);
        if (!ApplicationManager.getApplication().isUnitTestMode()) {
            newProject.save();
        }
        return newProject;
    } finally {
        projectBuilder.cleanup();
    }
}
Also used : Project(com.intellij.openapi.project.Project) ToolWindow(com.intellij.openapi.wm.ToolWindow) IdeFocusManager(com.intellij.openapi.wm.IdeFocusManager) ProjectManagerEx(com.intellij.openapi.project.ex.ProjectManagerEx) File(java.io.File) IdeFrame(com.intellij.openapi.wm.IdeFrame) IdeFrameEx(com.intellij.openapi.wm.ex.IdeFrameEx) Nullable(javax.annotation.Nullable)

Aggregations

ProjectManagerEx (com.intellij.openapi.project.ex.ProjectManagerEx)23 Project (com.intellij.openapi.project.Project)18 VirtualFile (com.intellij.openapi.vfs.VirtualFile)12 File (java.io.File)10 IOException (java.io.IOException)6 PsiFile (com.intellij.psi.PsiFile)5 ProjectManagerImpl (com.intellij.openapi.project.impl.ProjectManagerImpl)3 ProjectBuilder (com.intellij.ide.util.projectWizard.ProjectBuilder)2 Module (com.intellij.openapi.module.Module)2 IdeFrameEx (com.intellij.openapi.wm.ex.IdeFrameEx)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 GradleBuildFile (com.android.tools.idea.gradle.parser.GradleBuildFile)1 AndroidGradleProjectComponent (com.android.tools.idea.gradle.project.AndroidGradleProjectComponent)1 GradleUtil.getGradleBuildFile (com.android.tools.idea.gradle.util.GradleUtil.getGradleBuildFile)1 Projects.canImportAsGradleProject (com.android.tools.idea.gradle.util.Projects.canImportAsGradleProject)1 Projects.isLegacyIdeaAndroidProject (com.android.tools.idea.gradle.util.Projects.isLegacyIdeaAndroidProject)1 Document (com.intellij.openapi.editor.Document)1 FileDocumentManager (com.intellij.openapi.fileEditor.FileDocumentManager)1 FileDocumentManagerImpl (com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl)1