1 19 20 package org.netbeans.modules.j2ee.ejbcore.ui.logicalview.entres; 21 22 import java.awt.BorderLayout ; 23 import java.awt.Color ; 24 import java.awt.event.KeyAdapter ; 25 import java.awt.event.KeyEvent ; 26 import java.beans.PropertyChangeEvent ; 27 import java.beans.PropertyChangeListener ; 28 import java.io.IOException ; 29 import java.util.HashSet ; 30 import java.util.Set ; 31 import javax.lang.model.element.TypeElement; 32 import javax.swing.UIManager ; 33 import javax.swing.border.EtchedBorder ; 34 import javax.swing.event.DocumentEvent ; 35 import javax.swing.event.DocumentListener ; 36 import org.netbeans.api.java.project.JavaProjectConstants; 37 import org.netbeans.api.java.source.CompilationController; 38 import org.netbeans.api.java.source.ElementHandle; 39 import org.netbeans.api.java.source.JavaSource; 40 import org.netbeans.api.project.FileOwnerQuery; 41 import org.netbeans.api.project.Project; 42 import org.netbeans.api.project.ant.AntArtifactQuery; 43 import org.netbeans.modules.j2ee.api.ejbjar.EjbReference; 44 import org.netbeans.modules.j2ee.common.source.AbstractTask; 45 import org.netbeans.modules.j2ee.dd.api.common.EjbLocalRef; 46 import org.netbeans.modules.j2ee.dd.api.common.EjbRef; 47 import org.netbeans.modules.j2ee.dd.api.ejb.DDProvider; 48 import org.netbeans.modules.j2ee.dd.api.ejb.Ejb; 49 import org.netbeans.modules.j2ee.dd.api.ejb.EjbJar; 50 import org.netbeans.modules.j2ee.dd.api.ejb.EnterpriseBeans; 51 import org.netbeans.modules.j2ee.ejbcore.Utils; 52 import org.netbeans.modules.j2ee.ejbcore._RetoucheUtil; 53 import org.openide.ErrorManager; 54 import org.openide.filesystems.FileObject; 55 import org.openide.loaders.DataObject; 56 import org.openide.nodes.Node; 57 import org.openide.nodes.NodeAcceptor; 58 import org.openide.util.NbBundle; 59 60 61 66 public class CallEjbPanel extends javax.swing.JPanel { 67 68 public static final String IS_VALID = "CallEjbPanel_isValid"; 70 private final Set <String > refNameSet; 71 private final NodeDisplayPanel nodeDisplayPanel; 72 private final ServiceLocatorStrategyPanel slPanel; 73 private final NodeAcceptor nodeAcceptor; 74 private final Project project; 75 private final String className; 76 private final FileObject srcFile; 77 78 79 public CallEjbPanel(FileObject fileObject, Node rootNode, String lastLocator, String className) throws IOException { 80 initComponents(); 81 this.srcFile= fileObject; 82 this.project = FileOwnerQuery.getOwner(srcFile); 83 this.className = className; 84 this.nodeAcceptor = new NodeAcceptorImpl(); 85 this.refNameSet = new HashSet <String >(); 86 87 org.netbeans.modules.j2ee.api.ejbjar.EjbJar ejbModule = org.netbeans.modules.j2ee.api.ejbjar.EjbJar.getEjbJar(srcFile); 89 if (ejbModule != null) { 90 EjbJar ejbJar = null; 91 try { 92 ejbJar = DDProvider.getDefault().getMergedDDRoot(ejbModule.getMetadataUnit()); 93 } catch (IOException e) { 94 ErrorManager.getDefault().notify(e); 95 } 96 if (ejbJar != null) { 97 final EnterpriseBeans enterpriseBeans = ejbJar.getEnterpriseBeans(); 98 JavaSource javaSource = JavaSource.forFileObject(srcFile); 99 if (enterpriseBeans != null && javaSource != null) { 100 javaSource.runUserActionTask(new AbstractTask<CompilationController>() { 101 public void run(CompilationController controller) throws IOException { 102 controller.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED); 103 TypeElement beanClass = controller.getElements().getTypeElement(CallEjbPanel.this.className); 104 for (Ejb ejb : enterpriseBeans.getEjbs()) { 105 if (beanClass.getQualifiedName().contentEquals(ejb.getEjbClass())) { 106 EjbRef[] ejbRefs = ejb.getEjbRef(); 107 EjbLocalRef[] ejbLocalRefs = ejb.getEjbLocalRef(); 108 for (int j = 0; j < ejbRefs.length; j++) { 109 refNameSet.add(ejbRefs[j].getEjbRefName()); 110 } 111 for (int j = 0; j < ejbLocalRefs.length; j++) { 112 refNameSet.add(ejbLocalRefs[j].getEjbRefName()); 113 } 114 return; 115 } 116 } 117 } 118 }, true); 119 } 120 } 121 } 122 setErrorFieldColor(true); 123 nodeDisplayPanel = new NodeDisplayPanel(rootNode); 124 nodeDisplayPanel.setBorder(new EtchedBorder ()); 125 displayPanel.add(nodeDisplayPanel); 126 nodeDisplayPanel.addPropertyChangeListener(new PropertyChangeListener () { 127 public void propertyChange(PropertyChangeEvent pce) { 128 Node[] nodes = nodeDisplayPanel.getSelectedNodes(); 129 if (nodes.length == 0) { 130 return; 131 } 132 EjbReference ejbReference = (EjbReference) nodes[0].getCookie(EjbReference.class); 133 if (ejbReference != null) { 134 try { 135 generateName(ejbReference, remoteRadioButton.isSelected(), nodes[0]); 136 } catch (IOException ioe) { 137 ErrorManager.getDefault().notify(ioe); 138 } 139 } 140 validateReferences(); 141 } 142 }); 143 referenceNameTextField.addKeyListener(new KeyAdapter () { 144 public void keyReleased(KeyEvent keyEvent) { 145 validateReferences(); 146 } 147 }); 148 149 slPanel = new ServiceLocatorStrategyPanel(lastLocator); 150 slPanel.getUnreferencedServiceLocator().addItemListener(new java.awt.event.ItemListener () { 151 public void itemStateChanged(java.awt.event.ItemEvent evt) { 152 validateReferences(); 153 } 154 }); 155 slPanel.getClassName().getDocument().addDocumentListener(new DocumentListener () { 156 public void insertUpdate(DocumentEvent documentEvent) { 157 validateReferences(); 158 } 159 public void removeUpdate(DocumentEvent documentEvent) { 160 validateReferences(); 161 } 162 public void changedUpdate(DocumentEvent documentEvent) { 163 validateReferences(); 164 } 165 }); 166 serviceLocatorPanel.add(slPanel, BorderLayout.CENTER); 167 validateReferences(); 168 } 169 170 public void disableServiceLocator() { 171 serviceLocatorPanel.setVisible(false); 172 } 173 174 private void setErrorFieldColor(boolean error){ 175 if (error){ 176 Color color = UIManager.getColor("nb.errorForeground"); errorField.setForeground(color == null ? new Color (89, 79, 191) : color); 178 } else { 179 Color color = UIManager.getColor("nb.warningForeground"); errorField.setForeground(color == null ? Color.DARK_GRAY : color); 181 } 182 } 183 184 private void setErrorMessage(String message) { 185 setErrorFieldColor(true); 186 setMessage(message); 187 } 188 189 private void setWarningMessage(String message){ 190 setErrorFieldColor(false); 191 setMessage(message); 192 } 193 194 private void setMessage(String message){ 195 String messageCopy = (message == null ? " " : message); 196 errorField.setText(messageCopy); 197 errorField.setToolTipText(messageCopy); 198 errorField.setCaretPosition(0); 199 } 200 201 public void validateReferences() { 202 boolean nodeAccepted = nodeAcceptor.acceptNodes(nodeDisplayPanel.getSelectedNodes()); 203 if ((slPanel.getUnreferencedServiceLocator().isSelected() && 204 slPanel.getClassName().getText().trim().equals("")) || 205 !nodeAccepted) { 206 firePropertyChange(IS_VALID, true, false); 207 } else { 208 firePropertyChange(IS_VALID, false, true); 209 } 210 } 211 212 217 private void initComponents() { 219 java.awt.GridBagConstraints gridBagConstraints; 220 javax.swing.JLabel jLabel1; 221 222 intefaceButtonGroup = new javax.swing.ButtonGroup (); 223 serviceLocatorPanel = new javax.swing.JPanel (); 224 convertToRuntime = new javax.swing.JCheckBox (); 225 displayPanel = new javax.swing.JPanel (); 226 jLabel1 = new javax.swing.JLabel (); 227 errorField = new javax.swing.JTextField (); 228 jLabel2 = new javax.swing.JLabel (); 229 jLabel3 = new javax.swing.JLabel (); 230 referenceNameTextField = new javax.swing.JTextField (); 231 localRadioButton = new javax.swing.JRadioButton (); 232 remoteRadioButton = new javax.swing.JRadioButton (); 233 234 setLayout(new java.awt.GridBagLayout ()); 235 236 getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entres/Bundle").getString("ACS_CallEJBPanel")); 237 getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entres/Bundle").getString("ACS_CallEJBPanel")); 238 serviceLocatorPanel.setLayout(new java.awt.BorderLayout ()); 239 240 convertToRuntime.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entres/Bundle").getString("LBL_ConvertToRuntimeMneumonic").charAt(0)); 241 convertToRuntime.setSelected(true); 242 convertToRuntime.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entres/Bundle").getString("LBL_ConvertToRuntime")); 243 serviceLocatorPanel.add(convertToRuntime, java.awt.BorderLayout.SOUTH); 244 convertToRuntime.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CallEjbPanel.class, "ACSD_ConvertToRuntime")); 245 246 gridBagConstraints = new java.awt.GridBagConstraints (); 247 gridBagConstraints.gridx = 0; 248 gridBagConstraints.gridy = 2; 249 gridBagConstraints.gridwidth = 3; 250 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 251 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 252 gridBagConstraints.weightx = 1.0; 253 gridBagConstraints.insets = new java.awt.Insets (0, 5, 5, 5); 254 add(serviceLocatorPanel, gridBagConstraints); 255 256 displayPanel.setLayout(new java.awt.BorderLayout ()); 257 258 gridBagConstraints = new java.awt.GridBagConstraints (); 259 gridBagConstraints.gridx = 0; 260 gridBagConstraints.gridy = 1; 261 gridBagConstraints.gridwidth = 3; 262 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 263 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 264 gridBagConstraints.weightx = 1.0; 265 gridBagConstraints.weighty = 1.0; 266 gridBagConstraints.insets = new java.awt.Insets (5, 5, 5, 5); 267 add(displayPanel, gridBagConstraints); 268 displayPanel.getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entres/Bundle").getString("LBL_DisplayPanel")); 269 displayPanel.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entres/Bundle").getString("ACSD_DisplayPanel")); 270 271 jLabel1.setLabelFor(displayPanel); 272 jLabel1.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entres/Bundle").getString("LBL_ModuleMustBeInSameApplication")); 273 gridBagConstraints = new java.awt.GridBagConstraints (); 274 gridBagConstraints.gridx = 0; 275 gridBagConstraints.gridy = 0; 276 gridBagConstraints.gridwidth = 3; 277 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 278 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 279 gridBagConstraints.insets = new java.awt.Insets (5, 5, 0, 5); 280 add(jLabel1, gridBagConstraints); 281 282 errorField.setBackground(getBackground()); 283 errorField.setEditable(false); 284 errorField.setBorder(null); 285 gridBagConstraints = new java.awt.GridBagConstraints (); 286 gridBagConstraints.gridx = 0; 287 gridBagConstraints.gridy = 5; 288 gridBagConstraints.gridwidth = 3; 289 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 290 gridBagConstraints.weightx = 1.0; 291 gridBagConstraints.insets = new java.awt.Insets (0, 5, 5, 5); 292 add(errorField, gridBagConstraints); 293 errorField.getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entres/Bundle").getString("ACS_ErrorField")); 294 errorField.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entres/Bundle").getString("ACS_ErrorField")); 295 296 jLabel2.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entres/Bundle").getString("MN_ReferenceName").charAt(0)); 297 jLabel2.setLabelFor(referenceNameTextField); 298 jLabel2.setText(org.openide.util.NbBundle.getMessage(CallEjbPanel.class, "LBL_ReferenceName")); 299 gridBagConstraints = new java.awt.GridBagConstraints (); 300 gridBagConstraints.gridx = 0; 301 gridBagConstraints.gridy = 3; 302 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 303 gridBagConstraints.insets = new java.awt.Insets (0, 5, 5, 5); 304 add(jLabel2, gridBagConstraints); 305 306 jLabel3.setText(org.openide.util.NbBundle.getMessage(CallEjbPanel.class, "LBL_ReferencedInterface")); 307 gridBagConstraints = new java.awt.GridBagConstraints (); 308 gridBagConstraints.gridx = 0; 309 gridBagConstraints.gridy = 4; 310 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 311 gridBagConstraints.insets = new java.awt.Insets (0, 5, 5, 5); 312 add(jLabel3, gridBagConstraints); 313 314 gridBagConstraints = new java.awt.GridBagConstraints (); 315 gridBagConstraints.gridx = 1; 316 gridBagConstraints.gridy = 3; 317 gridBagConstraints.gridwidth = 2; 318 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 319 gridBagConstraints.insets = new java.awt.Insets (0, 5, 5, 5); 320 add(referenceNameTextField, gridBagConstraints); 321 referenceNameTextField.getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entres/Bundle").getString("LBL_ReferenceName")); 322 referenceNameTextField.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entres/Bundle").getString("LBL_ReferenceName")); 323 324 intefaceButtonGroup.add(localRadioButton); 325 localRadioButton.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entres/Bundle").getString("MN_Local").charAt(0)); 326 localRadioButton.setSelected(true); 327 localRadioButton.setText(org.openide.util.NbBundle.getMessage(CallEjbPanel.class, "LBL_Local")); 328 gridBagConstraints = new java.awt.GridBagConstraints (); 329 gridBagConstraints.gridx = 1; 330 gridBagConstraints.gridy = 4; 331 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 332 gridBagConstraints.insets = new java.awt.Insets (0, 5, 5, 5); 333 add(localRadioButton, gridBagConstraints); 334 localRadioButton.getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entres/Bundle").getString("LBL_Local")); 335 localRadioButton.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entres/Bundle").getString("LBL_Local")); 336 337 intefaceButtonGroup.add(remoteRadioButton); 338 remoteRadioButton.setMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entres/Bundle").getString("MN_Remote").charAt(0)); 339 remoteRadioButton.setText(org.openide.util.NbBundle.getMessage(CallEjbPanel.class, "LBL_Remote")); 340 remoteRadioButton.addItemListener(new java.awt.event.ItemListener () { 341 public void itemStateChanged(java.awt.event.ItemEvent evt) { 342 remoteRadioButtonItemStateChanged(evt); 343 } 344 }); 345 346 gridBagConstraints = new java.awt.GridBagConstraints (); 347 gridBagConstraints.gridx = 2; 348 gridBagConstraints.gridy = 4; 349 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 350 gridBagConstraints.weightx = 1.0; 351 gridBagConstraints.insets = new java.awt.Insets (0, 0, 5, 5); 352 add(remoteRadioButton, gridBagConstraints); 353 remoteRadioButton.getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entres/Bundle").getString("LBL_Remote")); 354 remoteRadioButton.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entres/Bundle").getString("LBL_Remote")); 355 356 } 358 private void remoteRadioButtonItemStateChanged(java.awt.event.ItemEvent evt) { validateReferences(); 360 } 362 363 private javax.swing.JCheckBox convertToRuntime; 365 private javax.swing.JPanel displayPanel; 366 private javax.swing.JTextField errorField; 367 private javax.swing.ButtonGroup intefaceButtonGroup; 368 private javax.swing.JLabel jLabel2; 369 private javax.swing.JLabel jLabel3; 370 private javax.swing.JRadioButton localRadioButton; 371 private javax.swing.JTextField referenceNameTextField; 372 private javax.swing.JRadioButton remoteRadioButton; 373 private javax.swing.JPanel serviceLocatorPanel; 374 376 public boolean convertToRuntime() { 377 return convertToRuntime.isSelected(); 378 } 379 380 public Node getEjb() { 381 Node[] selectedNodes = nodeDisplayPanel.getSelectedNodes(); 382 return selectedNodes.length > 0 ? selectedNodes[0] : null; 383 } 384 385 public String getServiceLocator() { 386 return slPanel.classSelected(); 387 } 388 389 public String getReferenceName() { 390 return referenceNameTextField.getText(); 391 } 392 393 public boolean isRemoteInterfaceSelected() { 394 return remoteRadioButton.isSelected(); 395 } 396 397 private void generateName(EjbReference ejbReference, boolean remote, Node selectedNode) throws IOException { 398 if (ejbReference.getClientJarTarget() == null) { 399 referenceNameTextField.setText(""); 400 return; 401 } 402 String name = ""; 403 if (remote) { 404 boolean targetIsJavaSE = Utils.isTargetJavaSE(srcFile, className); 405 if (targetIsJavaSE && Utils.isJavaEE5orHigher(project)){ 406 ElementHandle<TypeElement> elementHandle = _RetoucheUtil.getJavaClassFromNode(selectedNode); 407 name = elementHandle.getQualifiedName(); 408 } else if (targetIsJavaSE){ 409 name = ejbReference.createRef().getHome(); 410 } else { 411 name = ejbReference.createRef().getEjbRefName(); 412 } 413 } else { 414 name = ejbReference.createLocalRef().getEjbRefName(); 415 } 416 int uniquifier = 1; 417 String newName = name; 418 while (refNameSet.contains(newName)) { 419 newName = name + String.valueOf(uniquifier++); 420 } 421 referenceNameTextField.setText(name); 422 } 423 424 private class NodeAcceptorImpl implements NodeAcceptor { 425 426 public NodeAcceptorImpl() {} 427 428 public boolean acceptNodes(Node[] nodes) { 429 setErrorMessage(" "); 431 if (nodes.length == 0) { 433 setErrorMessage(NbBundle.getMessage(CallEjbPanel.class, "LBL_SelectOneEJB")); return false; 435 } 436 if (nodes.length > 1) { 438 setErrorMessage(NbBundle.getMessage(CallEjbPanel.class, "LBL_MoreEJBsSelected")); return false; 440 } 441 ElementHandle<TypeElement> elementHandle = null; 442 try { 443 elementHandle = _RetoucheUtil.getJavaClassFromNode(nodes[0]); 444 } catch (IOException ioe) { 445 ErrorManager.getDefault().notify(ioe); 446 } 447 if (elementHandle == null) { 449 setErrorMessage(NbBundle.getMessage(CallEjbPanel.class, "LBL_NodeIsNotEJB")); return false; 451 } 452 453 if (elementHandle.getQualifiedName().equals(className)) { 454 setErrorMessage(NbBundle.getMessage(CallEjbPanel.class, "LBL_CannotCallItself", className)); return false; 456 } 457 458 if (!hasJarArtifact()) { 460 setErrorMessage(NbBundle.getMessage(CallEjbPanel.class, "LBL_EJBNotInDistributionArchive")); return false; 462 } 463 if (nodes[0].getCookie(EjbReference.class) == null) { 465 setErrorMessage(NbBundle.getMessage(CallEjbPanel.class, "LBL_ReferencesNotSupported")); return false; 467 } 468 if (!acceptInterfaces(nodes)) { 470 return false; 471 } 472 if (!validateRefName()) { 474 return false; 475 } 476 477 DataObject dataObject = (DataObject) nodes[0].getCookie(DataObject.class); 479 if (dataObject == null) { 480 setErrorMessage(NbBundle.getMessage(CallEjbPanel.class, "LBL_NoSourcesForBean")); return false; 482 } 483 Project nodeProject = FileOwnerQuery.getOwner(dataObject.getPrimaryFile()); 484 if (!isRemoteInterfaceSelected() && 485 !nodeProject.equals(project) && 486 !Utils.areInSameJ2EEApp(project, nodeProject)) { 487 setErrorMessage(NbBundle.getMessage(CallEjbPanel.class, "LBL_NotInSameEarOrProject")); return false; 489 } 490 491 if (!isRemoteInterfaceSelected() && 493 Utils.isAppClient(project)) { 494 setErrorMessage(NbBundle.getMessage(CallEjbPanel.class, "LBL_CannotCallLocalInAC")); return false; 496 } 497 498 try { 500 if (!isRemoteInterfaceSelected() && Utils.isTargetJavaSE(srcFile, className)) { 501 setErrorMessage(NbBundle.getMessage(CallEjbPanel.class, "LBL_CannotCallLocalInJSE")); return false; 503 } 504 } catch (IOException ioe) { 505 ErrorManager.getDefault().notify(ioe); 506 return false; 507 } 508 509 if (!Utils.isJavaEE5orHigher(project) && Utils.isJavaEE5orHigher(nodeProject)){ 511 setWarningMessage(NbBundle.getMessage(CallEjbPanel.class, "LBL_JEESpecificationLevelsDiffer")); } 513 514 return true; 515 } 516 517 private boolean acceptInterfaces(Node[] nodes) { 518 EjbReference ejbReference = (EjbReference) nodes[0].getCookie(EjbReference.class); 519 if (ejbReference == null) { 520 return false; 521 } 522 523 boolean shouldEnableLocal = ejbReference.supportsLocalInvocation(); 524 boolean shouldEnableRemote = ejbReference.supportsRemoteInvocation(); 525 localRadioButton.setEnabled(shouldEnableLocal); 526 remoteRadioButton.setEnabled(shouldEnableRemote); 527 if (!shouldEnableLocal && !shouldEnableRemote) { 528 setErrorMessage(NbBundle.getMessage(CallEjbPanel.class, "LBL_ReferencesNotSupported")); return false; 530 } else if (shouldEnableLocal && !shouldEnableRemote) { 531 localRadioButton.setSelected(true); 532 } else if (!shouldEnableLocal && shouldEnableRemote) { 533 remoteRadioButton.setSelected(true); 534 } 535 setErrorMessage(" "); return true; 537 } 538 539 private boolean hasJarArtifact() { 540 Project nodeProject = FileOwnerQuery.getOwner(srcFile); 541 if (nodeProject.equals(project)) { 542 return true; 544 } 545 return AntArtifactQuery.findArtifactsByType(nodeProject, JavaProjectConstants.ARTIFACT_TYPE_JAR).length > 0; 546 } 547 548 private boolean validateRefName() { 549 String refName = referenceNameTextField.getText(); 550 if (refNameSet.contains(refName)) { 551 setErrorMessage(NbBundle.getMessage(CallEjbPanel.class, "ERR_ReferenceNameExists", refName)); return false; 553 } 554 return true; 555 } 556 } 557 558 } 559 | Popular Tags |