PageRenderTime 63ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 1ms

/src/mpv5/ui/dialogs/subcomponents/ControlPanel_Reminder.java

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Java | 623 lines | 468 code | 84 blank | 71 comment | 45 complexity | d8af7c7872f5bd6ec9a0462fa3ebe8f0 MD5 | raw file
Possible License(s): LGPL-3.0, Apache-2.0, GPL-3.0, GPL-2.0, AGPL-3.0, JSON, BSD-3-Clause
  1. /*
  2. * This file is part of YaBS.
  3. *
  4. * YaBS is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * YaBS is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with YaBS. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /*
  18. * GeneralListPanel.java
  19. *
  20. * Created on 03.04.2009, 15:26:37
  21. */
  22. package mpv5.ui.dialogs.subcomponents;
  23. import java.awt.Component;
  24. import mpv5.data.PropertyStore;
  25. import mpv5.ui.panels.*;
  26. import enoa.handler.TemplateHandler;
  27. import java.awt.event.ActionEvent;
  28. import java.awt.event.ActionListener;
  29. import java.io.File;
  30. import java.util.Date;
  31. import java.util.HashMap;
  32. import java.util.List;
  33. import java.util.Vector;
  34. import java.util.logging.Level;
  35. import java.util.logging.Logger;
  36. import javax.swing.DefaultListModel;
  37. import mpv5.db.common.Context;
  38. import mpv5.db.common.DatabaseObject;
  39. import mpv5.db.common.NodataFoundException;
  40. import mpv5.db.objects.Item;
  41. import mpv5.db.objects.Reminder;
  42. import mpv5.db.objects.Stage;
  43. import mpv5.db.objects.Template;
  44. import mpv5.globals.Constants;
  45. import mpv5.globals.Messages;
  46. import mpv5.handler.FormFieldsHandler;
  47. import mpv5.logging.Log;
  48. import mpv5.ui.dialogs.ControlApplet;
  49. import mpv5.ui.dialogs.DialogForFile;
  50. import mpv5.ui.dialogs.Popup;
  51. import mpv5.ui.frames.MPView;
  52. import mpv5.utils.export.Export;
  53. import mpv5.utils.export.Exportable;
  54. import mpv5.utils.files.FileDirectoryHandler;
  55. import mpv5.utils.jobs.Job;
  56. import mpv5.utils.models.MPTableModel;
  57. import mpv5.utils.numberformat.FormatNumber;
  58. import mpv5.utils.tables.Selection;
  59. /**
  60. *
  61. *
  62. */
  63. public class ControlPanel_Reminder extends javax.swing.JPanel implements DataPanel, ControlApplet {
  64. private static final long serialVersionUID = 1L;
  65. Stage dataOwner = new Stage();
  66. private java.util.ResourceBundle bundle = mpv5.i18n.LanguageManager.getBundle();
  67. /** Creates new form GeneralListPanel */
  68. public ControlPanel_Reminder() {
  69. initComponents();
  70. labeledTextField1.set_ValueClass(Double.class);
  71. labeledCombobox2.setContext(Context.getGroup());
  72. labeledCombobox2.setSearchEnabled(true);
  73. labeledCombobox2.setEditable(true);
  74. labeledCombobox2.triggerSearch();
  75. try {
  76. jTable1.setModel(new MPTableModel(Context.getStage(), jTable1));
  77. } catch (Exception e) {
  78. Log.Debug(this, e.getMessage());
  79. }
  80. }
  81. /** This method is called from within the constructor to
  82. * initialize the form.
  83. * WARNING: Do NOT modify this code. The content of this method is
  84. * always regenerated by the Form Editor.
  85. */
  86. @SuppressWarnings("unchecked")
  87. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  88. private void initComponents() {
  89. jPanel1 = new javax.swing.JPanel();
  90. jScrollPane1 = new javax.swing.JScrollPane();
  91. jTextPane1 = new javax.swing.JTextPane();
  92. labeledTextField1 = new mpv5.ui.beans.LabeledTextField();
  93. labeledCombobox2 = new mpv5.ui.beans.LabeledCombobox();
  94. jLabel1 = new javax.swing.JLabel();
  95. labeledTextField2 = new mpv5.ui.beans.LabeledTextField();
  96. jPanel2 = new javax.swing.JPanel();
  97. jButton3 = new javax.swing.JButton();
  98. jButton7 = new javax.swing.JButton();
  99. jButton8 = new javax.swing.JButton();
  100. jButton6 = new javax.swing.JButton();
  101. jButton2 = new javax.swing.JButton();
  102. jButton4 = new javax.swing.JButton();
  103. jSeparator1 = new javax.swing.JSeparator();
  104. jPanel3 = new javax.swing.JPanel();
  105. jScrollPane2 = new javax.swing.JScrollPane();
  106. jTable1 = new javax.swing.JTable();
  107. java.util.ResourceBundle bundle = mpv5.i18n.LanguageManager.getBundle(); // NOI18N
  108. setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("RemindPanel.border.title"))); // NOI18N
  109. setLayout(new java.awt.BorderLayout());
  110. jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("ControlPanel_Reminder.jPanel1.border.title"))); // NOI18N
  111. jPanel1.setName("jPanel1"); // NOI18N
  112. jScrollPane1.setName("jScrollPane1"); // NOI18N
  113. jTextPane1.setBackground(new java.awt.Color(254, 254, 254));
  114. jTextPane1.setName("jTextPane1"); // NOI18N
  115. jScrollPane1.setViewportView(jTextPane1);
  116. labeledTextField1.set_Label(bundle.getString("ControlPanel_Reminder.labeledTextField1._Label")); // NOI18N
  117. labeledTextField1.setName("labeledTextField1"); // NOI18N
  118. labeledCombobox2.set_Label(bundle.getString("ControlPanel_Reminder.labeledCombobox2._Label")); // NOI18N
  119. labeledCombobox2.setName("labeledCombobox2"); // NOI18N
  120. jLabel1.setText(bundle.getString("ControlPanel_Reminder.jLabel1.text")); // NOI18N
  121. jLabel1.setName("jLabel1"); // NOI18N
  122. labeledTextField2.set_Label(bundle.getString("ControlPanel_Reminder.labeledTextField2._Label")); // NOI18N
  123. labeledTextField2.setName("labeledTextField2"); // NOI18N
  124. javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  125. jPanel1.setLayout(jPanel1Layout);
  126. jPanel1Layout.setHorizontalGroup(
  127. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  128. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
  129. .addContainerGap()
  130. .addComponent(labeledTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  131. .addGroup(jPanel1Layout.createSequentialGroup()
  132. .addGap(2, 2, 2)
  133. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  134. .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE)
  135. .addComponent(labeledTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE)
  136. .addGroup(jPanel1Layout.createSequentialGroup()
  137. .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
  138. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  139. .addComponent(labeledCombobox2, javax.swing.GroupLayout.PREFERRED_SIZE, 227, javax.swing.GroupLayout.PREFERRED_SIZE))))
  140. );
  141. jPanel1Layout.setVerticalGroup(
  142. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  143. .addGroup(jPanel1Layout.createSequentialGroup()
  144. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
  145. .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
  146. .addComponent(labeledCombobox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  147. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  148. .addComponent(labeledTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  149. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  150. .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE)
  151. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  152. .addComponent(labeledTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  153. );
  154. add(jPanel1, java.awt.BorderLayout.EAST);
  155. jPanel2.setBackground(new java.awt.Color(255, 255, 255));
  156. jPanel2.setName("jPanel2"); // NOI18N
  157. jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
  158. jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/22/view_text.png"))); // NOI18N
  159. jButton3.setText(bundle.getString("ControlPanel_Reminder.jButton3.text")); // NOI18N
  160. jButton3.setFocusable(false);
  161. jButton3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  162. jButton3.setName("jButton3"); // NOI18N
  163. jButton3.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
  164. jButton3.addActionListener(new java.awt.event.ActionListener() {
  165. public void actionPerformed(java.awt.event.ActionEvent evt) {
  166. jButton3ActionPerformed(evt);
  167. }
  168. });
  169. jPanel2.add(jButton3);
  170. jButton7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/22/mimetypes/pdf.png"))); // NOI18N
  171. jButton7.setText(bundle.getString("ControlPanel_Reminder.jButton7.text")); // NOI18N
  172. jButton7.setFocusable(false);
  173. jButton7.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  174. jButton7.setName("jButton7"); // NOI18N
  175. jButton7.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
  176. jButton7.addActionListener(new java.awt.event.ActionListener() {
  177. public void actionPerformed(java.awt.event.ActionEvent evt) {
  178. jButton7ActionPerformed(evt);
  179. }
  180. });
  181. jPanel2.add(jButton7);
  182. jButton8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/22/mimetypes/odt.png"))); // NOI18N
  183. jButton8.setText(bundle.getString("ControlPanel_Reminder.jButton8.text")); // NOI18N
  184. jButton8.setFocusable(false);
  185. jButton8.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  186. jButton8.setName("jButton8"); // NOI18N
  187. jButton8.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
  188. jButton8.addActionListener(new java.awt.event.ActionListener() {
  189. public void actionPerformed(java.awt.event.ActionEvent evt) {
  190. jButton8ActionPerformed(evt);
  191. }
  192. });
  193. jPanel2.add(jButton8);
  194. jButton6.setText(bundle.getString("ControlPanel_Reminder.jButton6.text")); // NOI18N
  195. jButton6.setName("jButton6"); // NOI18N
  196. jButton6.addActionListener(new java.awt.event.ActionListener() {
  197. public void actionPerformed(java.awt.event.ActionEvent evt) {
  198. jButton6ActionPerformed(evt);
  199. }
  200. });
  201. jPanel2.add(jButton6);
  202. jButton2.setText(bundle.getString("ControlPanel_Reminder.jButton2.text")); // NOI18N
  203. jButton2.setName("jButton2"); // NOI18N
  204. jButton2.addActionListener(new java.awt.event.ActionListener() {
  205. public void actionPerformed(java.awt.event.ActionEvent evt) {
  206. jButton2ActionPerformed(evt);
  207. }
  208. });
  209. jPanel2.add(jButton2);
  210. jButton4.setText(bundle.getString("ControlPanel_Reminder.jButton4.text")); // NOI18N
  211. jButton4.setName("jButton4"); // NOI18N
  212. jButton4.addActionListener(new java.awt.event.ActionListener() {
  213. public void actionPerformed(java.awt.event.ActionEvent evt) {
  214. jButton4ActionPerformed(evt);
  215. }
  216. });
  217. jPanel2.add(jButton4);
  218. jSeparator1.setName("jSeparator1"); // NOI18N
  219. jPanel2.add(jSeparator1);
  220. add(jPanel2, java.awt.BorderLayout.PAGE_END);
  221. jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("ControlPanel_Reminder.jPanel3.border.title"))); // NOI18N
  222. jPanel3.setName("jPanel3"); // NOI18N
  223. jPanel3.setLayout(new java.awt.BorderLayout());
  224. jScrollPane2.setName("jScrollPane2"); // NOI18N
  225. jTable1.setModel(new javax.swing.table.DefaultTableModel(
  226. new Object [][] {
  227. },
  228. new String [] {
  229. }
  230. ));
  231. jTable1.setName("jTable1"); // NOI18N
  232. jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
  233. public void mouseClicked(java.awt.event.MouseEvent evt) {
  234. jTable1MouseClicked(evt);
  235. }
  236. });
  237. jScrollPane2.setViewportView(jTable1);
  238. jPanel3.add(jScrollPane2, java.awt.BorderLayout.CENTER);
  239. add(jPanel3, java.awt.BorderLayout.CENTER);
  240. }// </editor-fold>//GEN-END:initComponents
  241. private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
  242. String msg = Popup.Enter_Value(Messages.ENTER_A_DESCRIPTION);
  243. if (msg != null) {
  244. Stage s = new Stage();
  245. s.setCname(msg);
  246. s.setGroupsids(mpv5.db.objects.User.getCurrentUser().__getGroupsids());
  247. s.setDescription(jTextPane1.getText());
  248. s.setExtravalue(FormatNumber.parseDezimal(labeledTextField1.getText()).doubleValue());
  249. if (labeledCombobox2.getSelectedItem() != null) {
  250. s.setTemplategroup(Integer.valueOf(labeledCombobox2.getSelectedItem().getId()));
  251. }
  252. s.save();
  253. }
  254. }//GEN-LAST:event_jButton4ActionPerformed
  255. private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
  256. dataOwner.delete();
  257. }//GEN-LAST:event_jButton6ActionPerformed
  258. private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
  259. int group = 1;
  260. PreviewPanel pr;
  261. if (dataOwner != null && dataOwner.isExisting()) {
  262. if (labeledCombobox2.getSelectedItem() != null) {
  263. group = Integer.valueOf(labeledCombobox2.getSelectedItem().getId());
  264. }
  265. Template t = TemplateHandler.loadTemplate(group, Constants.TYPE_REMINDER);
  266. if (t != null) {
  267. Exportable te = TemplateHandler.loadTemplate(group, Constants.TYPE_REMINDER).getExFile();
  268. HashMap<String, Object> hm1 = new FormFieldsHandler(dataOwner).getFormattedFormFields(null);
  269. File f2 = FileDirectoryHandler.getTempFile("pdf");
  270. Export ex = new Export(t);
  271. ex.putAll(hm1);
  272. ex.setTemplate(te);
  273. ex.setTargetFile(f2);
  274. // try {
  275. // Stage g = (Stage) DatabaseObject.getObject(Context.getStage(), dataOwner.__getStagesids());
  276. // ex.put("reminder.stage", g.__getCname());
  277. // } catch (NodataFoundException ex1) {
  278. // Log.Debug(ex1);
  279. // }
  280. // try {
  281. // Item i = (Item) DatabaseObject.getObject(Context.getItem(), dataOwner.__getItemsids());
  282. // ex.put("reminder.count", Reminder.getRemindersOf(i).size());
  283. // } catch (NodataFoundException nodataFoundException) {
  284. // Log.Debug(nodataFoundException);
  285. // }
  286. pr = new PreviewPanel();
  287. pr.setDataOwner(dataOwner);
  288. new Job(ex, pr).execute();
  289. } else {
  290. Popup.notice(Messages.NO_TEMPLATE_DEFINDED);
  291. }
  292. }
  293. }//GEN-LAST:event_jButton3ActionPerformed
  294. private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
  295. int group = 1;
  296. if (dataOwner != null && dataOwner.isExisting()) {
  297. if (labeledCombobox2.getSelectedItem() != null) {
  298. group = Integer.valueOf(labeledCombobox2.getSelectedItem().getId());
  299. }
  300. Template t = TemplateHandler.loadTemplate(group, Constants.TYPE_REMINDER);
  301. if (t != null) {
  302. Exportable te = TemplateHandler.loadTemplate(group, Constants.TYPE_REMINDER).getExFile();
  303. HashMap<String, Object> hm1 = new HashMap<String, Object>();
  304. File f2 = FileDirectoryHandler.getTempFile("pdf");
  305. // try {
  306. // Stage g = (Stage) DatabaseObject.getObject(Context.getStage(), dataOwner.__getStagesids());
  307. // hm1.put("reminder.stage", g.__getCname());
  308. // } catch (NodataFoundException ex1) {
  309. // Log.Debug(ex1);
  310. // }
  311. // try {
  312. // Item i = (Item) DatabaseObject.getObject(Context.getItem(), dataOwner.__getItemsids());
  313. // hm1.put("reminder.count", Reminder.getRemindersOf(i).size());
  314. // } catch (NodataFoundException nodataFoundException) {
  315. // Log.Debug(nodataFoundException);
  316. // }
  317. new Job(Export.createFile(dataOwner.__getCname(), t, dataOwner, hm1), new DialogForFile(DialogForFile.FILES_ONLY, dataOwner.__getCname())).execute();
  318. } else {
  319. Popup.notice(Messages.NO_TEMPLATE_DEFINDED);
  320. }
  321. }
  322. }//GEN-LAST:event_jButton7ActionPerformed
  323. private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
  324. int group = 1;
  325. PreviewPanel pr;
  326. if (dataOwner != null && dataOwner.isExisting()) {
  327. if (labeledCombobox2.getSelectedItem() != null) {
  328. group = Integer.valueOf(labeledCombobox2.getSelectedItem().getId());
  329. }
  330. Template t = TemplateHandler.loadTemplate(group, Constants.TYPE_REMINDER);
  331. if (t != null) {
  332. Exportable te = TemplateHandler.loadTemplate(group, Constants.TYPE_REMINDER).getExFile();
  333. HashMap<String, Object> hm1 = new HashMap<String, Object>();
  334. File f2 = FileDirectoryHandler.getTempFile("odt");
  335. //
  336. // try {
  337. // Stage g = (Stage) DatabaseObject.getObject(Context.getStage(), dataOwner.__getStagesids());
  338. // hm1.put("reminder.stage", g.__getCname());
  339. // } catch (NodataFoundException ex1) {
  340. // Log.Debug(ex1);
  341. // }
  342. // try {
  343. // Item i = (Item) DatabaseObject.getObject(Context.getItem(), dataOwner.__getItemsids());
  344. // hm1.put("reminder.count", Reminder.getRemindersOf(i).size());
  345. // } catch (NodataFoundException nodataFoundException) {
  346. // Log.Debug(nodataFoundException);
  347. // }
  348. new Job(Export.sourceFile(dataOwner.__getCname(), t, dataOwner, hm1), new DialogForFile(DialogForFile.FILES_ONLY, dataOwner.__getCname())).execute();
  349. } else {
  350. Popup.notice(Messages.NO_TEMPLATE_DEFINDED);
  351. }
  352. }
  353. }//GEN-LAST:event_jButton8ActionPerformed
  354. private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
  355. if (dataOwner != null) {
  356. DatabaseObject dato = dataOwner;
  357. dato.getPanelData(this);
  358. if (dato.save()) {
  359. } else {
  360. showRequiredFields();
  361. }
  362. }
  363. }//GEN-LAST:event_jButton2ActionPerformed
  364. private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
  365. Selection s = new Selection(jTable1);
  366. if (s.checkID()) {
  367. try {
  368. setDataOwner(DatabaseObject.getObject(Context.getStage(), s.getId()), true);
  369. } catch (NodataFoundException ex) {
  370. }
  371. }
  372. }//GEN-LAST:event_jTable1MouseClicked
  373. // Variables declaration - do not modify//GEN-BEGIN:variables
  374. private javax.swing.JButton jButton2;
  375. private javax.swing.JButton jButton3;
  376. private javax.swing.JButton jButton4;
  377. private javax.swing.JButton jButton6;
  378. private javax.swing.JButton jButton7;
  379. private javax.swing.JButton jButton8;
  380. private javax.swing.JLabel jLabel1;
  381. private javax.swing.JPanel jPanel1;
  382. private javax.swing.JPanel jPanel2;
  383. private javax.swing.JPanel jPanel3;
  384. private javax.swing.JScrollPane jScrollPane1;
  385. private javax.swing.JScrollPane jScrollPane2;
  386. private javax.swing.JSeparator jSeparator1;
  387. private javax.swing.JTable jTable1;
  388. private javax.swing.JTextPane jTextPane1;
  389. private mpv5.ui.beans.LabeledCombobox labeledCombobox2;
  390. private mpv5.ui.beans.LabeledTextField labeledTextField1;
  391. private mpv5.ui.beans.LabeledTextField labeledTextField2;
  392. // End of variables declaration//GEN-END:variables
  393. private double extravalue_;
  394. public String cname_;
  395. public String description_;
  396. public int intaddedby_;
  397. public int ids_;
  398. public Date dateadded_;
  399. public int groupsids_ = 1;
  400. public int templategroup_;
  401. public boolean save() {
  402. Selection sel = new Selection(jTable1);
  403. if (sel.checkID()) {
  404. try {
  405. Stage s = null;
  406. try {
  407. s = (Stage) DatabaseObject.getObject(Context.getStage(), sel.getId());
  408. } catch (Exception nodataFoundException) {
  409. String msg = Popup.Enter_Value(Messages.ENTER_A_DESCRIPTION);
  410. if (msg == null) {
  411. msg = "autogenerated stage";
  412. }
  413. s = new Stage();
  414. s.setCname(msg);
  415. s.setGroupsids(mpv5.db.objects.User.getCurrentUser().__getGroupsids());
  416. s.setDescription(jTextPane1.getText());
  417. try {
  418. s.setExtravalue(labeledTextField1.getValue(0d));
  419. } catch (NumberFormatException numberFormatException) {
  420. s.setExtravalue(0d);
  421. }
  422. s.save();
  423. }
  424. dataOwner.setDescription(jTextPane1.getText());
  425. try {
  426. dataOwner.setExtravalue(Double.valueOf(labeledTextField1.getText()));
  427. } catch (NumberFormatException numberFormatException) {
  428. dataOwner.setExtravalue(0d);
  429. }
  430. } catch (Exception ex) {
  431. Log.Debug(this, ex);
  432. return false;
  433. }
  434. }
  435. return true;
  436. }
  437. private void refresh(Item bill) {
  438. if (bill != null) {
  439. DefaultListModel d = new DefaultListModel();
  440. List<Reminder> data = Reminder.getRemindersOf(bill);
  441. for (int i = 0; i < data.size(); i++) {
  442. Reminder reminder = data.get(i);
  443. d.addElement(reminder);
  444. }
  445. } else {
  446. }
  447. }
  448. private void expose(Stage r) {
  449. dataOwner = r;
  450. try {
  451. labeledCombobox2.setModel(Item.getObject(Context.getGroup(), r.__getGroupsids()));
  452. } catch (NodataFoundException ex) {
  453. }
  454. labeledTextField1.setText(r.__getExtravalue());
  455. jTextPane1.setText(r.__getDescription());
  456. labeledTextField2.setText(r.__getCname());
  457. }
  458. @Override
  459. public boolean collectData() {
  460. try {
  461. extravalue_ = labeledTextField1.getValue(0d);
  462. cname_ = labeledTextField2.getText(true, Messages.NAME.getValue());
  463. description_ = jTextPane1.getText();
  464. if (labeledCombobox2.getSelectedItem() != null) {
  465. templategroup_ = (Integer.valueOf(labeledCombobox2.getSelectedItem().getId()));
  466. } else {
  467. templategroup_ = 1;
  468. }
  469. } catch (Exception exception) {
  470. return false;
  471. }
  472. return false;
  473. }
  474. @Override
  475. public DatabaseObject getDataOwner() {
  476. return dataOwner;
  477. }
  478. @Override
  479. public void setDataOwner(DatabaseObject object, boolean populateData) {
  480. dataOwner = (Stage) object;
  481. if (populateData) {
  482. expose(dataOwner);
  483. }
  484. }
  485. @Override
  486. public void refresh() {
  487. refresh(null);
  488. }
  489. @Override
  490. public void exposeData() {
  491. expose(dataOwner);
  492. }
  493. @Override
  494. public void paste(DatabaseObject... dbo) {
  495. if (dbo.length > 0) {
  496. setDataOwner(dbo[0], true);
  497. }
  498. }
  499. @Override
  500. public void showRequiredFields() {
  501. }
  502. @Override
  503. public void showSearchBar(boolean show) {
  504. }
  505. @Override
  506. public void actionAfterSave() {
  507. }
  508. @Override
  509. public void actionAfterCreate() {
  510. }
  511. @Override
  512. public void actionBeforeCreate() {
  513. }
  514. @Override
  515. public void actionBeforeSave() throws ChangeNotApprovedException {
  516. }
  517. @Override
  518. public void mail() {
  519. }
  520. @Override
  521. public void print() {
  522. }
  523. @Override
  524. public Component getAndRemoveActionPanel() {
  525. this.remove(jPanel2);
  526. validate();
  527. return jPanel2;
  528. }
  529. @Override
  530. public void setValues(PropertyStore values) {
  531. }
  532. @Override
  533. public String getUname() {
  534. return "Stages";
  535. }
  536. @Override
  537. public void reset() {
  538. }
  539. }