/* * 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 SpecListPanel extends javax.swing.JPanel implements IView { private SpecListController controller; private Window view; /** Creates new form SpecListPanel */ public SpecListPanel(SpecListController controller) { initComponents(); if ( controller == null ) return; this.controller = controller; controller.setView(view); specTable.setModel(controller.getModel()); controller.getModel().setTable(specTable); } @Override public void setParent(Window window) { this.view = window; } /** 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(); specTable = new javax.swing.JTable(); filterField = new javax.swing.JTextField(); jLabel1 = new javax.swing.JLabel(); goButton = 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), "Produktliste")); setMinimumSize(new java.awt.Dimension(380, 350)); specTable.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" } )); specTable.setMinimumSize(new java.awt.Dimension(310, 72)); jScrollPane1.setViewportView(specTable); filterField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { searchActionPerformed(evt); } }); jLabel1.setText("Filter:"); goButton.setText("Los"); goButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { searchActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(filterField, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(goButton, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(445, 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(goButton)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 488, Short.MAX_VALUE)) ); }// </editor-fold>//GEN-END:initComponents private void searchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchActionPerformed controller.filter(filterField.getText()); }//GEN-LAST:event_searchActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTextField filterField; private javax.swing.JButton goButton; private javax.swing.JLabel jLabel1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTable specTable; // End of variables declaration//GEN-END:variables public static void main(String[] args) { SpecListController controller; ProductProcessorStub stub = new ProductProcessorStub(); controller = new SpecListController(stub.getSpecAgentStub()); OkCancelDialog<SpecListPanel> panel = new OkCancelDialog<>("blub", new SpecListPanel(controller)); panel.setVisible(true); System.exit(0); } }