01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc;
06:
07: import org.dijon.ContainerResource;
08: import org.dijon.TextField;
09:
10: import com.tc.admin.common.XContainer;
11:
12: import java.awt.event.HierarchyEvent;
13: import java.awt.event.HierarchyListener;
14:
15: import javax.swing.JOptionPane;
16:
17: public class AddModuleDialog extends XContainer {
18:
19: private static SessionIntegratorContext CONTEXT = SessionIntegrator
20: .getContext();
21: private TextField m_nameField;
22: private TextField m_versionField;
23:
24: public AddModuleDialog() {
25: super ();
26: load(CONTEXT.topRes.findComponent("ModulesDialog"));
27: }
28:
29: public void load(ContainerResource containerRes) {
30: super .load(containerRes);
31: m_nameField = (TextField) findComponent("ModuleNameField");
32: m_versionField = (TextField) findComponent("ModuleVersionField");
33:
34: addHierarchyListener(new HierarchyListener() {
35: private volatile boolean working;
36:
37: public void hierarchyChanged(HierarchyEvent he) {
38: if (working)
39: return;
40: working = true;
41: new Thread() {
42: public void run() {
43: try {
44: Thread.sleep(400);
45: m_nameField.requestFocusInWindow();
46: working = false;
47: } catch (Exception e) {
48: // ignore
49: }
50: }
51: }.start();
52: }
53: });
54: }
55:
56: public String[] prompt() {
57: reset();
58: int option = JOptionPane.showOptionDialog(this , this ,
59: "Enter Module Information",
60: JOptionPane.OK_CANCEL_OPTION,
61: JOptionPane.QUESTION_MESSAGE, null, null, null);
62:
63: if (option == JOptionPane.OK_OPTION) {
64: String[] values = new String[2];
65: values[0] = m_nameField.getText().trim();
66: values[1] = m_versionField.getText().trim();
67: if (!values[0].equals("") || !values[0].equals(""))
68: return values;
69: }
70: return null;
71: }
72:
73: private void reset() {
74: m_nameField.setText("");
75: m_versionField.setText("");
76: }
77: }
|