KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.Iterator JavaDoc;
15
16 import org.eclipse.core.runtime.IConfigurationElement;
17 import org.eclipse.jface.action.IAction;
18 import org.eclipse.ui.IActionBars;
19 import org.eclipse.ui.IWorkbenchWindow;
20 import org.eclipse.ui.internal.registry.ActionSetDescriptor;
21 import org.eclipse.ui.internal.registry.IActionSet;
22
23 /**
24  * A PluginActionSet is a proxy for an action set defined in XML.
25  * It creates a PluginAction for each action and does the required
26  * cleanup on dispose.
27  */

28 public class PluginActionSet implements IActionSet {
29     private ActionSetDescriptor desc;
30
31     private ArrayList JavaDoc pluginActions = new ArrayList JavaDoc(4);
32
33     private ActionSetActionBars bars;
34
35     /**
36      * PluginActionSet constructor comment.
37      *
38      * @param desc the descriptor
39      */

40     public PluginActionSet(ActionSetDescriptor desc) {
41         super();
42         this.desc = desc;
43     }
44
45     /**
46      * Adds one plugin action ref to the list.
47      *
48      * @param action the action
49      */

50     public void addPluginAction(WWinPluginAction action) {
51         pluginActions.add(action);
52     }
53
54     /**
55      * Returns the list of plugin actions for the set.
56      *
57      * @return the actions for the set
58      */

59     public IAction[] getPluginActions() {
60         IAction result[] = new IAction[pluginActions.size()];
61         pluginActions.toArray(result);
62         return result;
63     }
64
65     /**
66      * Disposes of this action set.
67      */

68     public void dispose() {
69         Iterator JavaDoc iter = pluginActions.iterator();
70         while (iter.hasNext()) {
71             WWinPluginAction action = (WWinPluginAction) iter.next();
72             action.dispose();
73         }
74         pluginActions.clear();
75         bars = null;
76     }
77
78     /**
79      */

80     /* package */ActionSetActionBars getBars() {
81         return bars;
82     }
83
84     /**
85      * Returns the configuration element.
86      *
87      * @return the configuration element
88      */

89     public IConfigurationElement getConfigElement() {
90         return desc.getConfigurationElement();
91     }
92
93     /**
94      * Returns the underlying descriptor.
95      *
96      * @return the descriptor
97      */

98     public ActionSetDescriptor getDesc() {
99         return desc;
100     }
101
102     /**
103      * Initializes this action set, which is expected to add it actions as required
104      * to the given workbench window and action bars.
105      *
106      * @param window the workbench window
107      * @param bars the action bars
108      */

109     public void init(IWorkbenchWindow window, IActionBars bars) {
110         this.bars = (ActionSetActionBars) bars;
111     }
112 }
113
Popular Tags