KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > AbstractEnabledHandler


1 /*******************************************************************************
2  * Copyright (c) 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  ******************************************************************************/

11
12 package org.eclipse.ui.internal;
13
14 import org.eclipse.core.commands.AbstractHandler;
15 import org.eclipse.core.commands.HandlerEvent;
16
17 /**
18  * Abstract base class that provides the enabled state, where changing the state
19  * fires the HandlerEvent.
20  *
21  * @since 3.3
22  */

23 public abstract class AbstractEnabledHandler extends AbstractHandler {
24
25     private boolean enabled = true;
26
27     /*
28      * (non-Javadoc)
29      *
30      * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
31      */

32     public boolean isEnabled() {
33         return enabled;
34     }
35
36     protected void setEnabled(boolean isEnabled) {
37         if (enabled != isEnabled) {
38             enabled = isEnabled;
39             fireHandlerChanged(new HandlerEvent(this, true, false));
40         }
41     }
42 }
43
Popular Tags