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.model.impl;
021:
022: import java.util.List;
023:
024: import org.netbeans.modules.bpel.model.api.BpelEntity;
025: import org.netbeans.modules.bpel.model.api.CompositeActivity;
026: import org.netbeans.modules.bpel.model.api.ExtendableActivity;
027: import org.w3c.dom.Element;
028:
029: /**
030: * @author ads
031: */
032: public abstract class CompositeActivityImpl extends ActivityImpl
033: implements CompositeActivity {
034:
035: CompositeActivityImpl(BpelModelImpl model, Element e) {
036: super (model, e);
037: }
038:
039: CompositeActivityImpl(BpelBuilderImpl builder, String tagName) {
040: super (builder, tagName);
041: }
042:
043: /*
044: * (non-Javadoc)
045: *
046: * @see org.netbeans.modules.soa.model.bpel.api.CompositeActivity#getActivities()
047: */
048: public ExtendableActivity[] getActivities() {
049: readLock();
050: try {
051: List<ExtendableActivity> list = getChildren(ExtendableActivity.class);
052: return list.toArray(new ExtendableActivity[list.size()]);
053: } finally {
054: readUnlock();
055: }
056: }
057:
058: /*
059: * (non-Javadoc)
060: *
061: * @see org.netbeans.modules.soa.model.bpel.api.CompositeActivity#getActivity(int)
062: */
063: public ExtendableActivity getActivity(int i) {
064: return getChild(ExtendableActivity.class, i);
065: }
066:
067: /* (non-Javadoc)
068: * @see org.netbeans.modules.soa.model.bpel20.api.CompositeActivity#setActivity(org.netbeans.modules.soa.model.bpel20.api.ExtendableActivity, int)
069: */
070: public void setActivity(ExtendableActivity activity, int i) {
071: setChildAtIndex(activity, ExtendableActivity.class, i);
072:
073: }
074:
075: /*
076: * (non-Javadoc)
077: *
078: * @see org.netbeans.modules.soa.model.bpel.api.CompositeActivity#removeActivity(int)
079: */
080: public void removeActivity(int i) {
081: removeChild(ExtendableActivity.class, i);
082: }
083:
084: public void insertActivity(ExtendableActivity activity, int i) {
085: insertAtIndex(activity, ExtendableActivity.class, i);
086: }
087:
088: /*
089: * (non-Javadoc)
090: *
091: * @see org.netbeans.modules.soa.model.bpel.api.CompositeActivity#addActivity(org.netbeans.modules.soa.model.bpel.api.Activity)
092: */
093: public void addActivity(ExtendableActivity activity) {
094: addChildBefore(activity, ExtendableActivity.class);
095: }
096:
097: /*
098: * (non-Javadoc)
099: *
100: * @see org.netbeans.modules.soa.model.bpel.api.CompositeActivity#sizeOfActivities()
101: */
102: public int sizeOfActivities() {
103: readLock();
104: try {
105: return getChildren(ExtendableActivity.class).size();
106: } finally {
107: readUnlock();
108: }
109: }
110:
111: public void setActivtities(ExtendableActivity[] activities) {
112: setArrayBefore(activities, ExtendableActivity.class);
113: }
114:
115: /*
116: * (non-Javadoc)
117: *
118: * @see org.netbeans.modules.soa.model.bpel.xdm.impl.BpelContainerImpl#create(org.w3c.dom.Element)
119: */
120: @Override
121: protected BpelEntity create(Element element) {
122: BpelEntity component = Utils.createActivityGroup(this
123: .getModel(), element);
124: if (component == null) {
125: return super .create(element);
126: }
127: return component;
128: }
129:
130: /* (non-Javadoc)
131: * @see org.netbeans.modules.soa.model.bpel20.impl.BpelContainerImpl#getChildType(T)
132: */
133: @Override
134: protected <T extends BpelEntity> Class<? extends BpelEntity> getChildType(
135: T entity) {
136: if (entity instanceof ExtendableActivity) {
137: return ExtendableActivity.class;
138: }
139: return super.getChildType(entity);
140: }
141:
142: }
|