soundaction.java

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

JAVA
50
字号
/************************************************************
 *
 * 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;

public class SoundAction extends Action 
{
	private MainView view = null;
	
	public SoundAction(String label, MainView view)
	{
		super(label);		
		this.view = view;
		this.setToolTipText(SokobanMessages.getString("SoundAction.disable")); //$NON-NLS-1$
		if(this.view.getPreferences().isSoundEnabled())
			this.setChecked(true);
		else
			this.setChecked(false);
	}
	
	public void run()
	{
		SokobanPlugin.trace(this.getClass().getName(),"Change sound mode."); //$NON-NLS-1$
		if(this.view.getPreferences().isSoundEnabled())
		{
			this.view.getPreferences().setSoundEnabled(false);
			this.setToolTipText(SokobanMessages.getString("SoundAction.enable")); //$NON-NLS-1$
		}
		else
		{
			this.view.getPreferences().setSoundEnabled(true);
			this.setToolTipText(SokobanMessages.getString("SoundAction.disable")); //$NON-NLS-1$
		}
		view.setFocus(); // Workaround to Bugzilla Bug 42670
	}
}

⌨️ 快捷键说明

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