Esempio n. 1
0
  private void showDetail() {
    Session session = HibernateUtils.openSession();
    try {
      int selectedRow = table.getSelectedRow();
      if (selectedRow < 0) {
        return;
      }
      int itemId =
          (int)
              table
                  .getModel()
                  .getValueAt(selectedRow, tableParameters.get(ColumnEnum.ID).getColumnIndex());

      ItemFacade facade = ItemFacade.getInstance();
      Item item = facade.getDetail(itemId, session);

      StockForm stockForm = new StockForm(this, ActionType.UPDATE);
      stockForm.setFormDetailValue(item);
      stockForm.setVisible(true);

      btnRefresh.doClick();
    } finally {
      session.close();
    }
  }
Esempio n. 2
0
 @Override
 protected void keyEventListener(int keyCode) {
   switch (keyCode) {
     case KeyEvent.VK_F5:
       btnRegistrasi.doClick();
       break;
     case KeyEvent.VK_F6:
       btnPrintBarcode.doClick();
       break;
     case KeyEvent.VK_F8:
       txtBarcode.setText("");
       txtBarcode.requestFocus();
       break;
     default:
       break;
   }
 }
Esempio n. 3
0
  private void tambah() {
    new StockForm(StockListDialog.this, ActionType.CREATE).setVisible(true);
    btnRefresh.doClick();

    int row = table.getRowCount() - 1;
    int column = table.getSelectedColumn();
    table.requestFocus();
    table.changeSelection(row, column, false, false);
  }
Esempio n. 4
0
  public StockListDialog(Window parent) {
    super(parent);

    setTitle("Master Barang");
    setPermissionCode(PermissionConstants.STOCK_LIST);
    getContentPane().setLayout(new MigLayout("", "[1000]", "[][300,grow][]"));

    table =
        new XJTable() {
          private static final long serialVersionUID = 1L;

          @Override
          public void rowSelected() {
            btnDetail.doClick();
          }
        };
    XTableUtils.initTable(table, tableParameters);

    XJPanel pnlFilter = new XJPanel();
    getContentPane().add(pnlFilter, "cell 0 0,grow");
    pnlFilter.setLayout(new MigLayout("", "[][grow][]", "[][][][grow]"));

    XJLabel lblKode = new XJLabel();
    lblKode.setText("Kode Barang");
    pnlFilter.add(lblKode, "cell 0 0");

    txtKode = new XJTextField();
    txtKode.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(KeyEvent e) {
            try {
              /*
               * TODO Perbaiki supaya kalo pas key = alt+tab, ga usah load
               * data
               */
              loadDataInThread();
            } catch (Exception ex) {
              ExceptionHandler.handleException(StockListDialog.this, ex);
            }
          }
        });
    pnlFilter.add(txtKode, "cell 1 0 2 1,growx");
    txtKode.setColumns(10);

    XJLabel lblNama = new XJLabel();
    lblNama.setText("Nama Barang");
    pnlFilter.add(lblNama, "cell 0 1");

    txtNama = new XJTextField();
    txtNama.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(KeyEvent e) {
            try {
              loadDataInThread();
            } catch (Exception ex) {
              ExceptionHandler.handleException(StockListDialog.this, ex);
            }
          }
        });
    pnlFilter.add(txtNama, "cell 1 1 2 1,growx");
    txtNama.setColumns(10);

    lblBarcodef = new XJLabel();
    lblBarcodef.setText("Barcode [F8]");
    pnlFilter.add(lblBarcodef, "cell 0 2");

    txtBarcode = new XJTextField();
    txtBarcode.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyReleased(KeyEvent e) {
            try {
              loadDataInThread();
            } catch (Exception ex) {
              ExceptionHandler.handleException(StockListDialog.this, ex);
            }
          }
        });
    pnlFilter.add(txtBarcode, "cell 1 2 2 1,growx");

    XJPanel pnlRadioButton = new XJPanel();
    pnlFilter.add(pnlRadioButton, "cell 1 3,grow");
    pnlRadioButton.setLayout(new MigLayout("", "[]", "[][]"));

    rdBarangAktif = new XJRadioButton();
    rdBarangAktif.setText("Barang Aktif");
    pnlRadioButton.add(rdBarangAktif, "cell 0 0");
    rdBarangAktif.setSelected(true);
    btnGroup.add(rdBarangAktif);

    rdBarangTidakAktif = new XJRadioButton();
    rdBarangTidakAktif.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            try {
              loadDataInThread();
            } catch (Exception ex) {
              ExceptionHandler.handleException(StockListDialog.this, ex);
            }
          }
        });
    rdBarangTidakAktif.setText("Barang Tidak Aktif");
    pnlRadioButton.add(rdBarangTidakAktif, "cell 0 1");
    btnGroup.add(rdBarangTidakAktif);

    btnRefresh = new XJButton();
    btnRefresh.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            try {
              loadDataInThread();
            } catch (Exception ex) {
              ExceptionHandler.handleException(StockListDialog.this, ex);
            }
          }
        });
    btnRefresh.setMnemonic('R');
    btnRefresh.setText("<html><center>Refresh<br/>[Alt+R]</center></html>");
    pnlFilter.add(btnRefresh, "cell 2 3,grow");

    JScrollPane scrollPane = new JScrollPane(table);
    getContentPane().add(scrollPane, "cell 0 1,grow");

    XJPanel panel = new XJPanel();
    getContentPane().add(panel, "cell 0 2,alignx center,growy");
    panel.setLayout(new MigLayout("", "[][][][]", "[]"));

    btnRegistrasi = new XJButton();
    btnRegistrasi.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            tambah();
          }
        });

    XJButton btnKeluar = new XJButton();
    btnKeluar.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        });
    btnKeluar.setText("<html><center>Keluar<br/>[Esc]</center></html>");
    panel.add(btnKeluar, "cell 0 0");
    panel.add(btnRegistrasi, "cell 1 0");
    btnRegistrasi.setText("<html><center>Registrasi Barang Baru<br/>[F5]</center><html>");

    btnDetail = new XJButton();
    btnDetail.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            try {
              showDetail();
            } catch (Exception ex) {
              ExceptionHandler.handleException(StockListDialog.this, ex);
            }
          }
        });

    btnPrintBarcode = new XJButton();
    btnPrintBarcode.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            try {
              printBarcode();
            } catch (Exception ex) {
              ExceptionHandler.handleException(StockListDialog.this, ex);
            }
          }
        });
    btnPrintBarcode.setText("<html><center>Print Barcode<br/>[F6]</center><html>");
    panel.add(btnPrintBarcode, "cell 2 0");
    btnDetail.setText("<html><center>Lihat Detail<br/>[Enter]</center></html>");
    panel.add(btnDetail, "cell 3 0");

    btnRefresh.doClick();

    pack();
    setLocationRelativeTo(parent);
  }