[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

20040105: Tooltips on the "Data selector" gui?



>From: "Paul Gifford" <address@hidden>
>Organization: 
>Keywords: 200312310359.hBV3xkp2021360 IDV tooltips

Hi Paul-

>  How can I add tooltips to the leaves of trees (Data sources and Fields)?
>I find I need a little more room to describe the data sufficiently.

If you look at ucar.unidata.idv.ui.DataTree, the tooltips are set
as follows:

                    if (o instanceof DerivedDataChoice) {
                        DerivedDataChoice ddc =  (DerivedDataChoice) o;
                        if (ddc.getFormula () != null) {
                            setToolTipText (ddc.getFormula ());
                        }
                    } else if (o instanceof DataChoice) {
                        DataChoice dc =  (DataChoice) o;
                        setToolTipText ("<html> "+dc.getName()+"<br> "+dc.getDes
cription()+"</html>");
                    } else if (o instanceof DataSource) {
                        setToolTipText (((DataSource)o).getFullDescription ());
                    }

So for a DataChoice, you could control what's shown by passing in
a long description (using html tags if you want) in the constructor.

For the DataSource, the getFullDescription returns:

    public String getFullDescription  () {
        return getDescription () + "<p>" + name;
    }

so, you could either override this method in your subclass, or 
use the constructor that passes in a description.

Let me know if you have any questions about this.

Don Murray