Show CloseTournamentAction.java syntax highlighted
package geronimo.hoshigo.control.tournament;
import geronimo.hoshigo.control.MainController;
import geronimo.hoshigo.model.tournament.Tournament;
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 CloseTournamentAction extends Action
{
private static CloseTournamentAction instance;
private Tournament tournament = null;
/**
* Création de l'action. Privé car on n'autorise qu'une seule instance
* de la classe.
*/
private CloseTournamentAction()
{
super();
this.setText("&Fermer le tournoi@Ctrl+Q");
this.setToolTipText("Fermer le tournoi");
this.setImageDescriptor(IconRegistry.getDescriptor("close_tournament",IconSize.SMALL));
this.setEnabled(false);
}
/**
* Accès à l'instance de la classe.
* @return Retourne l'instance
*/
public synchronized static CloseTournamentAction getInstance()
{
// Creation de l'instance au premier appel
if(instance == null)
{
instance = new CloseTournamentAction();
}
return instance;
}
/**
* Changement de tournoi actif
* @param tournament Nouveau tournoi actif
*/
public void setActiveTournament(Tournament tournament)
{
this.tournament = tournament;
this.setEnabled(tournament != null);
}
/**
* Lancement de l'action. Supprime la partie du répertoire
*/
public void run()
{
if(this.tournament != null)
{
MainController.getGameDirectory().removeTournament(this.tournament);
}
}
}
See more files for this project here