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: package org.netbeans.modules.bpel.nodes.refactoring;
020:
021: import org.netbeans.modules.bpel.editors.api.nodes.NodeType;
022: import org.netbeans.modules.bpel.model.api.BpelEntity;
023: import org.netbeans.modules.bpel.nodes.navigator.NavigatorNodeFactory;
024: import org.netbeans.modules.bpel.properties.PropertyNodeFactory;
025: import org.netbeans.modules.xml.wsdl.model.extensions.bpel.BPELExtensibilityComponent;
026: import org.netbeans.modules.xml.wsdl.model.extensions.bpel.CorrelationProperty;
027: import org.netbeans.modules.xml.wsdl.model.extensions.bpel.PartnerLinkType;
028: import org.netbeans.modules.xml.wsdl.model.extensions.bpel.PropertyAlias;
029: import org.netbeans.modules.xml.wsdl.model.extensions.bpel.Query;
030: import org.netbeans.modules.xml.wsdl.model.extensions.bpel.Role;
031: import org.openide.nodes.Children;
032: import org.openide.nodes.Node;
033: import org.openide.util.Lookup;
034:
035: /**
036: *
037: * @author Vitaly Bychkov
038: * @version 1.0
039: *
040: */
041: public abstract class RefactoringNodeCreatorAbstract implements
042: RefactoringNodeCreator {
043:
044: public RefactoringNodeCreatorAbstract() {
045: }
046:
047: protected Node getInternalNode(UsageNodeType nodeType,
048: Object reference) {
049: if (!isSupported(nodeType)) {
050: return null;
051: }
052:
053: PropertyNodeFactory propertyNodeFactory = PropertyNodeFactory
054: .getInstance();
055: Node node = null;
056: NodeType bpelNodeType = null;
057: if (reference instanceof BPELExtensibilityComponent) {
058: bpelNodeType = getBpelExtensionElementNodeType((BPELExtensibilityComponent) reference);
059: } else if (reference instanceof BpelEntity) {
060: bpelNodeType = org.netbeans.modules.bpel.editors.api.utils.Util
061: .getBasicNodeType((BpelEntity) reference);
062: if (bpelNodeType == NodeType.VARIABLE_CONTAINER
063: || bpelNodeType == NodeType.VARIABLE_CONTAINER
064: || bpelNodeType == NodeType.CORRELATION_SET_CONTAINER
065: || bpelNodeType == NodeType.MESSAGE_EXCHANGE_CONTAINER) {
066: reference = ((BpelEntity) reference).getParent();
067: }
068:
069: if (bpelNodeType == null
070: || bpelNodeType == NodeType.UNKNOWN_TYPE) {
071: bpelNodeType = NodeType.DEFAULT_BPEL_ENTITY_NODE;
072: }
073: }
074: //
075: // if (! (reference instanceof BpelEntity)) {
076: // if (reference instanceof BPELExtensibilityComponent) {
077: // NodeType bpelExtNodeType =
078: // getBpelExtensionElementNodeType((BPELExtensibilityComponent)reference);
079: // if (bpelExtNodeType != null) {
080: // node = propertyNodeFactory.createNode(
081: // bpelExtNodeType,reference,null,
082: // Children.LEAF, Lookup.getDefault());
083: // }
084: // }
085: //
086: // return node;
087: // }
088: //
089: // org.netbeans.modules.bpel.design.nodes.NodeType bpelNodeType =
090: // NavigatorNodeFactory.getBasicNodeType((BpelEntity) reference);
091:
092: if (bpelNodeType != null) {
093:
094: node = propertyNodeFactory.createNode(bpelNodeType,
095: reference, Children.LEAF, Lookup.getDefault());
096: // if (bpelNodeType == org.netbeans.modules.bpel.design.nodes
097: // .NodeType.UNKNOWN_TYPE)
098: // {
099: // node = propertyNodeFactory.createNode(
100: // bpelNodeType,reference,null,
101: // Children.LEAF, Lookup.getDefault());
102: // } else {
103: // node = propertyNodeFactory.createNode(
104: // bpelNodeType,reference,null,
105: // Children.LEAF, Lookup.getDefault());
106: // }
107: }
108: return node;
109: }
110:
111: private NodeType getBpelExtensionElementNodeType(
112: BPELExtensibilityComponent component) {
113: if (component instanceof PropertyAlias) {
114: return NodeType.CORRELATION_PROPERTY_ALIAS;
115: }
116:
117: if (component instanceof PartnerLinkType) {
118: return NodeType.PARTNER_LINK_TYPE;
119: }
120:
121: if (component instanceof CorrelationProperty) {
122: return NodeType.CORRELATION_PROPERTY;
123: }
124:
125: if (component instanceof Role) {
126: return NodeType.PARTNER_ROLE;
127: }
128:
129: if (component instanceof Query) {
130: return NodeType.QUERY;
131: }
132:
133: return NodeType.UNKNOWN_TYPE;
134: }
135: }
|