1 5 package com.tc; 6 7 import org.dijon.ContainerResource; 8 import org.dijon.TextField; 9 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.getContext(); 20 private TextField m_nameField; 21 private TextField m_versionField; 22 23 public AddModuleDialog() { 24 super(); 25 load(CONTEXT.topRes.findComponent("ModulesDialog")); 26 } 27 28 public void load(ContainerResource containerRes) { 29 super.load(containerRes); 30 m_nameField = (TextField) findComponent("ModuleNameField"); 31 m_versionField = (TextField) findComponent("ModuleVersionField"); 32 33 addHierarchyListener(new HierarchyListener () { 34 private volatile boolean working; 35 36 public void hierarchyChanged(HierarchyEvent he) { 37 if (working) return; 38 working = true; 39 new Thread () { 40 public void run() { 41 try { 42 Thread.sleep(400); 43 m_nameField.requestFocusInWindow(); 44 working = false; 45 } catch (Exception e) { 46 } 48 } 49 }.start(); 50 } 51 }); 52 } 53 54 public String [] prompt() { 55 reset(); 56 int option = JOptionPane.showOptionDialog(this, this, "Enter Module Information", JOptionPane.OK_CANCEL_OPTION, 57 JOptionPane.QUESTION_MESSAGE, null, null, null); 58 59 if (option == JOptionPane.OK_OPTION) { 60 String [] values = new String [2]; 61 values[0] = m_nameField.getText().trim(); 62 values[1] = m_versionField.getText().trim(); 63 if (!values[0].equals("") || !values[0].equals("")) return values; 64 } 65 return null; 66 } 67 68 private void reset() { 69 m_nameField.setText(""); 70 m_versionField.setText(""); 71 } 72 } 73
| Popular Tags
|