SDK:
- Make real nice notify about failed scene / application ;) - Use notify system in logger (warnings, errors, exceptions) git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10253 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
@@ -31,6 +31,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.jme3.gde.core.scene;
|
package com.jme3.gde.core.scene;
|
||||||
|
|
||||||
|
import com.jme3.gde.core.util.notify.NotifyUtil;
|
||||||
import com.jme3.util.JmeFormatter;
|
import com.jme3.util.JmeFormatter;
|
||||||
import java.util.logging.Handler;
|
import java.util.logging.Handler;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@@ -54,9 +55,16 @@ public class ApplicationLogHandler extends Handler {
|
|||||||
@Override
|
@Override
|
||||||
public void publish(LogRecord record) {
|
public void publish(LogRecord record) {
|
||||||
if (record.getLevel().equals(Level.SEVERE)) {
|
if (record.getLevel().equals(Level.SEVERE)) {
|
||||||
|
Throwable thrown = record.getThrown();
|
||||||
|
if (thrown != null) {
|
||||||
|
NotifyUtil.error("Exception!", formatter.formatMessage(record), false);
|
||||||
|
}else{
|
||||||
|
NotifyUtil.error("Severe error!", formatter.formatMessage(record), true);
|
||||||
|
}
|
||||||
io.getErr().println(formatter.formatMessage(record));
|
io.getErr().println(formatter.formatMessage(record));
|
||||||
} else if (record.getLevel().equals(Level.WARNING)) {
|
} else if (record.getLevel().equals(Level.WARNING)) {
|
||||||
io.getErr().println(formatter.formatMessage(record));
|
io.getErr().println(formatter.formatMessage(record));
|
||||||
|
NotifyUtil.warn("Warning!", formatter.formatMessage(record), true);
|
||||||
} else if (record.getLevel().equals(Level.INFO)) {
|
} else if (record.getLevel().equals(Level.INFO)) {
|
||||||
io.getOut().println(formatter.formatMessage(record));
|
io.getOut().println(formatter.formatMessage(record));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ import com.jme3.gde.core.scene.processors.WireProcessor;
|
|||||||
import com.jme3.gde.core.sceneexplorer.nodes.NodeUtility;
|
import com.jme3.gde.core.sceneexplorer.nodes.NodeUtility;
|
||||||
import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent;
|
import com.jme3.gde.core.sceneviewer.SceneViewerTopComponent;
|
||||||
import com.jme3.gde.core.undoredo.SceneUndoRedoManager;
|
import com.jme3.gde.core.undoredo.SceneUndoRedoManager;
|
||||||
|
import com.jme3.gde.core.util.notify.MessageType;
|
||||||
|
import com.jme3.gde.core.util.notify.NotifyUtil;
|
||||||
import com.jme3.input.FlyByCamera;
|
import com.jme3.input.FlyByCamera;
|
||||||
import com.jme3.input.MouseInput;
|
import com.jme3.input.MouseInput;
|
||||||
import com.jme3.input.controls.MouseAxisTrigger;
|
import com.jme3.input.controls.MouseAxisTrigger;
|
||||||
@@ -57,7 +59,11 @@ import com.jme3.system.awt.AwtPanel;
|
|||||||
import com.jme3.system.awt.AwtPanelsContext;
|
import com.jme3.system.awt.AwtPanelsContext;
|
||||||
import com.jme3.system.awt.PaintMode;
|
import com.jme3.system.awt.PaintMode;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
@@ -69,6 +75,7 @@ import org.openide.DialogDisplayer;
|
|||||||
import org.openide.NotifyDescriptor;
|
import org.openide.NotifyDescriptor;
|
||||||
import org.openide.NotifyDescriptor.Confirmation;
|
import org.openide.NotifyDescriptor.Confirmation;
|
||||||
import org.openide.NotifyDescriptor.Message;
|
import org.openide.NotifyDescriptor.Message;
|
||||||
|
import org.openide.awt.HtmlBrowser;
|
||||||
import org.openide.awt.StatusDisplayer;
|
import org.openide.awt.StatusDisplayer;
|
||||||
import org.openide.loaders.DataObject;
|
import org.openide.loaders.DataObject;
|
||||||
import org.openide.util.Exceptions;
|
import org.openide.util.Exceptions;
|
||||||
@@ -157,11 +164,11 @@ public class SceneApplication extends Application implements LookupProvider {
|
|||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
SceneViewerTopComponent.showOpenGLError(e.toString());
|
|
||||||
Exceptions.printStackTrace(e);
|
Exceptions.printStackTrace(e);
|
||||||
|
showStartupErrorMessage(e);
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
SceneViewerTopComponent.showOpenGLError(e.toString());
|
|
||||||
Exceptions.printStackTrace(e);
|
Exceptions.printStackTrace(e);
|
||||||
|
showStartupErrorMessage(e);
|
||||||
} finally {
|
} finally {
|
||||||
getProgressHandle().finish();
|
getProgressHandle().finish();
|
||||||
}
|
}
|
||||||
@@ -262,10 +269,10 @@ public class SceneApplication extends Application implements LookupProvider {
|
|||||||
started = true;
|
started = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Exceptions.printStackTrace(e);
|
Exceptions.printStackTrace(e);
|
||||||
SceneViewerTopComponent.showOpenGLError(e.toString());
|
showStartupErrorMessage(e);
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
Exceptions.printStackTrace(e);
|
Exceptions.printStackTrace(e);
|
||||||
SceneViewerTopComponent.showOpenGLError(e.toString());
|
showStartupErrorMessage(e);
|
||||||
} finally {
|
} finally {
|
||||||
getProgressHandle().finish();
|
getProgressHandle().finish();
|
||||||
}
|
}
|
||||||
@@ -614,7 +621,7 @@ public class SceneApplication extends Application implements LookupProvider {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!started) {
|
if (!started) {
|
||||||
SceneViewerTopComponent.showOpenGLError(msg);
|
showStartupErrorMessage(t);
|
||||||
Exceptions.printStackTrace(t);
|
Exceptions.printStackTrace(t);
|
||||||
} else {
|
} else {
|
||||||
if (lastError != null && !lastError.equals(msg)) {
|
if (lastError != null && !lastError.equals(msg)) {
|
||||||
@@ -625,6 +632,19 @@ public class SceneApplication extends Application implements LookupProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void showStartupErrorMessage(Throwable exception) {
|
||||||
|
ActionListener lst = new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
try {
|
||||||
|
HtmlBrowser.URLDisplayer.getDefault().showURL(new URL("http://jmonkeyengine.org/wiki/doku.php/sdk:troubleshooting"));
|
||||||
|
} catch (MalformedURLException ex) {
|
||||||
|
Exceptions.printStackTrace(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NotifyUtil.show("Error starting OpenGL context!", exception.getMessage() + " - Click here to go to troubleshooting web page.", MessageType.EXCEPTION, lst, 0);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RenderManager getRenderManager() {
|
public RenderManager getRenderManager() {
|
||||||
return renderManager;
|
return renderManager;
|
||||||
|
|||||||
@@ -28,9 +28,13 @@ import com.jme3.gde.core.filters.FilterExplorerTopComponent;
|
|||||||
import com.jme3.gde.core.icons.IconList;
|
import com.jme3.gde.core.icons.IconList;
|
||||||
import com.jme3.gde.core.scene.SceneApplication;
|
import com.jme3.gde.core.scene.SceneApplication;
|
||||||
import com.jme3.gde.core.scene.SceneRequest;
|
import com.jme3.gde.core.scene.SceneRequest;
|
||||||
|
import com.jme3.gde.core.util.notify.MessageType;
|
||||||
|
import com.jme3.gde.core.util.notify.NotifyUtil;
|
||||||
import com.jme3.input.awt.AwtKeyInput;
|
import com.jme3.input.awt.AwtKeyInput;
|
||||||
import com.jme3.input.event.KeyInputEvent;
|
import com.jme3.input.event.KeyInputEvent;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.KeyListener;
|
import java.awt.event.KeyListener;
|
||||||
import java.awt.event.MouseWheelEvent;
|
import java.awt.event.MouseWheelEvent;
|
||||||
@@ -90,10 +94,10 @@ public final class SceneViewerTopComponent extends TopComponent {
|
|||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Exceptions.printStackTrace(e);
|
Exceptions.printStackTrace(e);
|
||||||
showOpenGLError(e.toString());
|
SceneApplication.showStartupErrorMessage(e);
|
||||||
} catch (Error err) {
|
} catch (Error err) {
|
||||||
Exceptions.printStackTrace(err);
|
Exceptions.printStackTrace(err);
|
||||||
showOpenGLError(err.toString());
|
SceneApplication.showStartupErrorMessage(err);
|
||||||
}
|
}
|
||||||
//TODO: camera tools (see SwitchFrontViewAction)
|
//TODO: camera tools (see SwitchFrontViewAction)
|
||||||
// Collection<? extends Action> result = Lookups.forPath("CameraTools").lookupAll(Action.class);
|
// Collection<? extends Action> result = Lookups.forPath("CameraTools").lookupAll(Action.class);
|
||||||
@@ -300,24 +304,6 @@ public final class SceneViewerTopComponent extends TopComponent {
|
|||||||
return getDefault();
|
return getDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showOpenGLError(String e) {
|
|
||||||
Message msg = new NotifyDescriptor.Message(
|
|
||||||
"Error opening OpenGL window!\n"
|
|
||||||
+ "Error: " + e + "\n"
|
|
||||||
+ "See http://jmonkeyengine.org/wiki/doku.php/sdk:troubleshooting \n"
|
|
||||||
+ "for more info."
|
|
||||||
+ NotifyDescriptor.ERROR_MESSAGE);
|
|
||||||
DialogDisplayer.getDefault().notifyLater(msg);
|
|
||||||
if (!browserOpened) {
|
|
||||||
browserOpened = true;
|
|
||||||
try {
|
|
||||||
HtmlBrowser.URLDisplayer.getDefault().showURL(new URL("http://jmonkeyengine.org/wiki/doku.php/sdk:troubleshooting"));
|
|
||||||
} catch (MalformedURLException ex) {
|
|
||||||
Exceptions.printStackTrace(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPersistenceType() {
|
public int getPersistenceType() {
|
||||||
return TopComponent.PERSISTENCE_ALWAYS;
|
return TopComponent.PERSISTENCE_ALWAYS;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ package com.jme3.gde.core.util.notify;
|
|||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import javax.swing.Timer;
|
||||||
import org.openide.awt.Notification;
|
import org.openide.awt.Notification;
|
||||||
import org.openide.awt.NotificationDisplayer;
|
import org.openide.awt.NotificationDisplayer;
|
||||||
|
|
||||||
@@ -48,10 +49,20 @@ public class NotifyUtil {
|
|||||||
/**
|
/**
|
||||||
* Show message with the specified type and action listener
|
* Show message with the specified type and action listener
|
||||||
*/
|
*/
|
||||||
public static void show(String title, String message, MessageType type, ActionListener actionListener, boolean clear) {
|
public static void show(String title, String message, MessageType type, ActionListener actionListener, int timeout) {
|
||||||
Notification n = (Notification) NotificationDisplayer.getDefault().notify(title, type.getIcon(), message, actionListener);
|
final Notification n = (Notification) NotificationDisplayer.getDefault().notify(title, type.getIcon(), message, actionListener);
|
||||||
if (clear == true) {
|
if (timeout > 0) {
|
||||||
n.clear();
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
Timer timer = new Timer(10000, new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
n.clear();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
timer.setRepeats(false);
|
||||||
|
timer.start();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +70,7 @@ public class NotifyUtil {
|
|||||||
* Show message with the specified type and a default action which displays
|
* Show message with the specified type and a default action which displays
|
||||||
* the message using {@link MessageUtil} with the same message type
|
* the message using {@link MessageUtil} with the same message type
|
||||||
*/
|
*/
|
||||||
public static void show(String title, final String message, final MessageType type, boolean clear) {
|
public static void show(String title, final String message, final MessageType type, int timeout) {
|
||||||
ActionListener actionListener = new ActionListener() {
|
ActionListener actionListener = new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
@@ -67,11 +78,12 @@ public class NotifyUtil {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
show(title, message, type, actionListener, clear);
|
show(title, message, type, actionListener, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show an information notification
|
* Show an information notification
|
||||||
|
*
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
public static void info(String title, String message) {
|
public static void info(String title, String message) {
|
||||||
@@ -80,14 +92,16 @@ public class NotifyUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Show an information notification
|
* Show an information notification
|
||||||
|
*
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
public static void info(String title, String message, boolean clear) {
|
public static void info(String title, String message, boolean clear) {
|
||||||
show(title, message, MessageType.INFO, clear);
|
show(title, message, MessageType.INFO, 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show an exception
|
* Show an exception
|
||||||
|
*
|
||||||
* @param exception
|
* @param exception
|
||||||
*/
|
*/
|
||||||
public static void error(Throwable exception) {
|
public static void error(Throwable exception) {
|
||||||
@@ -96,14 +110,16 @@ public class NotifyUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Show an error notification
|
* Show an error notification
|
||||||
|
*
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
public static void error(String title, String message, boolean clear) {
|
public static void error(String title, String message, boolean clear) {
|
||||||
show(title, message, MessageType.ERROR, clear);
|
show(title, message, MessageType.ERROR, 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show an error notification for an exception
|
* Show an error notification for an exception
|
||||||
|
*
|
||||||
* @param message
|
* @param message
|
||||||
* @param exception
|
* @param exception
|
||||||
*/
|
*/
|
||||||
@@ -116,22 +132,24 @@ public class NotifyUtil {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
show(title, message, MessageType.EXCEPTION, actionListener, clear);
|
show(title, message, MessageType.EXCEPTION, actionListener, 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show an warning notification
|
* Show an warning notification
|
||||||
|
*
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
public static void warn(String title, String message, boolean clear) {
|
public static void warn(String title, String message, boolean clear) {
|
||||||
show(title, message, MessageType.WARNING, clear);
|
show(title, message, MessageType.WARNING, 5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show an plain notification
|
* Show an plain notification
|
||||||
|
*
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
public static void plain(String title, String message, boolean clear) {
|
public static void plain(String title, String message, boolean clear) {
|
||||||
show(title, message, MessageType.PLAIN, clear);
|
show(title, message, MessageType.PLAIN, 5000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user