1 11 package org.eclipse.ui.internal.menus; 12 13 import org.eclipse.core.commands.common.AbstractBitSetEvent; 14 15 33 public final class MenuManagerEvent extends AbstractBitSetEvent { 34 35 41 private static final int CHANGED_ACTION_SET_DEFINED = 1; 42 43 49 private static final int CHANGED_GROUP_DEFINED = 1 << 1; 50 51 57 private static final int CHANGED_ITEM_DEFINED = 1 << 2; 58 59 65 private static final int CHANGED_MENU_DEFINED = 1 << 3; 66 67 73 private static final int CHANGED_WIDGET_DEFINED = 1 << 4; 74 75 80 private final String actionSetId; 81 82 87 private final String groupId; 88 89 94 private final String itemId; 95 96 101 private final String menuId; 102 103 106 private final SMenuManager menuManager; 107 108 113 private final String widgetId; 114 115 152 MenuManagerEvent(final SMenuManager menuManager, final String groupId, 153 final boolean groupIdAdded, final String itemId, 154 final boolean itemIdAdded, final String menuId, 155 final boolean menuIdAdded, final String widgetId, 156 final boolean widgetIdAdded, final String actionSetId, 157 final boolean actionSetIdAdded) { 158 if (menuManager == null) { 159 throw new NullPointerException ( 160 "An event must refer to its menu manager"); } 162 163 this.menuManager = menuManager; 164 this.groupId = groupId; 165 this.itemId = itemId; 166 this.menuId = menuId; 167 this.widgetId = widgetId; 168 this.actionSetId = actionSetId; 169 170 if (groupIdAdded) { 171 changedValues |= CHANGED_GROUP_DEFINED; 172 } 173 if (itemIdAdded) { 174 changedValues |= CHANGED_ITEM_DEFINED; 175 } 176 if (menuIdAdded) { 177 changedValues |= CHANGED_MENU_DEFINED; 178 } 179 if (widgetIdAdded) { 180 changedValues |= CHANGED_WIDGET_DEFINED; 181 } 182 if (actionSetIdAdded) { 183 changedValues |= CHANGED_ACTION_SET_DEFINED; 184 } 185 } 186 187 193 public final String getActionSetId() { 194 return groupId; 195 } 196 197 203 public final String getGroupId() { 204 return groupId; 205 } 206 207 213 public final String getItemId() { 214 return itemId; 215 } 216 217 223 public final String getMenuId() { 224 return menuId; 225 } 226 227 233 public final SMenuManager getMenuManager() { 234 return menuManager; 235 } 236 237 243 public final String getWidgetId() { 244 return widgetId; 245 } 246 247 253 public final boolean isActionSetChanged() { 254 return (actionSetId != null); 255 } 256 257 265 public final boolean isActionSetDefined() { 266 return (((changedValues & CHANGED_ACTION_SET_DEFINED) != 0) && (actionSetId != null)); 267 } 268 269 275 public final boolean isGroupChanged() { 276 return (groupId != null); 277 } 278 279 286 public final boolean isGroupDefined() { 287 return (((changedValues & CHANGED_GROUP_DEFINED) != 0) && (groupId != null)); 288 } 289 290 296 public final boolean isItemChanged() { 297 return (itemId != null); 298 } 299 300 307 public final boolean isItemDefined() { 308 return (((changedValues & CHANGED_ITEM_DEFINED) != 0) && (itemId != null)); 309 } 310 311 317 public final boolean isMenuChanged() { 318 return (menuId != null); 319 } 320 321 328 public final boolean isMenuDefined() { 329 return (((changedValues & CHANGED_MENU_DEFINED) != 0) && (menuId != null)); 330 } 331 332 338 public final boolean isWidgetChanged() { 339 return (widgetId != null); 340 } 341 342 349 public final boolean isWidgetDefined() { 350 return (((changedValues & CHANGED_WIDGET_DEFINED) != 0) && (widgetId != null)); 351 } 352 } 353 | Popular Tags |