/* * Copyright (C) 2014 GG-Net GmbH - Oliver Günther * * 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 eu.ggnet.dwoss.receipt.product; import java.awt.Window; import eu.ggnet.dwoss.receipt.stub.ProductProcessorStub; import eu.ggnet.dwoss.util.IView; import eu.ggnet.dwoss.util.OkCancelDialog; /** * * @author pascal.perau */ public class CpuListPanel extends javax.swing.JPanel implements IView<Window> { private CpuListController controller; private Window view; /** Creates new form ListCpuPanel */ public CpuListPanel(CpuListController controller) { initComponents(); if ( controller == null ) return; this.controller = controller; controller.setView(view); cpuTable.setModel(controller.getModel()); controller.getModel().setTable(cpuTable); } /** 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() { jScrollPane1 = new javax.swing.JScrollPane(); cpuTable = new javax.swing.JTable(); jLabel1 = new javax.swing.JLabel(); filterField = new javax.swing.JTextField(); searchButton = new javax.swing.JButton(); setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED, new java.awt.Color(204, 204, 255), java.awt.Color.black), "Cpu-Liste")); setMinimumSize(new java.awt.Dimension(640, 360)); setName(""); setPreferredSize(new java.awt.Dimension(640, 360)); cpuTable.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null}, {null, null, null, null}, {null, null, null, null}, {null, null, null, null} }, new String [] { "Title 1", "Title 2", "Title 3", "Title 4" } )); cpuTable.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { cpuTableMouseClicked(evt); } }); jScrollPane1.setViewportView(cpuTable); jLabel1.setText("Filter:"); searchButton.setText("Los !"); searchButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { searchButtonActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(filterField, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(searchButton, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(244, Short.MAX_VALUE)) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 628, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(filterField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(searchButton)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE)) ); }// </editor-fold>//GEN-END:initComponents private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchButtonActionPerformed if ( controller != null ) controller.filter(filterField.getText()); }//GEN-LAST:event_searchButtonActionPerformed private void cpuTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cpuTableMouseClicked if ( evt.getClickCount() == 2 ) { controller.editSelected(); } }//GEN-LAST:event_cpuTableMouseClicked // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTable cpuTable; private javax.swing.JTextField filterField; private javax.swing.JLabel jLabel1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JButton searchButton; // End of variables declaration//GEN-END:variables public static void main(String[] args) { CpuListController controller; ProductProcessorStub stub = new ProductProcessorStub(); controller = new CpuListController(stub.getSpecAgentStub()); OkCancelDialog<CpuListPanel> panel = new OkCancelDialog<>("blub", new CpuListPanel(controller)); panel.setVisible(true); System.exit(0); } @Override public void setParent(Window window) { this.view = window; } }