| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package org.xmlhammer.gui.output; |
| 22 |
|
|
| 23 |
|
import java.net.URI; |
| 24 |
|
|
| 25 |
|
import javax.swing.ImageIcon; |
| 26 |
|
import javax.swing.JFrame; |
| 27 |
|
import javax.swing.JPopupMenu; |
| 28 |
|
|
| 29 |
|
import org.bounce.RunnableAction; |
| 30 |
|
import org.bounce.MenuUtilities; |
| 31 |
|
import org.bounce.image.ImageLoader; |
| 32 |
|
import org.bounce.util.URIUtils; |
| 33 |
|
import org.xmlhammer.model.project.Fatal; |
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
0 |
public class FatalNode extends ResultNode { |
| 42 |
|
private static final long serialVersionUID = 4477033541781195906L; |
| 43 |
|
|
| 44 |
22 |
private static final ImageIcon ICON = ImageLoader.get().getImage( "/org/xmlhammer/gui/icons/obj16/error_obj.gif"); |
| 45 |
22 |
private static ExceptionDetailsDialog dialog = null; |
| 46 |
|
|
| 47 |
44 |
private Fatal fatal = null; |
| 48 |
44 |
private URI uri = null; |
| 49 |
|
|
| 50 |
44 |
public FatalNode(URI uri, Fatal fatal) { |
| 51 |
44 |
this.fatal = fatal; |
| 52 |
44 |
this.uri = uri; |
| 53 |
44 |
} |
| 54 |
|
|
| 55 |
|
public Fatal getFatal() { |
| 56 |
0 |
return fatal; |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
public String getValue() { |
| 60 |
0 |
StringBuilder builder = new StringBuilder(); |
| 61 |
|
|
| 62 |
0 |
if (fatal.getSystemId() != null) { |
| 63 |
0 |
URI systemId = URIUtils.createURI(fatal.getSystemId()); |
| 64 |
|
|
| 65 |
0 |
if (uri.compareTo(systemId) != 0) { |
| 66 |
0 |
builder.append(URIUtils.getName(systemId)); |
| 67 |
0 |
builder.append(" - "); |
| 68 |
|
} |
| 69 |
|
} |
| 70 |
|
|
| 71 |
0 |
if (getNumber(fatal.getLine()) != -1) { |
| 72 |
0 |
builder.append("["); |
| 73 |
0 |
builder.append(getNumber(fatal.getLine())); |
| 74 |
0 |
builder.append(":"); |
| 75 |
0 |
builder.append(getNumber(fatal.getColumn())); |
| 76 |
0 |
builder.append("] "); |
| 77 |
|
} |
| 78 |
|
|
| 79 |
0 |
builder.append(fatal.getLocalizedMessage()); |
| 80 |
|
|
| 81 |
0 |
return builder.toString(); |
| 82 |
|
} |
| 83 |
|
|
| 84 |
|
public String getName() { |
| 85 |
0 |
return getValue(); |
| 86 |
|
} |
| 87 |
|
|
| 88 |
|
public String getDescription() { |
| 89 |
0 |
return getValue(); |
| 90 |
|
} |
| 91 |
|
|
| 92 |
|
public ImageIcon getIcon() { |
| 93 |
0 |
return ICON; |
| 94 |
|
} |
| 95 |
|
|
| 96 |
|
public String getContext() { |
| 97 |
0 |
return ""; |
| 98 |
|
} |
| 99 |
|
|
| 100 |
|
@Override |
| 101 |
|
public JPopupMenu getPopupMenu(JFrame parent) { |
| 102 |
0 |
JPopupMenu popup = new JPopupMenu(); |
| 103 |
0 |
popup.add(getOpenURIAction(getOpenableURI(), getNumber(fatal.getLine()), getNumber(fatal.getColumn()))); |
| 104 |
0 |
popup.add(getEditURIAction(getOpenableURI(), getNumber(fatal.getLine()), getNumber(fatal.getColumn()))); |
| 105 |
0 |
popup.addSeparator(); |
| 106 |
0 |
popup.add(getCopyAction()); |
| 107 |
0 |
popup.addSeparator(); |
| 108 |
0 |
popup.add(getPropertiesAction(getDialog(parent))); |
| 109 |
|
|
| 110 |
0 |
MenuUtilities.alignMenu(popup); |
| 111 |
|
|
| 112 |
0 |
return popup; |
| 113 |
|
} |
| 114 |
|
|
| 115 |
|
@Override |
| 116 |
|
public RunnableAction getDefaultAction(JFrame parent) { |
| 117 |
0 |
return getPropertiesAction(getDialog(parent)); |
| 118 |
|
} |
| 119 |
|
|
| 120 |
|
private ExceptionDetailsDialog getDialog(JFrame parent) { |
| 121 |
0 |
if (dialog == null) { |
| 122 |
0 |
dialog = new ExceptionDetailsDialog(parent, "Fatal Error Details"); |
| 123 |
|
} |
| 124 |
|
|
| 125 |
0 |
dialog.setException(fatal, uri, ICON); |
| 126 |
|
|
| 127 |
0 |
return dialog; |
| 128 |
|
} |
| 129 |
|
|
| 130 |
|
private static int getNumber(Integer integer) { |
| 131 |
0 |
if (integer != null) { |
| 132 |
0 |
return integer; |
| 133 |
|
} |
| 134 |
|
|
| 135 |
0 |
return -1; |
| 136 |
|
} |
| 137 |
|
|
| 138 |
|
public String getCopyValue() { |
| 139 |
0 |
return "[fatal] "+getValue(); |
| 140 |
|
} |
| 141 |
|
|
| 142 |
|
private URI getOpenableURI() { |
| 143 |
0 |
if (fatal.getSystemId() != null) { |
| 144 |
0 |
return URIUtils.createURI(fatal.getSystemId()); |
| 145 |
|
} |
| 146 |
|
|
| 147 |
0 |
return uri; |
| 148 |
|
} |
| 149 |
|
} |