/*
* JFLAP - Formal Languages and Automata Package
*
*
* Susan H. Rodger
* Computer Science Department
* Duke University
* August 27, 2009
* Copyright (c) 2002-2009
* All rights reserved.
* JFLAP is open source software. Please see the LICENSE for terms.
*
*/
package gui.action;
import grammar.ConvertedUnrestrictedGrammar;
import grammar.Grammar;
import javax.swing.Icon;
/**
* The GrammarAction
is the general action that various
* controllers for operators on grammars should subclass. The only real change
* from the RestrictedAction
is that by default the .isAcceptable
* method now only returns true if the object is an instance of Grammar
.
*
* @see grammar.Grammar
*
* @author Thomas Finley
*/
public abstract class GrammarAction extends RestrictedAction {
/**
* Instantiates a new GrammarAction
.
*
* @param string
* a string description
* @param icon
* the optional icon, or null
if there is to be no
* icon associated with this action
*/
public GrammarAction(String string, Icon icon) {
super(string, icon);
}
/**
* Given an object, determine if this grammar action is able to be applied
* to that object based on its class. By default, this method returns true
* if this object is an instance of Grammar
.
*
* @param object
* the object to test for "applicability"
* @return true
if this action should be available to an
* object of this type, false
otherwise.
*/
public static boolean isApplicable(Object object) {
if (object instanceof Grammar)
{
Grammar g=(Grammar) object;
if (g.isConverted())
{
// System.out.println("false");
return false;
}
// System.out.println("true");
return true;
}
return false;
}
}