/* * Copyright (C) 2012 Miguel Angel Garcia<miguelangel.garcia@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.magmax.master.project.admin; import org.magmax.master.project.admin.user.UserCrudModel; import org.magmax.eswing.crud.CrudTable; import org.magmax.eswing.crud.DefaultCrudUIDelete; import org.magmax.master.project.admin.product.ProductCrudModel; import org.magmax.master.project.admin.product.ProductDialog; import org.magmax.master.project.admin.section.SectionCrudModel; import org.magmax.master.project.admin.section.SectionDialog; import org.magmax.master.project.admin.user.UserDialog; /** * * @author Miguel Angel Garcia<miguelangel.garcia@gmail.com> */ public class MainWindow extends javax.swing.JFrame { private CrudTable userTable; private CrudTable sectionTable; private CrudTable productTable; private UserCrudModel userCrudModel; /** * Creates new form MainWindow */ public MainWindow() { initComponents(); setLocationByPlatform(true); initializeUserPanel(); initializeSectionPanel(); initializeProductPanel(); } private void initializeProductPanel() { ProductCrudModel productCrudModel = new ProductCrudModel(); productTable = new CrudTable(productCrudModel); jPanel3.add(productTable); ProductDialog productDialog = new ProductDialog(this); productTable.setCrudUICreate(productDialog); productTable.setCrudUIUpdate(productDialog); productTable.setCrudUIDetails(productDialog); productTable.setCrudUIDelete(new DefaultCrudUIDelete()); productTable.loadData(); } private void initializeSectionPanel() { sectionTable = new CrudTable(new SectionCrudModel()); jPanel2.add(sectionTable); SectionDialog sectionDialog = new SectionDialog((this)); sectionTable.setCrudUICreate(sectionDialog); sectionTable.setCrudUIUpdate(sectionDialog); //sectionTable.setCrudUIDetails(sectionDialog); sectionTable.setCrudUIDelete(new DefaultCrudUIDelete()); sectionTable.loadData(); } private void initializeUserPanel() { userCrudModel = new UserCrudModel(); userTable = new CrudTable(userCrudModel); jPanel1.add(userTable); UserDialog userDialog = new UserDialog(this); // userTable.setCrudUICreate(userDialog); // deshabilitado, ya que no puede introducir la contraseña userTable.setCrudUIUpdate(userDialog); userTable.setCrudUIDetails(userDialog); userTable.setCrudUIDelete(new DefaultCrudUIDelete()); userTable.loadData(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jTabbedPane1 = new javax.swing.JTabbedPane(); jPanel1 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); jPanel3 = new javax.swing.JPanel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Ventana de administración"); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { close(evt); } }); jTabbedPane1.setTabPlacement(javax.swing.JTabbedPane.LEFT); jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.LINE_AXIS)); jTabbedPane1.addTab("Users", jPanel1); jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.LINE_AXIS)); jTabbedPane1.addTab("Sections", jPanel2); jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.LINE_AXIS)); jTabbedPane1.addTab("Products", jPanel3); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 585, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 379, Short.MAX_VALUE) ); pack(); }// </editor-fold>//GEN-END:initComponents private void close(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_close Persistence.getInstance().destroy(); }//GEN-LAST:event_close /** * @param args the command line arguments */ public static void main(String args[]) { /* * Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* * If Nimbus (introduced in Java SE 6) is not available, stay with the * default look and feel. For details see * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(MainWindow.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* * Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new MainWindow().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JTabbedPane jTabbedPane1; // End of variables declaration//GEN-END:variables }