PageRenderTime 147ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/src/mpv5/ui/toolbars/DataPanelTB.java

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Java | 657 lines | 512 code | 72 blank | 73 comment | 72 complexity | f71333c6d9ce73c1bd20aef96b1c5127 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. * ContactsTB.java
  19. *
  20. * Created on 25.01.2009, 16:54:29
  21. */
  22. package mpv5.ui.toolbars;
  23. import java.awt.Color;
  24. import java.awt.Component;
  25. import java.awt.event.ActionListener;
  26. import java.awt.event.ItemListener;
  27. import mpv5.db.common.Context;
  28. import mpv5.db.common.DatabaseObject;
  29. import mpv5.db.common.QueryHandler;
  30. import mpv5.globals.Messages;
  31. import mpv5.db.objects.Favourite;
  32. import mpv5.logging.Log;
  33. import mpv5.ui.dialogs.Popup;
  34. import mpv5.ui.frames.MPView;
  35. import mpv5.ui.panels.ChangeNotApprovedException;
  36. import mpv5.ui.panels.DataPanel;
  37. import mpv5.ui.panels.ExportablePanel;
  38. /**
  39. *
  40. *
  41. */
  42. public class DataPanelTB extends javax.swing.JPanel implements ActionListener, ItemListener {
  43. private static final long serialVersionUID = -8215471082724735228L;
  44. private DataPanel parents;
  45. private final ActionListener action1 = new java.awt.event.ActionListener() {
  46. public void actionPerformed(java.awt.event.ActionEvent evt) {
  47. favAdd(evt);
  48. }
  49. };
  50. private final ActionListener action2 = new java.awt.event.ActionListener() {
  51. public void actionPerformed(java.awt.event.ActionEvent evt) {
  52. favRemover(evt);
  53. }
  54. };
  55. /**
  56. *
  57. * @param panel
  58. */
  59. public DataPanelTB(DataPanel panel) {
  60. initComponents();
  61. parents = panel;
  62. parents.showSearchBar(mpv5.db.objects.User.getCurrentUser().getProperties().getProperty(this, "jToggleButton1"));
  63. but1.setSelected(mpv5.db.objects.User.getCurrentUser().getProperties().getProperty(this, "jToggleButton1"));
  64. but6.setEnabled(!DatabaseObject.isAutoLockEnabled());
  65. if (!(parents instanceof ExportablePanel)) {
  66. commonActionsToolbar.remove(odtButton);
  67. commonActionsToolbar.remove(pdfButton);
  68. commonActionsToolbar.validate();
  69. }
  70. }
  71. /**
  72. * Disable the button with the given number (from left to right)
  73. * @param button
  74. */
  75. public void disableButton(int button) {
  76. Component[] c = commonActionsToolbar.getComponents();
  77. for (int i = 0; i < c.length; i++) {
  78. Component component = c[i];
  79. if (component.getName().equals("but" + button)) {
  80. (component).setEnabled(false);
  81. }
  82. }
  83. }
  84. /**
  85. *
  86. * @param on
  87. */
  88. public void setEditable(boolean on) {
  89. but3.setEnabled(on);
  90. but5.setEnabled(on);
  91. but6.setEnabled(on);
  92. }
  93. /**
  94. *
  95. * @param favourite
  96. */
  97. public void setFavourite(boolean favourite) {
  98. if (!favourite) {
  99. but7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bookmark_add.png"))); // NOI18N
  100. but7.setFocusable(false);
  101. but7.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  102. but7.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
  103. but7.removeActionListener(action2);
  104. but7.removeActionListener(action1);
  105. but7.addActionListener(action1);
  106. } else {
  107. but7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bookmark.png"))); // NOI18N
  108. but7.setFocusable(false);
  109. but7.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  110. but7.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
  111. but7.removeActionListener(action1);
  112. but7.removeActionListener(action2);
  113. but7.addActionListener(action2);
  114. }
  115. this.validate();
  116. }
  117. /** This method is called from within the constructor to
  118. * initialize the form.
  119. * WARNING: Do NOT modify this code. The content of this method is
  120. * always regenerated by the Form Editor.
  121. */
  122. @SuppressWarnings("unchecked")
  123. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  124. private void initComponents() {
  125. commonActionsToolbar = new javax.swing.JToolBar();
  126. but1 = new javax.swing.JToggleButton();
  127. jSeparator4 = new javax.swing.JToolBar.Separator();
  128. but2 = new javax.swing.JButton();
  129. but3 = new javax.swing.JButton();
  130. but4 = new javax.swing.JButton();
  131. jSeparator1 = new javax.swing.JToolBar.Separator();
  132. but5 = new javax.swing.JButton();
  133. jSeparator3 = new javax.swing.JToolBar.Separator();
  134. but6 = new javax.swing.JButton();
  135. but7 = new javax.swing.JButton();
  136. but10 = new javax.swing.JButton();
  137. jSeparator2 = new javax.swing.JToolBar.Separator();
  138. printButton = new javax.swing.JButton();
  139. mailButton = new javax.swing.JButton();
  140. pdfButton = new javax.swing.JButton();
  141. odtButton = new javax.swing.JButton();
  142. setName("Form"); // NOI18N
  143. commonActionsToolbar.setFloatable(false);
  144. commonActionsToolbar.setRollover(true);
  145. commonActionsToolbar.setName("commonActionsToolbar"); // NOI18N
  146. commonActionsToolbar.setPreferredSize(new java.awt.Dimension(342, 41));
  147. but1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/viewmag.png"))); // NOI18N
  148. java.util.ResourceBundle bundle = mpv5.i18n.LanguageManager.getBundle(); // NOI18N
  149. but1.setText(bundle.getString("DataPanelTB.but1.text")); // NOI18N
  150. but1.setToolTipText(bundle.getString("DataPanelTB.but1.toolTipText")); // NOI18N
  151. but1.setContentAreaFilled(false);
  152. but1.setFocusable(false);
  153. but1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  154. but1.setName("but1"); // NOI18N
  155. but1.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bright_viewmag.png"))); // NOI18N
  156. but1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
  157. but1.addItemListener(this);
  158. but1.addActionListener(this);
  159. commonActionsToolbar.add(but1);
  160. jSeparator4.setName("jSeparator4"); // NOI18N
  161. commonActionsToolbar.add(jSeparator4);
  162. but2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/revert.png"))); // NOI18N
  163. but2.setText(bundle.getString("MPV5View.jButton22.text")); // NOI18N
  164. but2.setToolTipText(bundle.getString("MPV5View.jButton22.toolTipText")); // NOI18N
  165. but2.setContentAreaFilled(false);
  166. but2.setFocusable(false);
  167. but2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  168. but2.setName("but2"); // NOI18N
  169. but2.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
  170. but2.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bright_revert.png"))); // NOI18N
  171. but2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
  172. but2.addActionListener(this);
  173. commonActionsToolbar.add(but2);
  174. but3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/3floppy_unmount.png"))); // NOI18N
  175. but3.setText(bundle.getString("MPV5View.jButton25.text")); // NOI18N
  176. but3.setToolTipText(bundle.getString("MPV5View.jButton25.toolTipText")); // NOI18N
  177. but3.setContentAreaFilled(false);
  178. but3.setFocusable(false);
  179. but3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  180. but3.setName("but3"); // NOI18N
  181. but3.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
  182. but3.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bright_3floppy_unmount.png"))); // NOI18N
  183. but3.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
  184. but3.addActionListener(this);
  185. commonActionsToolbar.add(but3);
  186. but4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/filenew.png"))); // NOI18N
  187. but4.setText(bundle.getString("MPV5View.jButton4.text")); // NOI18N
  188. but4.setToolTipText(bundle.getString("MPV5View.jButton4.toolTipText")); // NOI18N
  189. but4.setContentAreaFilled(false);
  190. but4.setFocusable(false);
  191. but4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  192. but4.setName("but4"); // NOI18N
  193. but4.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
  194. but4.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bright_filenew.png"))); // NOI18N
  195. but4.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
  196. but4.addActionListener(this);
  197. commonActionsToolbar.add(but4);
  198. jSeparator1.setName("jSeparator1"); // NOI18N
  199. commonActionsToolbar.add(jSeparator1);
  200. but5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/edittrash.png"))); // NOI18N
  201. but5.setText(bundle.getString("MPV5View.jButton26.text")); // NOI18N
  202. but5.setToolTipText(bundle.getString("MPV5View.jButton26.toolTipText")); // NOI18N
  203. but5.setContentAreaFilled(false);
  204. but5.setFocusable(false);
  205. but5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  206. but5.setName("but5"); // NOI18N
  207. but5.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
  208. but5.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bright_edittrash.png"))); // NOI18N
  209. but5.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
  210. but5.addActionListener(this);
  211. commonActionsToolbar.add(but5);
  212. jSeparator3.setName("jSeparator3"); // NOI18N
  213. commonActionsToolbar.add(jSeparator3);
  214. but6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/password.png"))); // NOI18N
  215. but6.setText(bundle.getString("MPV5View.jButton21.text")); // NOI18N
  216. but6.setToolTipText(bundle.getString("MPV5View.jButton21.toolTipText")); // NOI18N
  217. but6.setContentAreaFilled(false);
  218. but6.setFocusable(false);
  219. but6.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  220. but6.setName("but6"); // NOI18N
  221. but6.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
  222. but6.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bright_password.png"))); // NOI18N
  223. but6.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
  224. but6.addActionListener(this);
  225. commonActionsToolbar.add(but6);
  226. but7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bookmark_add.png"))); // NOI18N
  227. but7.setText(bundle.getString("MPV5View.jButton24.text")); // NOI18N
  228. but7.setToolTipText(bundle.getString("MPV5View.jButton24.toolTipText")); // NOI18N
  229. but7.setContentAreaFilled(false);
  230. but7.setFocusable(false);
  231. but7.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  232. but7.setName("but7"); // NOI18N
  233. but7.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
  234. but7.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bright_bookmark_add.png"))); // NOI18N
  235. but7.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
  236. but7.addActionListener(this);
  237. commonActionsToolbar.add(but7);
  238. but10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/add.png"))); // NOI18N
  239. but10.setText(bundle.getString("DataPanelTB.but10.text")); // NOI18N
  240. but10.setToolTipText(bundle.getString("DataPanelTB.but10.toolTipText")); // NOI18N
  241. but10.setContentAreaFilled(false);
  242. but10.setFocusable(false);
  243. but10.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  244. but10.setName("but10"); // NOI18N
  245. but10.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
  246. but10.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
  247. but10.addActionListener(this);
  248. commonActionsToolbar.add(but10);
  249. jSeparator2.setName("jSeparator2"); // NOI18N
  250. commonActionsToolbar.add(jSeparator2);
  251. printButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/printer.png"))); // NOI18N
  252. printButton.setText(bundle.getString("MPV5View.jButton23.text")); // NOI18N
  253. printButton.setToolTipText(bundle.getString("MPV5View.jButton23.toolTipText")); // NOI18N
  254. printButton.setContentAreaFilled(false);
  255. printButton.setFocusable(false);
  256. printButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  257. printButton.setName("printButton"); // NOI18N
  258. printButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
  259. printButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bright_printer.png"))); // NOI18N
  260. printButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
  261. printButton.addActionListener(this);
  262. commonActionsToolbar.add(printButton);
  263. mailButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/mail_reply.png"))); // NOI18N
  264. mailButton.setText(bundle.getString("DataPanelTB.mailButton.text")); // NOI18N
  265. mailButton.setToolTipText(bundle.getString("DataPanelTB.mailButton.toolTipText")); // NOI18N
  266. mailButton.setContentAreaFilled(false);
  267. mailButton.setFocusable(false);
  268. mailButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  269. mailButton.setName("mailButton"); // NOI18N
  270. mailButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
  271. mailButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bright_mail_reply.png"))); // NOI18N
  272. mailButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
  273. mailButton.addActionListener(this);
  274. commonActionsToolbar.add(mailButton);
  275. pdfButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/pdf.png"))); // NOI18N
  276. pdfButton.setText(bundle.getString("DataPanelTB.pdfButton.text")); // NOI18N
  277. pdfButton.setToolTipText(bundle.getString("DataPanelTB.pdfButton.toolTipText")); // NOI18N
  278. pdfButton.setContentAreaFilled(false);
  279. pdfButton.setFocusable(false);
  280. pdfButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  281. pdfButton.setName("pdfButton"); // NOI18N
  282. pdfButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
  283. pdfButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
  284. pdfButton.addActionListener(this);
  285. commonActionsToolbar.add(pdfButton);
  286. odtButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/openofficeorg-20-writer.png"))); // NOI18N
  287. odtButton.setText(bundle.getString("DataPanelTB.odtButton.text")); // NOI18N
  288. odtButton.setToolTipText(bundle.getString("DataPanelTB.odtButton.toolTipText")); // NOI18N
  289. odtButton.setContentAreaFilled(false);
  290. odtButton.setFocusable(false);
  291. odtButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  292. odtButton.setName("odtButton"); // NOI18N
  293. odtButton.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
  294. odtButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
  295. odtButton.addActionListener(this);
  296. commonActionsToolbar.add(odtButton);
  297. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
  298. this.setLayout(layout);
  299. layout.setHorizontalGroup(
  300. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  301. .addComponent(commonActionsToolbar, javax.swing.GroupLayout.DEFAULT_SIZE, 583, Short.MAX_VALUE)
  302. );
  303. layout.setVerticalGroup(
  304. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  305. .addComponent(commonActionsToolbar, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
  306. );
  307. }
  308. // Code for dispatching events from components to event handlers.
  309. public void actionPerformed(java.awt.event.ActionEvent evt) {
  310. if (evt.getSource() == but1) {
  311. DataPanelTB.this.but1ActionPerformed(evt);
  312. }
  313. else if (evt.getSource() == but2) {
  314. DataPanelTB.this.but2ActionPerformed(evt);
  315. }
  316. else if (evt.getSource() == but3) {
  317. DataPanelTB.this.but3ActionPerformed(evt);
  318. }
  319. else if (evt.getSource() == but4) {
  320. DataPanelTB.this.but4ActionPerformed(evt);
  321. }
  322. else if (evt.getSource() == but5) {
  323. DataPanelTB.this.but5ActionPerformed(evt);
  324. }
  325. else if (evt.getSource() == but6) {
  326. DataPanelTB.this.but6ActionPerformed(evt);
  327. }
  328. else if (evt.getSource() == but7) {
  329. DataPanelTB.this.but7ActionPerformed(evt);
  330. }
  331. else if (evt.getSource() == but10) {
  332. DataPanelTB.this.but10ActionPerformed(evt);
  333. }
  334. else if (evt.getSource() == printButton) {
  335. DataPanelTB.this.printButtonActionPerformed(evt);
  336. }
  337. else if (evt.getSource() == mailButton) {
  338. DataPanelTB.this.mailButtonActionPerformed(evt);
  339. }
  340. else if (evt.getSource() == pdfButton) {
  341. DataPanelTB.this.pdfButtonActionPerformed(evt);
  342. }
  343. else if (evt.getSource() == odtButton) {
  344. DataPanelTB.this.odtButtonActionPerformed(evt);
  345. }
  346. }
  347. public void itemStateChanged(java.awt.event.ItemEvent evt) {
  348. if (evt.getSource() == but1) {
  349. DataPanelTB.this.but1ItemStateChanged(evt);
  350. }
  351. }// </editor-fold>//GEN-END:initComponents
  352. private void but2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but2ActionPerformed
  353. DatabaseObject dato = parents.getDataOwner();
  354. if (dato.isExisting()) {
  355. dato.getPanelData((parents));
  356. dato.reset();
  357. parents.setDataOwner(dato, true);
  358. }
  359. }//GEN-LAST:event_but2ActionPerformed
  360. private void but3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but3ActionPerformed
  361. try {
  362. DatabaseObject dato = parents.getDataOwner();
  363. parents.actionBeforeSave();
  364. if (dato.getPanelData(parents) && dato.save()) {
  365. try {
  366. parents.actionAfterSave();
  367. parents.setDataOwner(dato, true);
  368. } catch (Exception e) {
  369. Log.Debug(this, e);
  370. }
  371. } else {
  372. parents.showRequiredFields();
  373. }
  374. } catch (ChangeNotApprovedException ex) {
  375. Log.Debug(this, ex.getMessage());
  376. }
  377. }//GEN-LAST:event_but3ActionPerformed
  378. private void but4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but4ActionPerformed
  379. DatabaseObject dato = parents.getDataOwner();
  380. boolean d = dato.getPanelData(parents);
  381. dato.setIDS(-1);
  382. parents.actionBeforeCreate();
  383. if (d && dato.save()) {
  384. try {
  385. parents.actionAfterCreate();
  386. parents.setDataOwner(dato, true);
  387. } catch (Exception e) {
  388. Log.Debug(this, e);
  389. }
  390. } else {
  391. parents.showRequiredFields();
  392. }
  393. }//GEN-LAST:event_but4ActionPerformed
  394. private void but6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but6ActionPerformed
  395. DatabaseObject dato = parents.getDataOwner();
  396. if (mpv5.db.objects.User.getCurrentUser().isDefault()) {
  397. Popup.notice(Messages.DEFAULT_USER);
  398. } else if (dato.isExisting()) {
  399. if (dato.lock()) {
  400. Popup.notice(dato.toString() + Messages.LOCKED);
  401. but6.setEnabled(false);
  402. } else {
  403. Popup.notice(Messages.LOCK_FAILED);
  404. }
  405. } else {
  406. Popup.notice(Messages.NOT_SAVED_YET);
  407. }
  408. }//GEN-LAST:event_but6ActionPerformed
  409. private void printButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_printButtonActionPerformed
  410. DatabaseObject dato = parents.getDataOwner();
  411. if (dato.isExisting()) {
  412. parents.print();
  413. final String fmessage = Messages.PRINTED + dato.__getCname();
  414. final String fdbid = dato.getDbIdentity();
  415. final int fids = dato.__getIDS();
  416. final int fgids = dato.__getGroupsids();
  417. Runnable runnable = new Runnable() {
  418. @Override
  419. public void run() {
  420. QueryHandler.instanceOf().clone(Context.getHistory()).insertHistoryItem(fmessage, mpv5.db.objects.User.getCurrentUser().__getCname(), fdbid, fids, fgids);
  421. }
  422. };
  423. new Thread(runnable).start();
  424. }
  425. }//GEN-LAST:event_printButtonActionPerformed
  426. private void but5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but5ActionPerformed
  427. DatabaseObject dato = parents.getDataOwner();
  428. if (dato.isExisting() && Popup.Y_N_dialog(Messages.REALLY_DELETE)) {
  429. dato.getPanelData(parents);
  430. dato.delete();
  431. parents.refresh();
  432. parents.setDataOwner(dato.getObject(dato.getContext()), true);
  433. }
  434. }//GEN-LAST:event_but5ActionPerformed
  435. private void but7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but7ActionPerformed
  436. }//GEN-LAST:event_but7ActionPerformed
  437. private void but1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but1ActionPerformed
  438. parents.showSearchBar(but1.isSelected());
  439. }//GEN-LAST:event_but1ActionPerformed
  440. private void but1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_but1ItemStateChanged
  441. mpv5.db.objects.User.getCurrentUser().getProperties().changeProperty(this, "jToggleButton1", but1.isSelected());
  442. }//GEN-LAST:event_but1ItemStateChanged
  443. private void mailButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mailButtonActionPerformed
  444. DatabaseObject dato = parents.getDataOwner();
  445. if (dato.isExisting()) {
  446. parents.mail();
  447. }
  448. }//GEN-LAST:event_mailButtonActionPerformed
  449. private void but10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but10ActionPerformed
  450. DatabaseObject dato = parents.getDataOwner();
  451. if (dato.isExisting()) {
  452. mpv5.YabsViewProxy.instance().addToClipBoard(dato);
  453. // mpv5.YabsViewProxy.instance().setClipBoardVisible(true);
  454. }
  455. }//GEN-LAST:event_but10ActionPerformed
  456. private void pdfButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pdfButtonActionPerformed
  457. DatabaseObject dato = parents.getDataOwner();
  458. if (dato.isExisting() && parents instanceof ExportablePanel) {
  459. ((ExportablePanel) parents).pdf();
  460. final String fmessage = Messages.PDF + dato.__getCname();
  461. final String fdbid = dato.getDbIdentity();
  462. final int fids = dato.__getIDS();
  463. final int fgids = dato.__getGroupsids();
  464. Runnable runnable = new Runnable() {
  465. @Override
  466. public void run() {
  467. QueryHandler.instanceOf().clone(Context.getHistory()).insertHistoryItem(fmessage, mpv5.db.objects.User.getCurrentUser().__getCname(), fdbid, fids, fgids);
  468. }
  469. };
  470. new Thread(runnable).start();
  471. }
  472. }//GEN-LAST:event_pdfButtonActionPerformed
  473. private void odtButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_odtButtonActionPerformed
  474. DatabaseObject dato = parents.getDataOwner();
  475. if (dato.isExisting()) {
  476. ((ExportablePanel) parents).odt();
  477. final String fmessage = Messages.ODT + dato.__getCname();
  478. final String fdbid = dato.getDbIdentity();
  479. final int fids = dato.__getIDS();
  480. final int fgids = dato.__getGroupsids();
  481. Runnable runnable = new Runnable() {
  482. @Override
  483. public void run() {
  484. QueryHandler.instanceOf().clone(Context.getHistory()).insertHistoryItem(fmessage, mpv5.db.objects.User.getCurrentUser().__getCname(), fdbid, fids, fgids);
  485. }
  486. };
  487. new Thread(runnable).start();
  488. }
  489. }//GEN-LAST:event_odtButtonActionPerformed
  490. // Variables declaration - do not modify//GEN-BEGIN:variables
  491. private javax.swing.JToggleButton but1;
  492. private javax.swing.JButton but10;
  493. private javax.swing.JButton but2;
  494. private javax.swing.JButton but3;
  495. private javax.swing.JButton but4;
  496. private javax.swing.JButton but5;
  497. private javax.swing.JButton but6;
  498. private javax.swing.JButton but7;
  499. private javax.swing.JToolBar commonActionsToolbar;
  500. private javax.swing.JToolBar.Separator jSeparator1;
  501. private javax.swing.JToolBar.Separator jSeparator2;
  502. private javax.swing.JToolBar.Separator jSeparator3;
  503. private javax.swing.JToolBar.Separator jSeparator4;
  504. private javax.swing.JButton mailButton;
  505. private javax.swing.JButton odtButton;
  506. private javax.swing.JButton pdfButton;
  507. private javax.swing.JButton printButton;
  508. // End of variables declaration//GEN-END:variables
  509. private void favRemover(java.awt.event.ActionEvent evt) {
  510. DatabaseObject dato = parents.getDataOwner();
  511. if (!mpv5.db.objects.User.getCurrentUser().isDefault() && dato.isExisting()) {
  512. dato.getPanelData(parents);
  513. if (dato.save()) {
  514. Favourite.removeFavourite(dato);
  515. mpv5.YabsViewProxy.instance().reloadFavorites();
  516. parents.setDataOwner(dato, true);
  517. } else {
  518. parents.showRequiredFields();
  519. }
  520. }
  521. }
  522. private void favAdd(java.awt.event.ActionEvent evt) {
  523. DatabaseObject dato = parents.getDataOwner();
  524. Favourite fav = null;
  525. if (!mpv5.db.objects.User.getCurrentUser().isDefault()) {
  526. if (dato.isExisting()) {
  527. dato.getPanelData(parents);
  528. if (dato.save()) {
  529. fav = new Favourite(dato);
  530. fav.save();
  531. mpv5.YabsViewProxy.instance().reloadFavorites();
  532. mpv5.YabsViewProxy.instance().addMessage(Messages.ADDED_TO_FAVOURITES + dato.__getCname(), Color.GREEN);
  533. parents.setDataOwner(dato, true);
  534. } else {
  535. parents.showRequiredFields();
  536. }
  537. }
  538. } else {
  539. Popup.notice(Messages.DEFAULT_USER);
  540. }
  541. }
  542. /**
  543. *
  544. * @param enable
  545. */
  546. public void setExportButtonsEnabled(boolean enable) {
  547. getMailButton().setEnabled(enable);
  548. }
  549. /**
  550. * @return the mailButton
  551. */
  552. public javax.swing.JButton getMailButton() {
  553. return mailButton;
  554. }
  555. /**
  556. * @return the odtButton
  557. */
  558. public javax.swing.JButton getOdtButton() {
  559. return odtButton;
  560. }
  561. /**
  562. * @return the pdfButton
  563. */
  564. public javax.swing.JButton getPdfButton() {
  565. return pdfButton;
  566. }
  567. /**
  568. * @return the printButton
  569. */
  570. public javax.swing.JButton getPrintButton() {
  571. return printButton;
  572. }
  573. /**
  574. * @return the pdfButton
  575. */
  576. public javax.swing.JButton getSaveButton() {
  577. return but3;
  578. }
  579. /**
  580. * @return the printButton
  581. */
  582. public javax.swing.JButton getCreateButton() {
  583. return but4;
  584. }
  585. }