pauseaction.java
来自「mywork是rcp开发的很好的例子」· Java 代码 · 共 70 行
JAVA
70 行
/************************************************************
*
* Copyright (c) 2003 Chemi. All rights reserved.
*
* This program and the accompanying materials
* are made available under the terms of the MIT License
* which accompanies this distribution, and is available at
* http://www.opensource.org/licenses/mit-license.html
*
************************************************************/
package es.org.chemi.games.sokoban.actions;
import org.eclipse.jface.action.Action;
import es.org.chemi.games.sokoban.SokobanMessages;
import es.org.chemi.games.sokoban.SokobanPlugin;
import es.org.chemi.games.sokoban.ui.MainView;
import es.org.chemi.games.sokoban.util.Constants;
import es.org.chemi.games.util.Timer;
public class PauseAction extends Action
{
private MainView view = null;
private boolean isGamePaused = false;
public PauseAction(String label, MainView view)
{
super(label);
this.view = view;
this.setToolTipText(SokobanMessages.getString("PauseAction.pause")); //$NON-NLS-1$
this.setChecked(false);
this.isGamePaused = false;
}
public void run()
{
SokobanPlugin.trace(this.getClass().getName(),"Pause game solicited."); //$NON-NLS-1$
if(isGamePaused)
{
this.setToolTipText(SokobanMessages.getString("PauseAction.pause")); //$NON-NLS-1$
((Timer)this.view.getCounters().get(Constants.COUNTER_TIME)).start();
isGamePaused = false;
}
else
{
this.setToolTipText(SokobanMessages.getString("PauseAction.continue")); //$NON-NLS-1$
((Timer)this.view.getCounters().get(Constants.COUNTER_TIME)).stop();
isGamePaused = true;
}
view.setFocus(); // Workaround to Bugzilla Bug 42670
}
public void setIsGamePaused(boolean param)
{
isGamePaused = param;
setChecked(param);
if(param == false)
this.setToolTipText(SokobanMessages.getString("PauseAction.pause")); //$NON-NLS-1$
else
this.setToolTipText(SokobanMessages.getString("PauseAction.continue")); //$NON-NLS-1$
}
public boolean isGamePaused()
{
return isGamePaused;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?