1 19 20 package org.netbeans.modules.j2ee.common.method; 21 22 import java.util.Collection ; 23 import org.netbeans.modules.j2ee.common.method.impl.MethodCustomizerPanel; 24 import org.netbeans.modules.j2ee.common.method.impl.ValidatingPropertyChangeListener; 25 import org.openide.DialogDescriptor; 26 import org.openide.DialogDisplayer; 27 import org.openide.NotifyDescriptor; 28 29 33 public final class MethodCustomizer { 34 35 private final MethodCustomizerPanel panel; 36 private final String title; 37 private final String prefix; 38 private final Collection <MethodModel> existingMethods; 39 40 protected MethodCustomizer(String title, MethodModel methodModel, boolean hasLocal, boolean hasRemote, boolean selectLocal, boolean selectRemote, 42 boolean hasReturnType, String ejbql, boolean hasFinderCardinality, boolean hasExceptions, boolean hasInterfaces, 43 String prefix, Collection <MethodModel> existingMethods) { 44 this.panel = MethodCustomizerPanel.create(methodModel, hasLocal, hasRemote, selectLocal, selectRemote, 45 hasReturnType, ejbql, hasFinderCardinality, hasExceptions, hasInterfaces); 46 this.title = title; 47 this.prefix = prefix; 48 this.existingMethods = existingMethods; 49 } 50 51 58 public boolean customizeMethod() { 59 DialogDescriptor notifyDescriptor = new DialogDescriptor( 60 panel, title, true, 61 DialogDescriptor.OK_CANCEL_OPTION, 62 DialogDescriptor.PLAIN_MESSAGE, 63 null 64 ); 65 panel.addPropertyChangeListener(new ValidatingPropertyChangeListener(panel, notifyDescriptor)); 66 return DialogDisplayer.getDefault().notify(notifyDescriptor) == NotifyDescriptor.OK_OPTION; 67 } 68 69 public MethodModel getMethodModel() { 70 return MethodModel.create( 71 panel.getMethodName(), 72 panel.getReturnType(), 73 panel.getMethodBody(), 74 panel.getParameters(), 75 panel.getExceptions(), 76 panel.getModifiers() 77 ); 78 } 79 80 public boolean finderReturnIsSingle() { 81 return false; 82 } 83 84 public boolean publishToLocal() { 85 return panel.hasLocal(); 86 } 87 88 public boolean publishToRemote() { 89 return panel.hasRemote(); 90 } 91 92 public String getEjbQL() { 93 return null; 94 95 } 96 97 } 98 | Popular Tags |