1 19 20 package org.netbeans.modules.apisupport.project.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 33 39 final class LibrariesSourceGroup implements SourceGroup { 40 41 private final FileObject root; 42 private final String displayName; 43 private final Icon icon; 44 private final Icon openIcon; 45 46 53 LibrariesSourceGroup(FileObject root, String displayName, Icon icon, Icon openIcon) { 54 assert root != null; 55 this.root = root; 56 this.displayName = displayName; 57 this.icon = icon; 58 this.openIcon = openIcon; 59 } 60 61 public FileObject getRootFolder() { 62 return this.root; 63 } 64 65 public String getName() { 66 try { 67 return root.getURL().toExternalForm(); 68 } catch (FileStateInvalidException fsi) { 69 ErrorManager.getDefault().notify(fsi); 70 return root.toString(); 71 } 72 } 73 74 public String getDisplayName() { 75 return this.displayName; 76 } 77 78 public Icon getIcon(boolean opened) { 79 return opened ? openIcon : icon; 80 } 81 82 public boolean contains(FileObject file) throws IllegalArgumentException { 83 return root.equals(file) || FileUtil.isParentOf(root,file); 84 } 85 86 public boolean equals(Object other) { 87 if (!(other instanceof LibrariesSourceGroup)) { 88 return false; 89 } 90 LibrariesSourceGroup osg = (LibrariesSourceGroup) other; 91 return displayName == null ? osg.displayName == null : displayName.equals(osg.displayName) && 92 root == null ? osg.root == null : root.equals(osg.root); 93 } 94 95 public int hashCode() { 96 return ((displayName == null ? 0 : displayName.hashCode())<<16) | ((root==null ? 0 : root.hashCode()) & 0xffff); 97 } 98 99 public void addPropertyChangeListener(PropertyChangeListener listener) { 100 } 102 103 public void removePropertyChangeListener(PropertyChangeListener listener) { 104 } 106 107 } 108 | Popular Tags |