Source code: jmmv/progs/DiskCat/FormMovie.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 FormMovie extends Form {
36 private JTextField fIDDisk;
37 private JTextField fIDFile;
38 private JTextField fTitle;
39 private JComboBox fFormat;
40
41 private RegisterSong reg;
42 private LangTable lang_movieformats;
43
44 FormMovie() {
45 // Initialize basic data
46 reg = new RegisterSong();
47 lang_movieformats = new LangTable("lang_movieformats");
48
49 // Create form fields
50 fIDDisk = new JTextField();
51 fIDFile = new JTextField();
52 fTitle = new JTextField();
53 fFormat = (JComboBox) LangCompFactory.getComponent(lang_movieformats, LangCompFactory.JCOMBOBOX);
54
55 // Add form entries
56 addEntry(Global.getResources().getString("SONGS_MAINTAINMENT_IDDISK"), fIDDisk, true);
57 addEntry(Global.getResources().getString("SONGS_MAINTAINMENT_IDFILE"), fIDFile, false);
58 addEntry(Global.getResources().getString("SONGS_MAINTAINMENT_TITLE"), fTitle, true);
59 addEntry(Global.getResources().getString("SONGS_MAINTAINMENT_FORMAT"), fFormat, true);
60 }
61
62 protected final void showRegister() {
63 ignoreEvents = true;
64 fIDDisk.setText(new Long(reg.getIDDisk()).toString());
65 fIDFile.setText(new Long(reg.getIDFile()).toString());
66 fTitle.setText(reg.getTitle());
67 fFormat.setSelectedItem(lang_movieformats.getLocalOf(reg.getFormat()));
68 ignoreEvents = false;
69 }
70
71 public final void emptyFields() {
72 reg = new RegisterSong();
73 reg.setNewValues();
74 showRegister();
75 }
76
77 public final Register getRegister() throws InvalidDataException, SQLException {
78 reg = new RegisterSong();
79
80 if (fIDDisk.getText().equals(""))
81 throw new InvalidDataException
82 (Global.getResources().getString("SONG_INVALIDDATA_IDDISK"));
83 reg.setIDDisk(Long.parseLong(fIDDisk.getText()));
84 if (!fIDDisk.getText().equals(""))
85 reg.setIDFile(Long.parseLong(fIDFile.getText()));
86 else
87 reg.setIDFile(0);
88 reg.setTitle(fTitle.getText());
89 reg.setFormat(lang_movieformats.getDefaultOf((String) fFormat.getSelectedItem()));
90
91 return reg;
92 }
93
94 public final void setRegister(Register r) {
95 reg = (RegisterSong) r;
96 showRegister();
97 }
98 }