Ignore:
Timestamp:
2012-02-11T18:56:53+01:00 (13 years ago)
Author:
simon04
Message:

fix #7370 - Refactor Command.getDescription

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/PseudoCommand.java

    r3479 r4918  
    33
    44import java.util.Collection;
     5import javax.swing.Icon;
     6import javax.swing.JLabel;
    57
    68import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    1416    /**
    1517     * Provide a description that can be presented in a list or tree view.
     18     * @deprecated This abstract method is deprecated.
     19     * On 2012-03-01, this abstract method will be removed.
     20     * At the same moment, the methods {@link #getDescrpitionText()} and {@link #getDescrpitionIcon()}
     21     * will be made abstract.
     22     * For a smooth transition, replace {@link #getDescription()} by implementations of
     23     * {@link #getDescrpitionText()} and {@link #getDescrpitionIcon()} as early as possible.
     24     * {@link #getDescription()} is no longer abstract and can therefore be removed.
    1625     */
    17     abstract public Object getDescription();
     26    @Deprecated
     27    public Object getDescription() {
     28        return null;
     29    }
     30
     31    /**
     32     * Provides a description text representing this command.
     33     */
     34    public String getDescriptionText() {
     35        Object o = getDescription();
     36        if (o instanceof JLabel) {
     37            return ((JLabel) o).getText();
     38        } else {
     39            return o.toString();
     40        }
     41    }
     42
     43    /**
     44     * Provides a descriptive icon of this command.
     45     */
     46    public Icon getDescriptionIcon() {
     47        Object o = getDescription();
     48        if (o instanceof JLabel) {
     49            return ((JLabel) o).getIcon();
     50        } else {
     51            return null;
     52        }
     53    }
    1854
    1955    /**
Note: See TracChangeset for help on using the changeset viewer.