1 | package de.uka.ipd.sdq.codegen.ejb; |
2 | |
3 | import org.eclipse.core.runtime.CoreException; |
4 | import org.eclipse.debug.core.ILaunchConfiguration; |
5 | |
6 | import de.uka.ipd.sdq.workflow.launchconfig.AbstractWorkflowBasedRunConfiguration; |
7 | import de.uka.ipd.sdq.workflow.launchconfig.AbstractWorkflowConfigurationBuilder; |
8 | import de.uka.ipd.sdq.workflow.pcm.ConstantsContainer; |
9 | import de.uka.ipd.sdq.workflow.pcm.configurations.AbstractCodeGenerationWorkflowRunConfiguration.CodeGenerationAdvice; |
10 | import de.uka.ipd.sdq.workflow.pcm.runconfig.SensitivityAnalysisConfiguration; |
11 | |
12 | public class EjbCodeGenerationLaunchConfigurationBasedConfigBuilder |
13 | extends |
14 | AbstractWorkflowConfigurationBuilder { |
15 | |
16 | public EjbCodeGenerationLaunchConfigurationBasedConfigBuilder( |
17 | ILaunchConfiguration configuration, String mode) throws CoreException { |
18 | super(configuration,mode); |
19 | } |
20 | |
21 | @Override |
22 | public void fillConfiguration(AbstractWorkflowBasedRunConfiguration configuration) throws CoreException { |
23 | EjbCodeGenerationConfiguration config = (EjbCodeGenerationConfiguration) configuration; |
24 | |
25 | config.setDebug(this.isDebug); |
26 | |
27 | config.setSensitivityAnalysisEnabled( |
28 | hasValidSensitvityVariableAttribute(ConstantsContainer.VARIABLE_TEXT)); |
29 | if (config.isSensitivityAnalysisEnabled()) { |
30 | SensitivityAnalysisConfiguration sensitivityConfig = |
31 | new SensitivityAnalysisConfiguration( |
32 | "EJB Sensitivity", |
33 | getStringAttribute(ConstantsContainer.VARIABLE_TEXT), |
34 | getDoubleAttribute(ConstantsContainer.MINIMUM_TEXT), |
35 | getDoubleAttribute(ConstantsContainer.MAXIMUM_TEXT), |
36 | getDoubleAttribute(ConstantsContainer.STEP_WIDTH_TEXT)); |
37 | config.setSensitivityAnalysisConfiguration(sensitivityConfig); |
38 | } |
39 | |
40 | String modelToCodeTarget = getStringAttribute(ConstantsContainer.MODEL_TO_TEXT_CHOICE); |
41 | if (ConstantsContainer.MODEL_TO_TEXT_TARGET_PROTO.equals(modelToCodeTarget)){ |
42 | config.setCodeGenerationAdvicesFile(CodeGenerationAdvice.PROTO); |
43 | } else { |
44 | config.setCodeGenerationAdvicesFile(CodeGenerationAdvice.EJB3); |
45 | } |
46 | |
47 | |
48 | } |
49 | |
50 | private boolean hasValidSensitvityVariableAttribute(String attribute) throws CoreException { |
51 | if (!configuration.hasAttribute(attribute)) |
52 | return false; |
53 | Object value = getStringAttribute(attribute); |
54 | //Anne: I sometimes get a "NO ELEMENT SELECTED" result from the LaunchConfig even if I deleted the string from the field |
55 | //I have no idea how to fix it directly, so I need to catch it here. |
56 | //It seems to only appear in the Design Space Exploration tab. |
57 | return value instanceof String && !value.equals("") && !value.equals("NO ELEMENT SELECTED"); |
58 | } |
59 | |
60 | } |