1 11 package org.eclipse.core.internal.events; 12 13 import java.util.HashMap ; 14 import java.util.Map ; 15 import org.eclipse.core.internal.resources.ModelObject; 16 import org.eclipse.core.resources.*; 17 import org.eclipse.core.runtime.*; 18 19 24 public class BuildCommand extends ModelObject implements ICommand { 25 28 private static final int MASK_AUTO = 0x01; 29 private static final int MASK_INCREMENTAL = 0x02; 30 private static final int MASK_FULL = 0x04; 31 private static final int MASK_CLEAN = 0x08; 32 33 36 private static final int MASK_CONFIGURABLE = 0x10; 37 38 42 private static final int MASK_CONFIG_COMPUTED = 0x20; 43 44 private static final int ALL_TRIGGERS = MASK_AUTO | MASK_CLEAN | MASK_FULL | MASK_INCREMENTAL; 45 46 protected HashMap arguments; 47 48 52 protected IncrementalProjectBuilder builder; 53 54 60 private int triggers = ALL_TRIGGERS; 61 62 65 private static int maskForTrigger(int trigger) { 66 switch (trigger) { 67 case IncrementalProjectBuilder.AUTO_BUILD : 68 return MASK_AUTO; 69 case IncrementalProjectBuilder.INCREMENTAL_BUILD : 70 return MASK_INCREMENTAL; 71 case IncrementalProjectBuilder.FULL_BUILD : 72 return MASK_FULL; 73 case IncrementalProjectBuilder.CLEAN_BUILD : 74 return MASK_CLEAN; 75 } 76 return 0; 77 } 78 79 public BuildCommand() { 80 super(""); this.arguments = new HashMap (0); 82 } 83 84 public Object clone() { 85 BuildCommand result = null; 86 result = (BuildCommand) super.clone(); 87 if (result == null) 88 return null; 89 result.setArguments(getArguments()); 90 result.setBuilder(null); 92 return result; 93 } 94 95 99 private void computeIsConfigurable() { 100 triggers |= MASK_CONFIG_COMPUTED; 101 IExtension extension = Platform.getExtensionRegistry().getExtension(ResourcesPlugin.PI_RESOURCES, ResourcesPlugin.PT_BUILDERS, name); 102 if (extension != null) { 103 IConfigurationElement[] configs = extension.getConfigurationElements(); 104 if (configs.length != 0) { 105 String value = configs[0].getAttribute("isConfigurable"); setConfigurable(value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())); 107 } 108 } 109 } 110 111 114 public boolean equals(Object object) { 115 if (this == object) 116 return true; 117 if (!(object instanceof BuildCommand)) 118 return false; 119 BuildCommand command = (BuildCommand) object; 120 return getBuilderName().equals(command.getBuilderName()) && getArguments(false).equals(command.getArguments(false)) && triggers == command.triggers; 122 } 123 124 127 public Map getArguments() { 128 return getArguments(true); 129 } 130 131 public Map getArguments(boolean makeCopy) { 132 return arguments == null ? null : (makeCopy ? (Map ) arguments.clone() : arguments); 133 } 134 135 public IncrementalProjectBuilder getBuilder() { 136 return builder; 137 } 138 139 142 public String getBuilderName() { 143 return getName(); 144 } 145 146 149 public int hashCode() { 150 return 37 * getName().hashCode() + triggers; 152 } 153 154 157 public boolean isBuilding(int trigger) { 158 return (triggers & maskForTrigger(trigger)) != 0; 159 } 160 161 public boolean isConfigurable() { 162 if ((triggers & MASK_CONFIG_COMPUTED) == 0) 163 computeIsConfigurable(); 164 return (triggers & MASK_CONFIGURABLE) != 0; 165 } 166 167 170 public void setArguments(Map value) { 171 arguments = value == null ? null : new HashMap (value); 173 } 174 175 public void setBuilder(IncrementalProjectBuilder builder) { 176 this.builder = builder; 177 } 178 179 182 public void setBuilderName(String value) { 183 setName(value == null ? "" : value); } 186 187 190 public void setBuilding(int trigger, boolean value) { 191 if (!isConfigurable()) 192 return; 193 if (value) 194 triggers |= maskForTrigger(trigger); 195 else 196 triggers &= ~maskForTrigger(trigger); 197 } 198 199 205 public void setConfigurable(boolean value) { 206 triggers |= MASK_CONFIG_COMPUTED; 207 if (value) 208 triggers |= MASK_CONFIGURABLE; 209 else 210 triggers = ALL_TRIGGERS; 211 } 212 213 216 public String toString() { 217 return "BuildCommand(" + getName() + ")"; } 219 } 220 | Popular Tags |