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.xslt.project.nodes;
020:
021: import java.awt.Image;
022: import javax.xml.namespace.QName;
023: import org.netbeans.modules.xslt.project.XsltproConstants;
024: import org.netbeans.modules.xslt.tmap.model.xsltmap.TransformationDesc;
025: import org.netbeans.modules.xslt.tmap.model.xsltmap.TransformationDescType;
026: import org.openide.nodes.AbstractNode;
027: import org.openide.nodes.Children;
028: import org.openide.util.Lookup;
029: import org.openide.util.NbBundle;
030: import org.openide.util.Utilities;
031:
032: /**
033: *
034: * @author Vitaly Bychkov
035: * @version 1.0
036: */
037: public class TransformationDescNode extends AbstractNode {
038: private TransformationDesc tDesc;
039: private static String INPUT_ICON = "org/netbeans/modules/xslt/project/resources/inputTransformationDesc.png"; // NOI18N
040: private static String OUTPUT_ICON = "org/netbeans/modules/xslt/project/resources/outputTransformationDesc.png"; // NOI18N
041: private static final String DOT = "."; // NOI18N
042: private static final String EMPTY_STRING = "";// NOI18N
043:
044: public TransformationDescNode(TransformationDesc tDesc) {
045: super (Children.LEAF);
046: this .tDesc = tDesc;
047: // set nodeDescription property which is shown in property sheet help region
048: setValue("nodeDescription", "");
049: }
050:
051: public TransformationDescNode(Lookup lookup) {
052: super (Children.LEAF, lookup);
053: }
054:
055: public String getDisplayName() {
056: return getName();
057: }
058:
059: public String getName() {
060: String roleName = tDesc.getRoleName();
061: String fileName = tDesc.getFile();
062: fileName = fileName == null ? " [empty file name] " : fileName;
063: roleName = roleName == null ? "" : roleName;
064:
065: QName portTypeQname = QName.valueOf(tDesc.getPortType());
066: String portType = portTypeQname == null ? null : portTypeQname
067: .getLocalPart();
068:
069: portType = portType == null ? EMPTY_STRING : portType;
070:
071: String operation = tDesc.getOperation();
072: operation = operation == null ? EMPTY_STRING : DOT + operation;
073:
074: return portType + operation;
075: }
076:
077: public String getHtmlDisplayName() {
078: String name = getName();
079: QName messageTypeQname = QName.valueOf(tDesc.getMessageType());
080: String messageType = messageTypeQname == null ? null
081: : messageTypeQname.getLocalPart();
082:
083: messageType = messageType == null ? null
084: : XsltproConstants.WHITESPACE
085: + NbBundle.getMessage(
086: TransformationDescNode.class,
087: "LBL_TRANSFORM_DESC_MESSAGE", // NOI18N
088: messageType);
089:
090: return org.netbeans.modules.xslt.tmap.util.Util.getGrayString(
091: name, messageType);
092: }
093:
094: public String getShortDescription() {
095: String roleName = tDesc.getRoleName();
096: String fileName = tDesc.getFile();
097: fileName = fileName == null ? " [empty file name] " : fileName;
098: roleName = roleName == null ? "" : roleName;
099: return "<html> <b>role</b> = " + roleName
100: + "<br> <b>file</b> =" + fileName + "</html>";
101:
102: }
103:
104: public Image getIcon(int type) {
105: // TODO m
106: return Utilities.loadImage(TransformationDescType.OUTPUT
107: .equals(tDesc.getType()) ? OUTPUT_ICON : INPUT_ICON);
108: }
109:
110: public Image getOpenedIcon(int type) {
111: return getIcon(type);
112: }
113:
114: public boolean canCopy() {
115: return false;
116: }
117:
118: public boolean canCut() {
119: return false;
120: }
121:
122: public boolean canDestroy() {
123: return false;
124: }
125:
126: public boolean canRename() {
127: return false;
128: }
129:
130: }
|