001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019:
020: package org.netbeans.modules.bpel.nodes.children;
021:
022: import java.util.ArrayList;
023: import java.util.Arrays;
024: import java.util.Collection;
025: import java.util.Collections;
026: import org.netbeans.modules.bpel.editors.api.nodes.NodeType;
027: import org.netbeans.modules.bpel.model.api.BpelEntity;
028: import org.netbeans.modules.bpel.model.api.Import;
029: import org.netbeans.modules.bpel.model.api.PartnerLink;
030: import org.netbeans.modules.bpel.model.api.PartnerLinkContainer;
031: import org.netbeans.modules.bpel.model.api.Process;
032: import org.netbeans.modules.bpel.nodes.navigator.NavigatorNodeFactory;
033: import org.netbeans.modules.bpel.nodes.navigator.NoneSchemaNodeFilter;
034: import org.netbeans.modules.soa.ui.ExtendedLookup;
035: import org.openide.nodes.Node;
036: import org.openide.util.Lookup;
037:
038: /**
039: *
040: * @author Vitaly Bychkov
041: * @version 18 January 2006
042: */
043: public class ProcessChildren extends
044: org.netbeans.modules.bpel.nodes.navigator.BaseScopeChildren {
045:
046: public ProcessChildren(Process process, Lookup contextLookup) {
047: super (process, new ExtendedLookup(contextLookup,
048: new NoneSchemaNodeFilter()));
049: }
050:
051: public Collection getNodeKeys() {
052: assert getReference() instanceof Process;
053: Process process = (Process) getReference();
054: if (process == null) {
055: return Collections.EMPTY_LIST;
056: }
057:
058: ArrayList<Object> processChilds = new ArrayList<Object>();
059: Collection baseNodes = super .getNodeKeys();
060:
061: if (baseNodes != null) {
062: processChilds.addAll(baseNodes);
063: }
064:
065: //set PartnerLink nodes
066: PartnerLinkContainer plCont = process.getPartnerLinkContainer();
067: if (plCont != null) {
068: PartnerLink[] pls = plCont.getPartnerLinks();
069: if (pls != null && pls.length > 0) {
070: processChilds.addAll(Arrays.asList(pls));
071: }
072: }
073:
074: // set import container node
075: processChilds.add(Import.class);
076:
077: return processChilds;
078: }
079:
080: protected Node[] createNodes(Object object) {
081: if (object == null) {
082: return new Node[0];
083: }
084: Node[] childNodes = super .createNodes(object);
085: if (childNodes != null && childNodes.length > 0) {
086: return childNodes;
087: }
088:
089: Node childNode = null;
090:
091: // create variable container node
092: if (object == Import.class) {
093: // childNode = NavigatorTreesNodeFactory.getInstance().createNode(
094: childNode = NavigatorNodeFactory.getInstance().createNode(
095: NodeType.IMPORT_CONTAINER, getReference(),
096: getLookup());
097: } else if (object instanceof BpelEntity) {
098: childNode = NavigatorNodeFactory.getInstance().createNode(
099: (BpelEntity) object, getLookup());
100: }
101:
102: return childNode == null ? new Node[0]
103: : new Node[] { childNode };
104: }
105:
106: }
|