KickJava   Java API By Example, From Geeks To Geeks.

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


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.util.Collection JavaDoc;
23 import java.util.Iterator JavaDoc;
24 import org.netbeans.api.looks.*;
25 import org.netbeans.spi.looks.*;
26 import org.netbeans.api.mdr.*;
27 import org.openide.util.NbBundle;
28 import xmlmodel.TextNode;
29 /**
30  *
31  * @author Tomas Zezula
32  */

33 public class TextNodeLook extends ElementNodeLook {
34
35     private static final String JavaDoc ICON = "org/netbeans/modules/mdrxml/resources/textNode";
36
37
38     /** Creates a new instance of TextNodeLook */
39     public TextNodeLook() {
40         super(NbBundle.getMessage(TextNodeLook.class, "TXT_TextNodeLook"));
41     }
42     
43     /** Overrides NodeLook.getName to truncate the
44      * string, if its lengt is greater than 20 chars.
45      */

46     public String JavaDoc getName(Look.NodeSubstitute substitute) {
47         try {
48             String JavaDoc result = ((TextNode)substitute.getRepresentedObject()).getName();
49             if (result == null)
50                 result = ""; // NoI18N
51
if (result.length() > 20)
52                 result = result.substring(0,20)+ "...";
53             return result;
54         }catch (javax.jmi.reflect.InvalidObjectException ioe) {
55             return new String JavaDoc();
56         }
57     }
58     
59     public String JavaDoc iconBase(Look.NodeSubstitute substitute) {
60         return ICON;
61     }
62     
63 }
64
Popular Tags