PageRenderTime 54ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/src/mpv5/ui/panels/HomeScreen.java

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Java | 964 lines | 830 code | 78 blank | 56 comment | 57 complexity | 67c55482efbaf42651481e6fe15da405 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.panels;
  23. import java.awt.Color;
  24. import java.awt.Component;
  25. import java.math.BigDecimal;
  26. import java.util.ArrayList;
  27. import java.util.Date;
  28. import java.util.HashMap;
  29. import java.util.Iterator;
  30. import java.util.List;
  31. import javax.swing.ImageIcon;
  32. import javax.swing.JComponent;
  33. import javax.swing.JSplitPane;
  34. import javax.swing.JTable;
  35. import javax.swing.table.TableCellRenderer;
  36. import mpv5.db.common.Context;
  37. import mpv5.db.common.DatabaseObject;
  38. import mpv5.db.common.NodataFoundException;
  39. import mpv5.db.objects.Group;
  40. import mpv5.db.objects.Item;
  41. import mpv5.db.objects.Reminder;
  42. import mpv5.db.objects.Schedule;
  43. import mpv5.db.objects.SubItem;
  44. import mpv5.db.objects.User;
  45. import mpv5.globals.Constants;
  46. import mpv5.globals.Messages;
  47. import mpv5.handler.Scheduler;
  48. import mpv5.logging.Log;
  49. import mpv5.ui.dialogs.Popup;
  50. import mpv5.ui.dialogs.ScheduleEvents;
  51. import mpv5.ui.misc.MPTable;
  52. import mpv5.ui.misc.TableViewPersistenceHandler;
  53. import mpv5.ui.panels.calendar.ScheduleCalendar;
  54. import mpv5.utils.date.DateConverter;
  55. import mpv5.utils.date.vTimeframe;
  56. import mpv5.utils.models.MPTableModel;
  57. import mpv5.utils.numberformat.FormatNumber;
  58. import mpv5.utils.renderer.TableCellRendererForDatabaseObjects;
  59. import mpv5.utils.tables.TableFormat;
  60. public class HomeScreen
  61. extends javax.swing.JPanel {
  62. private static final long serialVersionUID = 8043431014500289718L;
  63. private List<DatabaseObject> odata;
  64. private List<DatabaseObject> xdata;
  65. TableCellRendererForDatabaseObjects rend = new TableCellRendererForDatabaseObjects();
  66. private final ScheduleDayEventsPanel SDEPanel;
  67. private final ScheduleCalendar sc;
  68. private static HomeScreen icke;
  69. private BigDecimal billsSum = new BigDecimal(0);
  70. private BigDecimal orderSum = new BigDecimal(0);
  71. private BigDecimal offerSum = new BigDecimal(0);
  72. public static HomeScreen getInstance() {
  73. if (icke == null) {
  74. icke = new HomeScreen();
  75. } else {
  76. icke.refresh();
  77. }
  78. return icke;
  79. }
  80. /**
  81. *
  82. */
  83. private HomeScreen() {
  84. initComponents();
  85. setName("homescreenpanel");
  86. labeledCombobox1.setContext(Context.getGroup());
  87. labeledCombobox2.setModel(Item.getItemEnum());
  88. labeledCombobox3.setContext(Context.getGroup());
  89. labeledCombobox4.setModel(Item.getItemEnum());
  90. timeframeChooser1.setTime(new vTimeframe(DateConverter.getStartOfMonth(new Date()), DateConverter.getEndOfMonth(new Date())));
  91. timeframeChooser2.setTime(new vTimeframe(DateConverter.getStartOfMonth(new Date()), DateConverter.getEndOfMonth(new Date())));
  92. SDEPanel = ScheduleDayEventsPanel.instanceOf();
  93. jSplitPane1.setBottomComponent(SDEPanel);
  94. sc = ScheduleCalendar.instanceOf();
  95. jSplitPane1.setTopComponent(sc);
  96. initTable(overdue);
  97. initTable(nextEvents);
  98. }
  99. public JSplitPane getjSplitPane1() {
  100. return jSplitPane1;
  101. }
  102. private void initTable(JTable table) {
  103. table.setDefaultRenderer(String.class,
  104. rend);
  105. table.setDefaultRenderer(Date.class,
  106. rend);
  107. table.setDefaultRenderer(DatabaseObject.class,
  108. rend);
  109. ((MPTable) table).setDefaultColumns(new Integer[]{100,
  110. 100,
  111. 100,
  112. 100,
  113. 100,
  114. 100},
  115. new Boolean[]{true,
  116. true,
  117. true,
  118. true,
  119. true,
  120. true});
  121. ((MPTable) table).setPersistanceHandler(new TableViewPersistenceHandler(
  122. (MPTable) table,
  123. this));
  124. TableFormat.hideHeader(table);
  125. }
  126. public JTable getNextEvents() {
  127. return nextEvents;
  128. }
  129. public JTable getOverdue() {
  130. return overdue;
  131. }
  132. public <T extends DatabaseObject> void show(HashMap<Color, List<T>> map, JTable table) {
  133. Iterator<Color> it = map.keySet().
  134. iterator();
  135. List<DatabaseObject> ndata = new ArrayList<DatabaseObject>();
  136. while (it.hasNext()) {
  137. Color c = it.next();
  138. List<T> data = map.get(c);
  139. for (int i = 0; i < data.size(); i++) {
  140. T databaseObject = data.get(i);
  141. databaseObject.defineColor(c);
  142. ndata.add(databaseObject);
  143. }
  144. }
  145. labeledCombobox1.setSearchEnabled(true);
  146. labeledCombobox1.setContext(Context.getGroup());
  147. labeledCombobox1.triggerSearch();
  148. // timeframeChooser1.setTime(new vTimeframe(DateConverter.getStartOfMonth(new Date()), DateConverter.getEndOfMonth(new Date())));
  149. labeledCombobox3.setSearchEnabled(true);
  150. labeledCombobox3.setContext(Context.getGroup());
  151. labeledCombobox3.triggerSearch();
  152. // timeframeChooser2.setTime(new vTimeframe(DateConverter.getStartOfMonth(new Date()), DateConverter.getEndOfMonth(new Date())));
  153. if (table.equals(overdue)) {
  154. setData(ndata, table, false);
  155. odata = ndata;
  156. } else {
  157. setData(ndata, table, true);
  158. xdata = ndata;
  159. }
  160. validate();
  161. }
  162. public <T extends DatabaseObject> void setData(List<T> list, JTable table, Boolean isDBObj) {
  163. Object[][] data = null;
  164. int type;
  165. orderSum = new BigDecimal(0);
  166. offerSum = new BigDecimal(0);
  167. billsSum = new BigDecimal(0);
  168. BigDecimal tax;
  169. if (list != null) {
  170. data = new Object[list.size()][6];
  171. for (int i = 0; i < list.size(); i++) {
  172. if (isDBObj == false) {
  173. DatabaseObject databaseObject = list.get(i);
  174. data[i][0] = databaseObject;
  175. data[i][1] = User.getUsername(databaseObject.__getIntaddedby());
  176. data[i][2] = databaseObject.__getDateadded();
  177. try {
  178. data[i][3] = DatabaseObject.getObject(Context.getGroup(),
  179. databaseObject.__getGroupsids());
  180. } catch (NodataFoundException ex) {
  181. data[i][3] = "N/A";
  182. }
  183. type = ((Item) databaseObject).__getInttype();
  184. // <li>TYPE_BILL = 0;
  185. // <li>TYPE_ORDER = 1;
  186. // <li>TYPE_OFFER = 2;
  187. switch (type) {
  188. case Item.TYPE_BILL:
  189. tax = Constants.BD100.add(((Item) databaseObject).__getTaxvalue()).divide(Constants.BD100, 9, BigDecimal.ROUND_HALF_UP);
  190. billsSum = billsSum.add(((Item) databaseObject).__getNetvalue().multiply(tax));
  191. break;
  192. case Item.TYPE_OFFER:
  193. tax = Constants.BD100.add(((Item) databaseObject).__getTaxvalue()).divide(Constants.BD100, 9, BigDecimal.ROUND_HALF_UP);
  194. offerSum = offerSum.add(((Item) databaseObject).__getNetvalue().multiply(tax));
  195. break;
  196. case Item.TYPE_ORDER:
  197. tax = Constants.BD100.add(((Item) databaseObject).__getTaxvalue()).divide(Constants.BD100, 9, BigDecimal.ROUND_HALF_UP);
  198. orderSum = orderSum.add(((Item) databaseObject).__getNetvalue().multiply(tax));
  199. break;
  200. }
  201. data[i][4] = Item.getTypeString(type);
  202. data[i][5] = databaseObject.getIcon();
  203. ((ImageIcon) data[i][5]).setDescription(Item.getStatusString(((Item) databaseObject).__getIntstatus()));
  204. } else {
  205. Schedule sched = (Schedule) list.get(i);
  206. data[i][0] = sched;
  207. data[i][1] = User.getUsername(sched.__getIntaddedby());
  208. data[i][2] = sched.__getNextdate();
  209. data[i][3] = sched.__getStopdate();
  210. data[i][4] = Item.getTypeString(0);
  211. data[i][5] = sched.getIcon();
  212. ((ImageIcon) data[i][5]).setDescription(Messages.NEW_BILL.toString());
  213. }
  214. }
  215. } else {
  216. data = new Object[0][6];
  217. }
  218. MPTableModel m = new MPTableModel(data);
  219. m.setTypes(new Class[]{DatabaseObject.class,
  220. String.class,
  221. Date.class,
  222. DatabaseObject.class,
  223. String.class,
  224. ImageIcon.class
  225. });
  226. table.setModel(m);
  227. if (isDBObj == false) {
  228. orders.setText(FormatNumber.formatLokalCurrency(orderSum));
  229. offers.setText(FormatNumber.formatLokalCurrency(offerSum));
  230. bills.setText(FormatNumber.formatLokalCurrency(billsSum));
  231. }
  232. }
  233. /**
  234. * Filter by group
  235. * @param g
  236. */
  237. @SuppressWarnings("unchecked")
  238. public void filterByTimeframe(vTimeframe g) {
  239. HashMap<Color, List<Item>> map = Scheduler.getOverdueEvents();
  240. this.show(map, this.getOverdue());
  241. }
  242. /**
  243. * Filter by group
  244. * @param g
  245. */
  246. @SuppressWarnings("unchecked")
  247. public void filterByTimeframe2(vTimeframe g) {
  248. HashMap<Color, List<Schedule>> map = Scheduler.getScheduledBills(g);
  249. this.show(map, this.getNextEvents());
  250. }
  251. @SuppressWarnings("unchecked")
  252. public void filterByItemType(Integer Type) {
  253. setData(odata, overdue, false);
  254. if (Type >= 0) {
  255. Object[][] data = ((MPTableModel) overdue.getModel()).getData();
  256. List<DatabaseObject> list = new ArrayList<DatabaseObject>();
  257. for (int i = 0; i < data.length; i++) {
  258. Item d = (Item) data[i][0];
  259. if (d.__getInttype() == Type) {
  260. list.add(d);
  261. }
  262. }
  263. setData(list, overdue, false);
  264. }
  265. }
  266. /**
  267. * Filter by group
  268. * @param g
  269. */
  270. @SuppressWarnings({"unchecked"})
  271. public void filterByGroup(Group g) {
  272. setData(odata, overdue, false);
  273. Object[][] data = ((MPTableModel) overdue.getModel()).getData();
  274. List<DatabaseObject> list = new ArrayList<DatabaseObject>();
  275. if (g.__getIDS().
  276. intValue() != 1) {
  277. for (int i = 0; i < data.length; i++) {
  278. DatabaseObject d = (DatabaseObject) data[i][0];
  279. if (d.__getGroupsids() == g.__getIDS()) {
  280. list.add(d);
  281. }
  282. }
  283. } else {
  284. for (int i = 0; i < data.length; i++) {
  285. DatabaseObject d = (DatabaseObject) data[i][0];
  286. list.add(d);
  287. }
  288. }
  289. setData(list, overdue, false);
  290. }
  291. @SuppressWarnings("unchecked")
  292. public void filterByItemType2(Integer Type) {
  293. setData(xdata, nextEvents, false);
  294. if (Type >= 0) {
  295. Object[][] data = ((MPTableModel) nextEvents.getModel()).getData();
  296. List<DatabaseObject> list = new ArrayList<DatabaseObject>();
  297. for (int i = 0; i < data.length; i++) {
  298. Item d = (Item) data[i][0];
  299. if (d.__getInttype() == Type) {
  300. list.add(d);
  301. }
  302. }
  303. setData(list, nextEvents, false);
  304. }
  305. }
  306. /**
  307. * Filter by group
  308. * @param g
  309. */
  310. @SuppressWarnings({"unchecked"})
  311. public void filterByGroup2(Group g) {
  312. setData(xdata, nextEvents, false);
  313. Object[][] data = ((MPTableModel) nextEvents.getModel()).getData();
  314. List<DatabaseObject> list = new ArrayList<DatabaseObject>();
  315. if (g.__getIDS().
  316. intValue() != 1) {
  317. for (int i = 0; i < data.length; i++) {
  318. DatabaseObject d = (DatabaseObject) data[i][0];
  319. if (d.__getGroupsids() == g.__getIDS()) {
  320. list.add(d);
  321. }
  322. }
  323. } else {
  324. for (int i = 0; i < data.length; i++) {
  325. DatabaseObject d = (DatabaseObject) data[i][0];
  326. list.add(d);
  327. }
  328. }
  329. setData(list, nextEvents, false);
  330. }
  331. /** This method is called from within the constructor to
  332. * initialize the form.
  333. * WARNING: Do NOT modify this code. The content of this method is
  334. * always regenerated by the Form Editor.
  335. */
  336. @SuppressWarnings("unchecked")
  337. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  338. private void initComponents() {
  339. jSplitPane1 = new javax.swing.JSplitPane();
  340. jPanel1 = new javax.swing.JPanel();
  341. jButton1 = new javax.swing.JButton();
  342. jButton2 = new javax.swing.JButton();
  343. timeframeChooser1 = new mpv5.ui.beans.TimeframeChooser();
  344. labeledCombobox1 = new mpv5.ui.beans.LabeledCombobox();
  345. jScrollPane2 = new javax.swing.JScrollPane();
  346. overdue = new mpv5.ui.misc.MPTable(this) {
  347. private static final long serialVersionUID = 1L;
  348. public Component prepareRenderer(TableCellRenderer renderer,
  349. int rowIndex, int vColIndex) {
  350. Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
  351. if (c instanceof JComponent) {
  352. JComponent jc = (JComponent)c;
  353. jc.setToolTipText(String.valueOf(getValueAt(rowIndex, vColIndex)));
  354. }
  355. return c;
  356. }
  357. };
  358. labeledCombobox2 = new mpv5.ui.beans.LabeledCombobox();
  359. jButton3 = new javax.swing.JButton();
  360. offers = new mpv5.ui.beans.LabeledTextField();
  361. bills = new mpv5.ui.beans.LabeledTextField();
  362. orders = new mpv5.ui.beans.LabeledTextField();
  363. but6 = new javax.swing.JButton();
  364. jPanel2 = new javax.swing.JPanel();
  365. jButton6 = new javax.swing.JButton();
  366. jButton5 = new javax.swing.JButton();
  367. timeframeChooser2 = new mpv5.ui.beans.TimeframeChooser();
  368. labeledCombobox3 = new mpv5.ui.beans.LabeledCombobox();
  369. labeledCombobox4 = new mpv5.ui.beans.LabeledCombobox();
  370. jButton4 = new javax.swing.JButton();
  371. jScrollPane1 = new javax.swing.JScrollPane();
  372. nextEvents = new mpv5.ui.misc.MPTable(this) {
  373. private static final long serialVersionUID = 1L;
  374. public Component prepareRenderer(TableCellRenderer renderer,
  375. int rowIndex, int vColIndex) {
  376. Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
  377. if (c instanceof JComponent) {
  378. JComponent jc = (JComponent)c;
  379. jc.setToolTipText(String.valueOf(getValueAt(rowIndex, vColIndex)));
  380. }
  381. return c;
  382. }
  383. };
  384. but5 = new javax.swing.JButton();
  385. but4 = new javax.swing.JButton();
  386. setName("Form"); // NOI18N
  387. jSplitPane1.setDividerLocation(200);
  388. jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
  389. jSplitPane1.setName("jSplitPane1"); // NOI18N
  390. java.util.ResourceBundle bundle = mpv5.i18n.LanguageManager.getBundle(); // NOI18N
  391. jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("HomeScreen.jPanel1.border.title"))); // NOI18N
  392. jPanel1.setName("jPanel1"); // NOI18N
  393. jButton1.setText(bundle.getString("HomeScreen.jButton1.text")); // NOI18N
  394. jButton1.setName("jButton1"); // NOI18N
  395. jButton1.setPreferredSize(new java.awt.Dimension(60, 23));
  396. jButton1.addActionListener(new java.awt.event.ActionListener() {
  397. public void actionPerformed(java.awt.event.ActionEvent evt) {
  398. jButton1ActionPerformed(evt);
  399. }
  400. });
  401. jButton2.setText(bundle.getString("HomeScreen.jButton2.text")); // NOI18N
  402. jButton2.setName("jButton2"); // NOI18N
  403. jButton2.setPreferredSize(new java.awt.Dimension(60, 23));
  404. jButton2.addActionListener(new java.awt.event.ActionListener() {
  405. public void actionPerformed(java.awt.event.ActionEvent evt) {
  406. jButton2ActionPerformed(evt);
  407. }
  408. });
  409. timeframeChooser1.setName("timeframeChooser1"); // NOI18N
  410. labeledCombobox1.set_Label(bundle.getString("HomeScreen.labeledCombobox1._Label")); // NOI18N
  411. labeledCombobox1.setName("labeledCombobox1"); // NOI18N
  412. jScrollPane2.setName("jScrollPane2"); // NOI18N
  413. overdue.setAutoCreateRowSorter(true);
  414. overdue.setModel(new javax.swing.table.DefaultTableModel(
  415. new Object [][] {
  416. {},
  417. {},
  418. {},
  419. {}
  420. },
  421. new String [] {
  422. }
  423. ));
  424. overdue.setName("overdue"); // NOI18N
  425. overdue.setShowVerticalLines(false);
  426. overdue.addMouseListener(new java.awt.event.MouseAdapter() {
  427. public void mouseClicked(java.awt.event.MouseEvent evt) {
  428. overdueMouseClicked(evt);
  429. }
  430. });
  431. jScrollPane2.setViewportView(overdue);
  432. labeledCombobox2.set_Label(bundle.getString("HomeScreen.labeledCombobox2._Label")); // NOI18N
  433. labeledCombobox2.setName("labeledCombobox2"); // NOI18N
  434. jButton3.setText(bundle.getString("HomeScreen.jButton3.text")); // NOI18N
  435. jButton3.setName("jButton3"); // NOI18N
  436. jButton3.setPreferredSize(new java.awt.Dimension(60, 23));
  437. jButton3.addActionListener(new java.awt.event.ActionListener() {
  438. public void actionPerformed(java.awt.event.ActionEvent evt) {
  439. jButton3ActionPerformed(evt);
  440. }
  441. });
  442. offers.set_Label(bundle.getString("HomeScreen.offers._Label")); // NOI18N
  443. offers.setEnabled(false);
  444. offers.setName("offers"); // NOI18N
  445. bills.set_Label(bundle.getString("HomeScreen.bills._Label")); // NOI18N
  446. bills.setEnabled(false);
  447. bills.setName("bills"); // NOI18N
  448. orders.set_Label(bundle.getString("HomeScreen.orders._Label")); // NOI18N
  449. orders.setEnabled(false);
  450. orders.setName("orders"); // NOI18N
  451. but6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/agt_reload.png"))); // NOI18N
  452. but6.setText(bundle.getString("HomeScreen.but6.text")); // NOI18N
  453. but6.setToolTipText(bundle.getString("HomeScreen.but6.toolTipText")); // NOI18N
  454. but6.setContentAreaFilled(false);
  455. but6.setFocusable(false);
  456. but6.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  457. but6.setName("but6"); // NOI18N
  458. but6.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
  459. but6.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/agt_reload.png"))); // NOI18N
  460. but6.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
  461. but6.addActionListener(new java.awt.event.ActionListener() {
  462. public void actionPerformed(java.awt.event.ActionEvent evt) {
  463. but6ActionPerformed(evt);
  464. }
  465. });
  466. javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  467. jPanel1.setLayout(jPanel1Layout);
  468. jPanel1Layout.setHorizontalGroup(
  469. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  470. .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 882, Short.MAX_VALUE)
  471. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
  472. .addComponent(offers, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  473. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  474. .addComponent(orders, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  475. .addGap(117, 117, 117)
  476. .addComponent(bills, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  477. .addGroup(jPanel1Layout.createSequentialGroup()
  478. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  479. .addGroup(jPanel1Layout.createSequentialGroup()
  480. .addComponent(timeframeChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE)
  481. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  482. .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  483. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 435, Short.MAX_VALUE)
  484. .addComponent(but6, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
  485. .addGroup(jPanel1Layout.createSequentialGroup()
  486. .addComponent(labeledCombobox2, javax.swing.GroupLayout.PREFERRED_SIZE, 325, javax.swing.GroupLayout.PREFERRED_SIZE)
  487. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  488. .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  489. .addGap(18, 18, 18)
  490. .addComponent(labeledCombobox1, javax.swing.GroupLayout.PREFERRED_SIZE, 322, javax.swing.GroupLayout.PREFERRED_SIZE)
  491. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  492. .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
  493. .addContainerGap())
  494. );
  495. jPanel1Layout.setVerticalGroup(
  496. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  497. .addGroup(jPanel1Layout.createSequentialGroup()
  498. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  499. .addGroup(jPanel1Layout.createSequentialGroup()
  500. .addContainerGap()
  501. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
  502. .addComponent(timeframeChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  503. .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)))
  504. .addComponent(but6, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
  505. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  506. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
  507. .addComponent(labeledCombobox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  508. .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
  509. .addComponent(labeledCombobox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  510. .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
  511. .addGap(18, 18, 18)
  512. .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 43, Short.MAX_VALUE)
  513. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  514. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  515. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  516. .addComponent(orders, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  517. .addComponent(bills, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  518. .addComponent(offers, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  519. .addContainerGap())
  520. );
  521. jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("HomeScreen.jPanel2.border.title"))); // NOI18N
  522. jPanel2.setName("jPanel2"); // NOI18N
  523. jButton6.setText(bundle.getString("HomeScreen.jButton6.text")); // NOI18N
  524. jButton6.setName("jButton6"); // NOI18N
  525. jButton6.setPreferredSize(new java.awt.Dimension(60, 23));
  526. jButton6.addActionListener(new java.awt.event.ActionListener() {
  527. public void actionPerformed(java.awt.event.ActionEvent evt) {
  528. jButton6ActionPerformed(evt);
  529. }
  530. });
  531. jButton5.setText(bundle.getString("HomeScreen.jButton5.text")); // NOI18N
  532. jButton5.setName("jButton5"); // NOI18N
  533. jButton5.setPreferredSize(new java.awt.Dimension(60, 23));
  534. jButton5.addActionListener(new java.awt.event.ActionListener() {
  535. public void actionPerformed(java.awt.event.ActionEvent evt) {
  536. jButton5ActionPerformed(evt);
  537. }
  538. });
  539. timeframeChooser2.setName("timeframeChooser2"); // NOI18N
  540. labeledCombobox3.set_Label(bundle.getString("HomeScreen.labeledCombobox3._Label")); // NOI18N
  541. labeledCombobox3.setName("labeledCombobox3"); // NOI18N
  542. labeledCombobox4.set_Label(bundle.getString("HomeScreen.labeledCombobox4._Label")); // NOI18N
  543. labeledCombobox4.setName("labeledCombobox4"); // NOI18N
  544. jButton4.setText(bundle.getString("HomeScreen.jButton4.text")); // NOI18N
  545. jButton4.setName("jButton4"); // NOI18N
  546. jButton4.setPreferredSize(new java.awt.Dimension(60, 23));
  547. jButton4.addActionListener(new java.awt.event.ActionListener() {
  548. public void actionPerformed(java.awt.event.ActionEvent evt) {
  549. jButton4ActionPerformed(evt);
  550. }
  551. });
  552. jScrollPane1.setName("jScrollPane1"); // NOI18N
  553. nextEvents.setAutoCreateRowSorter(true);
  554. nextEvents.setModel(new javax.swing.table.DefaultTableModel(
  555. new Object [][] {
  556. {},
  557. {},
  558. {},
  559. {}
  560. },
  561. new String [] {
  562. }
  563. ));
  564. nextEvents.setName("nextEvents"); // NOI18N
  565. nextEvents.setShowVerticalLines(false);
  566. nextEvents.addMouseListener(new java.awt.event.MouseAdapter() {
  567. public void mouseClicked(java.awt.event.MouseEvent evt) {
  568. nextEventsMouseClicked(evt);
  569. }
  570. });
  571. jScrollPane1.setViewportView(nextEvents);
  572. but5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/edittrash.png"))); // NOI18N
  573. but5.setText(bundle.getString("HomeScreen.but5.text")); // NOI18N
  574. but5.setToolTipText(bundle.getString("HomeScreen.but5.toolTipText")); // NOI18N
  575. but5.setContentAreaFilled(false);
  576. but5.setFocusable(false);
  577. but5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  578. but5.setName("but5"); // NOI18N
  579. but5.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
  580. but5.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/bright_edittrash.png"))); // NOI18N
  581. but5.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
  582. but5.addActionListener(new java.awt.event.ActionListener() {
  583. public void actionPerformed(java.awt.event.ActionEvent evt) {
  584. but5ActionPerformed(evt);
  585. }
  586. });
  587. but4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/view_right.png"))); // NOI18N
  588. but4.setText(bundle.getString("HomeScreen.but4.text")); // NOI18N
  589. but4.setToolTipText(bundle.getString("HomeScreen.but4.toolTipText")); // NOI18N
  590. but4.setContentAreaFilled(false);
  591. but4.setFocusable(false);
  592. but4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
  593. but4.setName("but4"); // NOI18N
  594. but4.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/xclock.png"))); // NOI18N
  595. but4.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/mpv5/resources/images/32/view_right.png"))); // NOI18N
  596. but4.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
  597. but4.addActionListener(new java.awt.event.ActionListener() {
  598. public void actionPerformed(java.awt.event.ActionEvent evt) {
  599. but4ActionPerformed(evt);
  600. }
  601. });
  602. javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
  603. jPanel2.setLayout(jPanel2Layout);
  604. jPanel2Layout.setHorizontalGroup(
  605. jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  606. .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 882, Short.MAX_VALUE)
  607. .addGroup(jPanel2Layout.createSequentialGroup()
  608. .addComponent(but4, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
  609. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 804, Short.MAX_VALUE)
  610. .addComponent(but5, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
  611. .addGroup(jPanel2Layout.createSequentialGroup()
  612. .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  613. .addGroup(jPanel2Layout.createSequentialGroup()
  614. .addComponent(timeframeChooser2, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE)
  615. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  616. .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  617. .addGroup(jPanel2Layout.createSequentialGroup()
  618. .addComponent(labeledCombobox4, javax.swing.GroupLayout.PREFERRED_SIZE, 325, javax.swing.GroupLayout.PREFERRED_SIZE)
  619. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  620. .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  621. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  622. .addComponent(labeledCombobox3, javax.swing.GroupLayout.PREFERRED_SIZE, 322, javax.swing.GroupLayout.PREFERRED_SIZE)
  623. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  624. .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
  625. .addContainerGap(91, Short.MAX_VALUE))
  626. );
  627. jPanel2Layout.setVerticalGroup(
  628. jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  629. .addGroup(jPanel2Layout.createSequentialGroup()
  630. .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
  631. .addComponent(timeframeChooser2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  632. .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
  633. .addGap(9, 9, 9)
  634. .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
  635. .addComponent(labeledCombobox4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  636. .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  637. .addComponent(labeledCombobox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  638. .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
  639. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  640. .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 42, Short.MAX_VALUE)
  641. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  642. .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  643. .addComponent(but4, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
  644. .addComponent(but5, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
  645. .addContainerGap())
  646. );
  647. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
  648. this.setLayout(layout);
  649. layout.setHorizontalGroup(
  650. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  651. .addGroup(layout.createSequentialGroup()
  652. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  653. .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  654. .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  655. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  656. .addComponent(jSplitPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 252, javax.swing.GroupLayout.PREFERRED_SIZE))
  657. );
  658. layout.setVerticalGroup(
  659. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  660. .addGroup(layout.createSequentialGroup()
  661. .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  662. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  663. .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  664. .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 397, Short.MAX_VALUE)
  665. );
  666. }// </editor-fold>//GEN-END:initComponents
  667. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
  668. filterByTimeframe(timeframeChooser1.getTime());
  669. }//GEN-LAST:event_jButton1ActionPerformed
  670. private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
  671. try {
  672. filterByGroup((Group) Group.getObject(Context.getGroup(),
  673. Integer.valueOf(labeledCombobox1.getSelectedItem().
  674. getId())));
  675. } catch (Exception ex) {
  676. Log.Debug(ex);
  677. }
  678. }//GEN-LAST:event_jButton2ActionPerformed
  679. private void nextEventsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_nextEventsMouseClicked
  680. if (evt.getClickCount() > 1) {
  681. try {
  682. System.err.println(mpv5.YabsViewProxy.instance().
  683. getIdentifierView());
  684. createBill();
  685. } catch (Exception e) {
  686. Log.Debug(e);
  687. }
  688. }
  689. }//GEN-LAST:event_nextEventsMouseClicked
  690. private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
  691. filterByItemType(Integer.valueOf(labeledCombobox2.getSelectedItem().
  692. getId()));
  693. }//GEN-LAST:event_jButton3ActionPerformed
  694. private void overdueMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_overdueMouseClicked
  695. Reminder rem;
  696. DatabaseObject dbo;
  697. Item itm;
  698. if (evt.getClickCount() > 1) {
  699. try {
  700. System.err.println(mpv5.YabsViewProxy.instance().
  701. getIdentifierView());
  702. dbo = ((DatabaseObject) overdue.getModel().
  703. getValueAt(overdue.convertRowIndexToModel(overdue.getSelectedRow()),
  704. 0));
  705. if (dbo.getColor().equals(Color.RED)
  706. && (dbo instanceof Item)) {
  707. itm = (Item) dbo;
  708. if (itm.__getInttype() == Item.TYPE_BILL) {
  709. if (Popup.Y_N_dialog(Messages.CREATE_REMINDER.toString())) {
  710. rem = new Reminder();
  711. rem.setCname(Messages.REMINDER.toString() + "@" + dbo.__getCname());
  712. rem.setDateadded(new Date());
  713. rem.setDescription("");
  714. rem.setGroupsids(dbo.__getGroupsids());
  715. rem.setIntaddedby(User.getCurrentUser().getID());
  716. rem.setItemsids(dbo.__getIDS());
  717. rem.save();
  718. }
  719. }
  720. }
  721. mpv5.YabsViewProxy.instance().
  722. getIdentifierView().
  723. addTab(dbo);
  724. } catch (Exception e) {
  725. Log.Debug(e);
  726. }
  727. }
  728. }//GEN-LAST:event_overdueMouseClicked
  729. private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
  730. filterByItemType2(Integer.valueOf(labeledCombobox4.getSelectedItem().
  731. getId()));
  732. }//GEN-LAST:event_jButton4ActionPerformed
  733. private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
  734. try {
  735. filterByGroup2((Group) Group.getObject(Context.getGroup(),
  736. Integer.valueOf(labeledCombobox3.getSelectedItem().
  737. getId())));
  738. } catch (Exception ex) {
  739. Log.Debug(ex);
  740. }
  741. }//GEN-LAST:event_jButton5ActionPerformed
  742. private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
  743. filterByTimeframe2(timeframeChooser2.getTime());
  744. }//GEN-LAST:event_jButton6ActionPerformed
  745. private void but4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but4ActionPerformed
  746. Log.Debug(this, "adding new schedule from Homescreen");
  747. ScheduleEvents.instanceOf();
  748. }//GEN-LAST:event_but4ActionPerformed
  749. private void but5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but5ActionPerformed
  750. Schedule d = (Schedule) nextEvents.getModel().getValueAt(nextEvents.convertRowIndexToModel(nextEvents.getSelectedRow()), 0);
  751. Log.Debug(this, "deleting the marked entry from Homescreen (and database :-) )");
  752. d.delete();
  753. refresh();
  754. }//GEN-LAST:event_but5ActionPerformed
  755. private void but6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_but6ActionPerformed
  756. odata = xdata = null;
  757. refresh();
  758. HashMap<Color, List<Schedule>> map1 = Scheduler.getScheduledBills(null);
  759. Iterator<Color> it1 = map1.keySet().
  760. iterator();
  761. while (it1.hasNext()) {
  762. Color c = it1.next();
  763. List<Schedule> data = map1.get(c);
  764. if (!data.isEmpty()) {
  765. this.show(map1, this.getNextEvents());
  766. break;
  767. }
  768. }
  769. HashMap<Color, List<Item>> map2 = Scheduler.getOverdueEvents();
  770. Iterator<Color> it2 = map2.keySet().
  771. iterator();
  772. while (it2.hasNext()) {
  773. Color c = it2.next();
  774. List<Item> data = map2.get(c);
  775. if (!data.isEmpty()) {
  776. this.show(map2, this.getOverdue());
  777. break;
  778. }
  779. }
  780. }//GEN-LAST:event_but6ActionPerformed
  781. // Variables declaration - do not modify//GEN-BEGIN:variables
  782. private mpv5.ui.beans.LabeledTextField bills;
  783. private javax.swing.JButton but4;
  784. private javax.swing.JButton but5;
  785. private javax.swing.JButton but6;
  786. private javax.swing.JButton jButton1;
  787. private javax.swing.JButton jButton2;
  788. private javax.swing.JButton jButton3;
  789. private javax.swing.JButton jButton4;
  790. private javax.swing.JButton jButton5;
  791. private javax.swing.JButton jButton6;
  792. private javax.swing.JPanel jPanel1;
  793. private javax.swing.JPanel jPanel2;
  794. private javax.swing.JScrollPane jScrollPane1;
  795. private javax.swing.JScrollPane jScrollPane2;
  796. private javax.swing.JSplitPane jSplitPane1;
  797. private mpv5.ui.beans.LabeledCombobox labeledCombobox1;
  798. private mpv5.ui.beans.LabeledCombobox labeledCombobox2;
  799. private mpv5.ui.beans.LabeledCombobox labeledCombobox3;
  800. private mpv5.ui.beans.LabeledCombobox labeledCombobox4;
  801. private javax.swing.JTable nextEvents;
  802. private mpv5.ui.beans.LabeledTextField offers;
  803. private mpv5.ui.beans.LabeledTextField orders;
  804. private javax.swing.JTable overdue;
  805. private mpv5.ui.beans.TimeframeChooser timeframeChooser1;
  806. private mpv5.ui.beans.TimeframeChooser timeframeChooser2;
  807. // End of variables declaration//GEN-END:variables
  808. private void createBill() {
  809. if (Popup.Y_N_dialog(Messages.SCHEDULE_NEW_ITEMS)) {
  810. MPTableModel m = (MPTableModel) nextEvents.getModel();
  811. Schedule schedule = (Schedule) m.getValueAt(nextEvents.convertRowIndexToModel(nextEvents.getSelectedRow()),
  812. 0);
  813. Log.Debug(this, !schedule.__getIsdone());
  814. if (!schedule.__getIsdone()) {
  815. Log.Debug(this, "Objekt muss generiert werden ...");
  816. try {
  817. Item item = schedule.getItem();
  818. SubItem[] subs = item.getSubitems();
  819. item.setIDS(-1);
  820. item.setDateadded(new Date());
  821. try {
  822. item.setDatetodo(DateConverter.addDays(new Date(), Integer.valueOf(mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("bills.warn.days"))));
  823. item.setDateend(DateConverter.addDays(new Date(), Integer.valueOf(mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("bills.alert.days"))));
  824. } catch (Exception e) {
  825. item.setDatetodo(DateConverter.addDays(new Date(), 14));
  826. item.setDateend(DateConverter.addDays(new Date(), 30));
  827. }
  828. item.setIntreminders(0);
  829. item.setIntstatus(Item.STATUS_IN_PROGRESS);
  830. item.setDescription(item.__getDescription()
  831. + "\n"
  832. + Messages.SCHEDULE_GENERATED
  833. + "\n"
  834. + item.__getCname());
  835. Log.Debug(this, "Objekt wird gesichert ...");
  836. item.save();
  837. for (int j = 0; j < subs.length; j++) {
  838. SubItem subItem = subs[j];
  839. subItem.setItemsids(item.__getIDS());
  840. subItem.setIDS(-1);
  841. subItem.save(true);
  842. }
  843. Log.Debug(this, "Posten wurden gesichert ...");
  844. Date olddate = schedule.__getNextdate();
  845. schedule.setNextdate(DateConverter.addMonths(schedule.__getNextdate(), schedule.__getIntervalmonth()));
  846. if (schedule.__getNextdate().before(schedule.__getStopdate())) {
  847. Schedule s2 = (Schedule) schedule.clone();
  848. s2.setIsdone(false);
  849. s2.setIDS(-1);
  850. s2.save(true);
  851. schedule.setNextdate(olddate);
  852. schedule.setIsdone(true);
  853. schedule.save(true);
  854. } else {
  855. schedule.setNextdate(olddate);
  856. schedule.setIsdone(true);
  857. schedule.save(true);
  858. mpv5.YabsViewProxy.instance().addMessage(Messages.SCHEDULE_ITEM_REMOVED + " " + schedule);
  859. }
  860. Log.Debug(this, "Schedule wurde gesichert ...");
  861. mpv5.YabsViewProxy.instance().
  862. getIdentifierView().
  863. addTab(item);
  864. m.removeRow(nextEvents.convertRowIndexToModel(nextEvents.getSelectedRow()));
  865. } catch (NodataFoundException ex) {
  866. Log.Debug(ex);
  867. }
  868. }
  869. }
  870. }
  871. public void refresh() {
  872. // ?berf?llige Objekte zur?cksetzen ...
  873. timeframeChooser1.setTime(new vTimeframe(DateConverter.getStartOfMonth(new Date()), DateConverter.getEndOfMonth(new Date())));
  874. labeledCombobox1.getComboBox().setSelectedIndex(-1);
  875. labeledCombobox2.getComboBox().setSelectedIndex(-1);
  876. setData(odata, overdue, false);
  877. // Zyklische Objekte zur?cksetzen ...
  878. timeframeChooser2.setTime(new vTimeframe(DateConverter.getStartOfMonth(new Date()), DateConverter.getEndOfMonth(new Date())));
  879. labeledCombobox3.getComboBox().setSelectedIndex(-1);
  880. labeledCombobox4.getComboBox().setSelectedIndex(-1);
  881. setData(xdata, nextEvents, true);
  882. // Navigation rechts aktualisieren ...
  883. sc.setDate(new Date());
  884. SDEPanel.setDayEvents(null);
  885. }
  886. }