1 package ch.odi.justblog.gui;
2
3 import ch.odi.justblog.gui.swing.SwingUi;
4
5 /***
6 * Creates Ui instances.
7 *
8 * @author oglueck
9 */
10 public class UiFactory {
11 public static final int SWING = 1;
12 public static final int TEST = 2;
13 public static final int CLI = 3;
14 /***
15 *
16 */
17 private UiFactory() {
18 }
19
20 /***
21 * Valid Ui names are
22 *
23 * @param name
24 * @return
25 */
26 public static Ui getUi(int ui) {
27 switch (ui) {
28 case SWING: return new SwingUi();
29 case TEST:
30 Class clazz;
31 try {
32 clazz = Class.forName("ch.odi.justblog.gui.test.TestUi");
33 return (Ui) clazz.newInstance();
34 } catch (Exception e) {
35 throw new RuntimeException("Can not find Test UI");
36 }
37
38 default: return null;
39 }
40 }
41 }