01: /*
02: $Header: /cvsroot/xorm/xorm/tools/src/org/xorm/tools/editor/MainMenu.java,v 1.3 2002/04/26 22:01:05 wbiggs Exp $
03:
04: This file is part of XORM.
05:
06: XORM is free software; you can redistribute it and/or modify
07: it under the terms of the GNU General Public License as published by
08: the Free Software Foundation; either version 2 of the License, or
09: (at your option) any later version.
10:
11: XORM is distributed in the hope that it will be useful,
12: but WITHOUT ANY WARRANTY; without even the implied warranty of
13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: GNU General Public License for more details.
15:
16: You should have received a copy of the GNU General Public License
17: along with Foobar; if not, write to the Free Software
18: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: */
20: package org.xorm.tools.editor;
21:
22: import javax.jdo.PersistenceManager;
23: import java.io.*;
24:
25: public class MainMenu extends Action {
26: public MainMenu(PersistenceManager mgr) {
27: super (mgr);
28: }
29:
30: public Object go() {
31: boolean keepGoing = true;
32: Object obj = null;
33: while (keepGoing) {
34: System.out.println("OBJECT MANAGER");
35: System.out.println("[1] Create a new object");
36: System.out.println("[2] Lookup an object by ID");
37: System.out.println("[3] Run a JDOQL query");
38: System.out.println("[X] Exit");
39: String optLine = readLine();
40: char opt = optLine.charAt(0);
41: Action action = null;
42: switch (opt) {
43: case 'X':
44: keepGoing = false;
45: break;
46: case '1':
47: action = new CreateAction(mgr);
48: break;
49: case '2':
50: action = new LookupAction(mgr);
51: break;
52: case '3':
53: action = new QueryAction(mgr);
54: break;
55: }
56: if (keepGoing)
57: obj = action.go();
58: }
59: return obj;
60: }
61: }
|