1 /*******************************************************************************
2 * Copyright (c) 2002 International Business Machines Corp. and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v0.5
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v05.html
9 * IBM Corporation - initial API and implementation
10 ******************************************************************************/
11 package net.sourceforge.phpdt.internal.ui.actions;
13 import org.eclipse.jface.action.IMenuManager;
14 import org.eclipse.jface.util.Assert;
15 import org.eclipse.ui.IActionBars;
16 import org.eclipse.ui.actions.ActionContext;
17 import org.eclipse.ui.actions.ActionGroup;
19 public class CompositeActionGroup extends ActionGroup {
21 private ActionGroup[] fGroups;
23 public CompositeActionGroup() {
26 public CompositeActionGroup(ActionGroup[] groups) {
30 protected void setGroups(ActionGroup[] groups) {
31 Assert.isTrue(fGroups == null);
32 Assert.isNotNull(groups);
36 public ActionGroup get(int index) {
39 return fGroups[index];
42 public void addGroup(ActionGroup group) {
43 if (fGroups == null) {
44 fGroups = new ActionGroup[] { group };
46 ActionGroup[] newGroups = new ActionGroup[fGroups.length + 1];
47 System.arraycopy(fGroups, 0, newGroups, 0, fGroups.length);
48 newGroups[fGroups.length] = group;
53 public void dispose() {
57 for (int i = 0; i < fGroups.length; i++) {
62 public void fillActionBars(IActionBars actionBars) {
63 super.fillActionBars(actionBars);
66 for (int i = 0; i < fGroups.length; i++) {
67 fGroups[i].fillActionBars(actionBars);
71 public void fillContextMenu(IMenuManager menu) {
72 super.fillContextMenu(menu);
75 for (int i = 0; i < fGroups.length; i++) {
76 fGroups[i].fillContextMenu(menu);
80 public void setContext(ActionContext context) {
81 super.setContext(context);
84 for (int i = 0; i < fGroups.length; i++) {
85 fGroups[i].setContext(context);
89 public void updateActionBars() {
90 super.updateActionBars();
93 for (int i = 0; i < fGroups.length; i++) {
94 fGroups[i].updateActionBars();