001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: /*
043: * WSDesignViewNavigatorContent.java
044: *
045: * Created on April 9, 2007, 5:31 PM
046: *
047: * To change this template, choose Tools | Template Manager
048: * and open the template in the editor.
049: */
050:
051: package org.netbeans.modules.websvc.design.navigator;
052:
053: import java.awt.BorderLayout;
054: import java.beans.PropertyChangeEvent;
055: import java.beans.PropertyChangeListener;
056: import java.util.ArrayList;
057: import java.util.List;
058: import javax.swing.JPanel;
059: import org.netbeans.modules.websvc.design.javamodel.MethodModel;
060: import org.netbeans.modules.websvc.design.javamodel.ServiceModel;
061: import org.openide.explorer.ExplorerManager;
062: import org.openide.explorer.view.BeanTreeView;
063: import org.openide.explorer.view.TreeView;
064: import org.openide.loaders.DataObject;
065: import org.openide.nodes.AbstractNode;
066: import org.openide.nodes.Children;
067: import org.openide.nodes.Node;
068: import org.openide.util.NbBundle;
069:
070: /**
071: *
072: * @author rico
073: */
074: public class WSDesignViewNavigatorContent extends JPanel implements
075: ExplorerManager.Provider, PropertyChangeListener {
076:
077: /** Explorer manager for the tree view. */
078: private ExplorerManager explorerManager;
079: /** Our schema component node tree view. */
080: private TreeView treeView;
081:
082: /** Creates a new instance of WSDesignViewNavigatorContent */
083: public WSDesignViewNavigatorContent() {
084: setLayout(new BorderLayout());
085: explorerManager = new ExplorerManager();
086: treeView = new BeanTreeView();
087: explorerManager.addPropertyChangeListener(this );
088: }
089:
090: public void propertyChange(PropertyChangeEvent arg0) {
091:
092: }
093:
094: public ExplorerManager getExplorerManager() {
095: return explorerManager;
096: }
097:
098: public void navigate(DataObject implClass) {
099: add(treeView, BorderLayout.CENTER);
100: AbstractNode root = new AbstractNode(new WSChildren(implClass));
101: root.setName(NbBundle.getMessage(
102: WSDesignViewNavigatorContent.class, "LBL_Operations"));
103: getExplorerManager().setRootContext(root);
104: revalidate();
105: repaint();
106: }
107:
108: public class WSChildren extends Children.Keys<MethodModel> {
109: DataObject implClass;
110:
111: public WSChildren(DataObject implClass) {
112: this .implClass = implClass;
113: }
114:
115: protected Node[] createNodes(MethodModel key) {
116: AbstractNode n = new AbstractNode(Children.LEAF);
117: n.setName(key.getOperationName());
118: return new Node[] { n };
119: }
120:
121: @Override
122: protected void addNotify() {
123: updateKeys();
124: }
125:
126: private void updateKeys() {
127: List<MethodModel> keys = new ArrayList<MethodModel>();
128: if (implClass != null) {
129: ServiceModel model = ServiceModel
130: .getServiceModel(implClass.getPrimaryFile());
131: keys = model.getOperations();
132: }
133: this.setKeys(keys);
134: }
135:
136: }
137:
138: }
|