/** * PO_DBDialog * * A custom dialog for browsing the database * User can also extend this class for specific application capabilities * * @version 1.2 April 1997 * @author Francis Chan */ import java.awt.*; import java.util.*; import java.lang.*; import java.io.*; public class PO_DBDialog extends Frame{ public static final int OPEN = 0; public static final int SAVE = 1; private List m_dirs; private List m_files; protected Vector dirVec; protected Vector fileVec; private TextField m_filter; private TextField m_selection; private String m_fileSelected; private String m_dirSelected; private Vector contentsVec; private String title; private String user; private DirObject rootDir; private int mode = OPEN; private PersistentObject pObj; /** * Constructor for PO_DBDialog * * @param title Title for the dialog box * @param contentsVec Initial Contents of the dialog box */ public PO_DBDialog(String title, Vector contentsVec) { super(title); this.title = title; this.dirVec = contentsVec; fileVec = new Vector(); setup(); } /** * Constructor for PO_DBDialog * * @param user User name */ public PO_DBDialog(String user) { setTitle("DB Browser"); this.user = user; contentsVec = new Vector(); fileVec = new Vector(); setup(); } /** * Constructor for PO_DBDialog * * @param user User name * @param mode SAVE or OPEN * @param pObj Persistent Object to be saved (if any) */ public PO_DBDialog(String user, int mode, PersistentObject pObj) { setTitle("DB Browser"); this.user = user; this.mode = mode; this.pObj = pObj; contentsVec = new Vector(); fileVec = new Vector(); setup(); } private void setup(){ dirVec = new Vector(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setFont(new Font("Courier", Font.PLAIN, 14)); setLayout(gridbag); c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; c.gridwidth = GridBagConstraints.REMAINDER; //end row makeLabel("Filter", gridbag, c); c.anchor = GridBagConstraints.CENTER; //m_filter = new TextField("/", 80); m_filter = new TextField(80); makeTextField(m_filter, gridbag, c); c.anchor = GridBagConstraints.WEST; c.gridwidth = GridBagConstraints.RELATIVE; makeLabel("Directory", gridbag, c); c.gridwidth = GridBagConstraints.REMAINDER; //end row makeLabel("Contents", gridbag, c); c.weighty = 1.0; c.gridheight = 10; c.anchor = GridBagConstraints.CENTER; c.gridwidth = GridBagConstraints.RELATIVE; m_dirs = new List(); m_files = new List(); makeList(m_dirs, gridbag, c); c.gridwidth = GridBagConstraints.REMAINDER; //end row makeList(m_files, gridbag, c); c.gridheight = 1; c.weighty = 0.0; c.anchor = GridBagConstraints.WEST; c.gridwidth = GridBagConstraints.REMAINDER; //end row makeLabel("Entry", gridbag, c); c.anchor = GridBagConstraints.CENTER; m_selection = new TextField(80); //m_selection = new TextField("/", 80); makeTextField(m_selection, gridbag, c); MyPanel p = new MyPanel(); //p.setLayout(new GridLayout(1,3,15,15)); p.setLayout(new GridLayout(1,3,15,15)); p.insets(); p.add(new Button("Open")); if (mode == SAVE) p.add(new Button("Save")); //p.add(new Button("Up")); p.add(new Button("Cancel")); c.gridheight = 20; c.gridwidth = GridBagConstraints.REMAINDER; //end row makePanel(p, gridbag, c); resize(350, 380); init(); show(); } private void init(){ rootDir = new DirObject(); rootDir.getRoot(); PO_ObjectInfo rootDir = new PO_ObjectInfo("DirObject", "root", 11); dirVec.addElement(rootDir); m_dirs.addItem("root/"); m_files.addItem(""); } /** * Assesses the information in dirVec and fileVec * to update the m_dirs and m_files list */ private void updateInfo(){ int i; PO_ObjectInfo info; m_dirs.clear(); m_files.clear(); for (i=0; i