KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > presentations > SystemMenuStateChange


1 /*******************************************************************************
2  * Copyright (c) 2004, 2006 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 package org.eclipse.ui.internal.presentations;
12
13 import org.eclipse.jface.action.Action;
14 import org.eclipse.ui.presentations.IStackPresentationSite;
15
16 /**
17  *
18  *
19  * @since 3.0
20  */

21 public class SystemMenuStateChange extends Action implements
22         ISelfUpdatingAction {
23     private IStackPresentationSite site;
24
25     private int state;
26
27     public SystemMenuStateChange(IStackPresentationSite site, String JavaDoc name,
28             int state) {
29         this.site = site;
30         this.state = state;
31
32         setText(name);
33         update();
34     }
35
36     public void dispose() {
37         this.site = null;
38     }
39
40     public void run() {
41         site.setState(state);
42     }
43
44     public void update() {
45         setEnabled(site.getState() != state && site.supportsState(state));
46     }
47
48     public boolean shouldBeVisible() {
49         return site.supportsState(state);
50     }
51
52 }
53
Popular Tags