Source code: com/maddyhome/idea/vim/group/CommandGroups.java
1 package com.maddyhome.idea.vim.group;
2
3 /*
4 * IdeaVim - A Vim emulator plugin for IntelliJ Idea
5 * Copyright (C) 2003 Rick Maddy
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 */
21
22 import com.intellij.openapi.diagnostic.Logger;
23 import org.jdom.Element;
24
25 /**
26 * This singleton maintains the instances of all the key groups. All the key/action mappings get created the first
27 * this singleton is accessed.
28 */
29 public class CommandGroups
30 {
31 /**
32 * Gets the singleton instance
33 * @return The singleton instance
34 */
35 public static CommandGroups getInstance()
36 {
37 if (instance == null)
38 {
39 instance = new CommandGroups();
40 }
41
42 return instance;
43 }
44
45 /**
46 * Creates all the groups
47 */
48 private CommandGroups()
49 {
50 motion = new MotionGroup();
51 change = new ChangeGroup();
52 copy = new CopyGroup();
53 mark = new MarkGroup();
54 register = new RegisterGroup();
55 file = new FileGroup();
56 search = new SearchGroup();
57 process = new ProcessGroup();
58 macro = new MacroGroup();
59 }
60
61 /**
62 * Returns the motion group
63 * @return The motion group
64 */
65 public MotionGroup getMotion()
66 {
67 return motion;
68 }
69
70 /**
71 * Returns the change group
72 * @return The change group
73 */
74 public ChangeGroup getChange()
75 {
76 return change;
77 }
78
79 /**
80 * Returns the copy group
81 * @return The copy group
82 */
83 public CopyGroup getCopy()
84 {
85 return copy;
86 }
87
88 /**
89 * Returns the mark group
90 * @return The mark group
91 */
92 public MarkGroup getMark()
93 {
94 return mark;
95 }
96
97 /**
98 * Returns the register group
99 * @return The register group
100 */
101 public RegisterGroup getRegister()
102 {
103 return register;
104 }
105
106 /**
107 * Returns the file group
108 * @return The file group
109 */
110 public FileGroup getFile()
111 {
112 return file;
113 }
114
115 /**
116 * Returns the search group
117 * @return The search group
118 */
119 public SearchGroup getSearch()
120 {
121 return search;
122 }
123
124 /**
125 * Returns the process group
126 * @return The process group
127 */
128 public ProcessGroup getProcess()
129 {
130 return process;
131 }
132
133 /**
134 * Returns the macro group
135 * @return The macro group
136 */
137 public MacroGroup getMacro()
138 {
139 return macro;
140 }
141
142 /**
143 * Tells each group to save its data.
144 * @param element The plugin's root element
145 */
146 public void saveData(Element element)
147 {
148 motion.saveData(element);
149 change.saveData(element);
150 copy.saveData(element);
151 mark.saveData(element);
152 register.saveData(element);
153 file.saveData(element);
154 search.saveData(element);
155 process.saveData(element);
156 macro.saveData(element);
157 }
158
159 /**
160 * Tells each group to read its data.
161 * @param element The plugin's root element
162 */
163 public void readData(Element element)
164 {
165 logger.debug("readData");
166 motion.readData(element);
167 change.readData(element);
168 copy.readData(element);
169 mark.readData(element);
170 register.readData(element);
171 file.readData(element);
172 search.readData(element);
173 process.readData(element);
174 macro.readData(element);
175 }
176
177 private static CommandGroups instance;
178 private MotionGroup motion;
179 private ChangeGroup change;
180 private CopyGroup copy;
181 private MarkGroup mark;
182 private RegisterGroup register;
183 private FileGroup file;
184 private SearchGroup search;
185 private ProcessGroup process;
186 private MacroGroup macro;
187
188 private static Logger logger = Logger.getInstance(CommandGroups.class.getName());
189 }