KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > metadata > swing > HelpIcon


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

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 /**
31  * @author Matthew Large
32  * @version $Revision: 1.1 $
33  *
34  */

35 public class HelpIcon extends JToggleButton implements ActionListener {
36
37     private Property m_prop = null;
38     private String JavaDoc m_sSummary = "No description available.";
39     private String JavaDoc m_sTitle = "Property Help";
40
41     public HelpIcon(String JavaDoc sTitle, String JavaDoc 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     /**
53      *
54      */

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 JavaDoc getSummary() {
78         return this.m_sSummary;
79     }
80     
81     public String JavaDoc 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     /* (non-Javadoc)
96      * @see javax.swing.JComponent#createToolTip()
97      */

98     public JToolTip createToolTip() {
99         JMultiLineToolTip toolTip = new JMultiLineToolTip();
100         toolTip.setFixedWidth(300);
101         return toolTip;
102     }
103     
104     
105
106     /**
107      * @param arg0
108      */

109     private HelpIcon(String JavaDoc arg0) {
110         super(arg0);
111     }
112
113     /* (non-Javadoc)
114      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
115      */

116     public void actionPerformed(ActionEvent arg0) {
117         HelpPopup.getInstance().setHelpInfo(this);
118     }
119
120 }
121
Popular Tags