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