View Javadoc

1   /*
2    * $Id: ValueNode.java,v 1.7 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) 2002 - 2006 the Initial Developer. 
17   * All Rights Reserved.
18   *
19   * Contributor(s): Edwin Dankert <edankert@gmail.com>
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.xmlhammer.model.project.ValueType;
32  
33  /***
34   * The node for the XML tree, containing an XML element.
35   *
36   * @version	$Revision: 1.7 $, $Date: 2007/07/04 19:42:48 $
37   * @author Edwin Dankert <edankert@gmail.com>
38   */
39  public class ValueNode extends ResultNode {
40  	private static final long serialVersionUID = -6314127203480034911L;
41  
42      private ValueType value = null;
43      private URI uri = null;
44  	
45  	public ValueNode(URI uri, ValueType value) {
46  		this.value = value;
47          this.uri = uri;
48  	}
49  	
50  	public String getName() {
51  		return "";
52  	}
53  	
54  	public String getValue() {
55  		return value.getValue();
56  	}
57  	
58  	public String getDescription() {
59  		return value.getValue();
60  	}
61  	
62  	public ImageIcon getIcon() {
63  		return null;
64  	}
65      
66      @Override
67      public JPopupMenu getPopupMenu(JFrame parent) {
68          JPopupMenu popup = new JPopupMenu();
69          popup.add(getOpenURIAction(uri, 0, 0));
70          popup.add(getEditURIAction(uri, 0, 0));
71          popup.addSeparator();
72          popup.add(getCopyAction());
73          popup.addSeparator();
74          popup.add(getPropertiesAction(null));
75          
76          MenuUtilities.alignMenu(popup);
77  
78          return popup;
79      }
80      
81      public String getCopyValue() {
82          return value.getValue();
83      }
84  
85      @Override
86      public RunnableAction getDefaultAction(JFrame parent) {
87          return getPropertiesAction(null);
88      }
89  }