1 19 20 package org.netbeans.modules.j2ee.clientproject.ui; 21 22 import java.beans.PropertyChangeListener ; 23 import javax.swing.Icon ; 24 import org.netbeans.api.project.SourceGroup; 25 import org.openide.ErrorManager; 26 import org.openide.filesystems.FileObject; 27 import org.openide.filesystems.FileStateInvalidException; 28 import org.openide.filesystems.FileUtil; 29 30 36 final class LibrariesSourceGroup implements SourceGroup { 37 38 private final FileObject root; 39 private final String displayName; 40 private final Icon icon; 41 private final Icon openIcon; 42 43 48 LibrariesSourceGroup (FileObject root, String displayName ) { 49 this (root, displayName, null, null); 50 } 51 52 59 LibrariesSourceGroup (FileObject root, String displayName, Icon icon, Icon openIcon) { 60 assert root != null; 61 this.root = root; 62 this.displayName = displayName; 63 this.icon = icon; 64 this.openIcon = openIcon; 65 } 66 67 68 public FileObject getRootFolder() { 69 return this.root; 70 } 71 72 public String getName() { 73 try { 74 return root.getURL().toExternalForm(); 75 } catch (FileStateInvalidException fsi) { 76 ErrorManager.getDefault().notify (fsi); 77 return root.toString(); 78 } 79 } 80 81 public String getDisplayName() { 82 return this.displayName; 83 } 84 85 public Icon getIcon(boolean opened) { 86 return opened ? openIcon : icon; 87 } 88 89 public boolean contains(FileObject file) throws IllegalArgumentException { 90 return root.equals(file) || FileUtil.isParentOf(root,file); 91 } 92 93 public boolean equals (Object other) { 94 if (!(other instanceof LibrariesSourceGroup)) { 95 return false; 96 } 97 LibrariesSourceGroup osg = (LibrariesSourceGroup) other; 98 return displayName == null ? osg.displayName == null : displayName.equals (osg.displayName) && 99 root == null ? osg.root == null : root.equals (osg.root); 100 } 101 102 public int hashCode () { 103 return ((displayName == null ? 0 : displayName.hashCode())<<16) | ((root==null ? 0 : root.hashCode()) & 0xffff); 104 } 105 106 public void addPropertyChangeListener(PropertyChangeListener listener) { 107 } 109 110 public void removePropertyChangeListener(PropertyChangeListener listener) { 111 } 113 } 114 | Popular Tags |