/*
* 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 GpuListPanel extends javax.swing.JPanel implements IView {
private GpuListController controller;
private Window view;
/** Creates new form ListCpuPanel */
public GpuListPanel(GpuListController controller) {
initComponents();
if ( controller == null ) return;
this.controller = controller;
controller.setView(view);
gpuTable.setModel(controller.getModel());
controller.getModel().setTable(gpuTable);
}
@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();
gpuTable = new javax.swing.JTable();
jLabel1 = new javax.swing.JLabel();
filterField = new javax.swing.JTextField();
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), "Gpu-Liste"));
setMinimumSize(new java.awt.Dimension(640, 360));
setName("");
setPreferredSize(new java.awt.Dimension(640, 360));
gpuTable.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"
}
));
gpuTable.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
gpuTableMouseClicked(evt);
}
});
jScrollPane1.setViewportView(gpuTable);
jLabel1.setText("Filter:");
goButton.setText("Los !");
goButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
goButtonActionPerformed(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(goButton, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(183, 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(goButton))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 304, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void goButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_goButtonActionPerformed
if ( controller != null ) controller.filter(filterField.getText());
}//GEN-LAST:event_goButtonActionPerformed
private void gpuTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_gpuTableMouseClicked
if ( evt.getClickCount() == 2 ) {
controller.editSelected();
}
}//GEN-LAST:event_gpuTableMouseClicked
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField filterField;
private javax.swing.JButton goButton;
private javax.swing.JTable gpuTable;
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
// End of variables declaration//GEN-END:variables
public static void main(String[] args) {
GpuListController controller;
ProductProcessorStub stub = new ProductProcessorStub();
controller = new GpuListController(stub.getSpecAgentStub());
OkCancelDialog<GpuListPanel> panel = new OkCancelDialog<>("blub", new GpuListPanel(controller));
panel.setVisible(true);
System.exit(0);
}
}