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;
020:
021: import org.netbeans.modules.bpel.nodes.BpelNode;
022: import org.netbeans.modules.bpel.model.api.PatternedCorrelation;
023: import org.netbeans.modules.bpel.model.api.events.ChangeEvent;
024: import org.netbeans.modules.bpel.model.api.support.Initiate;
025: import org.netbeans.modules.bpel.model.api.support.Pattern;
026: import org.netbeans.modules.bpel.properties.Constants;
027: import org.netbeans.modules.bpel.editors.api.nodes.NodeType;
028: import org.netbeans.modules.bpel.model.api.BaseCorrelation;
029: import org.netbeans.modules.bpel.model.api.BpelEntity;
030: import org.netbeans.modules.bpel.model.api.events.PropertyRemoveEvent;
031: import org.netbeans.modules.bpel.properties.props.PropertyUtils;
032: import org.openide.nodes.Sheet;
033: import static org.netbeans.modules.bpel.properties.PropertyType.*;
034: import org.netbeans.modules.soa.ui.SoaUiUtil;
035: import org.openide.util.Lookup;
036:
037: /**
038: *
039: * @author nk160297
040: */
041: public class CorrelationPNode extends BpelNode<PatternedCorrelation> {
042:
043: public CorrelationPNode(PatternedCorrelation correlation,
044: Lookup lookup) {
045: super (correlation, lookup);
046: }
047:
048: public NodeType getNodeType() {
049: return NodeType.CORRELATION_P;
050: }
051:
052: protected Sheet createSheet() {
053: Sheet sheet = super .createSheet();
054:
055: if (getReference() == null) {
056: return sheet;
057: }
058: //
059: Sheet.Set mainPropertySet = getPropertySet(sheet,
060: Constants.PropertiesGroups.MAIN_SET);
061: //
062: getReference().getInitiate();
063: PropertyUtils.registerAttributeProperty(this , mainPropertySet,
064: BaseCorrelation.SET, CORRELATION_SET, "getSet", null,
065: null); // NOI18N
066: //
067: PropertyUtils.registerAttributeProperty(this , mainPropertySet,
068: BaseCorrelation.INITIATE, CORRELATION_INITIATE,
069: "getInitiate", "setInitiate", "removeInitiate"); // NOI18N
070: //
071: PropertyUtils.registerAttributeProperty(this , mainPropertySet,
072: PatternedCorrelation.PATTERN, CORRELATION_PATTERN,
073: "getPattern", "setPattern", "removePattern"); // NOI18N
074: //
075: PropertyUtils.registerProperty(this , mainPropertySet,
076: DOCUMENTATION, "getDocumentation", "setDocumentation",
077: "removeDocumentation"); // NOI18N
078: //
079: return sheet;
080: }
081:
082: protected String getImplHtmlDisplayName() {
083: String nodeName = null;
084: PatternedCorrelation ref = getReference();
085: if (ref == null) {
086: return super .getImplHtmlDisplayName();
087: }
088: Initiate initiate = ref.getInitiate();
089: nodeName = initiate == null
090: || initiate.equals(Initiate.INVALID) ? ""
091: : " initiate=" + initiate.toString(); // NOI18N
092:
093: Pattern pattern = ref.getPattern();
094: nodeName += pattern == null || pattern.isInvalid() ? ""
095: : " pattern=" + pattern.toString(); // NOI18N
096:
097: String baseName = getName();
098: baseName = baseName == null || baseName.length() < 1 ? ref
099: .getSet() != null ? ref.getSet().getRefString() : super
100: .getImplHtmlDisplayName() : baseName;
101: return SoaUiUtil.getGrayString(baseName,
102: nodeName == null ? getDisplayName() : nodeName);
103: }
104:
105: protected void updateComplexProperties(ChangeEvent event) {
106: if (event instanceof PropertyRemoveEvent) {
107: BpelEntity parentEvent = event.getParent();
108: if (parentEvent.equals(this .getReference())) {
109: String propName = event.getName();
110: if (PatternedCorrelation.PATTERN.equals(propName)) {
111: updateName();
112: }
113: }
114: }
115: }
116: }
|