Search in sources :

Example 6 with ApplicationImpl

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

the class _LastInSuiteTest method testProjectLeak.

public void testProjectLeak() throws Exception {
    boolean guiTestMode = Boolean.getBoolean("idea.test.guimode");
    if (guiTestMode) {
        final Application application = ApplicationManager.getApplication();
        TransactionGuard.getInstance().submitTransactionAndWait(() -> {
            IdeEventQueue.getInstance().flushQueue();
            ((ApplicationImpl) application).exit(true, true, false);
        });
        ShutDownTracker.getInstance().waitFor(100, TimeUnit.SECONDS);
        return;
    }
    UIUtil.invokeAndWaitIfNeeded((Runnable) () -> {
        try {
            LightPlatformTestCase.initApplication();
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        PlatformTestUtil.cleanupAllProjects();
        ApplicationImpl application = (ApplicationImpl) ApplicationManager.getApplication();
        System.out.println(application.writeActionStatistics());
        System.out.println(ActionUtil.ActionPauses.STAT.statistics());
        System.out.println(((AppScheduledExecutorService) AppExecutorUtil.getAppScheduledExecutorService()).statistics());
        System.out.println("ProcessIOExecutorService threads created: " + ((ProcessIOExecutorService) ProcessIOExecutorService.INSTANCE).getThreadCounter());
        application.setDisposeInProgress(true);
        LightPlatformTestCase.disposeApplication();
        UIUtil.dispatchAllInvocationEvents();
    });
    try {
        LeakHunter.checkProjectLeak();
        Disposer.assertIsEmpty(true);
    } catch (AssertionError | Exception e) {
        captureMemorySnapshot();
        throw e;
    }
    try {
        Disposer.assertIsEmpty(true);
    } catch (AssertionError | Exception e) {
        captureMemorySnapshot();
        throw e;
    }
}
Also used : AppScheduledExecutorService(com.intellij.util.concurrency.AppScheduledExecutorService) ApplicationImpl(com.intellij.openapi.application.impl.ApplicationImpl) Application(com.intellij.openapi.application.Application)

Example 7 with ApplicationImpl

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

the class IdeTestApplication method disposeInstance.

public static synchronized void disposeInstance() {
    if (!isLoaded()) {
        return;
    }
    IdeEventQueue.getInstance().flushQueue();
    final Application application = ApplicationManager.getApplication();
    ((ApplicationImpl) application).exit(true, true, false, false);
    ourInstance = null;
}
Also used : ApplicationImpl(com.intellij.openapi.application.impl.ApplicationImpl) Application(com.intellij.openapi.application.Application)

Example 8 with ApplicationImpl

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

the class EditorGutterComponentImpl method paint.

@Override
public void paint(Graphics g_) {
    ((ApplicationImpl) ApplicationManager.getApplication()).editorPaintStart();
    try {
        Rectangle clip = g_.getClipBounds();
        if (clip.height < 0)
            return;
        Graphics2D g = (Graphics2D) getComponentGraphics(g_);
        AffineTransform old = setMirrorTransformIfNeeded(g, 0, getWidth());
        EditorUIUtil.setupAntialiasing(g);
        Color backgroundColor = getBackground();
        if (myEditor.isDisposed()) {
            g.setColor(myEditor.getDisposedBackground());
            g.fillRect(clip.x, clip.y, clip.width, clip.height);
            return;
        }
        int startVisualLine = myEditor.yToVisibleLine(clip.y);
        int endVisualLine = myEditor.yToVisibleLine(clip.y + clip.height);
        // paint all backgrounds
        int gutterSeparatorX = getWhitespaceSeparatorOffset();
        paintBackground(g, clip, 0, gutterSeparatorX, backgroundColor);
        paintBackground(g, clip, gutterSeparatorX, getFoldingAreaWidth(), myEditor.getBackgroundColor());
        int firstVisibleOffset = myEditor.visualLineStartOffset(startVisualLine);
        int lastVisibleOffset = myEditor.visualLineStartOffset(endVisualLine + 1);
        paintEditorBackgrounds(g, firstVisibleOffset, lastVisibleOffset);
        Object hint = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
        if (!UIUtil.isJreHiDPI(g))
            g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
        try {
            paintAnnotations(g, startVisualLine, endVisualLine);
            paintLineMarkers(g, firstVisibleOffset, lastVisibleOffset);
            paintFoldingLines(g, clip);
            paintFoldingTree(g, clip, firstVisibleOffset, lastVisibleOffset);
            paintLineNumbers(g, startVisualLine, endVisualLine);
        } finally {
            g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, hint);
        }
        if (old != null)
            g.setTransform(old);
    } finally {
        ((ApplicationImpl) ApplicationManager.getApplication()).editorPaintFinish();
    }
}
Also used : ApplicationImpl(com.intellij.openapi.application.impl.ApplicationImpl) JBColor(com.intellij.ui.JBColor) AffineTransform(java.awt.geom.AffineTransform) RelativePoint(com.intellij.ui.awt.RelativePoint) HintHint(com.intellij.ui.HintHint)

Example 9 with ApplicationImpl

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

the class AppUIUtil method showPrivacyPolicyAgreement.

/**
   * @param htmlText Updated version of Privacy Policy text if any.
   *                 If it's {@code null}, the standard text from bundled resources would be used.
   */
public static void showPrivacyPolicyAgreement(@NotNull String htmlText) {
    DialogWrapper dialog = new DialogWrapper(true) {

        @Nullable
        @Override
        protected JComponent createCenterPanel() {
            JPanel centerPanel = new JPanel(new BorderLayout(JBUI.scale(5), JBUI.scale(5)));
            JEditorPane viewer = SwingHelper.createHtmlViewer(true, null, JBColor.WHITE, JBColor.BLACK);
            viewer.setFocusable(true);
            viewer.addHyperlinkListener(new HyperlinkAdapter() {

                @Override
                protected void hyperlinkActivated(HyperlinkEvent e) {
                    URL url = e.getURL();
                    if (url != null) {
                        BrowserUtil.browse(url);
                    } else {
                        SwingHelper.scrollToReference(viewer, e.getDescription());
                    }
                }
            });
            viewer.setText(htmlText);
            StyleSheet styleSheet = ((HTMLDocument) viewer.getDocument()).getStyleSheet();
            styleSheet.addRule("body {font-family: \"Segoe UI\", Tahoma, sans-serif;}");
            styleSheet.addRule("body {margin-top:0;padding-top:0;}");
            styleSheet.addRule("body {font-size:" + JBUI.scaleFontSize(13) + "pt;}");
            styleSheet.addRule("h2, em {margin-top:" + JBUI.scaleFontSize(20) + "pt;}");
            styleSheet.addRule("h1, h2, h3, p, h4, em {margin-bottom:0;padding-bottom:0;}");
            styleSheet.addRule("p, h1 {margin-top:0;padding-top:" + JBUI.scaleFontSize(6) + "pt;}");
            styleSheet.addRule("li {margin-bottom:" + JBUI.scaleFontSize(6) + "pt;}");
            styleSheet.addRule("h2 {margin-top:0;padding-top:" + JBUI.scaleFontSize(13) + "pt;}");
            viewer.setCaretPosition(0);
            viewer.setBorder(JBUI.Borders.empty(0, 5, 5, 5));
            centerPanel.add(new JLabel("Please read and accept these terms and conditions:"), BorderLayout.NORTH);
            centerPanel.add(new JBScrollPane(viewer, VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER), BorderLayout.CENTER);
            return centerPanel;
        }

        @Override
        protected void createDefaultActions() {
            super.createDefaultActions();
            init();
            setOKButtonText("Accept");
            setCancelButtonText("Reject and Exit");
            setAutoAdjustable(false);
        }

        @Override
        public void doCancelAction() {
            super.doCancelAction();
            ApplicationEx application = ApplicationManagerEx.getApplicationEx();
            if (application == null) {
                System.exit(Main.PRIVACY_POLICY_REJECTION);
            } else {
                ((ApplicationImpl) application).exit(true, true, false);
            }
        }
    };
    dialog.setModal(true);
    dialog.setTitle(ApplicationNamesInfo.getInstance().getFullProductName() + " Privacy Policy Agreement");
    dialog.setSize(JBUI.scale(509), JBUI.scale(395));
    dialog.show();
}
Also used : HyperlinkEvent(javax.swing.event.HyperlinkEvent) HTMLDocument(javax.swing.text.html.HTMLDocument) ApplicationImpl(com.intellij.openapi.application.impl.ApplicationImpl) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) URL(java.net.URL) StyleSheet(javax.swing.text.html.StyleSheet) ApplicationEx(com.intellij.openapi.application.ex.ApplicationEx) JBScrollPane(com.intellij.ui.components.JBScrollPane)

Example 10 with ApplicationImpl

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

the class GradleUtil method stopAllGradleDaemonsAndRestart.

public static void stopAllGradleDaemonsAndRestart() {
    DefaultGradleConnector.close();
    Application application = ApplicationManager.getApplication();
    if (application instanceof ApplicationImpl) {
        ((ApplicationImpl) application).restart(true);
    } else {
        application.restart();
    }
}
Also used : ApplicationImpl(com.intellij.openapi.application.impl.ApplicationImpl) Application(com.intellij.openapi.application.Application)

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