KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.netbeans.modules.j2ee.ddloaders.multiview;
20
21 import org.netbeans.modules.j2ee.dd.api.common.Icon;
22 import org.netbeans.modules.j2ee.dd.api.ejb.Ejb;
23 import org.netbeans.modules.j2ee.ddloaders.multiview.ui.EjbDetailForm;
24 import org.netbeans.modules.xml.multiview.ItemEditorHelper;
25 import org.netbeans.modules.xml.multiview.XmlMultiViewDataSynchronizer;
26 import org.netbeans.modules.xml.multiview.ui.SectionNodeView;
27
28 import java.awt.event.ActionEvent JavaDoc;
29 import java.awt.event.ActionListener JavaDoc;
30
31 /**
32  * @author pfiala
33  */

34 public class BeanDetailsPanel extends EjbDetailForm {
35
36     private final Ejb ejb;
37     private EjbJarMultiViewDataObject dataObject;
38
39     private class LargeIconEditorModel extends TextItemEditorModel {
40
41         public LargeIconEditorModel(XmlMultiViewDataSynchronizer synchronizer) {
42             super(synchronizer, true, true);
43         }
44
45         protected String JavaDoc getValue() {
46             return ejb.getLargeIcon();
47         }
48
49         protected void setValue(String JavaDoc value) {
50             ejb.setLargeIcon(value);
51         }
52     }
53
54     private class SmallIconEditorModel extends TextItemEditorModel {
55
56         public SmallIconEditorModel(XmlMultiViewDataSynchronizer synchronizer) {
57             super(synchronizer, true, true);
58         }
59
60         protected String JavaDoc getValue() {
61             return ejb.getSmallIcon();
62         }
63
64         protected void setValue(String JavaDoc value) {
65             ejb.setSmallIcon(value);
66         }
67     }
68
69     private class DescriptionEditorModel extends TextItemEditorModel {
70
71         public DescriptionEditorModel(XmlMultiViewDataSynchronizer synchronizer) {
72             super(synchronizer, true, true);
73         }
74
75         protected String JavaDoc getValue() {
76             return ejb.getDefaultDescription();
77         }
78
79         protected void setValue(String JavaDoc value) {
80             ejb.setDescription(value);
81         }
82     }
83
84     private class DisplayNameEditorModel extends TextItemEditorModel {
85
86         public DisplayNameEditorModel(XmlMultiViewDataSynchronizer synchronizer) {
87             super(synchronizer, true, true);
88         }
89
90         protected String JavaDoc getValue() {
91             return ejb.getDefaultDisplayName();
92         }
93
94         protected void setValue(String JavaDoc value) {
95             ejb.setDisplayName(value);
96         }
97     }
98
99     public BeanDetailsPanel(SectionNodeView sectionNodeView, final Ejb ejb) {
100         super(sectionNodeView);
101         this.dataObject = (EjbJarMultiViewDataObject) sectionNodeView.getDataObject();
102         XmlMultiViewDataSynchronizer synchronizer = dataObject.getModelSynchronizer();
103         this.ejb = ejb;
104         addRefreshable(new ItemEditorHelper(getDisplayNameTextField(), new DisplayNameEditorModel(synchronizer)));
105         addRefreshable(new ItemEditorHelper(getDescriptionTextArea(), new DescriptionEditorModel(synchronizer)));
106         addRefreshable(new ItemEditorHelper(getSmallIconTextField(), new SmallIconEditorModel(synchronizer)));
107         addRefreshable(new ItemEditorHelper(getLargeIconTextField(), new LargeIconEditorModel(synchronizer)));
108         getBrowseLargeIconButton().addActionListener(new ActionListener JavaDoc() {
109             public void actionPerformed(ActionEvent JavaDoc e) {
110                 String JavaDoc relativePath = Utils.browseIcon(dataObject);
111                 if (relativePath != null) {
112                     getLargeIconTextField().setText(relativePath);
113                 }
114             }
115         });
116         getBrowseSmallIconButton().addActionListener(new ActionListener JavaDoc() {
117             public void actionPerformed(ActionEvent JavaDoc e) {
118                 String JavaDoc relativePath = Utils.browseIcon(dataObject);
119                 if (relativePath != null) {
120                     getSmallIconTextField().setText(relativePath);
121                 }
122             }
123         });
124     }
125
126     public void dataModelPropertyChange(Object JavaDoc source, String JavaDoc propertyName, Object JavaDoc oldValue, Object JavaDoc newValue) {
127         if(source == ejb || source instanceof Icon) {
128             scheduleRefreshView();
129         }
130     }
131 }
132
Popular Tags