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;
16 import org.eclipse.ui.IActionBars;
17 import org.eclipse.ui.actions.ActionContext;
18 import org.eclipse.ui.actions.ActionGroup;
20 public class CompositeActionGroup extends ActionGroup {
22 private ActionGroup[] fGroups;
24 public CompositeActionGroup() {
27 public CompositeActionGroup(ActionGroup[] groups) {
31 protected void setGroups(ActionGroup[] groups) {
32 Assert.isTrue(fGroups == null);
33 Assert.isNotNull(groups);
37 public ActionGroup get(int index) {
40 return fGroups[index];
43 public void addGroup(ActionGroup group) {
44 if (fGroups == null) {
45 fGroups= new ActionGroup[] { group };
47 ActionGroup[] newGroups= new ActionGroup[fGroups.length + 1];
48 System.arraycopy(fGroups, 0, newGroups, 0, fGroups.length);
49 newGroups[fGroups.length]= group;
54 public void dispose() {
58 for (int i= 0; i < fGroups.length; i++) {
63 public void fillActionBars(IActionBars actionBars) {
64 super.fillActionBars(actionBars);
67 for (int i= 0; i < fGroups.length; i++) {
68 fGroups[i].fillActionBars(actionBars);
72 public void fillContextMenu(IMenuManager menu) {
73 super.fillContextMenu(menu);
76 for (int i= 0; i < fGroups.length; i++) {
77 fGroups[i].fillContextMenu(menu);
81 public void setContext(ActionContext context) {
82 super.setContext(context);
85 for (int i= 0; i < fGroups.length; i++) {
86 fGroups[i].setContext(context);
90 public void updateActionBars() {
91 super.updateActionBars();
94 for (int i= 0; i < fGroups.length; i++) {
95 fGroups[i].updateActionBars();