1 11 package org.eclipse.ui.internal.commands; 12 13 34 public final class CommandImageManagerEvent { 35 36 40 private final String [] changedCommandIds; 41 42 46 private final CommandImageManager commandImageManager; 47 48 51 private final String style; 52 53 56 private final int type; 57 58 69 CommandImageManagerEvent(final CommandImageManager commandImageManager, 70 final String [] changedCommandIds, final int type, final String style) { 71 if (commandImageManager == null) { 72 throw new NullPointerException ("An event must refer to its manager"); } 74 75 if ((changedCommandIds == null) || (changedCommandIds.length < 1)) { 76 throw new IllegalArgumentException ( 77 "There must be at least one change command identifier"); } 79 80 this.commandImageManager = commandImageManager; 81 this.changedCommandIds = changedCommandIds; 82 this.type = type; 83 this.style = style; 84 } 85 86 92 public final String [] getChangedCommandIds() { 93 final String [] copy = new String [changedCommandIds.length]; 94 System.arraycopy(changedCommandIds, 0, copy, 0, 95 changedCommandIds.length); 96 return copy; 97 } 98 99 105 public final CommandImageManager getCommandImageManager() { 106 return commandImageManager; 107 } 108 109 118 public final boolean isCommandIdChanged(final String commandId) { 119 for (int i = 0; i < changedCommandIds.length; i++) { 121 if (commandId.equals(changedCommandIds[i])) { 122 return true; 123 } 124 } 125 126 return false; 127 } 128 129 138 public final boolean isCommandImageChanged(final String commandId) { 139 return isCommandIdChanged(commandId) 140 && (type == CommandImageManager.TYPE_DEFAULT) 141 && (style == null); 142 } 143 144 159 public final boolean isCommandImageChanged(final String commandId, 160 final int type) { 161 return isCommandIdChanged(commandId) 162 && ((type == CommandImageManager.TYPE_DEFAULT) || (type == this.type)) 163 && (style == null); 164 } 165 166 184 public final boolean isCommandImageChanged(final String commandId, 185 final int type, final String style) { 186 return isCommandIdChanged(commandId) 187 && ((type == CommandImageManager.TYPE_DEFAULT) || (type == this.type)) 188 && ((style == null) || (style.equals(this.style))); 189 } 190 191 203 public final boolean isCommandImageChanged(final String commandId, 204 final String style) { 205 return isCommandIdChanged(commandId) 206 && (type == CommandImageManager.TYPE_DEFAULT) 207 && ((style == null) || (style.equals(this.style))); 208 } 209 } 210 | Popular Tags |