01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: ******************************************************************************/package org.eclipse.ui.internal;
11:
12: import org.eclipse.core.commands.AbstractHandler;
13: import org.eclipse.core.commands.HandlerEvent;
14:
15: /**
16: * Abstract base class that provides the enabled state, where changing the state
17: * fires the HandlerEvent.
18: *
19: * @since 3.3
20: */
21: public abstract class AbstractEnabledHandler extends AbstractHandler {
22:
23: private boolean enabled = true;
24:
25: /*
26: * (non-Javadoc)
27: *
28: * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
29: */
30: public boolean isEnabled() {
31: return enabled;
32: }
33:
34: protected void setEnabled(boolean isEnabled) {
35: if (enabled != isEnabled) {
36: enabled = isEnabled;
37: fireHandlerChanged(new HandlerEvent(this , true, false));
38: }
39: }
40: }
|