1 19 package org.openharmonise.him.metadata.swing; 20 21 import java.awt.*; 22 import java.awt.event.*; 23 24 import javax.swing.*; 25 26 import org.openharmonise.swing.*; 27 import org.openharmonise.vfs.gui.*; 28 import org.openharmonise.vfs.metadata.*; 29 30 35 public class HelpIcon extends JToggleButton implements ActionListener { 36 37 private Property m_prop = null; 38 private String m_sSummary = "No description available."; 39 private String m_sTitle = "Property Help"; 40 41 public HelpIcon(String sTitle, String sSummary) { 42 super(); 43 this.m_sSummary = sSummary; 44 if(sTitle.trim().equals("title")) { 45 this.m_sTitle = "Title"; 46 } else { 47 this.m_sTitle = sTitle; 48 } 49 this.setup(); 50 } 51 52 55 public HelpIcon(Property prop) { 56 super(); 57 this.m_prop = prop; 58 if(prop.getSummary()!=null && prop.getSummary().length()>0) { 59 this.m_sSummary = prop.getSummary(); 60 } 61 if(prop.getDisplayName()!=null && prop.getDisplayName().length()>0) { 62 if(prop.getDisplayName().trim().equals("title")) { 63 this.m_sTitle = "Title"; 64 } else { 65 this.m_sTitle = prop.getDisplayName(); 66 } 67 } else { 68 if(prop.getName().trim().equals("title")) { 69 this.m_sTitle = "Title"; 70 } else { 71 this.m_sTitle = prop.getName(); 72 } 73 } 74 this.setup(); 75 } 76 77 public String getSummary() { 78 return this.m_sSummary; 79 } 80 81 public String getTitle() { 82 return this.m_sTitle; 83 } 84 85 private void setup() { 86 87 this.setIcon(IconManager.getInstance().getIcon("16-command-help.gif")); 88 this.setPreferredSize( new Dimension(20,20) ); 89 this.setToolTipText(this.m_sSummary); 90 this.addActionListener(this); 91 this.setFocusable(false); 92 } 93 94 95 98 public JToolTip createToolTip() { 99 JMultiLineToolTip toolTip = new JMultiLineToolTip(); 100 toolTip.setFixedWidth(300); 101 return toolTip; 102 } 103 104 105 106 109 private HelpIcon(String arg0) { 110 super(arg0); 111 } 112 113 116 public void actionPerformed(ActionEvent arg0) { 117 HelpPopup.getInstance().setHelpInfo(this); 118 } 119 120 } 121 | Popular Tags |