PageRenderTime 108ms CodeModel.GetById 47ms RepoModel.GetById 0ms app.codeStats 1ms

/src/mpv5/ui/panels/StartPage.java

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Java | 366 lines | 296 code | 53 blank | 17 comment | 7 complexity | d48a01b9204bb7e7908836e25880b591 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. package mpv5.ui.panels;
  2. import java.awt.Component;
  3. import java.awt.event.ActionEvent;
  4. import java.io.File;
  5. import java.io.FileOutputStream;
  6. import java.io.InputStream;
  7. import java.io.OutputStream;
  8. import java.util.Arrays;
  9. import java.util.Collections;
  10. import java.util.Enumeration;
  11. import java.util.List;
  12. import java.util.Properties;
  13. import javax.swing.AbstractAction;
  14. import javax.swing.DefaultListModel;
  15. import javax.swing.JComponent;
  16. import javax.swing.JTable;
  17. import javax.swing.ListModel;
  18. import javax.swing.table.TableCellRenderer;
  19. import mpv5.Main;
  20. import mpv5.db.common.Context;
  21. import mpv5.db.common.DatabaseObject;
  22. import mpv5.db.objects.Contact;
  23. import mpv5.globals.Constants;
  24. import mpv5.globals.Headers;
  25. import mpv5.globals.LocalSettings;
  26. import mpv5.globals.Messages;
  27. import mpv5.handler.Scheduler;
  28. import mpv5.logging.Log;
  29. import mpv5.ui.dialogs.Search2;
  30. import mpv5.ui.frames.MPView;
  31. import mpv5.utils.files.FileReaderWriter;
  32. import mpv5.utils.images.MPIcon;
  33. import mpv5.utils.models.MPTableModel;
  34. import mpv5.utils.tables.TableFormat;
  35. /**
  36. *
  37. *
  38. */
  39. public class StartPage extends javax.swing.JPanel {
  40. private java.util.ResourceBundle bundle = mpv5.i18n.LanguageManager.getBundle();
  41. /** Creates new form ListPanel */
  42. public StartPage() {
  43. initComponents();
  44. setName("startpage");
  45. jTextArea1.setText(Messages.START_MESSAGE.getValue().replace("*", ""));
  46. Runnable runnable = new Runnable() {
  47. public void run() {
  48. fillFiles();
  49. }
  50. };
  51. new Thread(runnable).start();
  52. Runnable runnable1 = new Runnable() {
  53. public void run() {
  54. syst.setModel(getSysInfo());
  55. }
  56. };
  57. new Thread(runnable1).start();
  58. }
  59. /** This method is called from within the constructor to
  60. * initialize the form.
  61. * WARNING: Do NOT modify this code. The content of this method is
  62. * always regenerated by the Form Editor.
  63. *
  64. * DatabaseObject d = DatabaseObject.getObject(Context.getCustomer());
  65. ((mpv5.db.objects.Contact) d).setisCustomer(true);
  66. mpv5.YabsViewProxy.instance().getIdentifierView().addTab(d, Messages.NEW_CUSTOMER);
  67. */
  68. @SuppressWarnings("unchecked")
  69. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  70. private void initComponents() {
  71. jTabbedPane1 = new javax.swing.JTabbedPane();
  72. jScrollPane1 = new javax.swing.JScrollPane();
  73. jTextArea1 = new javax.swing.JTextArea();
  74. jPanel2 = new javax.swing.JPanel();
  75. jLabel1 = new javax.swing.JLabel();
  76. jScrollPane3 = new javax.swing.JScrollPane();
  77. jTextArea2 = new javax.swing.JTextArea();
  78. jScrollPane2 = new javax.swing.JScrollPane();
  79. licensetable = new JTable() {
  80. public Component prepareRenderer(TableCellRenderer renderer,
  81. int rowIndex, int vColIndex) {
  82. Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
  83. if (c instanceof JComponent) {
  84. JComponent jc = (JComponent)c;
  85. jc.setToolTipText(String.valueOf(getValueAt(rowIndex, vColIndex)));
  86. }
  87. return c;
  88. }
  89. };
  90. jPanel3 = new javax.swing.JPanel();
  91. jLabel3 = new javax.swing.JLabel();
  92. jScrollPane5 = new javax.swing.JScrollPane();
  93. images = new javax.swing.JList();
  94. jScrollPane4 = new javax.swing.JScrollPane();
  95. jTextArea3 = new javax.swing.JTextArea();
  96. jPanel1 = new javax.swing.JPanel();
  97. jScrollPane6 = new javax.swing.JScrollPane();
  98. syst = new javax.swing.JList();
  99. java.util.ResourceBundle bundle = mpv5.i18n.LanguageManager.getBundle(); // NOI18N
  100. setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("StartPage.border.title"))); // NOI18N
  101. setName("Form"); // NOI18N
  102. jTabbedPane1.setName("jTabbedPane1"); // NOI18N
  103. jScrollPane1.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
  104. jScrollPane1.setName("jScrollPane1"); // NOI18N
  105. jTextArea1.setColumns(20);
  106. jTextArea1.setLineWrap(true);
  107. jTextArea1.setRows(5);
  108. jTextArea1.setText(bundle.getString("StartPage.jTextArea1.text")); // NOI18N
  109. jTextArea1.setWrapStyleWord(true);
  110. jTextArea1.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
  111. jTextArea1.setName("jTextArea1"); // NOI18N
  112. jScrollPane1.setViewportView(jTextArea1);
  113. jTabbedPane1.addTab(bundle.getString("StartPage.jScrollPane1.TabConstraints.tabTitle"), jScrollPane1); // NOI18N
  114. jPanel2.setName("jPanel2"); // NOI18N
  115. jPanel2.setLayout(new java.awt.BorderLayout());
  116. jLabel1.setText(bundle.getString("StartPage.jLabel1.text")); // NOI18N
  117. jLabel1.setName("jLabel1"); // NOI18N
  118. jPanel2.add(jLabel1, java.awt.BorderLayout.PAGE_START);
  119. jScrollPane3.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
  120. jScrollPane3.setName("jScrollPane3"); // NOI18N
  121. jTextArea2.setColumns(20);
  122. jTextArea2.setLineWrap(true);
  123. jTextArea2.setRows(5);
  124. jTextArea2.setText(bundle.getString("StartPage.jTextArea2.text")); // NOI18N
  125. jTextArea2.setWrapStyleWord(true);
  126. jTextArea2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
  127. jTextArea2.setName("jTextArea2"); // NOI18N
  128. jScrollPane3.setViewportView(jTextArea2);
  129. jPanel2.add(jScrollPane3, java.awt.BorderLayout.PAGE_END);
  130. jScrollPane2.setName("jScrollPane2"); // NOI18N
  131. licensetable.setAutoCreateRowSorter(true);
  132. licensetable.setModel(new javax.swing.table.DefaultTableModel(
  133. new Object [][] {
  134. },
  135. new String [] {
  136. }
  137. ));
  138. licensetable.setName("licensetable"); // NOI18N
  139. jScrollPane2.setViewportView(licensetable);
  140. jPanel2.add(jScrollPane2, java.awt.BorderLayout.CENTER);
  141. jTabbedPane1.addTab(bundle.getString("StartPage.jPanel2.TabConstraints.tabTitle"), jPanel2); // NOI18N
  142. jPanel3.setName("jPanel3"); // NOI18N
  143. jLabel3.setText(bundle.getString("StartPage.jLabel3.text")); // NOI18N
  144. jLabel3.setName("jLabel3"); // NOI18N
  145. jScrollPane5.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
  146. jScrollPane5.setName("jScrollPane5"); // NOI18N
  147. images.setBorder(javax.swing.BorderFactory.createEtchedBorder());
  148. images.setFont(new java.awt.Font("Dialog", 0, 12));
  149. images.setModel(new javax.swing.AbstractListModel() {
  150. String[] strings = { "KDE Crystal Diamond Icons set compiled by Paolo Campitelli:", " ", "(Based on \"Crystal Project\", \"Human Kanpio Mod\", \"Vista Inspirate\", \"Crystal Clear\", \"Nuove XT\", \"OSX\" , \"SnowIsh\", \"Debian Icon\", \"Firefox Alternative\" )", " ", " ", "YaBS Logo by Jean-Christoph von Oertzen" };
  151. public int getSize() { return strings.length; }
  152. public Object getElementAt(int i) { return strings[i]; }
  153. });
  154. images.setName("images"); // NOI18N
  155. jScrollPane5.setViewportView(images);
  156. jScrollPane4.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
  157. jScrollPane4.setName("jScrollPane4"); // NOI18N
  158. jTextArea3.setColumns(20);
  159. jTextArea3.setLineWrap(true);
  160. jTextArea3.setRows(5);
  161. jTextArea3.setText(bundle.getString("StartPage.jTextArea3.text")); // NOI18N
  162. jTextArea3.setWrapStyleWord(true);
  163. jTextArea3.setBorder(javax.swing.BorderFactory.createEtchedBorder());
  164. jTextArea3.setName("jTextArea3"); // NOI18N
  165. jScrollPane4.setViewportView(jTextArea3);
  166. javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
  167. jPanel3.setLayout(jPanel3Layout);
  168. jPanel3Layout.setHorizontalGroup(
  169. jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  170. .addGroup(jPanel3Layout.createSequentialGroup()
  171. .addContainerGap()
  172. .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  173. .addGroup(jPanel3Layout.createSequentialGroup()
  174. .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 438, Short.MAX_VALUE)
  175. .addGap(22, 22, 22))
  176. .addGroup(jPanel3Layout.createSequentialGroup()
  177. .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  178. .addComponent(jScrollPane5, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
  179. .addComponent(jScrollPane4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 447, Short.MAX_VALUE))
  180. .addGap(13, 13, 13))))
  181. );
  182. jPanel3Layout.setVerticalGroup(
  183. jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  184. .addGroup(jPanel3Layout.createSequentialGroup()
  185. .addContainerGap()
  186. .addComponent(jLabel3)
  187. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  188. .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 188, Short.MAX_VALUE)
  189. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  190. .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE))
  191. );
  192. jTabbedPane1.addTab(bundle.getString("StartPage.jPanel3.TabConstraints.tabTitle"), jPanel3); // NOI18N
  193. jPanel1.setName("jPanel1"); // NOI18N
  194. jScrollPane6.setName("jScrollPane6"); // NOI18N
  195. syst.setName("syst"); // NOI18N
  196. jScrollPane6.setViewportView(syst);
  197. javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  198. jPanel1.setLayout(jPanel1Layout);
  199. jPanel1Layout.setHorizontalGroup(
  200. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  201. .addGroup(jPanel1Layout.createSequentialGroup()
  202. .addContainerGap()
  203. .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 448, Short.MAX_VALUE)
  204. .addContainerGap())
  205. );
  206. jPanel1Layout.setVerticalGroup(
  207. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  208. .addGroup(jPanel1Layout.createSequentialGroup()
  209. .addContainerGap()
  210. .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 337, Short.MAX_VALUE)
  211. .addContainerGap())
  212. );
  213. jTabbedPane1.addTab(bundle.getString("StartPage.jPanel1.TabConstraints.tabTitle"), jPanel1); // NOI18N
  214. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
  215. this.setLayout(layout);
  216. layout.setHorizontalGroup(
  217. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  218. .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 480, Short.MAX_VALUE)
  219. );
  220. layout.setVerticalGroup(
  221. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  222. .addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 399, Short.MAX_VALUE)
  223. );
  224. }// </editor-fold>//GEN-END:initComponents
  225. // Variables declaration - do not modify//GEN-BEGIN:variables
  226. private javax.swing.JList images;
  227. private javax.swing.JLabel jLabel1;
  228. private javax.swing.JLabel jLabel3;
  229. private javax.swing.JPanel jPanel1;
  230. private javax.swing.JPanel jPanel2;
  231. private javax.swing.JPanel jPanel3;
  232. private javax.swing.JScrollPane jScrollPane1;
  233. private javax.swing.JScrollPane jScrollPane2;
  234. private javax.swing.JScrollPane jScrollPane3;
  235. private javax.swing.JScrollPane jScrollPane4;
  236. private javax.swing.JScrollPane jScrollPane5;
  237. private javax.swing.JScrollPane jScrollPane6;
  238. private javax.swing.JTabbedPane jTabbedPane1;
  239. private javax.swing.JTextArea jTextArea1;
  240. private javax.swing.JTextArea jTextArea2;
  241. private javax.swing.JTextArea jTextArea3;
  242. private javax.swing.JTable licensetable;
  243. private javax.swing.JList syst;
  244. // End of variables declaration//GEN-END:variables
  245. @SuppressWarnings("unchecked")
  246. private ListModel getSysInfo() {
  247. DefaultListModel m = new DefaultListModel();
  248. m.addElement("YaBS Version: " + Constants.VERSION + " " + Constants.TITLE);
  249. m.addElement("Database: " + LocalSettings.getProperty(LocalSettings.DBPATH));
  250. m.addElement("Database type: " + LocalSettings.getProperty(LocalSettings.DBTYPE));
  251. m.addElement("Database driver: " + LocalSettings.getProperty(LocalSettings.DBDRIVER));
  252. m.addElement("Database minimal version: " + Constants.DATABASE_VERSION);
  253. m.addElement("Cache directory: " + LocalSettings.getProperty(LocalSettings.CACHE_DIR));
  254. m.addElement("Use OpenOffice: " + LocalSettings.getProperty(LocalSettings.OFFICE_USE));
  255. m.addElement("");
  256. m.addElement("");
  257. Properties sysprops = System.getProperties();
  258. Enumeration propn = sysprops.propertyNames();
  259. List v = Collections.list(propn);
  260. Collections.sort(v);
  261. Enumeration p = Collections.enumeration(v);
  262. while (p.hasMoreElements()) {
  263. String propname = (String) p.nextElement();
  264. m.addElement("System env: " + propname.toLowerCase() + ": " + System.getProperty(propname));
  265. }
  266. return m;
  267. }
  268. private void fillFiles() {
  269. if (Main.INSTANTIATED) {
  270. final DefaultListModel m = new DefaultListModel();
  271. Runnable runnable = new Runnable() {
  272. public void run() {
  273. try {
  274. try {
  275. File licenses = new File("licenses-list.txt");
  276. if (!licenses.exists()) {
  277. InputStream inputStream = Main.class.getResourceAsStream("/mpv5/resources/license/licenses-list");
  278. OutputStream out = new FileOutputStream(licenses);
  279. byte buf[] = new byte[1024];
  280. int len;
  281. while ((len = inputStream.read(buf)) > 0) {
  282. out.write(buf, 0, len);
  283. }
  284. out.close();
  285. inputStream.close();
  286. }
  287. String[] data = (new FileReaderWriter(licenses).readLines());
  288. Arrays.sort(data);
  289. String[][] model = new String[data.length][];
  290. for (int i = 0; i < data.length; i++) {
  291. String string = data[i];
  292. model[i] = string.split(";");
  293. }
  294. licensetable.setModel(new MPTableModel(model, Headers.LIBRARIEST ));
  295. } catch (Exception ex) {
  296. Log.Debug(this, ex.getLocalizedMessage());
  297. }
  298. DefaultListModel d = new DefaultListModel();
  299. ListModel list = images.getModel();
  300. for (int i = 0; i < list.getSize(); i++) {
  301. d.addElement(list.getElementAt(i));
  302. }
  303. d.addElement(new MPIcon("/mpv5/resources/images/icon.png"));
  304. images.setModel(d);
  305. } catch (Exception exception) {
  306. Log.Debug(exception);
  307. }
  308. }
  309. };
  310. new Thread(runnable).start();
  311. }
  312. }
  313. }