1 19 20 package org.netbeans.modules.j2ee.ddloaders.multiview; 21 22 import org.netbeans.modules.j2ee.dd.api.ejb.CmpField; 23 import org.netbeans.modules.j2ee.ejbcore.api.methodcontroller.EntityMethodController; 24 import org.openide.DialogDisplayer; 25 import org.openide.NotifyDescriptor; 26 import org.openide.util.NbBundle; 27 28 import java.io.IOException ; 29 import java.util.List ; 30 import java.util.Iterator ; 31 32 35 public class CmpFieldHelper { 36 37 private EntityHelper entityHelper; 38 private CmpField field; 39 public static final String PROPERTY_FIELD_ROW_CHANGED = "FIELD_ROW_CHANGED"; 41 public CmpFieldHelper(EntityHelper entityHelper, CmpField field) { 42 this.entityHelper = entityHelper; 43 this.field = field; 44 } 45 46 51 56 60 64 122 private void modelUpdatedFromUI() { 123 entityHelper.modelUpdatedFromUI(); 124 } 125 126 132 164 public void setLocalGetter(boolean create) { 165 entityHelper.updateFieldAccessor(getFieldName(), true, true, create); 166 } 167 168 public void setLocalSetter(boolean create) { 169 entityHelper.updateFieldAccessor(getFieldName(), false, true, create); 170 } 171 172 public void setRemoteGetter(boolean create) { 173 entityHelper.updateFieldAccessor(getFieldName(), true, false, create); 174 } 175 176 public void setRemoteSetter(boolean create) { 177 entityHelper.updateFieldAccessor(getFieldName(), false, false, create); 178 } 179 180 public boolean deleteCmpField() { 181 String message = NbBundle.getMessage(CmpFieldHelper.class, "MSG_ConfirmDeleteField", field.getFieldName()); 182 String title = NbBundle.getMessage(CmpFieldHelper.class, "MSG_ConfirmDeleteFieldTitle"); 183 NotifyDescriptor desc = new NotifyDescriptor.Confirmation(message, title, NotifyDescriptor.YES_NO_OPTION); 184 if (NotifyDescriptor.YES_OPTION.equals(DialogDisplayer.getDefault().notify(desc))) { 185 EntityMethodController entityMethodController = entityHelper.getEntityMethodController(); 186 try { 187 entityMethodController.deleteField(field, entityHelper.ejbJarFile); 188 modelUpdatedFromUI(); 189 return true; 190 } catch (IOException e) { 191 Utils.notifyError(e); 192 } 193 } 194 return false; 195 } 196 197 198 204 public void setFieldName(String newName) { 205 } 253 254 262 272 public void setDescription(String s) { 273 field.setDescription(s); 274 modelUpdatedFromUI(); 275 } 276 277 public String getDefaultDescription() { 278 return field.getDefaultDescription(); 279 } 280 281 public String getFieldName() { 282 return field.getFieldName(); 283 } 284 285 public boolean isPrimary() { 286 return getFieldName().equals(entityHelper.getPrimkeyField()); 287 } 288 289 public boolean edit() { 290 return false; 326 } 327 328 335 } 336 | Popular Tags |