1 11 package org.eclipse.jdt.internal.ui.actions; 12 13 import org.eclipse.core.runtime.Assert; 14 15 import org.eclipse.jface.action.IMenuManager; 16 17 import org.eclipse.ui.IActionBars; 18 import org.eclipse.ui.actions.ActionContext; 19 import org.eclipse.ui.actions.ActionGroup; 20 21 public class CompositeActionGroup extends ActionGroup { 22 23 private ActionGroup[] fGroups; 24 25 public CompositeActionGroup() { 26 } 27 28 public CompositeActionGroup(ActionGroup[] groups) { 29 setGroups(groups); 30 } 31 32 protected void setGroups(ActionGroup[] groups) { 33 Assert.isTrue(fGroups == null); 34 Assert.isNotNull(groups); 35 fGroups= groups; 36 } 37 38 public ActionGroup get(int index) { 39 if (fGroups == null) 40 return null; 41 return fGroups[index]; 42 } 43 44 public void addGroup(ActionGroup group) { 45 if (fGroups == null) { 46 fGroups= new ActionGroup[] { group }; 47 } else { 48 ActionGroup[] newGroups= new ActionGroup[fGroups.length + 1]; 49 System.arraycopy(fGroups, 0, newGroups, 0, fGroups.length); 50 newGroups[fGroups.length]= group; 51 fGroups= newGroups; 52 } 53 } 54 55 public void dispose() { 56 super.dispose(); 57 if (fGroups == null) 58 return; 59 for (int i= 0; i < fGroups.length; i++) { 60 fGroups[i].dispose(); 61 } 62 } 63 64 public void fillActionBars(IActionBars actionBars) { 65 super.fillActionBars(actionBars); 66 if (fGroups == null) 67 return; 68 for (int i= 0; i < fGroups.length; i++) { 69 fGroups[i].fillActionBars(actionBars); 70 } 71 } 72 73 public void fillContextMenu(IMenuManager menu) { 74 super.fillContextMenu(menu); 75 if (fGroups == null) 76 return; 77 for (int i= 0; i < fGroups.length; i++) { 78 fGroups[i].fillContextMenu(menu); 79 } 80 } 81 82 public void setContext(ActionContext context) { 83 super.setContext(context); 84 if (fGroups == null) 85 return; 86 for (int i= 0; i < fGroups.length; i++) { 87 fGroups[i].setContext(context); 88 } 89 } 90 91 public void updateActionBars() { 92 super.updateActionBars(); 93 if (fGroups == null) 94 return; 95 for (int i= 0; i < fGroups.length; i++) { 96 fGroups[i].updateActionBars(); 97 } 98 } 99 } 100 | Popular Tags |