1 package debugger.resources;
2
3 import debugger.gui.GuiFactory;
4 import debugger.gui.actions.editor.ShowRuleInfoAction;
5 import debugger.gui.resources.ResourceTree;
6 import debugger.resources.lr.LRRoot;
7 import debugger.resources.lr.LrModel;
8 import debugger.resources.pr.PRRoot;
9 import debugger.resources.pr.RuleModel;
10
11 import javax.swing.tree.TreeNode;
12 import javax.swing.tree.TreePath;
13
14
20
21 public class ResourcesFactory {
22 private static LrModel currentLrModel;
23 private static RuleModel currentRuleModel;
24 private static PRRoot prRoot;
25 private static LRRoot lrRoot;
26 private static PhaseController phaseController;
27 private static JapeFile currentJapeFile;
29 private static String currentJapeText;
30
31 public static PhaseController getPhaseController() {
32 if (phaseController == null) {
33 phaseController = new PhaseController();
34 }
35 return phaseController;
36 }
37
38 public static PRRoot getPrRoot() {
39 if (null == prRoot) {
40 prRoot = new PRRoot();
41 }
42 return prRoot;
43 }
44
45 public static void updateRoots() {
46 prRoot = null;
47 lrRoot = null;
48 }
49
50 public static LRRoot getLrRoot() {
51 if (null == lrRoot) {
52 lrRoot = new LRRoot();
53 }
54 return lrRoot;
55 }
56
57 public static RuleModel getCurrentRuleModel() {
58 return currentRuleModel;
59 }
60
61 public static void setCurrentRuleModel(RuleModel currentRuleModel) {
62 ResourcesFactory.currentRuleModel = currentRuleModel;
63 ResourceTree.PRTreeNode prtNode = GuiFactory.getResourceView().getNode(currentRuleModel);
65 TreeNode[] tn = prtNode.getPath();
66 TreePath tp = new TreePath(tn);
67 GuiFactory.getResourceView().getTree().setSelectionPath(tp);
68 GuiFactory.getResourceView().getTree().revalidate();
69 GuiFactory.getResourceView().getTree().repaint();
70 ShowRuleInfoAction.getInstance().actionPerformed(currentRuleModel);
71 }
72
73 public static void setCurrentLrModel(LrModel currentLrModel) {
74 ResourcesFactory.currentLrModel = currentLrModel;
75 }
76
77 public static LrModel getCurrentLrModel() {
78 return currentLrModel;
79 }
80
81 public static JapeFile getCurrentJapeFile() {
82 return currentJapeFile;
83 }
84
85 public static String getCurrentJapeText() {
86 return currentJapeText;
87 }
88
89 public static void setCurrentJapeText(String currentJapeText) {
90 ResourcesFactory.currentJapeText = currentJapeText;
91 }
92
93 public static void setCurrentJapeFile(JapeFile currentJapeFile) {
94 ResourcesFactory.currentJapeFile = currentJapeFile;
95 }
96 }
97