Show AnyColorPassAction.java syntax highlighted
package geronimo.hoshigo.control.player;
import geronimo.hoshigo.model.game.Game;
import geronimo.hoshigo.model.game.Player.PlayerState;
import geronimo.hoshigo.view.IconRegistry;
import geronimo.hoshigo.view.IconRegistry.IconSize;
public class AnyColorPassAction extends PassAction
{
private static AnyColorPassAction instance;
/**
* Constructeur. Il est privé car on ne peut créer qu'une instance de cette
* classe.
* @see AnyColorPassAction#getInstance()
*/
private AnyColorPassAction()
{
super();
this.setText("&Passer@Ctrl+P");
this.setImageDescriptor(IconRegistry.getDescriptor("pass",
IconSize.SMALL));
this.setEnabled(false);
}
/**
* Accès à l'instance
* @return Retourne l'instance de la classe
*/
public static synchronized AnyColorPassAction getInstance()
{
// Création de l'instance au premier appel
if( AnyColorPassAction.instance == null )
{
AnyColorPassAction.instance = new AnyColorPassAction();
}
return AnyColorPassAction.instance;
}
/**
* Changement de la partie active.
* @param game Nouvelle partie courante
*/
public void setActiveGame(Game game)
{
super.setActiveGame(game);
if( this.game != null
&& this.game.getCurrentPlayer().isHuman()
&& this.game.getCurrentPlayer().getState() == PlayerState.THINKING)
{
this.setEnabled(true);
}
else
{
this.setEnabled(false);
}
}
}
See more files for this project here