01: package org.airtodo.gui.dialog_table;
02:
03: import java.awt.Dialog;
04: import java.awt.Window;
05: import java.sql.SQLException;
06: import java.util.Map;
07: import java.util.Vector;
08:
09: import org.air.framework.core.Registry;
10: import org.air.framework.core.Utils;
11: import org.air.framework.db.DbUtilsCommon;
12: import org.air.framework.gui.dialogs.grid.AbstractGridDialog;
13: import org.air.framework.gui.dialogs.grid.IAddDeleteGridDialog;
14: import org.air.framework.gui.dialogs.grid.IOpenGridDialog;
15: import org.air.framework.gui.dialogs.input.AbstractDeleteDialog;
16: import org.air.framework.i18n.NlsRecords;
17: import org.airtodo.db.DbUtils;
18: import org.airtodo.gui.dialog_delete.NoteDeleteDialog;
19: import org.airtodo.gui.dialog_open.NoteOpenDialog;
20: import org.airtodo.headers.Note;
21: import org.airtodo.records.Initiators;
22: import org.airtodo.records.Notes;
23:
24: public class NoteGridNonSelectableDialog extends AbstractGridDialog
25: implements IAddDeleteGridDialog, IOpenGridDialog {
26: private long masterId;
27:
28: //
29: // C O N S T R U C T O R
30: //
31: public NoteGridNonSelectableDialog() {
32: super ();
33: }
34:
35: //
36: // C O N S T R U C T O R
37: //
38: public NoteGridNonSelectableDialog(Dialog owner, String title) {
39: super (owner, new Note());
40: setTitle(title + " - "
41: + NlsRecords.getTextPluralImenitelniy(Notes.class));
42: }
43:
44: //
45: // C O N S T R U C T O R
46: //
47: public NoteGridNonSelectableDialog(Dialog owner, Long id) {
48: super (owner, new Note(), id);
49: }
50:
51: @Override
52: public Vector<Map> getDataVector() throws SQLException {
53: return DbUtils.selectNotesByMasterId(masterId);
54: }
55:
56: public AbstractDeleteDialog getDeleteDialog(AbstractGridDialog owner) {
57: return new NoteDeleteDialog(owner);
58: }
59:
60: public Window getOpenDialog(
61: AbstractGridDialog abstractAddDeleteOpenDialog) {
62: return new NoteOpenDialog(abstractAddDeleteOpenDialog);
63: }
64:
65: @Override
66: public String getDialogTitle() {
67: return NlsRecords.getTextPluralImenitelniy(Notes.class);
68: }
69:
70: public int insert(Map map) throws SQLException {
71: map.put(Utils.getColumnIdentifier(Notes.MASTER_ID), masterId);
72: if (Registry.getDefaultId().containsKey(Initiators.class)) {
73: map.put(Utils.getColumnIdentifier(Notes.INITIATOR_ID),
74: Registry.getDefaultId().get(Initiators.class));
75: Map employeeMap = Registry.getDefaultMap().get(
76: Initiators.class);
77: Map initiatorMap = DbUtils
78: .convertEmployeesMapToInitiatorsMap(employeeMap);
79: map.putAll(initiatorMap);
80: }
81: return DbUtilsCommon.insert(map, Notes.class);
82: }
83:
84: public void setMasterId(long masterId) {
85: this.masterId = masterId;
86: }
87: }
|