| 1 | package de.uka.ipd.sdq.dsexplore.launch; |
| 2 | |
| 3 | import java.util.Hashtable; |
| 4 | |
| 5 | import org.eclipse.core.runtime.CoreException; |
| 6 | import org.eclipse.debug.core.ILaunchConfiguration; |
| 7 | import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; |
| 8 | import org.eclipse.swt.SWT; |
| 9 | import org.eclipse.swt.events.ModifyEvent; |
| 10 | import org.eclipse.swt.events.ModifyListener; |
| 11 | import org.eclipse.swt.events.SelectionAdapter; |
| 12 | import org.eclipse.swt.events.SelectionEvent; |
| 13 | import org.eclipse.swt.events.SelectionListener; |
| 14 | import org.eclipse.swt.layout.GridData; |
| 15 | import org.eclipse.swt.layout.GridLayout; |
| 16 | import org.eclipse.swt.widgets.Button; |
| 17 | import org.eclipse.swt.widgets.Composite; |
| 18 | import org.eclipse.swt.widgets.Group; |
| 19 | import org.eclipse.swt.widgets.Label; |
| 20 | import org.eclipse.swt.widgets.Text; |
| 21 | |
| 22 | import de.uka.ipd.sdq.workflow.launchconfig.RunConfigPlugin; |
| 23 | import de.uka.ipd.sdq.workflow.pcm.runconfig.FileNamesInputTab; |
| 24 | |
| 25 | public class TacticsTab extends FileNamesInputTab { |
| 26 | final static String TAB_NAME = "Tactics"; |
| 27 | private static final int DEFAULT_MARGIN = 15; |
| 28 | private static final int DEFAULT_HORIZONTAL_SPACING = 30; |
| 29 | private ModifyListener modifyListener; |
| 30 | |
| 31 | /* |
| 32 | * General Settings |
| 33 | */ |
| 34 | final static String GENERAL_SETTINGS_GROUP_NAME = "General Settings"; |
| 35 | final static String CONSIDER_QML_BOUNDS = "Consider QML bounds (Makes tactic application dependent of bound violations.)"; |
| 36 | final static String TACTICS_PROBABILITY = "Probability to try applying tactics when mating."; |
| 37 | |
| 38 | private Button considerQMLBoundsButton; |
| 39 | private Text tacticsProbabilityText; |
| 40 | |
| 41 | /* |
| 42 | * Reallocation Settings |
| 43 | */ |
| 44 | |
| 45 | final static String REALLOCATION_GROUP_NAME = "Reallocation Tactic"; |
| 46 | final static String USE_REALLOCATION = "Use reallocation tactic"; |
| 47 | final static String REALLOCATION_UTILISATION_DIFFERENCE = "Threshold for utilisation difference"; |
| 48 | final static String REALLOCATION_WEIGHT = "Weight of reallocation tactic"; |
| 49 | |
| 50 | private Button useReallocationButton; |
| 51 | private Text reallocationThresholdUtilisationDifference; |
| 52 | private Text reallocationWeight; |
| 53 | |
| 54 | private Label reallocationThresholdUtilisationDifferenceLabel; |
| 55 | private Label reallocationWeightLabel; |
| 56 | |
| 57 | final static boolean USE_REALLOCATION_DEFAULT = false; |
| 58 | final static double REALLOCATION_UTILISATION_DIFFERENCE_DEFAULT = 0.5; |
| 59 | final static double REALLOCATION_WEIGHT_DEFAULT = 1.0; |
| 60 | |
| 61 | /* |
| 62 | * Processing rate setting |
| 63 | */ |
| 64 | |
| 65 | final static String PROCESSING_RATE_GROUP_NAME = "Processing Rate Heuristic"; |
| 66 | final static String USE_PROCESSING_RATE = "Use processing rate tactic"; |
| 67 | final static String PROCESSING_RATE_THRESHOLD_LOW_UTILISATION = "Threshold for low utilisation"; |
| 68 | final static String PROCESSING_RATE_THRESHOLD_HIGH_UTILISATION = "Threshold for high utilisation"; |
| 69 | final static String PROCESSING_RATE_INCREASE_FACTOR = "Increase processing rate factor"; |
| 70 | final static String PROCESSING_RATE_DECREASE_FACTOR = "Decrease processing rate factor"; |
| 71 | final static String PROCESSING_RATE_WEIGHT = "Weight of processing rate tactic"; |
| 72 | |
| 73 | private Button useProcessingRateButton; |
| 74 | private Text processingRateThresholdLowUtilisation; |
| 75 | private Text processingRateThresholdHighUtilisation; |
| 76 | private Text processingRateDecreaseFactor; |
| 77 | private Text processingRateIncreaseFactor; |
| 78 | private Text processingRateWeight; |
| 79 | |
| 80 | private Label processingRateThresholdLowUtilisationLabel; |
| 81 | private Label processingRateThresholdHighUtilisationLabel; |
| 82 | private Label processingRateDecreaseFactorLabel; |
| 83 | private Label processingRateIncreaseFactorLabel; |
| 84 | private Label processingRateWeightLabel; |
| 85 | |
| 86 | final static boolean USE_PROCESSING_RATE_DEFAULT = false; |
| 87 | final static double PROCESSING_RATE_THRESHOLD_LOW_UTILISATION_DEFAULT = 0.2; |
| 88 | final static double PROCESSING_RATE_THRESHOLD_HIGH_UTILISATION_DEFAULT = 0.8; |
| 89 | final static double PROCESSING_RATE_INCREASE_FACTOR_DEFAULT = 0.25; |
| 90 | final static double PROCESSING_RATE_DECREASE_FACTOR_DEFAULT = 0.25; |
| 91 | final static double PROCESSING_RATE_WEIGHT_DEFAULT = 0.1; |
| 92 | |
| 93 | /* |
| 94 | * Server consolidation settings |
| 95 | */ |
| 96 | |
| 97 | final static String SERVER_CONSOLIDATION_GROUP_NAME = "Server Consolidation"; |
| 98 | final static String USE_SERVER_CONSOLIDATION = "Use server consolidation tactic"; |
| 99 | final static String SERVER_CONSOLIDATION_THRESHOLD_LOW_UTILISATION = "Threshold for low utilisation"; |
| 100 | final static String SERVER_CONSOLIDATION_WEIGHT = "Weight of server consolidation tactic"; |
| 101 | |
| 102 | private Button useServerConsolidationButton; |
| 103 | private Text serverConsolidationThresholdLowUtilisation; |
| 104 | private Text serverConsolidationWeight; |
| 105 | |
| 106 | private Label serverConsolidationThresholdLowUtilisationLabel; |
| 107 | private Label serverConsolidationWeightLabel; |
| 108 | |
| 109 | final static boolean USE_SERVER_CONSOLIDATION_DEFAULT = false; |
| 110 | final static double SERVER_CONSOLIDATION_THRESHOLD_LOW_UTILISATION_DEFAULT = 0.3; |
| 111 | final static double SERVER_CONSOLIDATION_WEIGHT_DEFAULT = 0.5; |
| 112 | |
| 113 | /* |
| 114 | * Server expansion settings |
| 115 | */ |
| 116 | |
| 117 | final static String SERVER_EXPANSION_GROUP_NAME = "Server expansion"; |
| 118 | final static String USE_SERVER_EXPANSION = "Use server expansion tactic"; |
| 119 | final static String SERVER_EXPANSION_THRESHOLD_HIGH_UTILISATION = "Threshold for high utilisation"; |
| 120 | final static String SERVER_EXPANSION_MAX_NUMBER_OF_REPLACEMENTS = "Maximum number of reallocations"; |
| 121 | final static String SERVER_EXPANSION_WEIGHT = "Weight of server expansion tactic"; |
| 122 | |
| 123 | private Button useServerExpansionButton; |
| 124 | private Text serverExpansionThresholdHighUtilisation; |
| 125 | private Text serverExpansionMaxNumberOfReplacements; |
| 126 | private Text serverExpansionWeight; |
| 127 | |
| 128 | private Label serverExpansionThresholdHighUtilisationLabel; |
| 129 | private Label serverExpansionMaxNumberOfReplacementsLabel; |
| 130 | private Label serverExpansionWeightLabel; |
| 131 | |
| 132 | /* Linking resource reallocation tactic*/ |
| 133 | private Button useLinkReallocationButton; |
| 134 | final static String REALLOCATION_FOR_LINK_USAGE_GROUP_NAME = "Reallocation for link usage tactic"; |
| 135 | final static String REALLOCATION_FOR_LINK_USAGE = "Use link reallocation tactic"; |
| 136 | |
| 137 | /* Antipattern settings */ |
| 138 | private Button useAntipatternsButton; |
| 139 | private static final String USE_ANTIPATTERNS = "Use antipattern knowledge"; |
| 140 | private static final String ANTIPATTERNS_GROUP_NAME = "Antipattern Detection and Solution"; |
| 141 | |
| 142 | /* defaults */ |
| 143 | final static boolean CONSIDER_QML_BOUNDS_DEFAULT = false; |
| 144 | final static boolean USE_SERVER_EXPANSION_DEFAULT = false; |
| 145 | final static double SERVER_EXPANSION_THRESHOLD_HIGH_UTILISATION_DEFAULT = 0.7; |
| 146 | final static int SERVER_EXPANSION_MAX_NUMBER_OF_REPLACEMENTS_DEFAULT = 1; |
| 147 | final static double SERVER_EXPANSION_WEIGHT_DEFAULT = 0.5; |
| 148 | |
| 149 | final static boolean USE_ANTIPATTERNS_DEFAULT = false; |
| 150 | final static boolean USE_LINK_REALLOCATION_DEFAULT = false; |
| 151 | |
| 152 | |
| 153 | |
| 154 | @Override |
| 155 | public void createControl(Composite parent) { |
| 156 | modifyListener = new ModifyListener() { |
| 157 | public void modifyText(ModifyEvent e) { |
| 158 | TacticsTab.this.setDirty(true); |
| 159 | TacticsTab.this.updateLaunchConfigurationDialog(); |
| 160 | } |
| 161 | }; |
| 162 | |
| 163 | final SelectionListener selectionListener = new SelectionListener() { |
| 164 | |
| 165 | public void widgetDefaultSelected(SelectionEvent e) { |
| 166 | TacticsTab.this.setDirty(true); |
| 167 | TacticsTab.this.updateLaunchConfigurationDialog(); |
| 168 | } |
| 169 | |
| 170 | public void widgetSelected(SelectionEvent e) { |
| 171 | TacticsTab.this.setDirty(true); |
| 172 | TacticsTab.this.updateLaunchConfigurationDialog(); |
| 173 | } |
| 174 | }; |
| 175 | |
| 176 | Composite container = new Composite(parent, SWT.NONE); |
| 177 | setControl(container); |
| 178 | container.setLayout(new GridLayout()); |
| 179 | |
| 180 | /* |
| 181 | * Consider QML bounds |
| 182 | */ |
| 183 | { |
| 184 | final Group generalSettingsGroup = new Group(container, SWT.NONE); |
| 185 | final GridLayout qmlGroupLayout = new GridLayout(); |
| 186 | qmlGroupLayout.numColumns = 4; |
| 187 | qmlGroupLayout.horizontalSpacing = DEFAULT_HORIZONTAL_SPACING; |
| 188 | qmlGroupLayout.marginHeight = DEFAULT_MARGIN; |
| 189 | qmlGroupLayout.marginWidth = DEFAULT_MARGIN; |
| 190 | generalSettingsGroup.setLayout(qmlGroupLayout); |
| 191 | generalSettingsGroup.setText(GENERAL_SETTINGS_GROUP_NAME); |
| 192 | generalSettingsGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, |
| 193 | true, false)); |
| 194 | |
| 195 | considerQMLBoundsButton = new Button(generalSettingsGroup, SWT.CHECK); |
| 196 | considerQMLBoundsButton.setEnabled(true); |
| 197 | considerQMLBoundsButton.setSelection(true); |
| 198 | considerQMLBoundsButton.setText(CONSIDER_QML_BOUNDS); |
| 199 | considerQMLBoundsButton.addSelectionListener(selectionListener); |
| 200 | |
| 201 | Label tacticsProbabilityLabel = new Label(generalSettingsGroup, SWT.NONE); |
| 202 | tacticsProbabilityLabel.setText(TACTICS_PROBABILITY); |
| 203 | |
| 204 | tacticsProbabilityText = new Text(generalSettingsGroup, SWT.SINGLE | SWT.BORDER); |
| 205 | tacticsProbabilityText.setText(""+DSEConstantsContainer.TACTICS_PROBABILITY_DEFAULT); |
| 206 | tacticsProbabilityText.addModifyListener(modifyListener); |
| 207 | } |
| 208 | |
| 209 | /* |
| 210 | * Reallocation |
| 211 | */ |
| 212 | { |
| 213 | final Group reallocationGroup = new Group(container, SWT.NONE); |
| 214 | final GridLayout reallocationGroupLayout = new GridLayout(); |
| 215 | reallocationGroupLayout.numColumns = 4; |
| 216 | reallocationGroupLayout.horizontalSpacing = DEFAULT_HORIZONTAL_SPACING; |
| 217 | reallocationGroupLayout.marginHeight = DEFAULT_MARGIN; |
| 218 | reallocationGroupLayout.marginWidth = DEFAULT_MARGIN; |
| 219 | reallocationGroup.setLayout(reallocationGroupLayout); |
| 220 | reallocationGroup.setText(REALLOCATION_GROUP_NAME); |
| 221 | reallocationGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, |
| 222 | true, false)); |
| 223 | |
| 224 | useReallocationButton = new Button(reallocationGroup, SWT.CHECK); |
| 225 | useReallocationButton.setEnabled(true); |
| 226 | useReallocationButton.setSelection(true); |
| 227 | useReallocationButton.setText(USE_REALLOCATION); |
| 228 | useReallocationButton.addSelectionListener(selectionListener); |
| 229 | useReallocationButton.addSelectionListener(new SelectionAdapter() { |
| 230 | @Override |
| 231 | public void widgetSelected(SelectionEvent e) { |
| 232 | // enable level and half-with fields if and only if check |
| 233 | // box is checked |
| 234 | updateReallocationSelection(); |
| 235 | } |
| 236 | |
| 237 | }); |
| 238 | |
| 239 | // spacer |
| 240 | new Label(reallocationGroup, SWT.NONE); |
| 241 | new Label(reallocationGroup, SWT.NONE); |
| 242 | new Label(reallocationGroup, SWT.NONE); |
| 243 | |
| 244 | reallocationThresholdUtilisationDifferenceLabel = new Label( |
| 245 | reallocationGroup, SWT.NONE); |
| 246 | reallocationThresholdUtilisationDifferenceLabel |
| 247 | .setText(REALLOCATION_UTILISATION_DIFFERENCE); |
| 248 | reallocationThresholdUtilisationDifference = new Text(reallocationGroup, |
| 249 | SWT.SINGLE | SWT.BORDER); |
| 250 | reallocationThresholdUtilisationDifference.setEnabled(true); |
| 251 | reallocationThresholdUtilisationDifference |
| 252 | .addModifyListener(modifyListener); |
| 253 | |
| 254 | reallocationWeightLabel = new Label(reallocationGroup, SWT.NONE); |
| 255 | reallocationWeightLabel.setText(REALLOCATION_WEIGHT); |
| 256 | reallocationWeight = new Text(reallocationGroup, SWT.SINGLE |
| 257 | | SWT.BORDER); |
| 258 | reallocationWeight.setEnabled(true); |
| 259 | reallocationWeight.addModifyListener(modifyListener); |
| 260 | } |
| 261 | |
| 262 | /* |
| 263 | * Processing Rate |
| 264 | */ |
| 265 | { |
| 266 | final Group processingRateGroup = new Group(container, SWT.NONE); |
| 267 | final GridLayout processingRateGroupLayout = new GridLayout(); |
| 268 | processingRateGroupLayout.numColumns = 4; |
| 269 | processingRateGroupLayout.horizontalSpacing = DEFAULT_HORIZONTAL_SPACING; |
| 270 | processingRateGroupLayout.marginHeight = DEFAULT_MARGIN; |
| 271 | processingRateGroupLayout.marginWidth = DEFAULT_MARGIN; |
| 272 | processingRateGroup.setLayout(processingRateGroupLayout); |
| 273 | processingRateGroup.setText(PROCESSING_RATE_GROUP_NAME); |
| 274 | processingRateGroup.setLayoutData(new GridData(SWT.FILL, |
| 275 | SWT.CENTER, true, false)); |
| 276 | |
| 277 | useProcessingRateButton = new Button(processingRateGroup, SWT.CHECK); |
| 278 | useProcessingRateButton.setEnabled(true); |
| 279 | useProcessingRateButton.setSelection(true); |
| 280 | useProcessingRateButton.setText(USE_PROCESSING_RATE); |
| 281 | useProcessingRateButton.addSelectionListener(selectionListener); |
| 282 | useProcessingRateButton |
| 283 | .addSelectionListener(new SelectionAdapter() { |
| 284 | @Override |
| 285 | public void widgetSelected(SelectionEvent e) { |
| 286 | // enable level and half-with fields if and only if |
| 287 | // check box is checked |
| 288 | updateProcessingRateSelection(); |
| 289 | } |
| 290 | |
| 291 | }); |
| 292 | |
| 293 | // spacer |
| 294 | new Label(processingRateGroup, SWT.NONE); |
| 295 | new Label(processingRateGroup, SWT.NONE); |
| 296 | new Label(processingRateGroup, SWT.NONE); |
| 297 | |
| 298 | processingRateThresholdHighUtilisationLabel = new Label( |
| 299 | processingRateGroup, SWT.NONE); |
| 300 | processingRateThresholdHighUtilisationLabel |
| 301 | .setText(PROCESSING_RATE_THRESHOLD_HIGH_UTILISATION); |
| 302 | processingRateThresholdHighUtilisation = new Text( |
| 303 | processingRateGroup, SWT.SINGLE | SWT.BORDER); |
| 304 | processingRateThresholdHighUtilisation.setEnabled(true); |
| 305 | processingRateThresholdHighUtilisation |
| 306 | .addModifyListener(modifyListener); |
| 307 | |
| 308 | processingRateThresholdLowUtilisationLabel = new Label( |
| 309 | processingRateGroup, SWT.NONE); |
| 310 | processingRateThresholdLowUtilisationLabel |
| 311 | .setText(PROCESSING_RATE_THRESHOLD_LOW_UTILISATION); |
| 312 | processingRateThresholdLowUtilisation = new Text( |
| 313 | processingRateGroup, SWT.SINGLE | SWT.BORDER); |
| 314 | processingRateThresholdLowUtilisation.setEnabled(true); |
| 315 | processingRateThresholdLowUtilisation |
| 316 | .addModifyListener(modifyListener); |
| 317 | |
| 318 | processingRateDecreaseFactorLabel = new Label(processingRateGroup, |
| 319 | SWT.NONE); |
| 320 | processingRateDecreaseFactorLabel |
| 321 | .setText(PROCESSING_RATE_DECREASE_FACTOR); |
| 322 | processingRateDecreaseFactor = new Text(processingRateGroup, |
| 323 | SWT.SINGLE | SWT.BORDER); |
| 324 | processingRateDecreaseFactor.setEnabled(true); |
| 325 | processingRateDecreaseFactor.addModifyListener(modifyListener); |
| 326 | |
| 327 | processingRateIncreaseFactorLabel = new Label(processingRateGroup, |
| 328 | SWT.NONE); |
| 329 | processingRateIncreaseFactorLabel |
| 330 | .setText(PROCESSING_RATE_INCREASE_FACTOR); |
| 331 | processingRateIncreaseFactor = new Text(processingRateGroup, |
| 332 | SWT.SINGLE | SWT.BORDER); |
| 333 | processingRateIncreaseFactor.setEnabled(true); |
| 334 | processingRateIncreaseFactor.addModifyListener(modifyListener); |
| 335 | |
| 336 | processingRateWeightLabel = new Label(processingRateGroup, SWT.NONE); |
| 337 | processingRateWeightLabel.setText(PROCESSING_RATE_WEIGHT); |
| 338 | processingRateWeight = new Text(processingRateGroup, SWT.SINGLE |
| 339 | | SWT.BORDER); |
| 340 | processingRateWeight.setEnabled(true); |
| 341 | processingRateWeight.addModifyListener(modifyListener); |
| 342 | } |
| 343 | |
| 344 | /* |
| 345 | * Server Consolidation |
| 346 | */ |
| 347 | { |
| 348 | final Group serverConsolidationGroup = new Group(container, |
| 349 | SWT.NONE); |
| 350 | final GridLayout serverConsolidationGroupLayout = new GridLayout(); |
| 351 | serverConsolidationGroupLayout.marginHeight = DEFAULT_MARGIN; |
| 352 | serverConsolidationGroupLayout.marginWidth = DEFAULT_MARGIN; |
| 353 | serverConsolidationGroupLayout.numColumns = 4; |
| 354 | serverConsolidationGroupLayout.horizontalSpacing = DEFAULT_HORIZONTAL_SPACING; |
| 355 | serverConsolidationGroup.setLayout(serverConsolidationGroupLayout); |
| 356 | serverConsolidationGroup.setText(SERVER_CONSOLIDATION_GROUP_NAME); |
| 357 | serverConsolidationGroup.setLayoutData(new GridData(SWT.FILL, |
| 358 | SWT.CENTER, true, false)); |
| 359 | |
| 360 | useServerConsolidationButton = new Button(serverConsolidationGroup, |
| 361 | SWT.CHECK); |
| 362 | useServerConsolidationButton.setEnabled(true); |
| 363 | useServerConsolidationButton.setSelection(true); |
| 364 | useServerConsolidationButton.setText(USE_SERVER_CONSOLIDATION); |
| 365 | useServerConsolidationButton.addSelectionListener(selectionListener); |
| 366 | useServerConsolidationButton |
| 367 | .addSelectionListener(new SelectionAdapter() { |
| 368 | @Override |
| 369 | public void widgetSelected(SelectionEvent e) { |
| 370 | // enable level and half-with fields if and only if |
| 371 | // check box is checked |
| 372 | updateServerConsolidationSelection(); |
| 373 | } |
| 374 | }); |
| 375 | |
| 376 | // spacer |
| 377 | new Label(serverConsolidationGroup, SWT.NONE); |
| 378 | new Label(serverConsolidationGroup, SWT.NONE); |
| 379 | new Label(serverConsolidationGroup, SWT.NONE); |
| 380 | |
| 381 | serverConsolidationThresholdLowUtilisationLabel = new Label( |
| 382 | serverConsolidationGroup, SWT.NONE); |
| 383 | serverConsolidationThresholdLowUtilisationLabel |
| 384 | .setText(SERVER_CONSOLIDATION_THRESHOLD_LOW_UTILISATION); |
| 385 | serverConsolidationThresholdLowUtilisation = new Text( |
| 386 | serverConsolidationGroup, SWT.SINGLE | SWT.BORDER); |
| 387 | serverConsolidationThresholdLowUtilisation.setEnabled(true); |
| 388 | serverConsolidationThresholdLowUtilisation |
| 389 | .addModifyListener(modifyListener); |
| 390 | |
| 391 | serverConsolidationWeightLabel = new Label( |
| 392 | serverConsolidationGroup, SWT.NONE); |
| 393 | serverConsolidationWeightLabel.setText(SERVER_CONSOLIDATION_WEIGHT); |
| 394 | serverConsolidationWeight = new Text(serverConsolidationGroup, |
| 395 | SWT.SINGLE | SWT.BORDER); |
| 396 | serverConsolidationWeight.setEnabled(true); |
| 397 | serverConsolidationWeight.addModifyListener(modifyListener); |
| 398 | } |
| 399 | |
| 400 | /* |
| 401 | * Server Expansion |
| 402 | */ |
| 403 | { |
| 404 | final Group serverExpansionGroup = new Group(container, SWT.NONE); |
| 405 | final GridLayout serverExpansionGroupLayout = new GridLayout(); |
| 406 | serverExpansionGroupLayout.marginHeight = DEFAULT_MARGIN; |
| 407 | serverExpansionGroupLayout.marginWidth = DEFAULT_MARGIN; |
| 408 | serverExpansionGroupLayout.numColumns = 4; |
| 409 | serverExpansionGroupLayout.horizontalSpacing = DEFAULT_HORIZONTAL_SPACING; |
| 410 | serverExpansionGroup.setLayout(serverExpansionGroupLayout); |
| 411 | serverExpansionGroup.setText(SERVER_EXPANSION_GROUP_NAME); |
| 412 | serverExpansionGroup.setLayoutData(new GridData(SWT.FILL, |
| 413 | SWT.CENTER, true, false)); |
| 414 | |
| 415 | useServerExpansionButton = new Button(serverExpansionGroup, |
| 416 | SWT.CHECK); |
| 417 | useServerExpansionButton.setEnabled(true); |
| 418 | useServerExpansionButton.setSelection(true); |
| 419 | useServerExpansionButton.setText(USE_SERVER_EXPANSION); |
| 420 | useServerExpansionButton.addSelectionListener(selectionListener); |
| 421 | useServerExpansionButton |
| 422 | .addSelectionListener(new SelectionAdapter() { |
| 423 | @Override |
| 424 | public void widgetSelected(SelectionEvent e) { |
| 425 | // enable level and half-with fields if and only if |
| 426 | // check box is |
| 427 | // checked |
| 428 | updateServerExpansionSelection(); |
| 429 | } |
| 430 | }); |
| 431 | |
| 432 | // spacer |
| 433 | new Label(serverExpansionGroup, SWT.NONE); |
| 434 | new Label(serverExpansionGroup, SWT.NONE); |
| 435 | new Label(serverExpansionGroup, SWT.NONE); |
| 436 | |
| 437 | serverExpansionThresholdHighUtilisationLabel = new Label( |
| 438 | serverExpansionGroup, SWT.NONE); |
| 439 | serverExpansionThresholdHighUtilisationLabel |
| 440 | .setText(SERVER_EXPANSION_THRESHOLD_HIGH_UTILISATION); |
| 441 | serverExpansionThresholdHighUtilisation = new Text( |
| 442 | serverExpansionGroup, SWT.SINGLE | SWT.BORDER); |
| 443 | serverExpansionThresholdHighUtilisation.setEnabled(true); |
| 444 | serverExpansionThresholdHighUtilisation |
| 445 | .addModifyListener(modifyListener); |
| 446 | |
| 447 | serverExpansionMaxNumberOfReplacementsLabel = new Label( |
| 448 | serverExpansionGroup, SWT.NONE); |
| 449 | serverExpansionMaxNumberOfReplacementsLabel |
| 450 | .setText(SERVER_EXPANSION_MAX_NUMBER_OF_REPLACEMENTS); |
| 451 | serverExpansionMaxNumberOfReplacements = new Text( |
| 452 | serverExpansionGroup, SWT.SINGLE | SWT.BORDER); |
| 453 | serverExpansionMaxNumberOfReplacements.setEnabled(true); |
| 454 | serverExpansionMaxNumberOfReplacements |
| 455 | .addModifyListener(modifyListener); |
| 456 | |
| 457 | serverExpansionWeightLabel = new Label(serverExpansionGroup, |
| 458 | SWT.NONE); |
| 459 | serverExpansionWeightLabel.setText(SERVER_EXPANSION_WEIGHT); |
| 460 | serverExpansionWeight = new Text(serverExpansionGroup, SWT.SINGLE |
| 461 | | SWT.BORDER); |
| 462 | serverExpansionWeight.setEnabled(true); |
| 463 | serverExpansionWeight.addModifyListener(modifyListener); |
| 464 | } |
| 465 | |
| 466 | { |
| 467 | // Link reallocation |
| 468 | final Group linkReallocGroup = new Group(container, SWT.NONE); |
| 469 | final GridLayout linkReallocGroupLayout = new GridLayout(); |
| 470 | linkReallocGroupLayout.marginHeight = DEFAULT_MARGIN; |
| 471 | linkReallocGroupLayout.marginWidth = DEFAULT_MARGIN; |
| 472 | linkReallocGroupLayout.numColumns = 4; |
| 473 | linkReallocGroupLayout.horizontalSpacing = DEFAULT_HORIZONTAL_SPACING; |
| 474 | linkReallocGroup.setLayout(linkReallocGroupLayout); |
| 475 | linkReallocGroup.setText(REALLOCATION_FOR_LINK_USAGE_GROUP_NAME); |
| 476 | linkReallocGroup.setLayoutData(new GridData(SWT.FILL, |
| 477 | SWT.CENTER, true, false)); |
| 478 | |
| 479 | useLinkReallocationButton = new Button(linkReallocGroup, |
| 480 | SWT.CHECK); |
| 481 | useLinkReallocationButton.setEnabled(true); |
| 482 | useLinkReallocationButton.setSelection(true); |
| 483 | useLinkReallocationButton.setText(REALLOCATION_FOR_LINK_USAGE); |
| 484 | useLinkReallocationButton.addSelectionListener(selectionListener); |
| 485 | } |
| 486 | |
| 487 | |
| 488 | { |
| 489 | /* |
| 490 | * Antipatterns |
| 491 | */ |
| 492 | final Group antipatternsGroup = new Group(container, SWT.NONE); |
| 493 | final GridLayout antipatternsGroupLayout = new GridLayout(); |
| 494 | antipatternsGroupLayout.marginHeight = DEFAULT_MARGIN; |
| 495 | antipatternsGroupLayout.marginWidth = DEFAULT_MARGIN; |
| 496 | antipatternsGroupLayout.numColumns = 4; |
| 497 | antipatternsGroupLayout.horizontalSpacing = DEFAULT_HORIZONTAL_SPACING; |
| 498 | antipatternsGroup.setLayout(antipatternsGroupLayout); |
| 499 | antipatternsGroup.setText(ANTIPATTERNS_GROUP_NAME); |
| 500 | antipatternsGroup.setLayoutData(new GridData(SWT.FILL, |
| 501 | SWT.CENTER, true, false)); |
| 502 | |
| 503 | useAntipatternsButton = new Button(antipatternsGroup, |
| 504 | SWT.CHECK); |
| 505 | useAntipatternsButton.setEnabled(true); |
| 506 | useAntipatternsButton.setSelection(true); |
| 507 | useAntipatternsButton.setText(USE_ANTIPATTERNS); |
| 508 | useAntipatternsButton.addSelectionListener(selectionListener); |
| 509 | } |
| 510 | |
| 511 | } |
| 512 | |
| 513 | @Override |
| 514 | public String getName() { |
| 515 | return TAB_NAME; |
| 516 | } |
| 517 | |
| 518 | @Override |
| 519 | public void initializeFrom(ILaunchConfiguration configuration) { |
| 520 | try { |
| 521 | considerQMLBoundsButton.setSelection(configuration.getAttribute(DSEConstantsContainer.CONSIDER_QML_BOUNDS, CONSIDER_QML_BOUNDS_DEFAULT)); |
| 522 | } catch (CoreException e) { |
| 523 | RunConfigPlugin.errorLogger(getName(), CONSIDER_QML_BOUNDS , e.getMessage()); |
| 524 | } |
| 525 | |
| 526 | try { |
| 527 | tacticsProbabilityText.setText(configuration.getAttribute(DSEConstantsContainer.TACTICS_PROBABILITY, ""+DSEConstantsContainer.TACTICS_PROBABILITY_DEFAULT )); |
| 528 | } catch (CoreException e) { |
| 529 | RunConfigPlugin.errorLogger(getName(), TACTICS_PROBABILITY , e.getMessage()); |
| 530 | } |
| 531 | |
| 532 | try { |
| 533 | useReallocationButton.setSelection(configuration.getAttribute(DSEConstantsContainer.USE_REALLOCATION, USE_REALLOCATION_DEFAULT)); |
| 534 | } catch (CoreException e) { |
| 535 | RunConfigPlugin.errorLogger(getName(), USE_REALLOCATION , e.getMessage()); |
| 536 | } |
| 537 | |
| 538 | try { |
| 539 | reallocationThresholdUtilisationDifference.setText(configuration.getAttribute(DSEConstantsContainer.REALLOCATION_UTILISATION_DIFFERENCE, "")); |
| 540 | } catch (CoreException e) { |
| 541 | RunConfigPlugin.errorLogger(getName(), REALLOCATION_UTILISATION_DIFFERENCE , e.getMessage()); |
| 542 | } |
| 543 | |
| 544 | try { |
| 545 | reallocationWeight.setText(configuration.getAttribute(DSEConstantsContainer.REALLOCATION_WEIGHT, "")); |
| 546 | } catch (CoreException e) { |
| 547 | RunConfigPlugin.errorLogger(getName(), REALLOCATION_WEIGHT , e.getMessage()); |
| 548 | } |
| 549 | |
| 550 | try { |
| 551 | useProcessingRateButton.setSelection(configuration.getAttribute(DSEConstantsContainer.USE_PROCESSING_RATE, USE_PROCESSING_RATE_DEFAULT)); |
| 552 | } catch (CoreException e) { |
| 553 | RunConfigPlugin.errorLogger(getName(), USE_PROCESSING_RATE , e.getMessage()); |
| 554 | } |
| 555 | |
| 556 | try { |
| 557 | useLinkReallocationButton.setSelection(configuration.getAttribute(DSEConstantsContainer.USE_LINK_REALLOCATION, USE_LINK_REALLOCATION_DEFAULT)); |
| 558 | } catch (CoreException e) { |
| 559 | RunConfigPlugin.errorLogger(getName(), REALLOCATION_FOR_LINK_USAGE , e.getMessage()); |
| 560 | } |
| 561 | |
| 562 | try { |
| 563 | useAntipatternsButton.setSelection(configuration.getAttribute(DSEConstantsContainer.USE_ANTIPATTERNS, USE_ANTIPATTERNS_DEFAULT)); |
| 564 | } catch (CoreException e) { |
| 565 | RunConfigPlugin.errorLogger(getName(), USE_ANTIPATTERNS , e.getMessage()); |
| 566 | } |
| 567 | |
| 568 | try { |
| 569 | processingRateDecreaseFactor.setText(configuration.getAttribute(DSEConstantsContainer.PROCESSING_RATE_DECREASE_FACTOR, "")); |
| 570 | } catch (CoreException e) { |
| 571 | RunConfigPlugin.errorLogger(getName(), PROCESSING_RATE_DECREASE_FACTOR , e.getMessage()); |
| 572 | } |
| 573 | |
| 574 | try { |
| 575 | processingRateIncreaseFactor.setText(configuration.getAttribute(DSEConstantsContainer.PROCESSING_RATE_INCREASE_FACTOR, "")); |
| 576 | } catch (CoreException e) { |
| 577 | RunConfigPlugin.errorLogger(getName(), PROCESSING_RATE_INCREASE_FACTOR , e.getMessage()); |
| 578 | } |
| 579 | |
| 580 | try { |
| 581 | processingRateThresholdHighUtilisation.setText(configuration.getAttribute(DSEConstantsContainer.PROCESSING_RATE_THRESHOLD_HIGH_UTILISATION, "")); |
| 582 | } catch (CoreException e) { |
| 583 | RunConfigPlugin.errorLogger(getName(), PROCESSING_RATE_THRESHOLD_HIGH_UTILISATION , e.getMessage()); |
| 584 | } |
| 585 | |
| 586 | try { |
| 587 | processingRateThresholdLowUtilisation.setText(configuration.getAttribute(DSEConstantsContainer.PROCESSING_RATE_THRESHOLD_LOW_UTILISATION, "")); |
| 588 | } catch (CoreException e) { |
| 589 | RunConfigPlugin.errorLogger(getName(), PROCESSING_RATE_THRESHOLD_LOW_UTILISATION , e.getMessage()); |
| 590 | } |
| 591 | |
| 592 | try { |
| 593 | processingRateWeight.setText(configuration.getAttribute(DSEConstantsContainer.PROCESSING_RATE_WEIGHT, "")); |
| 594 | } catch (CoreException e) { |
| 595 | RunConfigPlugin.errorLogger(getName(), PROCESSING_RATE_WEIGHT , e.getMessage()); |
| 596 | } |
| 597 | |
| 598 | try { |
| 599 | useServerConsolidationButton.setSelection(configuration.getAttribute(DSEConstantsContainer.USE_SERVER_CONSOLIDATION, USE_SERVER_CONSOLIDATION_DEFAULT)); |
| 600 | } catch (CoreException e) { |
| 601 | RunConfigPlugin.errorLogger(getName(), USE_SERVER_CONSOLIDATION , e.getMessage()); |
| 602 | } |
| 603 | |
| 604 | try { |
| 605 | serverConsolidationThresholdLowUtilisation.setText(configuration.getAttribute(DSEConstantsContainer.SERVER_CONSOLIDATION_THRESHOLD_LOW_UTILISATION, "")); |
| 606 | } catch (CoreException e) { |
| 607 | RunConfigPlugin.errorLogger(getName(), SERVER_CONSOLIDATION_THRESHOLD_LOW_UTILISATION , e.getMessage()); |
| 608 | } |
| 609 | |
| 610 | try { |
| 611 | serverConsolidationWeight.setText(configuration.getAttribute(DSEConstantsContainer.SERVER_CONSOLIDATION_WEIGHT, "")); |
| 612 | } catch (CoreException e) { |
| 613 | RunConfigPlugin.errorLogger(getName(), SERVER_CONSOLIDATION_WEIGHT , e.getMessage()); |
| 614 | } |
| 615 | |
| 616 | try { |
| 617 | useServerExpansionButton.setSelection(configuration.getAttribute(DSEConstantsContainer.USE_SERVER_EXPANSION, USE_SERVER_EXPANSION_DEFAULT)); |
| 618 | } catch (CoreException e) { |
| 619 | RunConfigPlugin.errorLogger(getName(), USE_SERVER_EXPANSION , e.getMessage()); |
| 620 | } |
| 621 | |
| 622 | try { |
| 623 | serverExpansionMaxNumberOfReplacements.setText(configuration.getAttribute(DSEConstantsContainer.SERVER_EXPANSION_MAX_NUMBER_OF_REPLACEMENTS, "")); |
| 624 | } catch (CoreException e) { |
| 625 | RunConfigPlugin.errorLogger(getName(), SERVER_EXPANSION_MAX_NUMBER_OF_REPLACEMENTS , e.getMessage()); |
| 626 | } |
| 627 | |
| 628 | try { |
| 629 | serverExpansionThresholdHighUtilisation.setText(configuration.getAttribute(DSEConstantsContainer.SERVER_EXPANSION_THRESHOLD_HIGH_UTILISATION, "")); |
| 630 | } catch (CoreException e) { |
| 631 | RunConfigPlugin.errorLogger(getName(), SERVER_EXPANSION_THRESHOLD_HIGH_UTILISATION , e.getMessage()); |
| 632 | } |
| 633 | |
| 634 | try { |
| 635 | serverExpansionWeight.setText(configuration.getAttribute(DSEConstantsContainer.SERVER_EXPANSION_WEIGHT, "")); |
| 636 | } catch (CoreException e) { |
| 637 | RunConfigPlugin.errorLogger(getName(), SERVER_EXPANSION_WEIGHT , e.getMessage()); |
| 638 | } |
| 639 | |
| 640 | updateSelections(); |
| 641 | } |
| 642 | |
| 643 | @Override |
| 644 | public void performApply(ILaunchConfigurationWorkingCopy configuration) { |
| 645 | configuration.setAttribute(DSEConstantsContainer.CONSIDER_QML_BOUNDS, considerQMLBoundsButton.getSelection()); |
| 646 | configuration.setAttribute(DSEConstantsContainer.TACTICS_PROBABILITY, tacticsProbabilityText.getText()); |
| 647 | |
| 648 | configuration.setAttribute(DSEConstantsContainer.USE_REALLOCATION, useReallocationButton.getSelection()); |
| 649 | configuration.setAttribute(DSEConstantsContainer.REALLOCATION_UTILISATION_DIFFERENCE, reallocationThresholdUtilisationDifference.getText()); |
| 650 | configuration.setAttribute(DSEConstantsContainer.REALLOCATION_WEIGHT, reallocationWeight.getText()); |
| 651 | |
| 652 | configuration.setAttribute(DSEConstantsContainer.USE_PROCESSING_RATE, useProcessingRateButton.getSelection()); |
| 653 | configuration.setAttribute(DSEConstantsContainer.PROCESSING_RATE_DECREASE_FACTOR, processingRateDecreaseFactor.getText()); |
| 654 | configuration.setAttribute(DSEConstantsContainer.PROCESSING_RATE_INCREASE_FACTOR, processingRateIncreaseFactor.getText()); |
| 655 | configuration.setAttribute(DSEConstantsContainer.PROCESSING_RATE_THRESHOLD_HIGH_UTILISATION, processingRateThresholdHighUtilisation.getText()); |
| 656 | configuration.setAttribute(DSEConstantsContainer.PROCESSING_RATE_THRESHOLD_LOW_UTILISATION, processingRateThresholdLowUtilisation.getText()); |
| 657 | configuration.setAttribute(DSEConstantsContainer.PROCESSING_RATE_WEIGHT, processingRateWeight.getText()); |
| 658 | |
| 659 | configuration.setAttribute(DSEConstantsContainer.USE_SERVER_CONSOLIDATION, useServerConsolidationButton.getSelection()); |
| 660 | configuration.setAttribute(DSEConstantsContainer.SERVER_CONSOLIDATION_THRESHOLD_LOW_UTILISATION, serverConsolidationThresholdLowUtilisation.getText()); |
| 661 | configuration.setAttribute(DSEConstantsContainer.SERVER_CONSOLIDATION_WEIGHT, serverConsolidationWeight.getText()); |
| 662 | |
| 663 | configuration.setAttribute(DSEConstantsContainer.USE_SERVER_EXPANSION, useServerExpansionButton.getSelection()); |
| 664 | configuration.setAttribute(DSEConstantsContainer.SERVER_EXPANSION_MAX_NUMBER_OF_REPLACEMENTS, serverExpansionMaxNumberOfReplacements.getText()); |
| 665 | configuration.setAttribute(DSEConstantsContainer.SERVER_EXPANSION_THRESHOLD_HIGH_UTILISATION, serverExpansionThresholdHighUtilisation.getText()); |
| 666 | configuration.setAttribute(DSEConstantsContainer.SERVER_EXPANSION_WEIGHT, serverExpansionWeight.getText()); |
| 667 | |
| 668 | configuration.setAttribute(DSEConstantsContainer.USE_LINK_REALLOCATION, useLinkReallocationButton.getSelection()); |
| 669 | |
| 670 | configuration.setAttribute(DSEConstantsContainer.USE_ANTIPATTERNS, useAntipatternsButton.getSelection()); |
| 671 | } |
| 672 | |
| 673 | @Override |
| 674 | public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { |
| 675 | // configuration.setAttribute(DSEConstantsContainer.THRESHOLD, "0.7"); |
| 676 | // configuration.setAttribute(DSEConstantsContainer.INCR_FACTOR, "1.1"); |
| 677 | // configuration.setAttribute( |
| 678 | // DSEConstantsContainer.INDIVIDUALS_PER_GENERATION, "3"); |
| 679 | // configuration.setAttribute(DSEConstantsContainer.DESIGN_DECISIONS_ONLY, |
| 680 | // false); |
| 681 | // configuration.setAttribute(DSEConstantsContainer.OPTIMISATION_ONLY, |
| 682 | // false); |
| 683 | |
| 684 | configuration.setAttribute(DSEConstantsContainer.USE_REALLOCATION, USE_REALLOCATION_DEFAULT); |
| 685 | configuration.setAttribute(DSEConstantsContainer.REALLOCATION_UTILISATION_DIFFERENCE, Double.toString(REALLOCATION_UTILISATION_DIFFERENCE_DEFAULT)); |
| 686 | configuration.setAttribute(DSEConstantsContainer.REALLOCATION_WEIGHT, Double.toString(REALLOCATION_WEIGHT_DEFAULT)); |
| 687 | |
| 688 | configuration.setAttribute(DSEConstantsContainer.USE_PROCESSING_RATE, USE_PROCESSING_RATE_DEFAULT); |
| 689 | configuration.setAttribute(DSEConstantsContainer.PROCESSING_RATE_DECREASE_FACTOR, Double.toString(PROCESSING_RATE_DECREASE_FACTOR_DEFAULT)); |
| 690 | configuration.setAttribute(DSEConstantsContainer.PROCESSING_RATE_INCREASE_FACTOR, Double.toString(PROCESSING_RATE_INCREASE_FACTOR_DEFAULT)); |
| 691 | configuration.setAttribute(DSEConstantsContainer.PROCESSING_RATE_THRESHOLD_HIGH_UTILISATION, Double.toString(PROCESSING_RATE_THRESHOLD_HIGH_UTILISATION_DEFAULT)); |
| 692 | configuration.setAttribute(DSEConstantsContainer.PROCESSING_RATE_THRESHOLD_LOW_UTILISATION, Double.toString(PROCESSING_RATE_THRESHOLD_LOW_UTILISATION_DEFAULT)); |
| 693 | configuration.setAttribute(DSEConstantsContainer.PROCESSING_RATE_WEIGHT, Double.toString(PROCESSING_RATE_WEIGHT_DEFAULT)); |
| 694 | |
| 695 | configuration.setAttribute(DSEConstantsContainer.USE_SERVER_CONSOLIDATION, USE_SERVER_CONSOLIDATION_DEFAULT); |
| 696 | configuration.setAttribute(DSEConstantsContainer.SERVER_CONSOLIDATION_THRESHOLD_LOW_UTILISATION, Double.toString(SERVER_CONSOLIDATION_THRESHOLD_LOW_UTILISATION_DEFAULT)); |
| 697 | configuration.setAttribute(DSEConstantsContainer.SERVER_CONSOLIDATION_WEIGHT, Double.toString(SERVER_CONSOLIDATION_WEIGHT_DEFAULT)); |
| 698 | |
| 699 | configuration.setAttribute(DSEConstantsContainer.USE_SERVER_EXPANSION, USE_SERVER_EXPANSION_DEFAULT); |
| 700 | configuration.setAttribute(DSEConstantsContainer.SERVER_EXPANSION_MAX_NUMBER_OF_REPLACEMENTS, Integer.toString(SERVER_EXPANSION_MAX_NUMBER_OF_REPLACEMENTS_DEFAULT)); |
| 701 | configuration.setAttribute(DSEConstantsContainer.SERVER_EXPANSION_THRESHOLD_HIGH_UTILISATION, Double.toString(SERVER_EXPANSION_THRESHOLD_HIGH_UTILISATION_DEFAULT)); |
| 702 | configuration.setAttribute(DSEConstantsContainer.SERVER_EXPANSION_WEIGHT, Double.toString(SERVER_EXPANSION_WEIGHT_DEFAULT)); |
| 703 | |
| 704 | configuration.setAttribute(DSEConstantsContainer.USE_ANTIPATTERNS, USE_ANTIPATTERNS_DEFAULT); |
| 705 | } |
| 706 | |
| 707 | /* |
| 708 | * (non-Javadoc) |
| 709 | * |
| 710 | * @see |
| 711 | * org.eclipse.debug.ui.AbstractLaunchConfigurationTab#isValid(org.eclipse |
| 712 | * .debug.core.ILaunchConfiguration) |
| 713 | */ |
| 714 | @Override |
| 715 | public boolean isValid(ILaunchConfiguration launchConfig) { |
| 716 | setErrorMessage(null); |
| 717 | |
| 718 | /* |
| 719 | * Check: is double? |
| 720 | */ |
| 721 | Hashtable<Text, String> valuesToCheck = new Hashtable<Text, String>(); |
| 722 | if (useProcessingRateButton.getSelection()) { |
| 723 | valuesToCheck.put(processingRateDecreaseFactor, "Processing rate: Decrease factor"); |
| 724 | valuesToCheck.put(processingRateIncreaseFactor, "Processing rate: Increase factor"); |
| 725 | } |
| 726 | for (Text text : valuesToCheck.keySet()) { |
| 727 | try { |
| 728 | Double.parseDouble(text.getText()); |
| 729 | } catch (NumberFormatException e) { |
| 730 | setErrorMessage(valuesToCheck.get(text) + " (" + text.getText() + ") must be a double value or empty."); |
| 731 | return false; |
| 732 | } |
| 733 | } |
| 734 | |
| 735 | /* |
| 736 | * Check: is int? |
| 737 | */ |
| 738 | valuesToCheck = new Hashtable<Text, String>(); |
| 739 | if (useServerExpansionButton.getSelection()) { |
| 740 | valuesToCheck.put(serverExpansionMaxNumberOfReplacements, "Server expansion: Maximum number of reallocations"); |
| 741 | } |
| 742 | for (Text text : valuesToCheck.keySet()) { |
| 743 | try { |
| 744 | Integer.parseInt(text.getText()); |
| 745 | } catch (NumberFormatException e) { |
| 746 | setErrorMessage(valuesToCheck.get(text) + " (" + text.getText() + ") must be an integer value or empty."); |
| 747 | return false; |
| 748 | } |
| 749 | } |
| 750 | |
| 751 | /* |
| 752 | * Check: is double in [0,1]? |
| 753 | */ |
| 754 | valuesToCheck = new Hashtable<Text, String>(); |
| 755 | valuesToCheck.put(tacticsProbabilityText, TACTICS_PROBABILITY); |
| 756 | |
| 757 | if (useProcessingRateButton.getSelection()) { |
| 758 | valuesToCheck.put(processingRateWeight, "Processing rate: Weight"); |
| 759 | valuesToCheck.put(processingRateThresholdLowUtilisation, "Processing rate: "+PROCESSING_RATE_THRESHOLD_LOW_UTILISATION); |
| 760 | valuesToCheck |
| 761 | .put(processingRateThresholdHighUtilisation, "Processing rate: "+PROCESSING_RATE_THRESHOLD_HIGH_UTILISATION); |
| 762 | } |
| 763 | if (useReallocationButton.getSelection()) { |
| 764 | valuesToCheck.put(reallocationWeight, "Reallocation: Weight"); |
| 765 | valuesToCheck.put(reallocationThresholdUtilisationDifference, "Reallocation: "+REALLOCATION_UTILISATION_DIFFERENCE); |
| 766 | } |
| 767 | if (useServerConsolidationButton.getSelection()) { |
| 768 | valuesToCheck.put(serverConsolidationWeight, SERVER_CONSOLIDATION_WEIGHT); |
| 769 | valuesToCheck.put(serverConsolidationThresholdLowUtilisation, |
| 770 | "Server consolidation: "+SERVER_CONSOLIDATION_THRESHOLD_LOW_UTILISATION); |
| 771 | } |
| 772 | if (useServerExpansionButton.getSelection()) { |
| 773 | valuesToCheck.put(serverExpansionWeight, "Server expansion: Weight"); |
| 774 | valuesToCheck.put(serverExpansionThresholdHighUtilisation, |
| 775 | "Server expansion: "+SERVER_EXPANSION_THRESHOLD_HIGH_UTILISATION); |
| 776 | } |
| 777 | |
| 778 | for (Text text : valuesToCheck.keySet()) { |
| 779 | try { |
| 780 | if (Double.parseDouble(text.getText()) < 0 || Double.parseDouble(text.getText()) > 1.0) { |
| 781 | throw new NumberFormatException(); |
| 782 | } |
| 783 | } catch (NumberFormatException e) { |
| 784 | setErrorMessage(valuesToCheck.get(text) + " (" + text.getText() + ") must be a double value between 0.0 and 1.0 or empty."); |
| 785 | return false; |
| 786 | } |
| 787 | } |
| 788 | |
| 789 | return true; |
| 790 | } |
| 791 | |
| 792 | @Override |
| 793 | public void activated(ILaunchConfigurationWorkingCopy workingCopy) { |
| 794 | // Leave this method empty to prevent unnecessary invocation of |
| 795 | // initializeFrom() and multiple resulting invocations of |
| 796 | // performApply(). |
| 797 | } |
| 798 | |
| 799 | @Override |
| 800 | public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) { |
| 801 | } |
| 802 | |
| 803 | private void updateSelections() { |
| 804 | updateProcessingRateSelection(); |
| 805 | updateReallocationSelection(); |
| 806 | updateServerConsolidationSelection(); |
| 807 | updateServerExpansionSelection(); |
| 808 | } |
| 809 | |
| 810 | private void updateServerConsolidationSelection() { |
| 811 | boolean selected = useServerConsolidationButton |
| 812 | .getSelection(); |
| 813 | serverConsolidationThresholdLowUtilisationLabel |
| 814 | .setEnabled(selected); |
| 815 | serverConsolidationThresholdLowUtilisation |
| 816 | .setEnabled(selected); |
| 817 | serverConsolidationWeightLabel.setEnabled(selected); |
| 818 | serverConsolidationWeight.setEnabled(selected); |
| 819 | TacticsTab.this |
| 820 | .updateLaunchConfigurationDialog(); |
| 821 | } |
| 822 | |
| 823 | /** |
| 824 | * |
| 825 | */ |
| 826 | private void updateServerExpansionSelection() { |
| 827 | boolean selected = useServerExpansionButton |
| 828 | .getSelection(); |
| 829 | serverExpansionThresholdHighUtilisationLabel |
| 830 | .setEnabled(selected); |
| 831 | serverExpansionThresholdHighUtilisation |
| 832 | .setEnabled(selected); |
| 833 | serverExpansionMaxNumberOfReplacementsLabel |
| 834 | .setEnabled(selected); |
| 835 | serverExpansionMaxNumberOfReplacements |
| 836 | .setEnabled(selected); |
| 837 | serverExpansionWeightLabel.setEnabled(selected); |
| 838 | serverExpansionWeight.setEnabled(selected); |
| 839 | TacticsTab.this |
| 840 | .updateLaunchConfigurationDialog(); |
| 841 | } |
| 842 | |
| 843 | |
| 844 | /** |
| 845 | * |
| 846 | */ |
| 847 | private void updateReallocationSelection() { |
| 848 | boolean selected = useReallocationButton.getSelection(); |
| 849 | reallocationThresholdUtilisationDifferenceLabel |
| 850 | .setEnabled(selected); |
| 851 | reallocationThresholdUtilisationDifference.setEnabled(selected); |
| 852 | reallocationWeightLabel.setEnabled(selected); |
| 853 | reallocationWeight.setEnabled(selected); |
| 854 | TacticsTab.this.updateLaunchConfigurationDialog(); |
| 855 | } |
| 856 | |
| 857 | |
| 858 | /** |
| 859 | * |
| 860 | */ |
| 861 | private void updateProcessingRateSelection() { |
| 862 | boolean selected = useProcessingRateButton |
| 863 | .getSelection(); |
| 864 | processingRateThresholdHighUtilisationLabel |
| 865 | .setEnabled(selected); |
| 866 | processingRateThresholdHighUtilisation |
| 867 | .setEnabled(selected); |
| 868 | processingRateThresholdLowUtilisationLabel |
| 869 | .setEnabled(selected); |
| 870 | processingRateThresholdLowUtilisation |
| 871 | .setEnabled(selected); |
| 872 | processingRateDecreaseFactorLabel |
| 873 | .setEnabled(selected); |
| 874 | processingRateDecreaseFactor.setEnabled(selected); |
| 875 | processingRateIncreaseFactorLabel |
| 876 | .setEnabled(selected); |
| 877 | processingRateIncreaseFactor.setEnabled(selected); |
| 878 | processingRateWeightLabel.setEnabled(selected); |
| 879 | processingRateWeight.setEnabled(selected); |
| 880 | TacticsTab.this |
| 881 | .updateLaunchConfigurationDialog(); |
| 882 | } |
| 883 | } |