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