diff -r 0df9cb6108b7 o.n.bootstrap/src/org/netbeans/ModuleManager.java --- a/o.n.bootstrap/src/org/netbeans/ModuleManager.java Wed Nov 07 16:27:53 2012 +0100 +++ b/o.n.bootstrap/src/org/netbeans/ModuleManager.java Wed Nov 07 17:36:29 2012 +0100 @@ -1387,6 +1387,9 @@ } // Also add anything it depends on, if not already there, // or already enabled. + if (m.getCodeName().contains("spring")) { + Thread.dumpStack(); + } for (Dependency dep : m.getDependenciesArray()) { if (dep.getType() == Dependency.TYPE_MODULE) { String codeNameBase = (String)Util.parseCodeName(dep.getName())[0]; diff -r 0df9cb6108b7 o.n.core/nbproject/project.xml --- a/o.n.core/nbproject/project.xml Wed Nov 07 16:27:53 2012 +0100 +++ b/o.n.core/nbproject/project.xml Wed Nov 07 17:36:29 2012 +0100 @@ -168,7 +168,7 @@ - 8.25 + 8.29 diff -r 0df9cb6108b7 o.n.core/src/org/netbeans/core/NbErrorManager.java --- a/o.n.core/src/org/netbeans/core/NbErrorManager.java Wed Nov 07 16:27:53 2012 +0100 +++ b/o.n.core/src/org/netbeans/core/NbErrorManager.java Wed Nov 07 17:36:29 2012 +0100 @@ -44,6 +44,7 @@ package org.netbeans.core; +import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintStream; import java.io.PrintWriter; @@ -61,6 +62,7 @@ import java.util.logging.LogRecord; import java.util.logging.Logger; import org.netbeans.core.startup.TopLogging; +import org.openide.util.UserQuestionException; /** Wraps errormanager with logger. * @@ -268,6 +270,14 @@ return false; } + final boolean isUserQuestion() { + return t instanceof UserQuestionException; + } + + final void confirm() throws IOException { + ((UserQuestionException)t).confirmed(); + } + /** @return class name of the exception */ String getClassName() { return (String)find(3); diff -r 0df9cb6108b7 o.n.core/src/org/netbeans/core/NotifyExcPanel.java --- a/o.n.core/src/org/netbeans/core/NotifyExcPanel.java Wed Nov 07 16:27:53 2012 +0100 +++ b/o.n.core/src/org/netbeans/core/NotifyExcPanel.java Wed Nov 07 17:36:29 2012 +0100 @@ -54,6 +54,7 @@ import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import java.lang.reflect.ParameterizedType; @@ -274,7 +275,7 @@ static void notify ( final NbErrorManager.Exc t ) { - if (!shallNotify(t.getSeverity(), false)) { + if (!t.isUserQuestion() && !shallNotify(t.getSeverity(), false)) { return; } @@ -285,10 +286,24 @@ } SwingUtilities.invokeLater (new Runnable () { + @Override public void run() { String glm = t.getLocalizedMessage(); Level gs = t.getSeverity(); boolean loc = t.isLocalized(); + + if (t.isUserQuestion() && loc) { + Object ret = DialogDisplayer.getDefault().notify( + new NotifyDescriptor.Confirmation(glm, NotifyDescriptor.OK_CANCEL_OPTION)); + if (ret == NotifyDescriptor.OK_OPTION) { + try { + t.confirm(); + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } + } + return; + } if (loc) { if (gs == Level.WARNING) { diff -r 0df9cb6108b7 o.n.core/test/unit/src/org/netbeans/core/NbErrorManagerUserQuestionTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/o.n.core/test/unit/src/org/netbeans/core/NbErrorManagerUserQuestionTest.java Wed Nov 07 17:36:29 2012 +0100 @@ -0,0 +1,175 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2012 Oracle and/or its affiliates. All rights reserved. + * + * Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners. + * + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle 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]" + * + * 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. + * + * Contributor(s): + * + * Portions Copyrighted 2012 Sun Microsystems, Inc. + */ +package org.netbeans.core; + +import java.awt.Dialog; +import java.awt.EventQueue; +import java.awt.GraphicsEnvironment; +import java.io.IOException; +import javax.swing.JDialog; +import junit.framework.Test; +import junit.framework.TestSuite; +import org.netbeans.core.startup.TopLogging; +import org.netbeans.junit.MockServices; +import org.netbeans.junit.NbTestCase; +import org.openide.DialogDescriptor; +import org.openide.DialogDisplayer; +import org.openide.NotifyDescriptor; +import org.openide.util.Exceptions; +import org.openide.util.UserQuestionException; + +/** + * + * @author Jaroslav Tulach + */ +public class NbErrorManagerUserQuestionTest extends NbTestCase { + + public static Test suite() { + return GraphicsEnvironment.isHeadless() ? new TestSuite() : new TestSuite(NbErrorManagerUserQuestionTest.class); + } + + public NbErrorManagerUserQuestionTest(String name) { + super(name); + } + + @Override + protected void setUp() throws Exception { + clearWorkDir(); + + MockServices.setServices(MockDD.class); + System.setProperty("netbeans.user", getWorkDirPath()); + + // init the whole system + TopLogging.initializeQuietly(); + } + + public void testUserQuestionExceptionDisplayedOK() throws Exception { + class UQE extends UserQuestionException { + UQE() { + super("HelloTest"); + } + + boolean confirm; + @Override + public void confirmed() throws IOException { + confirm = true; + } + + @Override + public String getLocalizedMessage() { + return "Reboot?"; + } + } + MockDD.reply = NotifyDescriptor.OK_OPTION; + + UQE ex = new UQE(); + Exceptions.printStackTrace(ex); + + waitEDT(); + + assertNotNull("Dialog created", MockDD.lastDescriptor); + assertEquals("Message is localized text", "Reboot?", MockDD.lastDescriptor.getMessage()); + assertTrue("The message has been confirmed", ex.confirm); + } + + public void testUserQuestionExceptionDisplayedCancel() throws Exception { + class UQE extends UserQuestionException { + UQE() { + super("HelloTest"); + } + + boolean confirm; + @Override + public void confirmed() throws IOException { + confirm = true; + } + + @Override + public String getLocalizedMessage() { + return "Reboot?"; + } + } + MockDD.reply = NotifyDescriptor.CLOSED_OPTION; + + UQE ex = new UQE(); + Exceptions.printStackTrace(ex); + + waitEDT(); + + assertNotNull("Dialog created", MockDD.lastDescriptor); + assertEquals("Message is localized text", "Reboot?", MockDD.lastDescriptor.getMessage()); + assertFalse("The message has not been confirmed", ex.confirm); + } + + private void waitEDT() throws Exception { + EventQueue.invokeAndWait(new Runnable() { + @Override + public void run() { + } + }); + } + + + public static final class MockDD extends DialogDisplayer { + static Object reply; + static NotifyDescriptor lastDescriptor; + + @Override + public Object notify(NotifyDescriptor descriptor) { + lastDescriptor = descriptor; + return reply; + } + + @Override + public Dialog createDialog(DialogDescriptor descriptor) { + lastDescriptor = descriptor; + return new JDialog() { + @SuppressWarnings("deprecation") + @Override + public void show() { + } + }; + } + } + + +} diff -r 0df9cb6108b7 openide.util/apichanges.xml --- a/openide.util/apichanges.xml Wed Nov 07 16:27:53 2012 +0100 +++ b/openide.util/apichanges.xml Wed Nov 07 17:36:29 2012 +0100 @@ -51,6 +51,24 @@ Actions API + + + Automatic support for UserQuestionException + + + + + +

+ The default NetBeans Platform infrastructure knows how to + display dialog when an UserQuestionException is + reported. +

+
+ + + +
UNC-safe File / URI interconversion diff -r 0df9cb6108b7 openide.util/manifest.mf --- a/openide.util/manifest.mf Wed Nov 07 16:27:53 2012 +0100 +++ b/openide.util/manifest.mf Wed Nov 07 17:36:29 2012 +0100 @@ -1,5 +1,5 @@ Manifest-Version: 1.0 OpenIDE-Module: org.openide.util OpenIDE-Module-Localizing-Bundle: org/openide/util/Bundle.properties -OpenIDE-Module-Specification-Version: 8.28 +OpenIDE-Module-Specification-Version: 8.29 diff -r 0df9cb6108b7 openide.util/src/org/openide/util/Exceptions.java --- a/openide.util/src/org/openide/util/Exceptions.java Wed Nov 07 16:27:53 2012 +0100 +++ b/openide.util/src/org/openide/util/Exceptions.java Wed Nov 07 17:36:29 2012 +0100 @@ -184,6 +184,14 @@ /** Notifies an exception with a severe level. Such exception is going * to be printed to log file and possibly also notified to alarm the * user somehow. + *

+ * Since version 8.29 the default implementation of this method inside + * a NetBeans Platform based application understands + * {@link UserQuestionException}. If the exception is thrown and later + * reported via this method, it is properly shown to the user as a + * dialog with approve/reject options. If approved, the infrastructure + * calls {@link UserQuestionException#confirmed()} method. + *

* * @param t the exception to notify */ diff -r 0df9cb6108b7 openide.util/src/org/openide/util/UserQuestionException.java --- a/openide.util/src/org/openide/util/UserQuestionException.java Wed Nov 07 16:27:53 2012 +0100 +++ b/openide.util/src/org/openide/util/UserQuestionException.java Wed Nov 07 17:36:29 2012 +0100 @@ -54,6 +54,11 @@ * The getLocalizedMessage method should return the user question, * which will be shown to the user in a dialog with OK, Cancel options and * if the user chooses OK, method ex.confirmed () will be called. +*

+* Since version 8.29 one can just catch the exception and report it to the +* infrastructure of any NetBeans Platform based application (for example +* via {@link Exceptions#printStackTrace(java.lang.Throwable)}) and the +* question dialog will be displayed automatically. * * @author Jaroslav Tulach */