KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > websphere6 > dd > loaders > appext > WSAppExtToolBarMVElement


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.websphere6.dd.loaders.appext;
20
21 import java.io.IOException JavaDoc;
22 import org.netbeans.modules.j2ee.websphere6.dd.beans.WSAppExt;
23 import org.netbeans.modules.j2ee.websphere6.dd.loaders.WSMultiViewDataObject;
24 import org.netbeans.modules.xml.multiview.*;
25 import org.netbeans.modules.xml.multiview.ui.*;
26 import org.openide.nodes.*;
27 import org.openide.util.RequestProcessor;
28 import org.netbeans.modules.xml.multiview.Error;
29 /**
30  *
31  * @author dlipin
32  */

33 public class WSAppExtToolBarMVElement extends ToolBarMultiViewElement implements java.beans.PropertyChangeListener JavaDoc{
34     private ToolBarDesignEditor comp;
35     private SectionView view;
36     private WSAppExtDataObject dObj;
37     private PanelFactory factory;
38     private RequestProcessor.Task repaintingTask;
39     private boolean needInit=true;
40     private static final long serialVersionUID = 76737428339792L;
41     
42      private static final String JavaDoc APPEXT_MV_ID = WSMultiViewDataObject.MULTIVIEW_APPEXT +
43             WSMultiViewDataObject.DD_MULTIVIEW_POSTFIX;
44     
45     public WSAppExtToolBarMVElement(WSAppExtDataObject dObj) {
46         super(dObj);
47         this.dObj=dObj;
48         comp = new ToolBarDesignEditor();
49         factory=new PanelFactory(comp,dObj);
50         setVisualEditor(comp);
51         repaintingTask = RequestProcessor.getDefault().create(new Runnable JavaDoc() {
52             public void run() {
53                 javax.swing.SwingUtilities.invokeLater(new Runnable JavaDoc() {
54                     public void run() {
55                         repaintView();
56                     }
57                 });
58             }
59         });
60     }
61     
62     private void repaintView() {
63         view =new WSAppExtView(dObj);
64         comp.setContentView(view);
65         Object JavaDoc lastActive = comp.getLastActive();
66         if (lastActive!=null) {
67             ((SectionView)view).openPanel(lastActive);
68         } else {
69            
70         }
71         view.checkValidity();
72         
73     }
74     
75     
76     
77     public SectionView getSectionView() {
78         return view;
79     }
80     public WSAppExtView getAppExtView() {
81         return (WSAppExtView)view;
82     }
83     
84     public void componentShowing() {
85         super.componentShowing();
86         if (needInit) {
87             repaintView();
88             needInit=false;
89         }
90         //view=new WSAppExtView(dObj);
91
comp.setContentView(view);
92         try {
93             ((SectionView)view).openPanel(dObj.getAppExt());
94         } catch(java.io.IOException JavaDoc e) {
95         }
96         view.checkValidity();
97     }
98     
99     public void componentOpened() {
100         super.componentOpened();
101         try {
102             dObj.getAppExt().addPropertyChangeListener(this);
103         } catch(IOException JavaDoc ex) {
104             ex=null;
105         }
106     }
107     
108     public void componentClosed() {
109         super.componentClosed();
110         try {
111             dObj.getAppExt().removePropertyChangeListener(this);
112         } catch(IOException JavaDoc ex) {
113             ex=null;
114         }
115     }
116     public void propertyChange(java.beans.PropertyChangeEvent JavaDoc evt) {
117         if (!dObj.isChangedFromUI()) {
118             String JavaDoc name = evt.getPropertyName();
119             if ( name.indexOf("ApplicationExt")>0 ) { //NOI18
120
// repaint view if the wiew is active and something is changed with filters
121
if (APPEXT_MV_ID.equals(dObj.getSelectedPerspective().preferredID())) {
122                     repaintingTask.schedule(100);
123                 } else {
124                     needInit=true;
125                 }
126             }
127         }
128     }
129     
130     private class WSAppExtView extends SectionView {
131         
132         private WSAppExt appext;
133         
134         WSAppExtView(WSAppExtDataObject dObj) {
135             super(factory);
136             
137             Children rootChildren = new Children.Array();
138             Node root = new AbstractNode(rootChildren);
139             try {
140                 this.appext=dObj.getAppExt();
141                 rootChildren.add(new Node[]{
142                     createAppExtAttrNode()
143                 });
144             } catch (java.io.IOException JavaDoc ex) {
145                 System.out.println("ex="+ex);
146                 root.setDisplayName("Invalid AppExt");
147             } finally {
148                 setRoot(root);
149             }
150             
151         }
152         
153         
154         
155         private Node createAppExtAttrNode() {
156             Node appextNode = new WSAppExtNode(dObj);
157             // add panels
158
addSection(new SectionPanel(this,appextNode,appext));
159             return appextNode;
160         }
161     }
162    
163     
164     public Error JavaDoc validateView() {
165         return null;
166     }
167     
168     
169     public static class WSAppExtNode extends org.openide.nodes.AbstractNode {
170         WSAppExtNode(WSAppExtDataObject appext) {
171             super(org.openide.nodes.Children.LEAF);
172             setDisplayName("Application Extension Deployment Information");
173             
174         }
175     }
176     
177 }
178
Popular Tags