Search in sources :

Example 1 with IdeFrameEx

use of com.intellij.openapi.wm.ex.IdeFrameEx in project intellij-community by JetBrains.

the class ToggleFullScreenAction method update.

@Override
public void update(@NotNull final AnActionEvent e) {
    Presentation p = e.getPresentation();
    IdeFrameEx frame = null;
    boolean isApplicable = WindowManager.getInstance().isFullScreenSupportedInCurrentOS() && (frame = getFrame()) != null;
    if (e.getPlace() != ActionPlaces.MAIN_TOOLBAR) {
        p.setVisible(isApplicable);
    }
    p.setEnabled(isApplicable);
    if (isApplicable) {
        p.setText(frame.isInFullScreen() ? TEXT_EXIT_FULL_SCREEN : TEXT_ENTER_FULL_SCREEN);
    }
}
Also used : Presentation(com.intellij.openapi.actionSystem.Presentation) IdeFrameEx(com.intellij.openapi.wm.ex.IdeFrameEx)

Example 2 with IdeFrameEx

use of com.intellij.openapi.wm.ex.IdeFrameEx in project intellij-community by JetBrains.

the class IdePopupManager method dispatch.

public boolean dispatch(@NotNull final AWTEvent e) {
    LOG.assertTrue(isPopupActive());
    if (e.getID() == WindowEvent.WINDOW_LOST_FOCUS) {
        ApplicationManager.getApplication().invokeLater(() -> {
            if (!isPopupActive())
                return;
            boolean shouldCloseAllPopup = false;
            Window focused = ((WindowEvent) e).getOppositeWindow();
            if (focused == null) {
                focused = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
            }
            if (focused == null) {
                shouldCloseAllPopup = true;
            }
            Component ultimateParentForFocusedComponent = UIUtil.findUltimateParent(focused);
            Window sourceWindow = ((WindowEvent) e).getWindow();
            Component ultimateParentForEventWindow = UIUtil.findUltimateParent(sourceWindow);
            if (!shouldCloseAllPopup && ultimateParentForEventWindow == null || ultimateParentForFocusedComponent == null) {
                shouldCloseAllPopup = true;
            }
            if (!shouldCloseAllPopup && ultimateParentForEventWindow instanceof IdeFrameEx) {
                IdeFrameEx ultimateParentWindowForEvent = ((IdeFrameEx) ultimateParentForEventWindow);
                if (ultimateParentWindowForEvent.isInFullScreen() && !ultimateParentForFocusedComponent.equals(ultimateParentForEventWindow)) {
                    shouldCloseAllPopup = true;
                }
            }
            if (!shouldCloseAllPopup && isPopupWindow(sourceWindow) && sourceWindow.getParent() == ((WindowEvent) e).getOppositeWindow()) {
                shouldCloseAllPopup = true;
            }
            if (shouldCloseAllPopup) {
                closeAllPopups();
            }
        });
    }
    if (e instanceof KeyEvent || e instanceof MouseEvent) {
        for (int i = myDispatchStack.size() - 1; (i >= 0 && i < myDispatchStack.size()); i--) {
            final boolean dispatched = myDispatchStack.get(i).dispatch(e);
            if (dispatched)
                return true;
        }
    }
    return false;
}
Also used : KeyEvent(java.awt.event.KeyEvent) MouseEvent(java.awt.event.MouseEvent) WindowEvent(java.awt.event.WindowEvent) IdeFrameEx(com.intellij.openapi.wm.ex.IdeFrameEx)

Example 3 with IdeFrameEx

use of com.intellij.openapi.wm.ex.IdeFrameEx in project android by JetBrains.

the class Projects method open.

/**
   * Opens the given project in the IDE.
   *
   * @param project the project to open.
   */
public static void open(@NotNull Project project) {
    updateLastProjectLocation(project.getBasePath());
    if (WindowManager.getInstance().isFullScreenSupportedInCurrentOS()) {
        IdeFocusManager instance = IdeFocusManager.findInstance();
        IdeFrame lastFocusedFrame = instance.getLastFocusedFrame();
        if (lastFocusedFrame instanceof IdeFrameEx) {
            boolean fullScreen = ((IdeFrameEx) lastFocusedFrame).isInFullScreen();
            if (fullScreen) {
                project.putUserData(SHOULD_OPEN_IN_FULL_SCREEN, TRUE);
            }
        }
    }
    ProjectManagerEx.getInstanceEx().openProject(project);
}
Also used : IdeFocusManager(com.intellij.openapi.wm.IdeFocusManager) IdeFrame(com.intellij.openapi.wm.IdeFrame) IdeFrameEx(com.intellij.openapi.wm.ex.IdeFrameEx)

Example 4 with IdeFrameEx

use of com.intellij.openapi.wm.ex.IdeFrameEx in project intellij-community by JetBrains.

the class NewProjectUtil method doCreate.

private static Project doCreate(final AbstractProjectWizard dialog, @Nullable Project projectToClose) throws IOException {
    final ProjectManagerEx projectManager = ProjectManagerEx.getInstanceEx();
    final String projectFilePath = dialog.getNewProjectFilePath();
    for (Project p : ProjectManager.getInstance().getOpenProjects()) {
        if (ProjectUtil.isSameProject(projectFilePath, p)) {
            ProjectUtil.focusProjectWindow(p, false);
            return null;
        }
    }
    final ProjectBuilder projectBuilder = dialog.getProjectBuilder();
    try {
        File projectDir = new File(projectFilePath).getParentFile();
        LOG.assertTrue(projectDir != null, "Cannot create project in '" + projectFilePath + "': no parent file exists");
        FileUtil.ensureExists(projectDir);
        if (StorageScheme.DIRECTORY_BASED == dialog.getStorageScheme()) {
            FileUtil.ensureExists(new File(projectFilePath, Project.DIRECTORY_STORE_FOLDER));
        }
        final Project newProject;
        if (projectBuilder == null || !projectBuilder.isUpdate()) {
            String name = dialog.getProjectName();
            newProject = projectBuilder == null ? projectManager.newProject(name, projectFilePath, true, false) : projectBuilder.createProject(name, projectFilePath);
        } else {
            newProject = projectToClose;
        }
        if (newProject == null)
            return projectToClose;
        final Sdk jdk = dialog.getNewProjectJdk();
        if (jdk != null) {
            CommandProcessor.getInstance().executeCommand(newProject, () -> ApplicationManager.getApplication().runWriteAction(() -> applyJdkToProject(newProject, jdk)), null, null);
        }
        final String compileOutput = dialog.getNewCompileOutput();
        CommandProcessor.getInstance().executeCommand(newProject, () -> ApplicationManager.getApplication().runWriteAction(() -> {
            String canonicalPath = compileOutput;
            try {
                canonicalPath = FileUtil.resolveShortWindowsName(compileOutput);
            } catch (IOException e) {
            //file doesn't exist
            }
            canonicalPath = FileUtil.toSystemIndependentName(canonicalPath);
            CompilerProjectExtension.getInstance(newProject).setCompilerOutputUrl(VfsUtilCore.pathToUrl(canonicalPath));
        }), null, null);
        if (!ApplicationManager.getApplication().isUnitTestMode()) {
            newProject.save();
        }
        if (projectBuilder != null && !projectBuilder.validate(projectToClose, newProject)) {
            return projectToClose;
        }
        if (newProject != projectToClose && !ApplicationManager.getApplication().isUnitTestMode()) {
            closePreviousProject(projectToClose);
        }
        if (projectBuilder != null) {
            projectBuilder.commit(newProject, null, ModulesProvider.EMPTY_MODULES_PROVIDER);
        }
        final boolean need2OpenProjectStructure = projectBuilder == null || projectBuilder.isOpenProjectSettingsAfter();
        StartupManager.getInstance(newProject).registerPostStartupActivity(() -> {
            // ensure the dialog is shown after all startup activities are done
            ApplicationManager.getApplication().invokeLater(() -> {
                if (newProject.isDisposed() || ApplicationManager.getApplication().isUnitTestMode())
                    return;
                if (need2OpenProjectStructure) {
                    ModulesConfigurator.showDialog(newProject, null, null);
                }
                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);
            }, ModalityState.NON_MODAL);
        });
        if (newProject != projectToClose) {
            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 {
        if (projectBuilder != null) {
            projectBuilder.cleanup();
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) ProjectBuilder(com.intellij.ide.util.projectWizard.ProjectBuilder) JavaSdk(com.intellij.openapi.projectRoots.JavaSdk) Sdk(com.intellij.openapi.projectRoots.Sdk) IOException(java.io.IOException) ProjectManagerEx(com.intellij.openapi.project.ex.ProjectManagerEx) File(java.io.File) IdeFrameEx(com.intellij.openapi.wm.ex.IdeFrameEx)

Example 5 with IdeFrameEx

use of com.intellij.openapi.wm.ex.IdeFrameEx 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

IdeFrameEx (com.intellij.openapi.wm.ex.IdeFrameEx)5 Project (com.intellij.openapi.project.Project)2 ProjectManagerEx (com.intellij.openapi.project.ex.ProjectManagerEx)2 IdeFocusManager (com.intellij.openapi.wm.IdeFocusManager)2 IdeFrame (com.intellij.openapi.wm.IdeFrame)2 File (java.io.File)2 ProjectBuilder (com.intellij.ide.util.projectWizard.ProjectBuilder)1 Presentation (com.intellij.openapi.actionSystem.Presentation)1 JavaSdk (com.intellij.openapi.projectRoots.JavaSdk)1 Sdk (com.intellij.openapi.projectRoots.Sdk)1 ToolWindow (com.intellij.openapi.wm.ToolWindow)1 KeyEvent (java.awt.event.KeyEvent)1 MouseEvent (java.awt.event.MouseEvent)1 WindowEvent (java.awt.event.WindowEvent)1 IOException (java.io.IOException)1 Nullable (javax.annotation.Nullable)1