Ejemplo n.º 1
0
 private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {
   AdminRoom adminRoom = new AdminRoom(dataE);
   // SelectRooms rooms = new SelectRooms();
   // rooms.setVisible(true);
   adminRoom.setVisible(true);
   this.setVisible(false);
   model.setArrayOfCards(WorkCard.getWork().getArrOfCards());
   searchFrame.setSearchRequest(null);
 }
Ejemplo n.º 2
0
 private void addButtonActionPerfomed(ActionEvent evt) {
   try {
     WorkCard.getWork().addCard(Integer.parseInt(tficon.getText()), tfcolor.getText());
     if (searchFrame.getSearchRequest() != null) {
       Search search = new CardSearch();
       model.setArrayOfCards(
           (ArrayList<Card>) search.regularSearch(searchFrame.getSearchRequest()));
     }
   } catch (NotFoundException ex) {
     log.debug(ex.getMessage());
   }
   tficon.setText("");
   tfcolor.setText("");
   jTable1.revalidate();
   jTable1.repaint();
 }
Ejemplo n.º 3
0
  private void deleteButtonActionPerfomed(ActionEvent evt) {
    try {
      if ((jTable1.getSelectedRow() >= 0)
          && (jTable1.getSelectedRow() < WorkCard.getWork().getOfCountCards())) {
        WorkCard.getWork()
            .deleteCard(
                WorkCard.getWork().getArrOfCards().get(jTable1.getSelectedRow()).getIcon(),
                WorkCard.getWork().getArrOfCards().get(jTable1.getSelectedRow()).getColor());
        if (searchFrame.getSearchRequest() != null) {
          Search search = new CardSearch();
          model.setArrayOfCards(
              (ArrayList<Card>) search.regularSearch(searchFrame.getSearchRequest()));
        }
      }
    } catch (NotFoundException e) {
      log.debug(e.getMessage());
    }

    jTable1.revalidate();
    jTable1.repaint();
  }
Ejemplo n.º 4
0
  private void initComponents() {

    searchFrame = new SearchFrameOfCard(dataE);
    setLayout(null);
    setBounds(200, 10, 710, 790);
    this.setLocationRelativeTo(null);

    this.setResizable(false);
    setTitle("Card list");

    panel = new JPanel();
    panel.setBorder(new TitledBorder("Add/delete cards"));
    panel.setBounds(10, 440, 670, 280);
    panel.setLayout(null);

    jScrollPane1 = new JScrollPane(jTable1);
    jScrollPane1.setBounds(10, 10, 670, 420);
    // Таблица и модель
    model = new CardTableModel();
    jTable1 = new JTable(model);
    model.addTableModelListener(jTable1);
    jTable1.setFont(new java.awt.Font("Comic Sans MS", 0, 12)); // NOI18N
    // jTable1.setSize(new java.awt.Dimension(500, 400));
    jScrollPane1.setViewportView(jTable1);

    backButton = new javax.swing.JButton();
    backButton.setFont(new java.awt.Font("Comic Sans MS", 0, 13)); // NOI18N
    backButton.setText("Back");
    panel.add(backButton);
    backButton.setBounds(500, 220, 150, 30); // 310 300 80 30
    backButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            backButtonActionPerformed(evt);
          }
        });

    searchButton = new javax.swing.JButton();
    searchButton.setFont(new java.awt.Font("Comic Sans MS", 0, 13)); // NOI18N
    searchButton.setText("Search");
    panel.add(searchButton);
    searchButton.setBounds(200, 190, 150, 30); // 310 300 80 30
    searchButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            searchButtonActionPerformed(evt);
          }
        });

    cleanButton = new javax.swing.JButton();
    cleanButton.setFont(new java.awt.Font("Comic Sans MS", 0, 13)); // NOI18N
    cleanButton.setText("Clean");
    panel.add(cleanButton);
    cleanButton.setBounds(200, 230, 150, 30); // 310 300 80 30
    cleanButton.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            clearButtonActionPerformed(evt);
          }
        });

    addButton = new JButton();
    addButton.setFont(new java.awt.Font("Comic Sans MS", 0, 13));
    addButton.setText("Add Card");
    panel.add(addButton);
    addButton.setBounds(20, 190, 150, 30);
    addButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            addButtonActionPerfomed(e);
          }
        });

    deleteButton = new JButton();
    deleteButton.setFont(new java.awt.Font("Comic Sans MS", 0, 13));
    deleteButton.setText("Delete Card");
    panel.add(deleteButton);
    deleteButton.setBounds(20, 230, 150, 30);
    deleteButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            deleteButtonActionPerfomed(e);
          }
        });

    // TextFields
    tficon = new JTextField();
    tficon.setFont(new java.awt.Font("Comic Sans MS", 0, 13));
    panel.add(tficon);
    tficon.setBounds(120, 30, 130, 30);

    tfcolor = new JTextField();
    tfcolor.setFont(new java.awt.Font("Comic Sans MS", 0, 13));
    panel.add(tfcolor);
    tfcolor.setBounds(490, 30, 130, 30);

    // Labels
    labicon = new JLabel("Icon");
    labicon.setFont(new java.awt.Font("Comic Sans MS", 0, 13));
    labicon.setBounds(20, 30, 90, 30);
    panel.add(labicon);

    labcolor = new JLabel("Color");
    labcolor.setFont(new java.awt.Font("Comic Sans MS", 0, 13));
    labcolor.setBounds(390, 30, 90, 30);
    panel.add(labcolor);

    // add(jTable1);
    add(panel);
    add(jScrollPane1);

    addWindowListener(
        new WindowListener() {

          @Override
          public void windowActivated(WindowEvent event) {}

          @Override
          public void windowClosed(WindowEvent event) {}
          // TODO есть ли смысл тут писать аналог как для пользователя?
          @Override
          public void windowClosing(WindowEvent event) {
            try {
              WorkUser workUser = WorkUser.getWork();
              FileHandler workWithFiles = new FileHandler();
              // sd.serializableData("serializableData_WorkUser.bin", workUser);
              workWithFiles.marshalData("marshalData_WorkUser.xml", workUser);
              throw new UnsupportedOperationException(
                  "Not supported yet."); // To change body of generated methods, choose Tools |
              // Templates.
            } catch (JAXBException ex) {
              log.debug(ex.getMessage());
            } //                catch (IOException ex) {
            //                    Logger.getLogger(SecondFrame.class.getName()).log(Level.SEVERE,
            // null, ex);
            //                }
            finally {
              event.getWindow().setVisible(false);
              System.exit(0);
            }
          }

          @Override
          public void windowDeactivated(WindowEvent event) {}

          @Override
          public void windowDeiconified(WindowEvent event) {}

          @Override
          public void windowIconified(WindowEvent event) {}

          @Override
          public void windowOpened(WindowEvent event) {}
        });

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  }
Ejemplo n.º 5
0
 private void clearButtonActionPerformed(ActionEvent evt) {
   model.setArrayOfCards(WorkCard.getWork().getArrOfCards());
   searchFrame.setSearchRequest(null);
   jTable1.revalidate();
   jTable1.repaint();
 }