Coverage Report - org.xmlhammer.gui.output.AttributeNode
 
Classes in this File Line Coverage Branch Coverage Complexity
AttributeNode
31% 
0% 
0
 
 1  
 /*
 2  
  * $Id: AttributeNode.java,v 1.9 2007/07/04 19:42:48 edankert Exp $
 3  
  *
 4  
  * The contents of this file are subject to the Mozilla Public License 
 5  
  * Version 1.1 (the "License"); you may not use this file except in 
 6  
  * compliance with the License. You may obtain a copy of the License at 
 7  
  * http://www.mozilla.org/MPL/ 
 8  
  *
 9  
  * Software distributed under the License is distributed on an "AS IS" basis, 
 10  
  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
 11  
  * for the specific language governing rights and limitations under the License.
 12  
  *
 13  
  * The Original Code is XML Hammer code. (org.xmlhammer.*)
 14  
  *
 15  
  * The Initial Developer of the Original Code is Edwin Dankert. Portions created 
 16  
  * by the Initial Developer are Copyright (C) 2005 - 2006 the Initial Developer. 
 17  
  * All Rights Reserved.
 18  
  *
 19  
  * Contributor(s): Edwin Dankert <edankert@gmail.com>
 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  
  * The node for an XML attribute.
 38  
  *
 39  
  * @version        $Revision: 1.9 $, $Date: 2007/07/04 19:42:48 $
 40  
  * @author Edwin Dankert <edankert@gmail.com>
 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  
 }