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.Collections;
23: import java.util.List;
24: import org.netbeans.modules.bpel.model.api.BpelEntity;
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.ConditionHolder;
29: import org.openide.util.NbBundle;
30:
31: /**
32: * The implementation of the MapperTreeModel for target tree for
33: * the following elements:
34: * -- If
35: * -- ElseIf
36: * -- While
37: * -- RepeatUntil
38: *
39: * The tree has very simple appearance. It has only one element.
40: *
41: * @author nk160297
42: */
43: public class ConditionValueTreeModel implements MapperTreeModel<Object> {
44:
45: public static final String BOOLEAN_CONDITION = NbBundle.getMessage(
46: ConditionValueTreeModel.class, "BOOLEAN_CONDITION"); // NOI18N
47:
48: private BpelEntity mContextEntity;
49:
50: public ConditionValueTreeModel(BpelEntity contextEntity) {
51: mContextEntity = contextEntity;
52: }
53:
54: public Object getRoot() {
55: return MapperTreeModel.TREE_ROOT;
56: }
57:
58: public List getChildren(
59: RestartableIterator<Object> dataObjectPathItr) {
60: Object parent = dataObjectPathItr.next();
61: if (parent == TREE_ROOT) {
62: return Collections.singletonList(mContextEntity);
63: }
64: if (parent instanceof ConditionHolder) {
65: return Collections.singletonList(BOOLEAN_CONDITION);
66: }
67: //
68: return null;
69: }
70:
71: public Boolean isLeaf(Object node) {
72: if (node == BOOLEAN_CONDITION) {
73: return true;
74: } else {
75: return false;
76: }
77: }
78:
79: public Boolean isConnectable(Object node) {
80: return isLeaf(node);
81: }
82:
83: public List getExtensionModelList() {
84: return null;
85: }
86:
87: public TreeItemInfoProvider getTreeItemInfoProvider() {
88: return SimpleTreeInfoProvider.getInstance();
89: }
90:
91: }
|