/plugins/ProjectViewer/tags/pv_2_9_3/projectviewer/vpt/VPTGroup.java

# · Java · 86 lines · 34 code · 12 blank · 40 comment · 6 complexity · caf7c44c049b079199a494ef2b552518 MD5 · raw file

  1. /*
  2. * :tabSize=4:indentSize=4:noTabs=false:
  3. * :folding=explicit:collapseFolds=1:
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. package projectviewer.vpt;
  20. //{{{ Imports
  21. import java.io.File;
  22. import javax.swing.Icon;
  23. import javax.swing.ImageIcon;
  24. import org.gjt.sp.jedit.GUIUtilities;
  25. //}}}
  26. /**
  27. * A VPTGroup is a container for groups and projects.
  28. *
  29. * @author Marcelo Vanzin
  30. * @version $Id: VPTGroup.java 15736 2009-07-22 04:21:44Z vanza $
  31. * @since PV 2.1.0
  32. */
  33. public class VPTGroup extends VPTNode {
  34. //{{{ Constants
  35. private final static Icon groupIcon =
  36. new ImageIcon(VPTGroup.class.getResource("/projectviewer/images/vpt_group.png"));
  37. //}}}
  38. //{{{ +VPTGroup(String) : <init>
  39. public VPTGroup(String name) {
  40. super(name, true);
  41. } //}}}
  42. //{{{ +getIcon(boolean) : Icon
  43. /**
  44. * Returns the icon to be shown on the tree next to the node name.
  45. *
  46. * @param expanded If the node is currently expanded or not.
  47. */
  48. public Icon getIcon(boolean expanded) {
  49. return groupIcon;
  50. } //}}}
  51. //{{{ +getNodePath() : String
  52. /** Returns the path to this group in the group tree. */
  53. public String getNodePath() {
  54. if (getParent() != null) {
  55. return ((VPTNode)getParent()).getNodePath() + getName();
  56. }
  57. return getName() + File.separator;
  58. } //}}}
  59. //{{{ +compareTo(VPTNode) : int
  60. public int compareTo(VPTNode n)
  61. {
  62. if (!n.isGroup()) {
  63. return -1;
  64. } else if (n.isRoot()) {
  65. return 1;
  66. } else {
  67. return compareName(n);
  68. }
  69. } //}}}
  70. //{{{ +toString() : String
  71. public String toString() {
  72. return "VPTGroup [" + getName() + "]";
  73. } //}}}
  74. }