KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > mdrxml > looks > AttributeNodeLook


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * 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 Forte for Java, Community Edition. The Initial
16  * Developer of the Original Software is Sun Microsystems, Inc. Portions
17  * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.mdrxml.looks;
21
22 import java.awt.datatransfer.Transferable JavaDoc;
23 import java.awt.datatransfer.StringSelection JavaDoc;
24 import java.io.IOException JavaDoc;
25 import org.openide.nodes.*;
26 import org.openide.util.NbBundle;
27 import org.netbeans.api.looks.*;
28 import org.netbeans.spi.looks.*;
29 import xmlmodel.AttributeNode;
30
31 /**
32  *
33  * @author Tomas Zezula
34  */

35 public class AttributeNodeLook extends NodeLook {
36
37     private static final String JavaDoc ICON = "org/netbeans/modules/mdrxml/resources/attributeNode";
38
39     private static class ValueProperty extends PropertySupport.ReadWrite {
40         
41         private AttributeNode node;
42         
43         public ValueProperty (AttributeNode node) {
44             super (NbBundle.getMessage(AttributeNodeLook.class,"TXT_Value"),String JavaDoc.class,NbBundle.getMessage(AttributeNodeLook.class,"TXT_Value"),NbBundle.getMessage(AttributeNodeLook.class,"TIP_Value"));
45             this.node = node;
46         }
47         
48         public Object JavaDoc getValue () {
49             if (this.node != null)
50                 return this.node.getValue();
51             else
52                 return null;
53         }
54         
55         public void setValue (Object JavaDoc value) {
56             if (value instanceof String JavaDoc && this.node != null)
57                 node.setValue ((String JavaDoc)value);
58         }
59     }
60     
61     /** Creates a new instance of AttributeNodeLook */
62     public AttributeNodeLook() {
63         super (NbBundle.getMessage (AttributeNodeLook.class, "TXT_AttributeNodeLook"));
64     }
65     
66     public String JavaDoc iconBase (Look.NodeSubstitute substitute) {
67         return ICON;
68     }
69     
70     public Node.PropertySet[] getPropertySets (Look.NodeSubstitute substitute) {
71         Node.PropertySet[] sets = super.getPropertySets (substitute);
72         ((Sheet.Set)sets[0]).put ( new ValueProperty ((AttributeNode)substitute.getRepresentedObject()));
73         return sets;
74     }
75     
76     public Transferable JavaDoc clipboardCopy (Look.NodeSubstitute substitute) throws IOException JavaDoc {
77         AttributeNode node = (AttributeNode) substitute.getRepresentedObject ();
78         String JavaDoc str = node.getName () + " = " + node.getValue (); //NOI18N
79
return new StringSelection JavaDoc (str);
80     }
81     
82 }
83
Popular Tags