undoaction.java

来自「mywork是rcp开发的很好的例子」· Java 代码 · 共 46 行

JAVA
46
字号
/************************************************************
 *
 * 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.SokobanPlugin;
import es.org.chemi.games.sokoban.ui.MainView;
import es.org.chemi.games.sokoban.util.Constants;

public class UndoAction extends Action 
{
	private MainView view = null;
	
	public UndoAction(String label, MainView view) 
	{
		super(label);
		this.view = view;
	}

	public void run() 
	{
		if(!view.getMap().getUndoAction().isEnabled())
			return ;
		SokobanPlugin.trace(this.getClass().getName(),"Undo last movement solicited."); //$NON-NLS-1$
		
		// Play sound.
		if(view.getPreferences().isSoundEnabled())
			SokobanPlugin.getResourceManager().getSound(Constants.SOUND_BACK).play();

		// Undo last movement.
		view.getMap().restoreTiles();
		view.getMap().redraw();
		view.getMap().setFocus();
		view.getMap().getUndoAction().setEnabled(false);
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?