Search in sources :

Example 1 with ApplicationImpl

use of com.intellij.openapi.application.impl.ApplicationImpl in project intellij-community by JetBrains.

the class InitialConfigurationDialog method doOKAction.

@Override
protected void doOKAction() {
    Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myMainPanel));
    super.doOKAction();
    // set keymap
    ((KeymapManagerImpl) KeymapManager.getInstance()).setActiveKeymap((Keymap) myKeymapComboBox.getSelectedItem());
    // set color scheme
    EditorColorsManager.getInstance().setGlobalScheme((EditorColorsScheme) myColorSchemeComboBox.getSelectedItem());
    // create default todo_pattern for color scheme
    TodoConfiguration.getInstance().resetToDefaultTodoPatterns();
    final boolean createScript = myCreateScriptCheckbox.isSelected();
    final boolean createEntry = myCreateEntryCheckBox.isSelected();
    if (createScript || createEntry) {
        final String pathName = myScriptPathTextField.getText();
        final boolean globalEntry = myGlobalEntryCheckBox.isSelected();
        ProgressManager.getInstance().run(new Task.Backgroundable(project, getTitle()) {

            @Override
            public void run(@NotNull final ProgressIndicator indicator) {
                indicator.setFraction(0.0);
                if (createScript) {
                    indicator.setText("Creating launcher script...");
                    try {
                        CreateLauncherScriptAction.createLauncherScript(pathName);
                    } catch (Exception e) {
                        CreateLauncherScriptAction.reportFailure(e, getProject());
                    }
                }
                indicator.setFraction(0.5);
                if (createEntry) {
                    indicator.setText("Creating desktop entry...");
                    try {
                        CreateDesktopEntryAction.createDesktopEntry(globalEntry);
                    } catch (Exception e) {
                        CreateDesktopEntryAction.reportFailure(e, getProject());
                    }
                }
                indicator.setFraction(1.0);
            }
        });
    }
    UIManager.LookAndFeelInfo info = (UIManager.LookAndFeelInfo) myAppearanceComboBox.getSelectedItem();
    LafManagerImpl lafManager = (LafManagerImpl) LafManager.getInstance();
    if (info.getName().contains("Darcula") != (LafManager.getInstance().getCurrentLookAndFeel() instanceof DarculaLookAndFeelInfo)) {
        lafManager.setLookAndFeelAfterRestart(info);
        String message = "IDE appearance settings will be applied after restart. Would you like to restart now?";
        int rc = Messages.showYesNoDialog(project, message, "IDE Appearance", Messages.getQuestionIcon());
        if (rc == Messages.YES) {
            ((ApplicationImpl) ApplicationManager.getApplication()).restart(true);
        }
    } else if (!info.equals(lafManager.getCurrentLookAndFeel())) {
        lafManager.setCurrentLookAndFeel(info);
        lafManager.updateUI();
    }
}
Also used : Task(com.intellij.openapi.progress.Task) DarculaLookAndFeelInfo(com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo) ApplicationImpl(com.intellij.openapi.application.impl.ApplicationImpl) DarculaLookAndFeelInfo(com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo) Project(com.intellij.openapi.project.Project) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) LafManagerImpl(com.intellij.ide.ui.laf.LafManagerImpl) KeymapManagerImpl(com.intellij.openapi.keymap.impl.KeymapManagerImpl)

Example 2 with ApplicationImpl

use of com.intellij.openapi.application.impl.ApplicationImpl in project intellij-community by JetBrains.

the class ApplicationActivationStateManager method updateState.

public static boolean updateState(final WindowEvent windowEvent) {
    final Application application = ApplicationManager.getApplication();
    if (!(application instanceof ApplicationImpl))
        return false;
    final Window eventWindow = windowEvent.getWindow();
    if (windowEvent.getID() == WindowEvent.WINDOW_ACTIVATED || windowEvent.getID() == WindowEvent.WINDOW_GAINED_FOCUS) {
        if (state.isInactive()) {
            Window window = windowEvent.getWindow();
            return setActive(application, window);
        }
    } else if (windowEvent.getID() == WindowEvent.WINDOW_DEACTIVATED && windowEvent.getOppositeWindow() == null) {
        requestToDeactivateTime.getAndSet(System.currentTimeMillis());
        // For stuff that cannot wait windowEvent notify about deactivation immediately
        if (state.isActive()) {
            IdeFrame ideFrame = getIdeFrameFromWindow(windowEvent.getWindow());
            if (ideFrame != null) {
                application.getMessageBus().syncPublisher(ApplicationActivationListener.TOPIC).applicationDeactivated(ideFrame);
            }
        }
        // We do not know for sure that application is going to be inactive,
        // windowEvent could just be showing a popup or another transient window.
        // So let's postpone the application deactivation for a while
        state = State.DEACTIVATING;
        LOG.debug("The app is in the deactivating state");
        Timer timer = UIUtil.createNamedTimer("ApplicationDeactivation", Registry.intValue("application.deactivation.timeout"), new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                if (state.equals(State.DEACTIVATING)) {
                    state = State.DEACTIVATED;
                    LOG.debug("The app is in the deactivated state");
                    IdeFrame ideFrame = getIdeFrameFromWindow(windowEvent.getWindow());
                    if (ideFrame != null) {
                        application.getMessageBus().syncPublisher(ApplicationActivationListener.TOPIC).delayedApplicationDeactivated(ideFrame);
                    }
                }
            }
        });
        timer.setRepeats(false);
        timer.start();
        return true;
    }
    return false;
}
Also used : ActionListener(java.awt.event.ActionListener) ApplicationImpl(com.intellij.openapi.application.impl.ApplicationImpl) ActionEvent(java.awt.event.ActionEvent) Application(com.intellij.openapi.application.Application) IdeFrame(com.intellij.openapi.wm.IdeFrame)

Example 3 with ApplicationImpl

use of com.intellij.openapi.application.impl.ApplicationImpl in project intellij-community by JetBrains.

the class IdeaLogger method logErrorHeader.

private void logErrorHeader() {
    final String info = ourApplicationInfoProvider.getInfo();
    if (info != null) {
        myLogger.error(info);
    }
    if (ourCompilationTimestamp != null) {
        myLogger.error("Internal version. Compiled " + ourCompilationTimestamp);
    }
    myLogger.error("JDK: " + System.getProperties().getProperty("java.version", "unknown"));
    myLogger.error("VM: " + System.getProperties().getProperty("java.vm.name", "unknown"));
    myLogger.error("Vendor: " + System.getProperties().getProperty("java.vendor", "unknown"));
    myLogger.error("OS: " + System.getProperties().getProperty("os.name", "unknown"));
    ApplicationImpl application = (ApplicationImpl) ApplicationManager.getApplication();
    if (application != null && application.isComponentsCreated() && !application.isDisposed()) {
        final String lastPreformedActionId = ourLastActionId;
        if (lastPreformedActionId != null) {
            myLogger.error("Last Action: " + lastPreformedActionId);
        }
        CommandProcessor commandProcessor = CommandProcessor.getInstance();
        if (commandProcessor != null) {
            final String currentCommandName = commandProcessor.getCurrentCommandName();
            if (currentCommandName != null) {
                myLogger.error("Current Command: " + currentCommandName);
            }
        }
    }
}
Also used : ApplicationImpl(com.intellij.openapi.application.impl.ApplicationImpl) CommandProcessor(com.intellij.openapi.command.CommandProcessor)

Example 4 with ApplicationImpl

use of com.intellij.openapi.application.impl.ApplicationImpl in project intellij-community by JetBrains.

the class EditorColorsManagerImpl method setGlobalScheme.

@Override
public void setGlobalScheme(@Nullable EditorColorsScheme scheme) {
    Application application = ApplicationManager.getApplication();
    boolean notify = (application instanceof ApplicationImpl && ((ApplicationImpl) application).isLoaded());
    mySchemeManager.setCurrent(scheme == null ? getDefaultScheme() : scheme, notify);
}
Also used : ApplicationImpl(com.intellij.openapi.application.impl.ApplicationImpl) Application(com.intellij.openapi.application.Application)

Example 5 with ApplicationImpl

use of com.intellij.openapi.application.impl.ApplicationImpl in project intellij-community by JetBrains.

the class TrailingSpacesStripperTest method testModifyLineAndExitApplication_ShouldStripEvenWhenCaretIsAtTheChangedLine.

public void testModifyLineAndExitApplication_ShouldStripEvenWhenCaretIsAtTheChangedLine() throws IOException {
    configureFromFileText("x.txt", "xxx        <caret>\n");
    type(' ');
    ApplicationImpl application = (ApplicationImpl) ApplicationManager.getApplication();
    application.setDisposeInProgress(true);
    try {
        FileDocumentManager.getInstance().saveAllDocuments();
        checkResultByText("xxx<caret>\n");
    } finally {
        application.setDisposeInProgress(false);
    }
}
Also used : ApplicationImpl(com.intellij.openapi.application.impl.ApplicationImpl)

Aggregations

ApplicationImpl (com.intellij.openapi.application.impl.ApplicationImpl)14 Application (com.intellij.openapi.application.Application)6 Project (com.intellij.openapi.project.Project)2 LocalHistoryAction (com.intellij.history.LocalHistoryAction)1 LafManagerImpl (com.intellij.ide.ui.laf.LafManagerImpl)1 DarculaLookAndFeelInfo (com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo)1 ApplicationEx (com.intellij.openapi.application.ex.ApplicationEx)1 CommandProcessor (com.intellij.openapi.command.CommandProcessor)1 BasicUndoableAction (com.intellij.openapi.command.undo.BasicUndoableAction)1 UndoableAction (com.intellij.openapi.command.undo.UndoableAction)1 DocumentEx (com.intellij.openapi.editor.ex.DocumentEx)1 KeymapManagerImpl (com.intellij.openapi.keymap.impl.KeymapManagerImpl)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Task (com.intellij.openapi.progress.Task)1 DialogWrapper (com.intellij.openapi.ui.DialogWrapper)1 EmptyRunnable (com.intellij.openapi.util.EmptyRunnable)1 Ref (com.intellij.openapi.util.Ref)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 IdeFrame (com.intellij.openapi.wm.IdeFrame)1 PsiElement (com.intellij.psi.PsiElement)1