1 19 package org.netbeans.modules.java.j2seplatform.platformdefinition; 20 21 import java.text.MessageFormat ; 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 toolTip; 32 private boolean broken; 33 34 public J2SEPlatformNode (J2SEPlatformImpl platform, DataObject definition) { 35 super (Children.LEAF, Lookups.fixed(new Object [] {platform, definition})); 36 this.platform = platform; 37 super.setIconBase ("org/netbeans/modules/java/j2seplatform/resources/platform"); 38 } 39 40 public String getDisplayName () { 41 return this.platform.getDisplayName(); 42 } 43 44 public String 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 getName () { 54 return this.getDisplayName(); 55 } 56 57 public void setName (String name) { 58 this.platform.setDisplayName (name); 59 } 60 61 public void setDisplayName(String name) { 62 this.setName (name); 63 } 64 65 public synchronized String getShortDescription() { 66 if (this.toolTip == null) { 67 this.toolTip = MessageFormat.format ( 68 NbBundle.getMessage(J2SEPlatformNode.class,"TXT_J2SEPlatformToolTip"), 69 new Object [] { 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 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 |