Index: core/arch/arch-core.xml =================================================================== RCS file: /shared/data/ccvs/repository/core/arch/arch-core.xml,v retrieving revision 1.15 retrieving revision 1.15.2.1 diff -u -r1.15 -r1.15.2.1 --- core/arch/arch-core.xml 20 Dec 2006 09:09:40 -0000 1.15 +++ core/arch/arch-core.xml 11 Jan 2007 19:23:04 -0000 1.15.2.1 @@ -566,7 +566,16 @@ -->

- XXX no answer for exec-reflection + + This module exports an API that allows the UI Gestures Collector module + to plug and enhance the behaviour of exception dialog by own buttons. + The behaviour is like this: If any of Handlers of + Logger.getLogger("") implements Callable<JButton> + then such button is going to be inserted to the exception dialog and + can react and change the behaviour of that dialog. Such a button is + going to be a "closing" one - e.g. the dialog will close as soon as + the button is pressed. +

Index: core/nbproject/project.properties =================================================================== RCS file: /shared/data/ccvs/repository/core/nbproject/project.properties,v retrieving revision 1.29 retrieving revision 1.29.4.1 diff -u -r1.29 -r1.29.4.1 --- core/nbproject/project.properties 19 Nov 2006 13:33:00 -0000 1.29 +++ core/nbproject/project.properties 11 Jan 2007 19:24:45 -0000 1.29.4.1 @@ -17,7 +17,7 @@ javac.compilerargs=-Xlint:unchecked javac.source=1.5 -spec.version.base=3.5.0 +spec.version.base=3.6.0 javadoc.arch=${basedir}/arch/arch-core.xml Index: core/src/org/netbeans/core/NotifyExcPanel.java =================================================================== RCS file: /shared/data/ccvs/repository/core/src/org/netbeans/core/NotifyExcPanel.java,v retrieving revision 1.3 retrieving revision 1.3.6.1 diff -u -r1.3 -r1.3.6.1 --- core/src/org/netbeans/core/NotifyExcPanel.java 2 Oct 2006 12:51:14 -0000 1.3 +++ core/src/org/netbeans/core/NotifyExcPanel.java 11 Jan 2007 19:02:56 -0000 1.3.6.1 @@ -30,9 +30,14 @@ import java.awt.event.ActionListener; import java.io.PrintWriter; import java.io.StringWriter; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; import java.util.ArrayList; import java.util.ResourceBundle; +import java.util.concurrent.Callable; +import java.util.logging.Handler; import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JButton; @@ -47,6 +52,7 @@ import org.openide.DialogDisplayer; import org.openide.NotifyDescriptor; import org.openide.awt.Mnemonics; +import org.openide.util.Exceptions; import org.openide.util.NbBundle; import org.openide.util.Utilities; import org.openide.windows.WindowManager; @@ -133,11 +139,7 @@ descriptor = new DialogDescriptor ("", ""); // NOI18N descriptor.setMessageType (DialogDescriptor.ERROR_MESSAGE); - descriptor.setOptions (new Object[] { - previous, - next, - DialogDescriptor.OK_OPTION - }); + descriptor.setOptions (computeOptions(previous, next)); descriptor.setAdditionalOptions (new Object[] { details }); @@ -160,6 +162,43 @@ dialog.getAccessibleContext().setAccessibleDescription(bundle.getString("ACD_NotifyExcPanel_Dialog")); // NOI18N } + static Object[] computeOptions(Object previous, Object next) { + ArrayList arr = new ArrayList(); + arr.add(previous); + arr.add(next); + + for (Handler h : Logger.getLogger("").getHandlers()) { + if (h instanceof Callable) { + boolean foundCallableForJButton = false; + for (Type t : h.getClass().getGenericInterfaces()) { + if (t instanceof ParameterizedType) { + ParameterizedType p = (ParameterizedType)t; + Type[] params = p.getActualTypeArguments(); + if (params.length == 1 && params[0] == JButton.class) { + foundCallableForJButton = true; + break; + } + } + } + if (!foundCallableForJButton) { + continue; + } + + + try { + Object o = ((Callable)h).call(); + assert o instanceof JButton; + arr.add(o); + } catch (Exception ex) { + Exceptions.printStackTrace(ex); + } + } + } + + arr.add(DialogDescriptor.OK_OPTION); + return arr.toArray(); + } + private static boolean isModalDialogPresent() { return hasModalDialog(WindowManager.getDefault().getMainWindow()) // XXX Trick to get the shared frame instance. Index: core/test/unit/src/org/netbeans/core/NotifyExcPanelTest.java =================================================================== RCS file: core/test/unit/src/org/netbeans/core/NotifyExcPanelTest.java diff -N core/test/unit/src/org/netbeans/core/NotifyExcPanelTest.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ core/test/unit/src/org/netbeans/core/NotifyExcPanelTest.java 11 Jan 2007 19:02:55 -0000 1.1.2.1 @@ -0,0 +1,104 @@ +/* + * The contents of this file are subject to the terms of the Common Development + * and Distribution License (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.html + * or http://www.netbeans.org/cddl.txt. + * + * When distributing Covered Code, include this CDDL Header Notice in each file + * and include the License file at http://www.netbeans.org/cddl.txt. + * If applicable, add the following below the CDDL Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * 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. + */ + +package org.netbeans.core; + +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.logging.Handler; +import java.util.logging.LogRecord; +import java.util.logging.Logger; +import javax.swing.JButton; +import org.netbeans.junit.NbTestCase; + +/** + * + * @author Jaroslav Tulach + */ +public class NotifyExcPanelTest extends NbTestCase { + Logger main; + + public NotifyExcPanelTest(String testName) { + super(testName); + } + + protected void setUp() throws Exception { + main = Logger.getLogger(""); + for (Handler h : main.getHandlers()) { + main.removeHandler(h); + } + } + + public void testHandlesThatImplementCallableForJButtonAreIncluded() throws Exception { + class H extends Handler + implements Callable { + public JButton button = new JButton("Extra"); + + public void publish(LogRecord arg0) { + } + + public void flush() { + } + + public void close() throws SecurityException { + } + + public JButton call() throws Exception { + return button; + } + } // end of H + + H handler = new H(); + + main.addHandler(handler); + + List options = Arrays.asList(NotifyExcPanel.computeOptions("prev", "next")); + + assertTrue("Contains our button: " + options, options.contains(handler.button)); + } + + public void testHandlesThatImplementCallableForOtherObjectsAreNotIncluded() throws Exception { + class H extends Handler + implements Callable { + public JButton button = new JButton("Extra"); + + public void publish(LogRecord arg0) { + } + + public void flush() { + } + + public void close() throws SecurityException { + } + + public JButton call() throws Exception { + return button; + } + } // end of H + + H handler = new H(); + + main.addHandler(handler); + + List options = Arrays.asList(NotifyExcPanel.computeOptions("prev", "next")); + + assertFalse("Does not contain our button: " + options, options.contains(handler.button)); + } +} Index: logger/uihandler/arch.xml =================================================================== RCS file: /shared/data/ccvs/repository/logger/uihandler/arch.xml,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -u -r1.7 -r1.7.2.1 --- logger/uihandler/arch.xml 11 Dec 2006 17:26:19 -0000 1.7 +++ logger/uihandler/arch.xml 11 Jan 2007 19:30:08 -0000 1.7.2.1 @@ -376,6 +376,14 @@ the analysis server. +
  • + This module makes on of its Handler implement + Callable<JButton> which is a signal for + core providing the exception dialog to include such a + JButton in its list of options. That way this + module can enhance the dialog with "Report..." button. + +
  • Index: logger/uihandler/src/org/netbeans/modules/uihandler/Bundle.properties =================================================================== RCS file: /shared/data/ccvs/repository/logger/uihandler/src/org/netbeans/modules/uihandler/Bundle.properties,v retrieving revision 1.20 retrieving revision 1.20.2.1 diff -u -r1.20 -r1.20.2.1 --- logger/uihandler/src/org/netbeans/modules/uihandler/Bundle.properties 10 Jan 2007 09:58:04 -0000 1.20 +++ logger/uihandler/src/org/netbeans/modules/uihandler/Bundle.properties 11 Jan 2007 19:02:55 -0000 1.20.2.1 @@ -77,6 +77,7 @@ # URL to display to as a welcome text in case of error ERROR_URL=http://logger.netbeans.org/nonav/welcome/error.html MSG_ERROR_URL_EXIT=&Cancel +MSG_SubmitButton=Report... # view data Index: logger/uihandler/src/org/netbeans/modules/uihandler/Installer.java =================================================================== RCS file: /shared/data/ccvs/repository/logger/uihandler/src/org/netbeans/modules/uihandler/Installer.java,v retrieving revision 1.40 retrieving revision 1.40.2.1 diff -u -r1.40 -r1.40.2.1 --- logger/uihandler/src/org/netbeans/modules/uihandler/Installer.java 11 Jan 2007 10:55:01 -0000 1.40 +++ logger/uihandler/src/org/netbeans/modules/uihandler/Installer.java 11 Jan 2007 19:02:55 -0000 1.40.2.1 @@ -115,11 +115,19 @@ log.addHandler(ui); Logger all = Logger.getLogger(""); all.addHandler(handler); for (Activated a : Lookup.getDefault().lookupAll(Activated.class)) { a.activated(log); @@ -467,6 +475,10 @@ url = getClass().getResource("UnknownHostException.html"); continue; } catch (UnknownHostException ex) { + LOG.log(Level.INFO, url.toExternalForm(), ex); + url = getClass().getResource("UnknownHostException.html"); + continue; + } catch (java.net.NoRouteToHostException ex) { LOG.log(Level.INFO, url.toExternalForm(), ex); url = getClass().getResource("UnknownHostException.html"); continue; Index: logger/uihandler/src/org/netbeans/modules/uihandler/UIHandler.java =================================================================== RCS file: /shared/data/ccvs/repository/logger/uihandler/src/org/netbeans/modules/uihandler/UIHandler.java,v retrieving revision 1.11 retrieving revision 1.11.2.1 diff -u -r1.11 -r1.11.2.1 --- logger/uihandler/src/org/netbeans/modules/uihandler/UIHandler.java 11 Jan 2007 10:55:01 -0000 1.11 +++ logger/uihandler/src/org/netbeans/modules/uihandler/UIHandler.java 11 Jan 2007 19:02:55 -0000 1.11.2.1 @@ -19,18 +19,24 @@ package org.netbeans.modules.uihandler; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.util.Queue; +import java.util.concurrent.Callable; import java.util.logging.Handler; import java.util.logging.Level; import java.util.logging.LogRecord; +import javax.swing.JButton; +import org.openide.util.NbBundle; /** * * @author Jaroslav Tulach */ -public class UIHandler extends Handler implements Runnable { +public class UIHandler extends Handler +implements ActionListener, Runnable, Callable { private final Queue logs; private final boolean exceptionOnly; static final PropertyChangeSupport SUPPORT = new PropertyChangeSupport(UIHandler.class); @@ -64,16 +70,6 @@ } SUPPORT.firePropertyChange(null, null, null); - - /* - if ( - exceptionOnly && - record.getLevel().intValue() >= Level.WARNING.intValue() && - record.getThrown() != null - ) { - Installer.RP.post(this); - } - */ } public void flush() { @@ -84,5 +80,18 @@ public void run() { Installer.displaySummary("ERROR_URL", false); // NOI18N + } + + private JButton button; + public JButton call() throws Exception { + if (button == null) { + button = new JButton(NbBundle.getMessage(UIHandler.class, "MSG_SubmitButton")); // NOI18N + button.addActionListener(this); + } + return button; + } + + public void actionPerformed(ActionEvent ev) { + run(); } } Index: logger/uihandler/src/org/netbeans/modules/uihandler/api/doc-files/ui.html =================================================================== RCS file: /shared/data/ccvs/repository/logger/uihandler/src/org/netbeans/modules/uihandler/api/doc-files/ui.html,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -r1.4 -r1.4.2.1 --- logger/uihandler/src/org/netbeans/modules/uihandler/api/doc-files/ui.html 4 Jan 2007 16:28:23 -0000 1.4 +++ logger/uihandler/src/org/netbeans/modules/uihandler/api/doc-files/ui.html 11 Jan 2007 19:34:44 -0000 1.4.2.1 @@ -10,7 +10,7 @@

    UI of Gestures Collector

    Ve rsion:
    -
    $Date: 2007/01/04 16:28:23 $
    +
    $Date: 2007/01/11 19:34:44 $
    Author:
    Jaroslav Tulach
    Abstract:
    @@ -232,7 +232,12 @@

    Error Dialog

    - This dialog appears when an exception occurs in the system: + When an exception is rised, its behaviour remains the same as is usual + - e.g. in develpment builds to common "Unexpected Exception Dialog" is shown, + in releases a blinking icon at the lower right corner starts to blink and + when clicked the dialog is shown. However in contrast to previous versions, + there is a new button Report... in the dialog. When clicked it + opens following dialog: