Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * InputPanel.java
- *
- * Created on March 12, 2008, 8:13 PM
- */
- package edu.ohiou.cs550.manufacturing.gui;
- import edu.ohiou.cs550.manufacturing.renderers.*;
- import edu.ohiou.cs550.manufacturing.listeners.*;
- import edu.ohiou.cs550.manufacturing.*;
- import javax.swing.table.*;
- import java.awt.event.*;
- import javax.swing.event.*;
- import javax.swing.table.*;
- /**
- *
- * @author alex
- */
- public class InputPanel extends javax.swing.JPanel {
- protected ManufacturingLayout layout;
- protected ManufacturingLayoutModel mlModel;
- protected InputTableValues itv = new InputTableValues();
- protected MachineRenderer machineCellRenderer = new MachineRenderer();
- protected MachineEditor machineCellEditor = new MachineEditor();
- protected SlotRenderer slotCellRenderer = new SlotRenderer();
- InputPartListener pListener = new InputPartListener();
- InputMachineListener mListener = new InputMachineListener();
- MachineCellListener mcListener = new MachineCellListener();
- /** Creates new form InputPanel */
- public InputPanel() {
- initComponents();
- }
- public void loadSystem(ManufacturingLayout layout, ManufacturingLayoutModel mlModel){
- this.layout = layout;
- this.mlModel = mlModel;
- if(this.layout != null){
- itv.loadSystem(layout, mlModel);
- machineCellRenderer.loadSystem(layout, mlModel);
- machineCellEditor.loadSystem(layout, mlModel);
- slotCellRenderer.loadSystem(layout, mlModel, itv);
- machineCellEditor.addCellEditorListener(mcListener);
- TableColumnModel tcm = inputTable.getColumnModel();
- TableColumn tcMachine = tcm.getColumn(InputTableValues.MACHINE);
- TableColumn tcSlot = tcm.getColumn(InputTableValues.SLOT);
- tcMachine.setCellRenderer(machineCellRenderer);
- tcMachine.setCellEditor(machineCellEditor);
- tcSlot.setCellRenderer(slotCellRenderer);
- if(mlModel != null){
- mlModel.addPartListener(pListener);
- mlModel.addMachineListener(mListener);
- }
- }
- }
- /** 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.
- */
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- inputLabel = new javax.swing.JLabel();
- jScrollPane1 = new javax.swing.JScrollPane();
- inputTable = new javax.swing.JTable();
- inputTextArea = new javax.swing.JTextArea();
- setLayout(new java.awt.BorderLayout());
- inputLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
- inputLabel.setText("Input Information"); // NOI18N
- add(inputLabel, java.awt.BorderLayout.PAGE_START);
- inputTable.setModel(itv);
- inputTable.setRowSelectionAllowed(false);
- jScrollPane1.setViewportView(inputTable);
- add(jScrollPane1, java.awt.BorderLayout.CENTER);
- inputTextArea.setColumns(20);
- inputTextArea.setEditable(false);
- inputTextArea.setRows(5);
- inputTextArea.setText("For each part set the machine and slot it should be routed to."); // NOI18N
- inputTextArea.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Instructions"));
- add(inputTextArea, java.awt.BorderLayout.SOUTH);
- }// </editor-fold>
- // Variables declaration - do not modify
- private javax.swing.JLabel inputLabel;
- private javax.swing.JTable inputTable;
- private javax.swing.JTextArea inputTextArea;
- private javax.swing.JScrollPane jScrollPane1;
- // End of variables declaration
- protected class InputPartListener implements PartListener {
- public void partAdded(String name, int loc){
- itv.addRow();
- }
- public void partRemoved(String name, int loc){
- itv.removeRow();
- }
- public void partSelected(String name){
- }
- }
- protected class InputMachineListener implements MachineListener {
- public void machineAdded(String name, int loc){
- machineCellEditor.loadItems();
- itv.fireTableRowsUpdated(0, itv.getRowCount()-1);
- }
- public void machineRemoved(String name, int loc){
- for(int i = 0; i < itv.getRowCount(); i++){
- if(itv.getValueAt(i, 0).equals(name)){
- itv.setValueAt("",i,0);
- }
- }
- machineCellEditor.loadItems();
- itv.fireTableRowsUpdated(0, itv.getRowCount()-1);
- }
- public void machineSelected(String name){
- }
- }
- public class MachineCellListener implements CellEditorListener {
- public void editingStopped(ChangeEvent e){
- itv.fireTableRowsUpdated(0, itv.getRowCount()-1);
- }
- public void editingCanceled(ChangeEvent e){
- }
- }
- }
Add Comment
Please, Sign In to add comment