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;
15 //import org.eclipse.jface.text.Assert;
16 import org.eclipse.core.runtime.Assert;
17 import org.eclipse.ui.IActionBars;
18 import org.eclipse.ui.actions.ActionContext;
19 import org.eclipse.ui.actions.ActionGroup;
21 public class CompositeActionGroup extends ActionGroup {
23 private ActionGroup[] fGroups;
25 public CompositeActionGroup() {
28 public CompositeActionGroup(ActionGroup[] groups) {
32 private void setGroups(ActionGroup[] groups) {
33 Assert.isTrue(fGroups == null);
34 Assert.isNotNull(groups);
38 public ActionGroup get(int index) {
41 return fGroups[index];
44 public void addGroup(ActionGroup group) {
45 if (fGroups == null) {
46 fGroups = new ActionGroup[] { group };
48 ActionGroup[] newGroups = new ActionGroup[fGroups.length + 1];
49 System.arraycopy(fGroups, 0, newGroups, 0, fGroups.length);
50 newGroups[fGroups.length] = group;
55 public void dispose() {
59 for (int i = 0; i < fGroups.length; i++) {
64 public void fillActionBars(IActionBars actionBars) {
65 super.fillActionBars(actionBars);
68 for (int i = 0; i < fGroups.length; i++) {
69 fGroups[i].fillActionBars(actionBars);
73 public void fillContextMenu(IMenuManager menu) {
74 super.fillContextMenu(menu);
77 for (int i = 0; i < fGroups.length; i++) {
78 fGroups[i].fillContextMenu(menu);
82 public void setContext(ActionContext context) {
83 super.setContext(context);
86 for (int i = 0; i < fGroups.length; i++) {
87 fGroups[i].setContext(context);
91 public void updateActionBars() {
92 super.updateActionBars();
95 for (int i = 0; i < fGroups.length; i++) {
96 fGroups[i].updateActionBars();