| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
package org.xmlhammer.gui.output; |
| 23 |
|
|
| 24 |
|
import java.awt.Dimension; |
| 25 |
|
import java.net.URI; |
| 26 |
|
|
| 27 |
|
import javax.swing.ImageIcon; |
| 28 |
|
import javax.swing.JFrame; |
| 29 |
|
import javax.swing.JPopupMenu; |
| 30 |
|
|
| 31 |
|
import org.bounce.RunnableAction; |
| 32 |
|
import org.bounce.MenuUtilities; |
| 33 |
|
import org.bounce.image.ImageLoader; |
| 34 |
|
import org.xmlhammer.model.project.Attribute; |
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
0 |
public class AttributeNode extends ResultNode { |
| 43 |
22 |
static final Dimension EDITORPANE_SIZE = new Dimension( 100, 60); |
| 44 |
|
|
| 45 |
|
private static final long serialVersionUID = -1312728718437717912L; |
| 46 |
|
|
| 47 |
22 |
private static final ImageIcon ICON = ImageLoader.get().getImage( "/org/xmlhammer/gui/icons/obj16/att_URI_obj.gif");; |
| 48 |
22 |
private static AttributeDetailsDialog dialog = null; |
| 49 |
|
|
| 50 |
132 |
private Attribute value = null; |
| 51 |
132 |
private URI uri = null; |
| 52 |
|
|
| 53 |
132 |
public AttributeNode(URI uri, Attribute value) { |
| 54 |
132 |
this.value = value; |
| 55 |
132 |
this.uri = uri; |
| 56 |
132 |
} |
| 57 |
|
|
| 58 |
|
public String getName() { |
| 59 |
0 |
return value.getName(); |
| 60 |
|
} |
| 61 |
|
|
| 62 |
|
public String getValue() { |
| 63 |
0 |
return value.getNodeName()+" - "+value.getNodeValue(); |
| 64 |
|
} |
| 65 |
|
|
| 66 |
|
public String getDescription() { |
| 67 |
0 |
return "{"+value.getNamespaceURI()+"}"+value.getName()+" - "+value.getValue(); |
| 68 |
|
} |
| 69 |
|
|
| 70 |
|
public ImageIcon getIcon() { |
| 71 |
0 |
return ICON; |
| 72 |
|
} |
| 73 |
|
|
| 74 |
|
@Override |
| 75 |
|
public JPopupMenu getPopupMenu(JFrame parent) { |
| 76 |
0 |
JPopupMenu popup = new JPopupMenu(); |
| 77 |
0 |
popup.add(getOpenURIAction(uri, 0, 0)); |
| 78 |
0 |
popup.add(getEditURIAction(uri, 0, 0)); |
| 79 |
0 |
popup.addSeparator(); |
| 80 |
0 |
popup.add(getCopyAction()); |
| 81 |
0 |
popup.addSeparator(); |
| 82 |
0 |
popup.add(getPropertiesAction(getDialog(parent))); |
| 83 |
|
|
| 84 |
0 |
MenuUtilities.alignMenu(popup); |
| 85 |
|
|
| 86 |
0 |
return popup; |
| 87 |
|
} |
| 88 |
|
|
| 89 |
|
@Override |
| 90 |
|
public RunnableAction getDefaultAction(JFrame parent) { |
| 91 |
0 |
return getPropertiesAction(getDialog(parent)); |
| 92 |
|
} |
| 93 |
|
|
| 94 |
|
private AttributeDetailsDialog getDialog(JFrame parent) { |
| 95 |
0 |
if (dialog == null) { |
| 96 |
0 |
dialog = new AttributeDetailsDialog(parent); |
| 97 |
|
} |
| 98 |
|
|
| 99 |
0 |
dialog.setAttribute(value); |
| 100 |
|
|
| 101 |
0 |
return dialog; |
| 102 |
|
} |
| 103 |
|
|
| 104 |
|
public String getCopyValue() { |
| 105 |
0 |
return value.getNodeName()+"=\""+value.getNodeValue()+"\""; |
| 106 |
|
} |
| 107 |
|
} |