mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
More cases in message box test action
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,24 +18,35 @@ package com.intellij.diagnostic;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class TestMessageBoxAction extends AnAction {
|
||||
private final Random myRandom = new Random();
|
||||
|
||||
public TestMessageBoxAction() {
|
||||
super("Test message box");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final AnActionEvent e) {
|
||||
final long l = System.currentTimeMillis();
|
||||
if (l % 3 == 0) {
|
||||
Messages.showErrorDialog("Test error message.", "Test");
|
||||
int r = myRandom.nextInt(10);
|
||||
if (r < 3) {
|
||||
String message = wrap("Test error message.", r);
|
||||
Messages.showErrorDialog(message, "Test");
|
||||
}
|
||||
else if (l % 5 == 0) {
|
||||
Messages.showWarningDialog("Test warning message.", "Test");
|
||||
else if (r < 6) {
|
||||
String message = wrap("Test warning message.", r);
|
||||
Messages.showWarningDialog(message, "Test");
|
||||
}
|
||||
else {
|
||||
Messages.showInfoMessage("Test info message.", "Test");
|
||||
String message = wrap("Test info message.", r);
|
||||
Messages.showInfoMessage(message, "Test");
|
||||
}
|
||||
}
|
||||
|
||||
private static String wrap(String s, int r) {
|
||||
return r % 2 == 0 ? s : "<html><body><i>" + StringUtil.repeat(s + "<br>", 10) + "</i></body></html>";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user