01: /*******************************************************************************
02: * Copyright (c) 2004, 2006 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.presentations;
11:
12: import org.eclipse.jface.action.Action;
13: import org.eclipse.ui.presentations.IStackPresentationSite;
14:
15: /**
16: *
17: *
18: * @since 3.0
19: */
20: public class SystemMenuStateChange extends Action implements
21: ISelfUpdatingAction {
22: private IStackPresentationSite site;
23:
24: private int state;
25:
26: public SystemMenuStateChange(IStackPresentationSite site,
27: String name, int state) {
28: this .site = site;
29: this .state = state;
30:
31: setText(name);
32: update();
33: }
34:
35: public void dispose() {
36: this .site = null;
37: }
38:
39: public void run() {
40: site.setState(state);
41: }
42:
43: public void update() {
44: setEnabled(site.getState() != state
45: && site.supportsState(state));
46: }
47:
48: public boolean shouldBeVisible() {
49: return site.supportsState(state);
50: }
51:
52: }
|