diff -r c67c10b5f3ec o.n.core/nbproject/project.xml
--- a/o.n.core/nbproject/project.xml Tue Oct 13 13:17:51 2009 +0200
+++ b/o.n.core/nbproject/project.xml Tue Oct 13 16:24:19 2009 +0200
@@ -92,7 +92,7 @@
- 7.14
+ 7.17
diff -r c67c10b5f3ec o.n.core/src/org/netbeans/core/ExceptionVisualizerProvider.java
--- a/o.n.core/src/org/netbeans/core/ExceptionVisualizerProvider.java Tue Oct 13 13:17:51 2009 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common
- * Development and Distribution License("CDDL") (collectively, the
- * "License"). You may not use this file except in compliance with the
- * License. You can obtain a copy of the License at
- * http://www.netbeans.org/cddl-gplv2.html
- * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
- * specific language governing permissions and limitations under the
- * License. When distributing the software, include this License Header
- * Notice in each file and include the License file at
- * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the GPL Version 2 section of the License file that
- * accompanied this code. If applicable, add the following below the
- * License Header, with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * If you wish your version of this file to be governed by only the CDDL
- * or only the GPL Version 2, indicate your decision by adding
- * "[Contributor] elects to include this software in this distribution
- * under the [CDDL or GPL Version 2] license." If you do not indicate a
- * single choice of license, a recipient has the option to distribute
- * your version of this file under either the CDDL, the GPL Version 2 or
- * to extend the choice of license to its licensees as provided above.
- * However, if you add GPL Version 2 code and therefore, elected the GPL
- * Version 2 license, then the option applies only if the new code is
- * made subject to such option by the copyright holder.
- */
-
-package org.netbeans.core;
-
-import java.awt.Component;
-import org.openide.awt.StatusLineElementProvider;
-
-/**
- *
- * @author Jiri Rechtacek
- */
-@org.openide.util.lookup.ServiceProvider(service=org.openide.awt.StatusLineElementProvider.class)
-public final class ExceptionVisualizerProvider implements StatusLineElementProvider {
- public Component getStatusLineElement () {
- return NotifyExcPanel.getNotificationVisualizer ();
- }
-}
diff -r c67c10b5f3ec o.n.core/src/org/netbeans/core/FlashingIcon.java
--- a/o.n.core/src/org/netbeans/core/FlashingIcon.java Tue Oct 13 13:17:51 2009 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,238 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common
- * Development and Distribution License("CDDL") (collectively, the
- * "License"). You may not use this file except in compliance with the
- * License. You can obtain a copy of the License at
- * http://www.netbeans.org/cddl-gplv2.html
- * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
- * specific language governing permissions and limitations under the
- * License. When distributing the software, include this License Header
- * Notice in each file and include the License file at
- * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the GPL Version 2 section of the License file that
- * accompanied this code. If applicable, add the following below the
- * License Header, with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- *
- * Contributor(s):
- *
- * The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
- * Microsystems, Inc. All Rights Reserved.
- *
- * If you wish your version of this file to be governed by only the CDDL
- * or only the GPL Version 2, indicate your decision by adding
- * "[Contributor] elects to include this software in this distribution
- * under the [CDDL or GPL Version 2] license." If you do not indicate a
- * single choice of license, a recipient has the option to distribute
- * your version of this file under either the CDDL, the GPL Version 2 or
- * to extend the choice of license to its licensees as provided above.
- * However, if you add GPL Version 2 code and therefore, elected the GPL
- * Version 2 license, then the option applies only if the new code is
- * made subject to such option by the copyright holder.
- */
-
-package org.netbeans.core;
-
-import java.awt.Cursor;
-import java.awt.Dimension;
-import java.awt.Point;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import javax.swing.Icon;
-import javax.swing.JComponent;
-import javax.swing.JToolTip;
-import org.openide.util.RequestProcessor;
-import org.openide.util.RequestProcessor.Task;
-
-/**
- * A flashing icon to provide visual feedback for the user when something
- * not very important happens in the system.
- * The icon is flashed for a few seconds and then remains visible for a while longer.
- *
- * @author saubrecht
- */
-abstract class FlashingIcon extends JComponent implements MouseListener {
-
- private static final long STOP_FLASHING_DELAY = 5 * 1000;
- private static final long DISAPPEAR_DELAY_MILLIS = STOP_FLASHING_DELAY + 30 * 1000;
-
- private Icon icon;
-
- private boolean keepRunning = false;
- private boolean isIconVisible = false;
- private boolean keepFlashing = true;
- private long startTime = 0;
- private RequestProcessor rp;
- private Task timerTask;
-
- /**
- * Creates a new instance of FlashingIcon
- *
- * @param icon The icon that will be flashing (blinking)
- */
- protected FlashingIcon( Icon icon ) {
- this.icon = icon;
- Dimension d = new Dimension( icon.getIconWidth(), icon.getIconHeight() );
- setMinimumSize( d );
- setMaximumSize( d );
- setPreferredSize( d );
- setVisible (false);
-
- addMouseListener( this );
- rp = new RequestProcessor( "Exception Notification Icon" ); //NOI18N
- }
-
- /**
- * Start flashing of the icon. If the icon is already flashing, the timer
- * is reset.
- * If the icon is visible but not flashing, it starts flashing again
- * and the disappear timer is reset.
- */
- public void startFlashing() {
- synchronized( this ) {
- startTime = System.currentTimeMillis();
- isIconVisible = !isIconVisible;
- keepRunning = true;
- keepFlashing = true;
- if( null == timerTask ) {
- timerTask = rp.create( new Timer() );
- }
- timerTask.run();
- this.setVisible (true);
- }
- repaint();
- }
-
- /**
- * Stop the flashing and hide the icon.
- */
- public void disappear() {
- synchronized( this ) {
- keepRunning = false;
- isIconVisible = false;
- keepFlashing = false;
- if( null != timerTask )
- timerTask.cancel();
- timerTask = null;
- setToolTipText( null );
- this.setVisible (false);
- }
- repaint();
- }
-
- /**
- * Stop flashing of the icon. The icon remains visible and active (listens
- * for mouse clicks and displays tooltip) until the disappear timer expires.
- */
- public void stopFlashing() {
- synchronized( this ) {
- if( keepRunning && !isIconVisible ) {
- isIconVisible = true;
- repaint();
- }
- }
- keepFlashing = false;
- }
-
- /**
- * Switch the current image and repaint
- */
- protected void flashIcon() {
- isIconVisible = !isIconVisible;
-
- repaint();
- }
-
- @Override
- public void paint(java.awt.Graphics g) {
- if( isIconVisible ) {
- icon.paintIcon( this, g, 0, 0 );
- }
- }
-
- public void mouseReleased(MouseEvent e) {}
-
- public void mousePressed(MouseEvent e) {
- stopFlashing();
- }
-
- public void mouseExited(MouseEvent e) {
- stopFlashing();
- }
-
- public void mouseEntered(MouseEvent e) {
- stopFlashing();
- }
-
- public void mouseClicked(MouseEvent e) {
- if( isIconVisible ) {
- disappear();
- onMouseClick();
- }
- }
-
- /**
- * Invoked when the user clicks the icon.
- */
- protected abstract void onMouseClick();
-
- /**
- * Invoked when the disappear timer expired.
- */
- protected abstract void timeout();
-
- @Override
- public Cursor getCursor() {
-
- if( isIconVisible ) {
- return Cursor.getPredefinedCursor( Cursor.HAND_CURSOR );
- }
- return Cursor.getDefaultCursor();
- }
-
- @Override
- public Point getToolTipLocation( MouseEvent event ) {
-
- JToolTip tip = createToolTip();
- tip.setTipText( getToolTipText() );
- Dimension d = tip.getPreferredSize();
-
-
- return new Point( getWidth()-d.width, -d.height );
- }
-
- private class Timer implements Runnable {
- public void run() {
- synchronized( FlashingIcon.this ) {
- try {
- long currentTime = System.currentTimeMillis();
- if( keepFlashing ) {
- if( currentTime - startTime < STOP_FLASHING_DELAY ) {
- flashIcon();
- } else {
- stopFlashing();
- }
- }
- if( currentTime - startTime >= DISAPPEAR_DELAY_MILLIS ) {
- disappear();
- timeout();
- } else {
- if( null != timerTask )
- timerTask.schedule( 500 );
- }
- } catch( Throwable e ) {
- //swallow all exceptions to avoid endless exception <-> notification loop
- e.printStackTrace();
- }
- }
- }
- }
-}
diff -r c67c10b5f3ec o.n.core/src/org/netbeans/core/NotifyExcPanel.java
--- a/o.n.core/src/org/netbeans/core/NotifyExcPanel.java Tue Oct 13 13:17:51 2009 +0200
+++ b/o.n.core/src/org/netbeans/core/NotifyExcPanel.java Tue Oct 13 16:24:19 2009 +0200
@@ -42,13 +42,14 @@
package org.netbeans.core;
import java.awt.BorderLayout;
-import java.awt.Component;
import java.awt.Dialog;
import java.awt.Dimension;
+import java.awt.EventQueue;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.Window;
+import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -61,7 +62,6 @@
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
-import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
@@ -69,16 +69,18 @@
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.SwingUtilities;
+import javax.swing.Timer;
import javax.swing.UIManager;
import org.netbeans.core.startup.CLIOptions;
import org.openide.DialogDescriptor;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.awt.Mnemonics;
+import org.openide.awt.Notification;
+import org.openide.awt.NotificationDisplayer;
import org.openide.util.Exceptions;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;
-import org.openide.util.Utilities;
import org.openide.windows.WindowManager;
/**
@@ -328,10 +330,11 @@
INSTANCE.updateState(t);
} else {
// No assertions, use the flashing icon.
- if( null != flasher && null == INSTANCE ) {
+ if( null == INSTANCE ) {
+ ImageIcon img1 = ImageUtilities.loadImageIcon("org/netbeans/core/resources/exception.gif", true);
+ String summary = getExceptionSummary(t);
+ ExceptionFlasher flash = ExceptionFlasher.notify(summary, img1);
//exception window is not visible, start flashing the icon
- flasher.setToolTipText( getExceptionSummary( t ) );
- flasher.startFlashing();
} else {
//exception window is already visible (or the flashing icon is not available)
//so we'll only update the exception window
@@ -590,41 +593,37 @@
}
}
+ private static class ExceptionFlasher implements ActionListener {
+ private static ExceptionFlasher flash;
+ private static synchronized ExceptionFlasher notify(String summary, ImageIcon icon) {
+ if (flash != null) {
+ flash.timer.restart();
+ } else {
+ flash = new ExceptionFlasher();
+ flash.note = NotificationDisplayer.getDefault().notify(
+ NbBundle.getMessage(NotifyExcPanel.class, "NTF_ExceptionalExceptionTitle"),
+ icon, summary,
+ flash, NotificationDisplayer.Priority.SILENT);
+ }
+ return flash;
+ }
+ Notification note;
+ private final Timer timer;
- /**
- * The icon shown in the main status bar that is flashing when an exception
- * is encountered.
- */
- static FlashingIcon flasher = null;
-
- /**
- * Return an icon that is flashing when a new internal exception occurs.
- * Clicking the icon opens the regular exception dialog box. The icon
- * disappears (is hidden) after a short period of time and the exception
- * list is cleared.
- *
- * @return A flashing icon component or null if console logging is switched on.
- */
- public static Component getNotificationVisualizer() {
- //do not create flashing icon if not allowed in system properties
- if( null == flasher ) {
- ImageIcon img1 = ImageUtilities.loadImageIcon("org/netbeans/core/resources/exception.gif", true);
- flasher = new ExceptionFlasher( img1 );
- }
- return flasher;
- }
-
- private static class ExceptionFlasher extends FlashingIcon {
- static final long serialVersionUID = 1L;
-
- public ExceptionFlasher( Icon img1 ) {
- super( img1 );
+ public ExceptionFlasher() {
+ timer = new Timer(30000, this);
+ timer.setRepeats(false);
+ timer.start();
}
- /**
- * User clicked the flashing icon, display the exception window.
- */
- protected void onMouseClick() {
+ public void actionPerformed(ActionEvent e) {
+ if (e.getSource() == timer) {
+ timeout();
+ return;
+ }
+ synchronized (ExceptionFlasher.class) {
+ flash = null;
+ }
if (null != exceptions && exceptions.size() > 0) {
if (INSTANCE == null) {
INSTANCE = new NotifyExcPanel();
@@ -633,22 +632,20 @@
}
}
- /**
- * The flashing icon disappeared (timed-out), clear the current
- * exception list.
- */
- protected void timeout() {
- SwingUtilities.invokeLater( new Runnable() {
- public void run() {
- if( null != INSTANCE ) {
- return;
- }
- if( null != exceptions ) {
- exceptions.clear();
- }
- exceptions = null;
+ private void timeout() {
+ synchronized (ExceptionFlasher.class) {
+ assert EventQueue.isDispatchThread();
+ if( null != INSTANCE ) {
+ return;
}
- });
+ if( null != exceptions ) {
+ exceptions.clear();
+ }
+ exceptions = null;
+ flash = null;
+ timer.stop();
+ note.clear();
+ }
}
}