Lines 42-54
Link Here
|
42 |
package org.netbeans.core; |
42 |
package org.netbeans.core; |
43 |
|
43 |
|
44 |
import java.awt.BorderLayout; |
44 |
import java.awt.BorderLayout; |
45 |
import java.awt.Component; |
|
|
46 |
import java.awt.Dialog; |
45 |
import java.awt.Dialog; |
47 |
import java.awt.Dimension; |
46 |
import java.awt.Dimension; |
|
|
47 |
import java.awt.EventQueue; |
48 |
import java.awt.Font; |
48 |
import java.awt.Font; |
49 |
import java.awt.GraphicsEnvironment; |
49 |
import java.awt.GraphicsEnvironment; |
50 |
import java.awt.Rectangle; |
50 |
import java.awt.Rectangle; |
51 |
import java.awt.Window; |
51 |
import java.awt.Window; |
|
|
52 |
import java.awt.event.ActionEvent; |
52 |
import java.awt.event.ActionListener; |
53 |
import java.awt.event.ActionListener; |
53 |
import java.io.PrintWriter; |
54 |
import java.io.PrintWriter; |
54 |
import java.io.StringWriter; |
55 |
import java.io.StringWriter; |
Lines 61-67
Link Here
|
61 |
import java.util.logging.Level; |
62 |
import java.util.logging.Level; |
62 |
import java.util.logging.LogRecord; |
63 |
import java.util.logging.LogRecord; |
63 |
import java.util.logging.Logger; |
64 |
import java.util.logging.Logger; |
64 |
import javax.swing.Icon; |
|
|
65 |
import javax.swing.ImageIcon; |
65 |
import javax.swing.ImageIcon; |
66 |
import javax.swing.JButton; |
66 |
import javax.swing.JButton; |
67 |
import javax.swing.JDialog; |
67 |
import javax.swing.JDialog; |
Lines 69-84
Link Here
|
69 |
import javax.swing.JScrollPane; |
69 |
import javax.swing.JScrollPane; |
70 |
import javax.swing.JTextPane; |
70 |
import javax.swing.JTextPane; |
71 |
import javax.swing.SwingUtilities; |
71 |
import javax.swing.SwingUtilities; |
|
|
72 |
import javax.swing.Timer; |
72 |
import javax.swing.UIManager; |
73 |
import javax.swing.UIManager; |
73 |
import org.netbeans.core.startup.CLIOptions; |
74 |
import org.netbeans.core.startup.CLIOptions; |
74 |
import org.openide.DialogDescriptor; |
75 |
import org.openide.DialogDescriptor; |
75 |
import org.openide.DialogDisplayer; |
76 |
import org.openide.DialogDisplayer; |
76 |
import org.openide.NotifyDescriptor; |
77 |
import org.openide.NotifyDescriptor; |
77 |
import org.openide.awt.Mnemonics; |
78 |
import org.openide.awt.Mnemonics; |
|
|
79 |
import org.openide.awt.Notification; |
80 |
import org.openide.awt.NotificationDisplayer; |
78 |
import org.openide.util.Exceptions; |
81 |
import org.openide.util.Exceptions; |
79 |
import org.openide.util.ImageUtilities; |
82 |
import org.openide.util.ImageUtilities; |
80 |
import org.openide.util.NbBundle; |
83 |
import org.openide.util.NbBundle; |
81 |
import org.openide.util.Utilities; |
|
|
82 |
import org.openide.windows.WindowManager; |
84 |
import org.openide.windows.WindowManager; |
83 |
|
85 |
|
84 |
/** |
86 |
/** |
Lines 328-337
Link Here
|
328 |
INSTANCE.updateState(t); |
330 |
INSTANCE.updateState(t); |
329 |
} else { |
331 |
} else { |
330 |
// No assertions, use the flashing icon. |
332 |
// No assertions, use the flashing icon. |
331 |
if( null != flasher && null == INSTANCE ) { |
333 |
if( null == INSTANCE ) { |
|
|
334 |
ImageIcon img1 = ImageUtilities.loadImageIcon("org/netbeans/core/resources/exception.gif", true); |
335 |
String summary = getExceptionSummary(t); |
336 |
ExceptionFlasher flash = ExceptionFlasher.notify(summary, img1); |
332 |
//exception window is not visible, start flashing the icon |
337 |
//exception window is not visible, start flashing the icon |
333 |
flasher.setToolTipText( getExceptionSummary( t ) ); |
|
|
334 |
flasher.startFlashing(); |
335 |
} else { |
338 |
} else { |
336 |
//exception window is already visible (or the flashing icon is not available) |
339 |
//exception window is already visible (or the flashing icon is not available) |
337 |
//so we'll only update the exception window |
340 |
//so we'll only update the exception window |
Lines 590-630
Link Here
|
590 |
} |
593 |
} |
591 |
} |
594 |
} |
592 |
|
595 |
|
|
|
596 |
private static class ExceptionFlasher implements ActionListener { |
597 |
private static ExceptionFlasher flash; |
598 |
private static synchronized ExceptionFlasher notify(String summary, ImageIcon icon) { |
599 |
if (flash != null) { |
600 |
flash.timer.restart(); |
601 |
} else { |
602 |
flash = new ExceptionFlasher(); |
603 |
flash.note = NotificationDisplayer.getDefault().notify( |
604 |
NbBundle.getMessage(NotifyExcPanel.class, "NTF_ExceptionalExceptionTitle"), |
605 |
icon, summary, |
606 |
flash, NotificationDisplayer.Priority.SILENT); |
607 |
} |
608 |
return flash; |
609 |
} |
610 |
Notification note; |
611 |
private final Timer timer; |
593 |
|
612 |
|
594 |
/** |
613 |
public ExceptionFlasher() { |
595 |
* The icon shown in the main status bar that is flashing when an exception |
614 |
timer = new Timer(30000, this); |
596 |
* is encountered. |
615 |
timer.setRepeats(false); |
597 |
*/ |
616 |
timer.start(); |
598 |
static FlashingIcon flasher = null; |
|
|
599 |
|
600 |
/** |
601 |
* Return an icon that is flashing when a new internal exception occurs. |
602 |
* Clicking the icon opens the regular exception dialog box. The icon |
603 |
* disappears (is hidden) after a short period of time and the exception |
604 |
* list is cleared. |
605 |
* |
606 |
* @return A flashing icon component or null if console logging is switched on. |
607 |
*/ |
608 |
public static Component getNotificationVisualizer() { |
609 |
//do not create flashing icon if not allowed in system properties |
610 |
if( null == flasher ) { |
611 |
ImageIcon img1 = ImageUtilities.loadImageIcon("org/netbeans/core/resources/exception.gif", true); |
612 |
flasher = new ExceptionFlasher( img1 ); |
613 |
} |
614 |
return flasher; |
615 |
} |
616 |
|
617 |
private static class ExceptionFlasher extends FlashingIcon { |
618 |
static final long serialVersionUID = 1L; |
619 |
|
620 |
public ExceptionFlasher( Icon img1 ) { |
621 |
super( img1 ); |
622 |
} |
617 |
} |
623 |
|
618 |
|
624 |
/** |
619 |
public void actionPerformed(ActionEvent e) { |
625 |
* User clicked the flashing icon, display the exception window. |
620 |
if (e.getSource() == timer) { |
626 |
*/ |
621 |
timeout(); |
627 |
protected void onMouseClick() { |
622 |
return; |
|
|
623 |
} |
624 |
synchronized (ExceptionFlasher.class) { |
625 |
flash = null; |
626 |
} |
628 |
if (null != exceptions && exceptions.size() > 0) { |
627 |
if (null != exceptions && exceptions.size() > 0) { |
629 |
if (INSTANCE == null) { |
628 |
if (INSTANCE == null) { |
630 |
INSTANCE = new NotifyExcPanel(); |
629 |
INSTANCE = new NotifyExcPanel(); |
Lines 633-654
Link Here
|
633 |
} |
632 |
} |
634 |
} |
633 |
} |
635 |
|
634 |
|
636 |
/** |
635 |
private void timeout() { |
637 |
* The flashing icon disappeared (timed-out), clear the current |
636 |
synchronized (ExceptionFlasher.class) { |
638 |
* exception list. |
637 |
assert EventQueue.isDispatchThread(); |
639 |
*/ |
638 |
if( null != INSTANCE ) { |
640 |
protected void timeout() { |
639 |
return; |
641 |
SwingUtilities.invokeLater( new Runnable() { |
|
|
642 |
public void run() { |
643 |
if( null != INSTANCE ) { |
644 |
return; |
645 |
} |
646 |
if( null != exceptions ) { |
647 |
exceptions.clear(); |
648 |
} |
649 |
exceptions = null; |
650 |
} |
640 |
} |
651 |
}); |
641 |
if( null != exceptions ) { |
|
|
642 |
exceptions.clear(); |
643 |
} |
644 |
exceptions = null; |
645 |
flash = null; |
646 |
timer.stop(); |
647 |
note.clear(); |
648 |
} |
652 |
} |
649 |
} |
653 |
} |
650 |
} |
654 |
|
651 |
|