001: package org.airtodo.gui.panel_open;
002:
003: import static org.air.framework.gui.box.Gap.small;
004:
005: import java.awt.Component;
006: import java.awt.Dialog;
007: import java.awt.event.ActionEvent;
008: import java.util.Map;
009:
010: import javax.swing.Box;
011: import javax.swing.SwingUtilities;
012:
013: import org.air.framework.core.Registry;
014: import org.air.framework.core.Utils;
015: import org.air.framework.gui.actions.basic.BasicAbstractAction;
016: import org.air.framework.gui.dialogs.grid.AbstractGridDialog;
017: import org.air.framework.gui.dialogs.input.AbstractOpenTabbedPanel;
018: import org.air.framework.gui.widgets.Button;
019: import org.air.framework.gui.widgets.WidgetTextArea;
020: import org.air.framework.gui.widgets.WidgetTextField;
021: import org.air.framework.properties.Icons;
022: import org.air.framework.records.Common;
023: import org.airtodo.gui.dialog_table.AttachmentGridNonSelectableDialog;
024: import org.airtodo.gui.dialog_table.NoteGridNonSelectableDialog;
025: import org.airtodo.gui.dialog_table.TaskGridNonSelectableDialog;
026: import org.airtodo.gui_common.actions.other.ActionAttachments;
027: import org.airtodo.gui_common.actions.other.ActionNotes;
028: import org.airtodo.records.Modules;
029:
030: public class ModulePanel extends AbstractOpenTabbedPanel {
031: //
032: private long projectId;
033:
034: private long moduleId;
035:
036: public ModulePanel() {
037: getTabGeneral().add(getWidgetTextFieldName());
038: getTabGeneral().add(getWidgetTextFieldDescription());
039: getTabGeneral().add(getWidgetTextAreaComment());
040: //
041: getButtonPanel().addAll(getButtonNotes(), small(),
042: getButtonAttachments(), small(), getButtonTasks(),
043: Box.createHorizontalGlue());
044: }
045:
046: //
047: // getButtonNotes
048: //
049: private Button buttonNotes;
050:
051: private Component getButtonNotes() {
052: if (buttonNotes == null) {
053: buttonNotes = new Button(new ActionNotes() {
054: public void actionPerformed(ActionEvent e) {
055: Dialog owner = (Dialog) SwingUtilities
056: .windowForComponent(getOwner());
057: NoteGridNonSelectableDialog dialog = new NoteGridNonSelectableDialog(
058: owner, getWidgetTextFieldName().getText());
059: dialog.setMasterId(moduleId);
060: dialog.loadAndSelect();
061: dialog.setVisible(true);
062: }
063: });
064: }
065: return buttonNotes;
066: }
067:
068: //
069: // getButtonTasks
070: //
071: private Button buttonTasks;
072:
073: private Component getButtonTasks() {
074: if (buttonTasks == null) {
075: buttonTasks = new Button(
076: new BasicAbstractAction(
077: new TaskGridNonSelectableDialog()
078: .getDialogTitle()
079: + BasicAbstractAction.ELLIPSIS,
080: Icons.TABLE) {
081: public void actionPerformed(ActionEvent e) {
082: Dialog owner = (Dialog) SwingUtilities
083: .windowForComponent(ModulePanel.this );
084: TaskGridNonSelectableDialog taskDialog = new TaskGridNonSelectableDialog(
085: owner);
086: Registry.getFilterId().put(Modules.class,
087: moduleId);
088: Map moduleMap = ((AbstractGridDialog) owner
089: .getOwner()).getTable()
090: .getSelectedRecord();
091: Registry.getFilterMap().put(Modules.class,
092: moduleMap);
093: fromGui(moduleMap);
094: taskDialog.loadAndSelect();
095: taskDialog.setVisible(true);
096: Registry.getFilterId()
097: .remove(Modules.class);
098: Registry.getFilterMap().remove(
099: Modules.class);
100: }
101: });
102: }
103: return buttonTasks;
104: }
105:
106: //
107: // getButtonAttachments
108: //
109: private Button buttonAttachments;
110:
111: private Component getButtonAttachments() {
112: if (buttonAttachments == null) {
113: buttonAttachments = new Button(new ActionAttachments() {
114: public void actionPerformed(ActionEvent e) {
115: Dialog owner = (Dialog) SwingUtilities
116: .windowForComponent(ModulePanel.this );
117: AttachmentGridNonSelectableDialog dialog = new AttachmentGridNonSelectableDialog(
118: owner, getWidgetTextFieldName().getText());
119: dialog.setMasterId(moduleId);
120: dialog.loadAndSelect();
121: dialog.setVisible(true);
122: }
123: });
124: }
125: return buttonAttachments;
126: }
127:
128: //
129: // getWidgetTextFieldName
130: //
131: private WidgetTextField widgetTextFieldName;
132:
133: private WidgetTextField getWidgetTextFieldName() {
134: if (widgetTextFieldName == null)
135: widgetTextFieldName = new WidgetTextField(Modules.NAME,
136: true);
137: return widgetTextFieldName;
138: }
139:
140: //
141: // getWidgetTextFieldDescription
142: //
143: private WidgetTextField widgetTextFieldDescription;
144:
145: private WidgetTextField getWidgetTextFieldDescription() {
146: if (widgetTextFieldDescription == null)
147: widgetTextFieldDescription = new WidgetTextField(
148: Modules.DESCRIPTION);
149: return widgetTextFieldDescription;
150: }
151:
152: //
153: // getWidgetTextAreaComment
154: //
155: private WidgetTextArea widgetTextAreaComment;
156:
157: private WidgetTextArea getWidgetTextAreaComment() {
158: if (widgetTextAreaComment == null)
159: widgetTextAreaComment = new WidgetTextArea(Modules.COMMENT);
160: return widgetTextAreaComment;
161: }
162:
163: //
164: // isFormValid
165: //
166: @Override
167: public boolean isFormValid() {
168: return getWidgetTextFieldName().isTextValid();
169: }
170:
171: @Override
172: public void fromGui(Map map) {
173: map.put(Utils.getColumnIdentifier(Modules.PROJECT_ID),
174: projectId);
175: getWidgetTextFieldName().fromGui(map);
176: getWidgetTextFieldDescription().fromGui(map);
177: getWidgetTextAreaComment().fromGui(map);
178: }
179:
180: @Override
181: public void toGui(Map map) {
182: projectId = (Long) map.get(Utils
183: .getColumnIdentifier(Modules.PROJECT_ID));
184: getWidgetTextFieldName().toGui(map);
185: getWidgetTextFieldDescription().toGui(map);
186: getWidgetTextAreaComment().toGui(map);
187: //
188: moduleId = (Long) map.get(Utils.getColumnIdentifier(Common.ID));
189: }
190: }
|