Show CloseGameAction.java syntax highlighted
package geronimo.hoshigo.control.game;
import geronimo.hoshigo.control.MainController;
import geronimo.hoshigo.model.game.Game;
import geronimo.hoshigo.model.tournament.TournamentGame;
import geronimo.hoshigo.view.IconRegistry;
import geronimo.hoshigo.view.IconRegistry.IconSize;
import org.eclipse.jface.action.Action;
/**
* Action de fermeture d'une partie. On ne peut fermer qu'un match amical
* @author Geronimo
*/
public class CloseGameAction extends Action
{
private static CloseGameAction instance;
private Game game = null;
/**
* Création de l'action. Privé car on n'autorise qu'une seule instance
* de la classe.
*/
private CloseGameAction()
{
super();
this.setText("&Fermer la partie@Ctrl+W");
this.setImageDescriptor(IconRegistry.getDescriptor("close_game",IconSize.SMALL));
this.setEnabled(false);
}
/**
* Accès à l'instance de la classe.
* @return Retourne l'instance
*/
public synchronized static CloseGameAction getInstance()
{
// Creation de l'instance au premier appel
if(instance == null)
{
instance = new CloseGameAction();
}
return instance;
}
/**
* Changement de la partie active.
* @param game Nouvelle partie courante
*/
public void setActiveGame(Game game)
{
this.game = game;
this.setEnabled(game != null && !(game instanceof TournamentGame) );
}
/**
* Lancement de l'action. Supprime la partie du répertoire
*/
public void run()
{
if(this.game != null)
{
if(this.game instanceof Game)
{
MainController.getGameDirectory().removeFreeGame(this.game);
}
}
}
}
See more files for this project here