package org.gemoc.gemoc_modeling_workbench.ui.launcher;

import org.gemoc.execution.engine.commons.deciders.CcslSolverDecider;
import org.gemoc.execution.engine.commons.deciders.RandomDecider;
import org.gemoc.execution.engine.commons.solvers.ccsl.CcslSolver;
import org.gemoc.execution.engine.io.views.UserDecider;
import org.gemoc.gemoc_language_workbench.api.core.ILogicalStepDecider;
import org.gemoc.gemoc_language_workbench.api.moc.Solver;

public class LogicalStepDeciderFactory {

	public static ILogicalStepDecider CreateDecider(String deciderKind, Solver solver) {
		ILogicalStepDecider decider = null;
		if (deciderKind.equals(GemocModelLauncherConfigurationConstants.DECIDER_RANDOM)) {
			decider = new RandomDecider();
		} else if (deciderKind.equals(GemocModelLauncherConfigurationConstants.DECIDER_ASKUSER)) {
			// use random as the only compatible decider
			decider = new UserDecider(false);
			
		} else if (deciderKind.equals(GemocModelLauncherConfigurationConstants.DECIDER_ASKUSER_STEP_BY_STEP)) {
			// use random as the only compatible decider
			decider = new UserDecider(true);			
		} else 	{
			if (solver instanceof CcslSolver) {
				// use solver proposition
				decider = new CcslSolverDecider((CcslSolver) solver);
			} else {
				// use random as the only compatible decider
				decider = new RandomDecider();
			}			
		}
		return decider;
	}
	
}

@@ -608,19 +608,25 @@
 null;%0A%09%09
-if 
+%0A%09%09switch
 (decider
@@ -625,32 +625,38 @@
 (deciderKind
-.equals(
+)%0A%09%09%7B%0A%09%09%09case 
 GemocModelLa
@@ -698,24 +698,22 @@
 R_RANDOM
-)) %7B
+:
 %0A%09%09%09
+%09
 decider 
@@ -741,38 +741,26 @@
 ;%0A%09%09
-%7D else if (deciderKind.equals(
+%09%09break;%0A%0A%09%09%09case 
 Gemo
@@ -815,61 +815,11 @@
 USER
-)) %7B%0A%09%09%09// use random as the only compatible decider%0A
+:%0A%09
 %09%09%09d
@@ -858,41 +858,25 @@
 %0A%09%09%09
-%0A%09%09%7D else if (deciderKind.equals(
+%09break;%0A%0A%09%09%09case 
 Gemo
@@ -944,61 +944,11 @@
 STEP
-)) %7B%0A%09%09%09// use random as the only compatible decider%0A
+:%0A%09
 %09%09%09d
@@ -988,18 +988,31 @@
 %09%0A%09%09
-%7D else %09%7B%0A
+%09%09break;%0A%0A%09%09%09default:%0A%09
 %09%09%09i
@@ -1046,24 +1046,25 @@
 lver) %7B%0A%09%09%09%09
+%09
 // use solve
@@ -1077,16 +1077,17 @@
 osition%0A
+%09
 %09%09%09%09deci
@@ -1139,16 +1139,17 @@
 er);%0A%09%09%09
+%09
 %7D else %7B
@@ -1149,16 +1149,17 @@
  else %7B%0A
+%09
 %09%09%09%09// u
@@ -1199,24 +1199,25 @@
 decider%0A%09%09%09%09
+%09
 decider = ne
@@ -1242,12 +1242,25 @@
 %0A%09%09%09
+%09
 %7D%09%09%09
+%09%0A%09%09%09%09break;
 %0A%09%09%7D

use switch instead of ifs