01: /*
02: * The contents of this file are subject to the terms of the Common Development
03: * and Distribution License (the License). You may not use this file except in
04: * compliance with the License.
05: *
06: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
07: * or http://www.netbeans.org/cddl.txt.
08: *
09: * 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-2007 Sun
17: * Microsystems, Inc. All Rights Reserved.
18: */
19:
20: package org.netbeans.modules.bpel.mapper.tree.models;
21:
22: import java.util.Arrays;
23: import java.util.Collections;
24: import java.util.List;
25: import org.netbeans.modules.bpel.mapper.tree.spi.MapperTreeModel;
26: import org.netbeans.modules.bpel.mapper.tree.spi.RestartableIterator;
27: import org.netbeans.modules.bpel.mapper.tree.spi.TreeItemInfoProvider;
28: import org.netbeans.modules.bpel.model.api.ForEach;
29: import org.openide.util.NbBundle;
30:
31: /**
32: * The implementation of the MapperTreeModel for target tree for
33: * the FroEach element.
34: *
35: * @author nk160297
36: */
37: public class ForEachConditionsTreeModel implements
38: MapperTreeModel<Object> {
39:
40: public static final String START_VALUE = NbBundle.getMessage(
41: ForEachConditionsTreeModel.class, "START_VALUE"); // NOI18N
42: public static final String FINAL_VALUE = NbBundle.getMessage(
43: ForEachConditionsTreeModel.class, "FINAL_VALUE"); // NOI18N
44: public static final String COMPLETION_CONDITION = NbBundle
45: .getMessage(ForEachConditionsTreeModel.class,
46: "COMPLETION_CONDITION"); // NOI18N
47:
48: private ForEach mContextEntity;
49:
50: public ForEachConditionsTreeModel(ForEach contextEntity) {
51: mContextEntity = contextEntity;
52: }
53:
54: public Object getRoot() {
55: return MapperTreeModel.TREE_ROOT;
56: }
57:
58: // TODO load names from resoureces
59: public List getChildren(
60: RestartableIterator<Object> dataObjectPathItr) {
61: Object parent = dataObjectPathItr.next();
62: if (parent == TREE_ROOT) {
63: return Collections.singletonList(mContextEntity);
64: }
65: if (parent instanceof ForEach) {
66: return Arrays.asList(START_VALUE, FINAL_VALUE,
67: COMPLETION_CONDITION);
68: }
69: //
70: return null;
71: }
72:
73: public Boolean isLeaf(Object node) {
74: if (node == START_VALUE || node == FINAL_VALUE
75: || node == COMPLETION_CONDITION) {
76: return true;
77: } else {
78: return false;
79: }
80: }
81:
82: public Boolean isConnectable(Object node) {
83: return isLeaf(node);
84: }
85:
86: public List getExtensionModelList() {
87: return null;
88: }
89:
90: public TreeItemInfoProvider getTreeItemInfoProvider() {
91: return SimpleTreeInfoProvider.getInstance();
92: }
93:
94: }
|