001    // This file is part of the Attempto Java Packages.
002    // Copyright 2008-2009, Attempto Group, University of Zurich (see http://attempto.ifi.uzh.ch).
003    //
004    // The Attempto Java Packages is free software: you can redistribute it and/or modify it under the
005    // terms of the GNU Lesser General Public License as published by the Free Software Foundation,
006    // either version 3 of the License, or (at your option) any later version.
007    //
008    // The Attempto Java Packages is distributed in the hope that it will be useful, but WITHOUT ANY
009    // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
010    // PURPOSE. See the GNU Lesser General Public License for more details.
011    //
012    // You should have received a copy of the GNU Lesser General Public License along with the Attempto
013    // Java Packages. If not, see http://www.gnu.org/licenses/.
014    
015    package ch.uzh.ifi.attempto.preditor;
016    
017    import nextapp.echo2.app.Extent;
018    import nextapp.echo2.app.Font;
019    import nextapp.echo2.app.event.ActionListener;
020    import ch.uzh.ifi.attempto.echocomp.Style;
021    
022    /**
023     * This abstract class represents a menu item that performs an action when the user clicks on it.
024     * 
025     * @author Tobias Kuhn
026     */
027    public class SpecialMenuItem extends MenuItem {
028    
029            private static final long serialVersionUID = -2762672905600512854L;
030    
031            /**
032             * Creates a new special menu item.
033             * 
034             * @param text The text of the menu item.
035             * @param actionCommand The action command.
036             * @param actionListener The action listener.
037             */
038            public SpecialMenuItem(String text, String actionCommand, ActionListener actionListener) {
039                    setText(text);
040                    setActionCommand(actionCommand);
041            setFont(new Font(Style.fontTypeface, Font.ITALIC, new Extent(12)));
042                    setForeground(Style.mediumForeground);
043                    if (actionListener != null) {
044                            addActionListener(actionListener);
045                    }
046        }
047            
048            /**
049             * Creates a new special menu item.
050             * 
051             * @param text The text of the menu item.
052             * @param actionCommand The action command.
053             */
054            public SpecialMenuItem(String text, String actionCommand) {
055                    this(text, actionCommand, null);
056        }
057    
058            /**
059             * Creates a new special menu item.
060             * 
061             * @param text The text of the menu item.
062             */
063            public SpecialMenuItem(String text) {
064                    this(text, text, null);
065        }
066    
067            public boolean equals(Object obj) {
068                    if (obj instanceof SpecialMenuItem) {
069                            return getText().equals(((SpecialMenuItem) obj).getText());
070                    }
071                    return false;
072            }
073        
074    }