01: /*
02: * $Author$
03: * $Id$
04: * This is free software, as software should be; you can redistribute
05: * it and/or modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08:
09: * See LICENSE.txt for the full license covering this software/program/code.
10: */
11:
12: package isql.commands;
13:
14: import isql.Command;
15: import util.PerlWrapper;
16: import isql.SQLForm;
17: import javax.swing.JTextArea;
18: import java.awt.Font;
19:
20: /**
21: * Class documentation.
22: * @author rahul kumar <rahul_kumar@yahoo.com>
23: * @see XXX
24: */
25:
26: public class SetCommand implements Command {
27:
28: /** ctor/constructor.
29: */
30: public SetCommand() {
31: }
32:
33: public String[] getCommandList() {
34: return commands;
35: }
36:
37: public void execute(SQLForm form, String command, String line) {
38: _form = form;
39: _form.setErrorArea('\n' + processSet(line));
40:
41: }
42:
43: private String processSet(String command) {
44: String[] result = PerlWrapper.perlMatch(
45: "set\\s+(\\w+)\\s+(.*)", command);
46: String value = null;
47: String option = null;
48: if (result != null) {
49: if (result.length == 2) {
50: option = result[0];
51: value = result[1];
52: } else
53: return usage;
54: } else
55: return usage;
56: _form.setAttribute(option, value);
57: if ("on".equalsIgnoreCase((String) _form
58: .getAttribute("verbose"))) {
59: System.out.println("set " + option + " to " + value);
60: }
61: if (option.equals("font")) {
62: // we get the selected component but that is a scrollpane,
63: // we need the jtetarea or jtable underlying.
64: /*
65: JScrollPane jsp = (JScrollPane) tp.getTabbedPane().getSelectedComponent();
66: Component c1[] = jsp.getComponents();
67: for( int i = 0; i < c1.length; i++ )
68: System.out.println( "C1:"+i+":"+c1.getName()+":");
69: */
70: JTextArea jta = (JTextArea) _form.tp.getActualComponent(1);
71: jta.setFont(new Font(value, Font.PLAIN, 12));
72:
73: }
74: if (option.equals("target")) {
75: _form.myjdbc.setVendorSpecificConfigurations(value);
76: }
77: return ("set " + option + " to (" + value + ')');
78: }
79:
80: public String getUsage(String s) {
81: return usage;
82: }
83:
84: String commands[] = { "set" };
85: SQLForm _form;
86:
87: final String usage = "set <option> <value>";
88:
89: ////// START INSTANCE VARIABLES //////
90:
91: ////// START CONSTANTS AND CLASS LEVEL VARIABLES //////
92: static final String P = "SetCommand"; // used in exception strings
93:
94: } // end of class
|