1 19 20 25 package org.netbeans.modules.j2ee.dd.impl.common; 26 27 import org.netbeans.modules.schema2beans.BaseBean; 28 import org.netbeans.modules.schema2beans.Version; 29 import org.netbeans.modules.j2ee.dd.api.ejb.EjbJar; 30 import org.netbeans.modules.j2ee.dd.api.common.IconInterface; 31 import org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException; 32 import org.netbeans.modules.j2ee.dd.api.common.DisplayNameInterface; 33 34 public abstract class ComponentBeanSingle extends DescriptionBeanSingle implements DisplayNameInterface, IconInterface { 35 36 public ComponentBeanSingle(java.util.Vector comps, Version version) { 37 super(comps, version); 38 } 39 40 public org.netbeans.modules.j2ee.dd.api.common.Icon getIcon(){return null;} 42 public void setIcon(org.netbeans.modules.j2ee.dd.api.common.Icon icon){} 43 public abstract String getDisplayName(); 44 public abstract void setDisplayName(String displayName); 45 46 47 public void setDisplayName(String locale, String displayName) throws VersionNotSupportedException { 48 if (locale==null) setDisplayName(displayName); 49 else throw new VersionNotSupportedException("2.0"); } 51 52 public void setAllDisplayNames(java.util.Map displayNames) throws VersionNotSupportedException { 53 throw new VersionNotSupportedException("2.0"); } 55 56 public String getDisplayName(String locale) throws VersionNotSupportedException { 57 if (locale==null) return getDisplayName(); 58 else throw new VersionNotSupportedException("2.0"); } 60 public String getDefaultDisplayName() { 61 return getDisplayName(); 62 } 63 public java.util.Map getAllDisplayNames() { 64 java.util.Map map = new java.util.HashMap (); 65 map.put(null, getDisplayName()); 66 return map; 67 } 68 69 public void removeDisplayNameForLocale(String locale) throws VersionNotSupportedException { 70 if (locale==null) setDisplayName(null); 71 else throw new VersionNotSupportedException("2.0"); } 73 public void removeDisplayName() { 74 setDisplayName(null); 75 } 76 public void removeAllDisplayNames() { 77 setDisplayName(null); 78 } 79 80 public void setSmallIcon(String locale, String icon) throws VersionNotSupportedException { 82 if (locale==null) setSmallIcon(icon); 83 else throw new VersionNotSupportedException("2.0"); } 85 public void setSmallIcon(String icon) { 86 setIcon(icon, true); 87 } 88 public void setLargeIcon(String locale, String icon) throws VersionNotSupportedException { 89 if (locale==null) setLargeIcon(icon); 90 else throw new VersionNotSupportedException("2.0"); } 92 public void setLargeIcon(String icon) { 93 setIcon(icon, false); 94 } 95 public void setAllIcons(String [] locales, String [] smallIcons, String [] largeIcons) throws VersionNotSupportedException { 96 throw new VersionNotSupportedException("2.0"); } 98 public String getSmallIcon(String locale) throws VersionNotSupportedException { 100 if (locale==null) return getSmallIcon(); 101 else throw new VersionNotSupportedException("2.0"); } 103 public String getSmallIcon() { 104 org.netbeans.modules.j2ee.dd.api.common.Icon icon = getIcon(); 105 if (icon==null) return null; 106 else return icon.getSmallIcon(); 107 } 108 public String getLargeIcon(String locale) throws VersionNotSupportedException { 109 if (locale==null) return getLargeIcon(); 110 else throw new VersionNotSupportedException("2.0"); } 112 public String getLargeIcon() { 113 org.netbeans.modules.j2ee.dd.api.common.Icon icon = getIcon(); 114 if (icon==null) return null; 115 else return icon.getLargeIcon(); 116 } 117 public org.netbeans.modules.j2ee.dd.api.common.Icon getDefaultIcon() { 118 return getIcon(); 119 } 120 public java.util.Map getAllIcons() { 121 java.util.Map map = new java.util.HashMap (); 122 org.netbeans.modules.j2ee.dd.api.common.Icon icon = getIcon(); 123 if (icon!=null) { 124 String [] icons = new String []{icon.getSmallIcon(),icon.getLargeIcon()}; 125 map.put(null, icons); 126 } 127 return map; 128 } 129 public void removeSmallIcon(String locale) throws VersionNotSupportedException { 131 if (locale==null) removeSmallIcon(); 132 else throw new VersionNotSupportedException("2.0"); } 134 public void removeLargeIcon(String locale) throws VersionNotSupportedException { 135 if (locale==null) removeLargeIcon(); 136 else throw new VersionNotSupportedException("2.0"); } 138 public void removeIcon(String locale) throws VersionNotSupportedException { 139 if (locale==null) removeIcon(); 140 else throw new VersionNotSupportedException("2.0"); } 142 public void removeSmallIcon() { 143 org.netbeans.modules.j2ee.dd.api.common.Icon icon = getIcon(); 144 if (icon!=null) { 145 icon.setSmallIcon(null); 146 if (icon.getLargeIcon()==null) setIcon(null); 147 } 148 } 149 public void removeLargeIcon() { 150 org.netbeans.modules.j2ee.dd.api.common.Icon icon = getIcon(); 151 if (icon!=null) { 152 icon.setLargeIcon(null); 153 if (icon.getSmallIcon()==null) setIcon(null); 154 } 155 } 156 public void removeIcon() { 157 setIcon(null); 158 } 159 public void removeAllIcons() { 160 setIcon(null); 161 } 162 private void setIcon(String icon, boolean isSmall) { 164 org.netbeans.modules.j2ee.dd.api.common.Icon oldIcon = getIcon(); 165 if (oldIcon==null) { 166 if (icon!=null) { 167 try { 168 org.netbeans.modules.j2ee.dd.api.common.Icon newIcon = (org.netbeans.modules.j2ee.dd.api.common.Icon) createBean("Icon"); 169 if (isSmall) newIcon.setSmallIcon(icon); 170 else newIcon.setLargeIcon(icon); 171 setIcon(newIcon); 172 } catch(ClassNotFoundException ex){} 173 } 174 } else { 175 if (icon==null) { 176 if (isSmall) { 177 oldIcon.setSmallIcon(null); 178 if (oldIcon.getLargeIcon()==null) setIcon(null); 179 } else { 180 oldIcon.setLargeIcon(null); 181 if (oldIcon.getSmallIcon()==null) setIcon(null); 182 } 183 } else { 184 if (isSmall) oldIcon.setSmallIcon(icon); 185 else oldIcon.setLargeIcon(icon); 186 } 187 } 188 } 189 } 190 | Popular Tags |