Added MenuAction class which allows the creation of new menu event handler with ease.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/com/panayotis/jubler/MenuAction.java Mon Oct 19 15:37:50 2009 +0100
1.3 @@ -0,0 +1,95 @@
1.4 +/*
1.5 + * MenuAction.java
1.6 + *
1.7 + * Created on: 06-Oct-2009 at 18:43:18
1.8 + *
1.9 + *
1.10 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
1.11 + *
1.12 + * This file is part of Jubler.
1.13 + *
1.14 + * Jubler is free software; you can redistribute it and/or modify
1.15 + * it under the terms of the GNU General Public License as published by
1.16 + * the Free Software Foundation, version 2.
1.17 + *
1.18 + *
1.19 + * Jubler is distributed in the hope that it will be useful,
1.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.22 + * GNU General Public License for more details.
1.23 + *
1.24 + * You should have received a copy of the GNU General Public License
1.25 + * along with Jubler; if not, write to the Free Software
1.26 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1.27 + *
1.28 + * Contributor(s):
1.29 + *
1.30 + */
1.31 +package com.panayotis.jubler;
1.32 +
1.33 +import com.panayotis.jubler.subs.Share;
1.34 +import java.awt.event.ActionListener;
1.35 +import javax.swing.JMenuItem;
1.36 +
1.37 +/**
1.38 + *
1.39 + * @author hoang_tran <hoangduytran1960@googlemail.com>
1.40 + */
1.41 +public abstract class MenuAction extends JMenuItem implements ActionListener {
1.42 +
1.43 + protected String actionName = null;
1.44 + protected Jubler jublerParent = null;
1.45 +
1.46 + public MenuAction() {}
1.47 +
1.48 + /**
1.49 + * Default constructor, setting action-name and add the action listener
1.50 + * implemented by this class.
1.51 + */
1.52 + public MenuAction(String actionName) {
1.53 + this.actionName = actionName;
1.54 + if (! Share.isEmpty(actionName)) {
1.55 + setText(actionName);
1.56 + setName(actionName);
1.57 + }//end if
1.58 + addActionListener(this);
1.59 + }
1.60 +
1.61 + /**
1.62 + * Peform default construction with the addition of setting reference
1.63 + * for the {@link Jubler} parent.
1.64 + * @param jublerParent The reference to {@link Jubler} running instance.
1.65 + */
1.66 + public MenuAction(Jubler jublerParent, String actionName) {
1.67 + this(actionName);
1.68 + this.jublerParent = jublerParent;
1.69 + }
1.70 +
1.71 + /**
1.72 + * @return the actionName
1.73 + */
1.74 + public String getActionName() {
1.75 + return actionName;
1.76 + }
1.77 +
1.78 + /**
1.79 + * @param actionName the actionName to set
1.80 + */
1.81 + public void setActionName(String actionName) {
1.82 + this.actionName = actionName;
1.83 + }
1.84 +
1.85 + /**
1.86 + * @return the jublerParent
1.87 + */
1.88 + public Jubler getJublerParent() {
1.89 + return jublerParent;
1.90 + }
1.91 +
1.92 + /**
1.93 + * @param jublerParent the jublerParent to set
1.94 + */
1.95 + public void setJublerParent(Jubler jublerParent) {
1.96 + Jubler jb = jublerParent;
1.97 + }
1.98 +}//end public abstract class MenuAction extends JMenuItem implements ActionListener