This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 174183
Collapse All | Expand All

(-)a/o.n.core/nbproject/project.xml (-1 / +1 lines)
Lines 92-98 Link Here
92
                    <build-prerequisite/>
92
                    <build-prerequisite/>
93
                    <compile-dependency/>
93
                    <compile-dependency/>
94
                    <run-dependency>
94
                    <run-dependency>
95
                        <specification-version>7.14</specification-version>
95
                        <specification-version>7.17</specification-version>
96
                    </run-dependency>
96
                    </run-dependency>
97
                </dependency>
97
                </dependency>
98
                <dependency>
98
                <dependency>
(-)a/o.n.core/src/org/netbeans/core/ExceptionVisualizerProvider.java (-56 lines)
Removed Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
42
package org.netbeans.core;
43
44
import java.awt.Component;
45
import org.openide.awt.StatusLineElementProvider;
46
47
/**
48
 *
49
 * @author  Jiri Rechtacek
50
 */
51
@org.openide.util.lookup.ServiceProvider(service=org.openide.awt.StatusLineElementProvider.class)
52
public final class ExceptionVisualizerProvider implements StatusLineElementProvider {
53
    public Component getStatusLineElement () {
54
        return NotifyExcPanel.getNotificationVisualizer ();
55
    }
56
}
(-)a/o.n.core/src/org/netbeans/core/FlashingIcon.java (-238 lines)
Removed Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * Contributor(s):
25
 *
26
 * The Original Software is NetBeans. The Initial Developer of the Original
27
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
 * Microsystems, Inc. All Rights Reserved.
29
 *
30
 * If you wish your version of this file to be governed by only the CDDL
31
 * or only the GPL Version 2, indicate your decision by adding
32
 * "[Contributor] elects to include this software in this distribution
33
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
34
 * single choice of license, a recipient has the option to distribute
35
 * your version of this file under either the CDDL, the GPL Version 2 or
36
 * to extend the choice of license to its licensees as provided above.
37
 * However, if you add GPL Version 2 code and therefore, elected the GPL
38
 * Version 2 license, then the option applies only if the new code is
39
 * made subject to such option by the copyright holder.
40
 */
41
42
package org.netbeans.core;
43
44
import java.awt.Cursor;
45
import java.awt.Dimension;
46
import java.awt.Point;
47
import java.awt.event.MouseEvent;
48
import java.awt.event.MouseListener;
49
import javax.swing.Icon;
50
import javax.swing.JComponent;
51
import javax.swing.JToolTip;
52
import org.openide.util.RequestProcessor;
53
import org.openide.util.RequestProcessor.Task;
54
55
/**
56
 * A flashing icon to provide visual feedback for the user when something
57
 * not very important happens in the system.
58
 * The icon is flashed for a few seconds and then remains visible for a while longer. 
59
 *
60
 * @author saubrecht
61
 */
62
abstract class FlashingIcon extends JComponent implements MouseListener {
63
    
64
    private static final long STOP_FLASHING_DELAY = 5 * 1000;
65
    private static final long DISAPPEAR_DELAY_MILLIS = STOP_FLASHING_DELAY + 30 * 1000;
66
    
67
    private Icon icon;
68
    
69
    private boolean keepRunning = false;
70
    private boolean isIconVisible = false;
71
    private boolean keepFlashing = true;
72
    private long startTime = 0;
73
    private RequestProcessor rp;
74
    private Task timerTask;
75
    
76
    /** 
77
     * Creates a new instance of FlashingIcon 
78
     *
79
     * @param icon The icon that will be flashing (blinking)
80
     */
81
    protected FlashingIcon( Icon icon ) {
82
        this.icon = icon;
83
        Dimension d = new Dimension( icon.getIconWidth(), icon.getIconHeight() );
84
        setMinimumSize( d );
85
        setMaximumSize( d );
86
        setPreferredSize( d );
87
        setVisible (false);
88
        
89
        addMouseListener( this );
90
        rp = new RequestProcessor( "Exception Notification Icon" ); //NOI18N
91
    }
92
93
    /**
94
     * Start flashing of the icon. If the icon is already flashing, the timer
95
     * is reset.
96
     * If the icon is visible but not flashing, it starts flashing again
97
     * and the disappear timer is reset.
98
     */
99
    public void startFlashing() {
100
        synchronized( this ) {
101
            startTime = System.currentTimeMillis();
102
            isIconVisible = !isIconVisible;
103
            keepRunning = true;
104
            keepFlashing = true;
105
            if( null == timerTask ) {
106
                timerTask = rp.create( new Timer() );
107
            }
108
            timerTask.run();
109
            this.setVisible (true);
110
        }
111
        repaint();
112
    }
113
    
114
    /**
115
     * Stop the flashing and hide the icon.
116
     */
117
    public void disappear() {
118
        synchronized( this ) {
119
            keepRunning = false;
120
            isIconVisible = false;
121
            keepFlashing = false;
122
            if( null != timerTask )
123
                timerTask.cancel();
124
            timerTask = null;
125
            setToolTipText( null );
126
            this.setVisible (false);
127
        }
128
        repaint();
129
    }
130
    
131
    /**
132
     * Stop flashing of the icon. The icon remains visible and active (listens 
133
     * for mouse clicks and displays tooltip) until the disappear timer expires.
134
     */
135
    public void stopFlashing() {
136
        synchronized( this ) {
137
            if( keepRunning && !isIconVisible ) {
138
                isIconVisible = true;
139
                repaint();
140
            }
141
        }
142
        keepFlashing = false;
143
    }
144
    
145
    /**
146
     * Switch the current image and repaint
147
     */
148
    protected void flashIcon() {
149
        isIconVisible = !isIconVisible;
150
        
151
        repaint();
152
    }
153
154
    @Override
155
    public void paint(java.awt.Graphics g) {
156
        if( isIconVisible ) {
157
            icon.paintIcon( this, g, 0, 0 );
158
        }
159
    }
160
161
    public void mouseReleased(MouseEvent e) {}
162
163
    public void mousePressed(MouseEvent e) {
164
        stopFlashing();
165
    }
166
167
    public void mouseExited(MouseEvent e) {
168
        stopFlashing();
169
    }
170
171
    public void mouseEntered(MouseEvent e) {
172
        stopFlashing();
173
    }
174
175
    public void mouseClicked(MouseEvent e) {
176
        if( isIconVisible ) {
177
            disappear();
178
            onMouseClick();
179
        }
180
    }
181
    
182
    /**
183
     * Invoked when the user clicks the icon.
184
     */
185
    protected abstract void onMouseClick();
186
187
    /**
188
     * Invoked when the disappear timer expired.
189
     */
190
    protected abstract void timeout();
191
192
    @Override
193
    public Cursor getCursor() {
194
195
        if( isIconVisible ) {
196
            return Cursor.getPredefinedCursor( Cursor.HAND_CURSOR );
197
        }
198
        return Cursor.getDefaultCursor();
199
    }
200
201
    @Override
202
    public Point getToolTipLocation( MouseEvent event ) {
203
204
        JToolTip tip = createToolTip();
205
        tip.setTipText( getToolTipText() );
206
        Dimension d = tip.getPreferredSize();
207
        
208
        
209
        return new Point( getWidth()-d.width, -d.height );
210
    }
211
    
212
    private class Timer implements Runnable {
213
        public void run() {
214
            synchronized( FlashingIcon.this ) {
215
                try {
216
                    long currentTime = System.currentTimeMillis();
217
                    if( keepFlashing ) {
218
                        if( currentTime - startTime < STOP_FLASHING_DELAY ) {
219
                            flashIcon();
220
                        } else {
221
                            stopFlashing();
222
                        }
223
                    }
224
                    if( currentTime - startTime >= DISAPPEAR_DELAY_MILLIS ) {
225
                        disappear();
226
                        timeout();
227
                    } else {
228
                        if( null != timerTask )
229
                            timerTask.schedule( 500 );
230
                    }
231
                } catch( Throwable e ) {
232
                    //swallow all exceptions to avoid endless exception <-> notification loop
233
                    e.printStackTrace();
234
                }
235
            }
236
        }
237
    }
238
}
(-)a/o.n.core/src/org/netbeans/core/NotifyExcPanel.java (-53 / +50 lines)
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

Return to bug 174183