KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > j2seplatform > platformdefinition > J2SEPlatformNode


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 NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.java.j2seplatform.platformdefinition;
20
21 import java.text.MessageFormat JavaDoc;
22 import org.openide.nodes.AbstractNode;
23 import org.openide.nodes.Children;
24 import org.openide.loaders.DataObject;
25 import org.openide.util.NbBundle;
26 import org.openide.util.lookup.Lookups;
27
28 class J2SEPlatformNode extends AbstractNode {
29
30     private J2SEPlatformImpl platform;
31     private String JavaDoc toolTip;
32     private boolean broken;
33
34     public J2SEPlatformNode (J2SEPlatformImpl platform, DataObject definition) {
35         super (Children.LEAF, Lookups.fixed(new Object JavaDoc[] {platform, definition}));
36         this.platform = platform;
37         super.setIconBase ("org/netbeans/modules/java/j2seplatform/resources/platform");
38     }
39
40     public String JavaDoc getDisplayName () {
41         return this.platform.getDisplayName();
42     }
43
44     public String JavaDoc getHtmlDisplayName() {
45         if (isBroken()) {
46             return "<font color=\"#A40000\">"+this.platform.getDisplayName()+"</font>";
47         }
48         else {
49             return null;
50         }
51     }
52
53     public String JavaDoc getName () {
54         return this.getDisplayName();
55     }
56
57     public void setName (String JavaDoc name) {
58         this.platform.setDisplayName (name);
59     }
60
61     public void setDisplayName(String JavaDoc name) {
62         this.setName (name);
63     }
64     
65     public synchronized String JavaDoc getShortDescription() {
66         if (this.toolTip == null) {
67             this.toolTip = MessageFormat.format (
68             NbBundle.getMessage(J2SEPlatformNode.class,"TXT_J2SEPlatformToolTip"),
69             new Object JavaDoc[] {
70                 this.platform.getSpecification().getVersion()
71             });
72         }
73         return this.toolTip;
74     }
75
76     public boolean hasCustomizer () {
77         return true;
78     }
79
80     public java.awt.Component JavaDoc getCustomizer () {
81         if (isBroken()) {
82             return new BrokenPlatformCustomizer (this.platform);
83         }
84         else {
85             return new J2SEPlatformCustomizer (this.platform);
86         }
87     }
88
89     private boolean isBroken () {
90         if (this.platform.getInstallFolders().size()==0) {
91             return true;
92         }
93         for (int i=0; i<PlatformConvertor.IMPORTANT_TOOLS.length; i++) {
94             if (this.platform.findTool(PlatformConvertor.IMPORTANT_TOOLS[i]) == null) {
95                 return true;
96             }
97         }
98         return false;
99     }
100
101 }
102
Popular Tags