KickJava   Java API By Example, From Geeks To Geeks.

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


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.xml.multiview.SectionNode;
22 import org.netbeans.modules.xml.multiview.ToolBarMultiViewElement;
23 import org.netbeans.modules.xml.multiview.ui.SectionNodeView;
24 import org.netbeans.modules.xml.multiview.ui.SectionView;
25 import org.netbeans.modules.xml.multiview.ui.ToolBarDesignEditor;
26
27 import java.beans.PropertyChangeEvent JavaDoc;
28 import java.beans.PropertyChangeListener JavaDoc;
29
30 /**
31  * @author pfiala
32  */

33 public abstract class EjbJarMultiviewElement extends ToolBarMultiViewElement {
34
35     private SectionView view;
36     protected ToolBarDesignEditor comp;
37     protected EjbJarMultiViewDataObject dataObject;
38
39     public EjbJarMultiviewElement(EjbJarMultiViewDataObject dataObject) {
40         super(dataObject);
41         this.dataObject = dataObject;
42         comp = new ToolBarDesignEditor();
43         setVisualEditor(comp);
44     }
45
46     public void componentShowing() {
47         if (view == null) {
48             view = createView();
49             if (view instanceof SectionNodeView) {
50                 dataObject.getEjbJar().addPropertyChangeListener(new PropertyChangeListener JavaDoc() {
51                     public void propertyChange(PropertyChangeEvent JavaDoc evt) {
52                         ((SectionNodeView) view).dataModelPropertyChange(evt.getSource(), evt.getPropertyName(),
53                                 evt.getOldValue(), evt.getNewValue());
54                     }
55                 });
56             }
57         }
58         comp.setContentView(view);
59         if (view instanceof SectionNodeView) {
60             ((SectionNodeView) view).refreshView();
61         }
62         view.checkValidity();
63         super.componentShowing();
64         Object JavaDoc lastActive = comp.getLastActive();
65         final SectionNode node;
66         final SectionNodeView sectionNodeView = ((SectionNodeView) view);
67         if (lastActive instanceof SectionNode) {
68             node = (SectionNode) lastActive;
69         } else {
70             node = sectionNodeView.getRootNode();
71         }
72         sectionNodeView.openPanel(node);
73         dataObject.checkParseable();
74     }
75
76     protected abstract SectionView createView();
77     
78     public SectionView getSectionView() {
79         return view;
80     }
81 }
82
Popular Tags