KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > loskutov > bco > compare > actions > ToggleASMifierModeAction


1 /*******************************************************************************
2  * Copyright (c) 2004 Andrei Loskutov.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the BSD License
5  * which accompanies this distribution, and is available at
6  * http://www.opensource.org/licenses/bsd-license.php
7  * Contributor: Andrei Loskutov - initial API and implementation
8  *******************************************************************************/

9 package de.loskutov.bco.compare.actions;
10
11 import org.eclipse.jface.action.Action;
12 import org.eclipse.ui.plugin.AbstractUIPlugin;
13
14 import de.loskutov.bco.BytecodeOutlinePlugin;
15
16 /**
17  * Action used in compare view/bytecode view to toggle ASMifier formatter on/off.
18  * To use it, register IPropertyChangeListener and check for IAction.CHECKED
19  * event name.
20  * @author Andrei
21  */

22 public class ToggleASMifierModeAction extends Action {
23     private static final String TASM_ID = "tasm"; //$NON-NLS-1$
24
private boolean isASMifierMode;
25
26     /**
27      * Init action with image/text/tooltip
28      */

29     public ToggleASMifierModeAction() {
30         super();
31         setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(
32             BytecodeOutlinePlugin.getDefault().getBundle().getSymbolicName(),
33             BytecodeOutlinePlugin.IMG_ASM));
34
35         setText(BytecodeOutlinePlugin
36             .getResourceString("ToggleASMifierModeAction.toggleASMifierMode.label")); //$NON-NLS-1$
37
setToolTipText(BytecodeOutlinePlugin
38             .getResourceString("ToggleASMifierModeAction.toggleASMifierMode.tooltip")); //$NON-NLS-1$
39
}
40
41     /**
42      * @see org.eclipse.jface.action.IAction#getId()
43      */

44     public String getId() {
45         return TASM_ID;
46     }
47
48     /**
49      * @see org.eclipse.jface.action.IAction#run()
50      */

51     public void run() {
52         isASMifierMode = !isASMifierMode;
53         setChecked(isASMifierMode);
54     }
55 }
Popular Tags