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