KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ddloaders > multiview > SelectMethodsNode


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.j2ee.ddloaders.multiview;
21
22 import java.awt.event.FocusEvent JavaDoc;
23 import java.awt.event.FocusListener JavaDoc;
24 import org.netbeans.modules.xml.multiview.ui.SectionNodeInnerPanel;
25 import org.netbeans.modules.xml.multiview.ui.SectionNodeView;
26 import org.netbeans.modules.xml.multiview.SectionNode;
27 import org.netbeans.modules.j2ee.dd.api.ejb.Query;
28 import org.openide.util.NbBundle;
29
30 /**
31  * @author pfiala
32  */

33 public class SelectMethodsNode extends EjbSectionNode {
34     
35     private EntityHelper.Queries queries;
36     
37     SelectMethodsNode(SectionNodeView sectionNodeView, EntityHelper.Queries queries) {
38         super(sectionNodeView, true, queries, Utils.getBundleMessage("LBL_CmpSelects"), Utils.ICON_BASE_MISC_NODE);
39         this.queries = queries;
40     }
41     
42     protected SectionNodeInnerPanel createNodeInnerPanel() {
43         final SelectMethodsTableModel model = queries.getSelectMethodsTableModel();
44         final InnerTablePanel innerTablePanel = new InnerTablePanel(getSectionNodeView(), model) {
45
46             protected void editCell(final int row, final int column) {
47                 if (!model.editRow(row)){
48                     getSectionNodeView().getErrorPanel().setError(
49                             new org.netbeans.modules.xml.multiview.Error(org.netbeans.modules.xml.multiview.Error.TYPE_WARNING,
50                             NbBundle.getMessage(SelectMethodsNode.class, "TXT_MethodNotFound"), getTable()));
51                 }
52             }
53             
54             public void dataModelPropertyChange(Object JavaDoc source, String JavaDoc propertyName, Object JavaDoc oldValue, Object JavaDoc newValue) {
55                 super.dataModelPropertyChange(source, propertyName, oldValue, newValue);
56             }
57             
58             
59             public void focusData(Object JavaDoc element) {
60                 if (element instanceof Query) {
61                     final int row = queries.getSelectMethodRow((Query) element);
62                     if (row >= 0) {
63                         getTable().getSelectionModel().setSelectionInterval(row, row);
64                     }
65                 }
66                 
67             }
68         };
69         innerTablePanel.addFocusListener(new FocusListener JavaDoc() {
70             public void focusGained(FocusEvent JavaDoc e) {
71                 
72             }
73             public void focusLost(FocusEvent JavaDoc e) {
74                 innerTablePanel.getSectionView().getErrorPanel().clearError();
75             }
76         });
77         
78         return innerTablePanel;
79     }
80     
81     public SectionNode getNodeForElement(Object JavaDoc element) {
82         if (element instanceof Query) {
83             if (queries.getSelectMethodRow((Query) element) >= 0) {
84                 return this;
85             }
86         }
87         return super.getNodeForElement(element);
88     }
89     
90 }
91
Popular Tags