Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: jmmv/progs/DiskCat/FormFile.java


1   /*
2    * DiskCat - Disk Cataloguer
3    * Copyright (C) 2002 Julio Merino <slink@unixbsd.org>
4    *
5    * This program is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU General Public License as
7    * published by the Free Software Foundation; either version 2 of the
8    * License, or (at your option) any later version.
9   
10   * This program is distributed in the hope that it will be useful, but
11   * WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   * General Public License for more details.
14  
15   * You should have received a copy of the GNU General Public License
16   * along with this program; if not, write to the Free Software
17   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18   * USA
19   */
20  
21  package jmmv.progs.DiskCat;
22  
23  import jmmv.Global;
24  import jmmv.db.LangTable;
25  import jmmv.db.InvalidDataException;
26  import jmmv.db.Register;
27  import jmmv.ui.Form;
28  import jmmv.ui.LangCompFactory;
29  import jmmv.ui.DateEntry;
30  
31  import java.sql.SQLException;
32  import javax.swing.JComboBox;
33  import javax.swing.JTextField;
34  
35  final class FormFile extends Form {
36      private JTextField fIDDisk;
37      private JTextField fDirectory;
38      private JTextField fFilename;
39  
40      private RegisterFile reg;
41  
42      FormFile() {
43    // Initialize basic data
44    reg = new RegisterFile();
45  
46    // Create form fields
47    fIDDisk = new JTextField();
48    fDirectory = new JTextField();
49    fFilename = new JTextField();
50    
51    // Add form entries
52    addEntry(Global.getResources().getString("FILES_MAINTAINMENT_IDDISK"), fIDDisk, true);
53    addEntry(Global.getResources().getString("FILES_MAINTAINMENT_DIRECTORY"), fDirectory, true);
54    addEntry(Global.getResources().getString("FILES_MAINTAINMENT_FILENAME"), fFilename, true);
55      }
56  
57      protected final void showRegister() {
58    ignoreEvents = true;
59    fIDDisk.setText(new Long(reg.getIDDisk()).toString());
60    fDirectory.setText(reg.getDirectory());
61    fFilename.setText(reg.getFilename());
62    ignoreEvents = false;
63      }
64  
65      public final void emptyFields() {
66    reg = new RegisterFile();
67    reg.setNewValues();
68    showRegister();
69      }
70      
71      public final Register getRegister() throws InvalidDataException, SQLException {
72    reg = new RegisterFile();
73  
74    if (fIDDisk.getText().equals(""))
75        throw new InvalidDataException(Global.getResources().getString("PROGRAM_INVALIDDATA_IDDISK"));
76    reg.setIDDisk(Long.parseLong(fIDDisk.getText()));
77    reg.setDirectory(fDirectory.getText());
78    reg.setFilename(fFilename.getText());
79    
80    return reg;
81      }
82  
83      public final void setRegister(Register r) {
84    reg = (RegisterFile) r;
85    showRegister();
86      }
87  }