View Javadoc

1   /*
2    * $Id$
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  package org.xmlhammer.gui.output;
22  
23  import java.net.URI;
24  
25  import javax.swing.Icon;
26  import javax.swing.ImageIcon;
27  import javax.swing.JFrame;
28  import javax.swing.JPopupMenu;
29  
30  import org.bounce.RunnableAction;
31  import org.bounce.MenuUtilities;
32  import org.bounce.image.ImageLoader;
33  import org.bounce.util.URIUtils;
34  
35  /***
36   * A Directory Node.
37   *
38   * @version	$Revision$, $Date$
39   * @author Edwin Dankert <edankert@gmail.com>
40   */
41  public class DirectoryNode extends URINode {
42      private static final long serialVersionUID = -8085361000356059123L;
43     
44      private static final ImageIcon ICON = ImageLoader.get().getImage( "/org/xmlhammer/gui/icons/etool16/dir.gif");
45  
46  	public DirectoryNode(URI uri) {
47          super(uri);
48  	}
49      
50      public String getName() {
51          return URIUtils.getDirectoryName(getURI());
52      }
53  
54      public String getValue() {
55          return getName();
56      }
57      
58      public String getDescription() {
59          return URIUtils.toString(getURI());
60      }
61  
62      public Icon getIcon() {
63  		return ICON;
64  	}
65      
66      @Override
67      public JPopupMenu getPopupMenu(JFrame parent) {
68          JPopupMenu popup = new JPopupMenu();
69          popup.add(getOpenURIAction(null, 0, 0));
70          popup.add(getEditURIAction(null, 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      @Override
82      public RunnableAction getDefaultAction(JFrame parent) {
83          return null;
84      }
85  }