Ejemplo n.º 1
0
 @SuppressWarnings("unchecked")
 @Override
 public int loop() {
   synchronized (lock) {
     try {
       if (!ui.isVisible()) handler.stopMod(getName());
       World world = minecraft.getWorld();
       JTable list = ui.getList();
       DefaultTableModel model = (DefaultTableModel) list.getModel();
       TableRowSorter<TableModel> sorter = (TableRowSorter<TableModel>) list.getRowSorter();
       if (world != null) {
         Player currentPlayer = minecraft.getPlayer();
         int playerX = (int) java.lang.Math.round(currentPlayer.getX());
         int playerY = (int) java.lang.Math.round(currentPlayer.getY());
         int playerZ = (int) java.lang.Math.round(currentPlayer.getZ());
         ArrayList<Block> blocks = new ArrayList<Block>();
         for (int x = playerX - radius; x < playerX + radius; x++)
           for (int y = playerY - radius; y < playerY + radius; y++)
             for (int z = playerZ - radius; z < playerZ + radius; z++)
               if (world.getBlockIDAt(x, y, z) == blockID) blocks.add(new Block(x, y, z));
         label:
         for (int row = 0; row < model.getRowCount(); row++) {
           int x = (Integer) model.getValueAt(row, 1);
           int y = (Integer) model.getValueAt(row, 2);
           int z = (Integer) model.getValueAt(row, 3);
           for (Block block : blocks) {
             if (x == block.getX() && y == block.getY() && z == block.getZ()) {
               model.setValueAt(getDistanceTo(x, y, z, currentPlayer), row, 0);
               continue label;
             }
           }
           model.removeRow(row);
         }
         label:
         for (Block block : blocks) {
           for (int row = 0; row < model.getRowCount(); row++) {
             int x = (Integer) model.getValueAt(row, 1);
             int y = (Integer) model.getValueAt(row, 2);
             int z = (Integer) model.getValueAt(row, 3);
             if (x == block.getX() && y == block.getY() && z == block.getZ()) continue label;
           }
           model.addRow(
               new Object[] {
                 getDistanceTo(block.getX(), block.getY(), block.getZ(), minecraft.getPlayer()),
                 block.getX(),
                 block.getY(),
                 block.getZ()
               });
         }
         sorter.sort();
         list.repaint();
       } else {
         for (int i = model.getRowCount() - 1; i >= 0; i--) model.removeRow(i);
       }
     } catch (Exception exception) {
     }
   }
   return 500;
 }
Ejemplo n.º 2
0
 @Override
 public void actionPerformed(ActionEvent e) {
   ID = (Integer) hashRoomType.get(boxRoomTypeID.getSelectedItem().toString());
   IDSTATUS = (Integer) hashRoomStatus.get(boxRoomStatusID.getSelectedItem().toString());
   if (e.getSource() == buttonInsert) {
     try {
       Rooms rooms = new Rooms(txtRoomNumber.getText(), txtDescription.getText(), ID, IDSTATUS);
       RoomsController.roomsController.save(rooms);
       int c = model.getRowCount();
       for (int i = c - 1; i >= 0; i--) {
         model.removeRow(i);
         jRoom.revalidate();
       }
       all();
       JOptionPane.showMessageDialog(this, "ok");
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (e.getSource() == buttonUpdate) {
     try {
       Rooms rooms = new Rooms(txtRoomNumber.getText(), txtDescription.getText(), ID, IDSTATUS);
       rooms.setRoomID(IDROOM);
       RoomsController.roomsController.update(rooms);
       int c = model.getRowCount();
       for (int i = c - 1; i >= 0; i--) {
         model.removeRow(i);
         jRoom.revalidate();
       }
       all();
       JOptionPane.showMessageDialog(this, "Update to succeed !");
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (e.getSource() == buttonDelete) {
     try {
       List<CheckIn> temp = CheckInController.checkInController.all();
       for (int i = 0; i < temp.size(); i++) {
         if (IDROOM == temp.get(i).getRoomID()) {
           this.error = 0;
         } else {
           this.error = 0;
           RoomsController.roomsController.delete(IDROOM);
           int c = model.getRowCount();
           for (int ii = c - 1; ii >= 0; ii--) {
             model.removeRow(ii);
             jRoom.revalidate();
           }
           all();
         }
       }
       JOptionPane.showMessageDialog(this, "Delete to succeed !");
     } catch (Exception ex) {
       JOptionPane.showMessageDialog(this, "can't delete row bcause check still !");
     }
   }
   if (e.getSource() == buttonRefresh) {}
 }
Ejemplo n.º 3
0
 private void clearAllButtonActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_clearAllButtonActionPerformed
   DefaultTableModel model = (DefaultTableModel) this.outputTable.getModel();
   if (model.getRowCount() > 0) {
     for (int i = model.getRowCount() - 1; i > -1; i--) {
       model.removeRow(i);
     }
   }
 } // GEN-LAST:event_clearAllButtonActionPerformed
Ejemplo n.º 4
0
 private void clearButtonActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_clearButtonActionPerformed
   DefaultTableModel liveModel = (DefaultTableModel) liveTable.getModel();
   while (liveModel.getRowCount() > 0) {
     for (int i = 0; i < liveModel.getRowCount(); i++) {
       liveModel.removeRow(i);
     }
   }
 } // GEN-LAST:event_clearButtonActionPerformed
Ejemplo n.º 5
0
  private void ClearButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_ClearButtonActionPerformed
    DefaultTableModel dtm = (DefaultTableModel) IPTable.getModel();
    while (dtm.getRowCount() > 0) {
      dtm.removeRow(0);
    }

    dtm = (DefaultTableModel) PacketInfoTable.getModel();
    while (dtm.getRowCount() > 0) dtm.removeRow(0);
    PacketDataTextArea.setText(null);
    // TODO add your handling code here:
  } // GEN-LAST:event_ClearButtonActionPerformed
Ejemplo n.º 6
0
 @SuppressWarnings("unchecked")
 private void exportBtnActionPerformed(java.awt.event.ActionEvent evt) {
   toggle(false);
   JFileChooser fc = new JFileChooser();
   String path =
       FileUtils.getUserDirectoryPath() + File.separator + treeViewNode.getText() + ".csv";
   fc.setSelectedFile(new File(path));
   fc.showSaveDialog(this);
   File target = fc.getSelectedFile();
   int row = model.getRowCount();
   try {
     boolean written;
     try (FileOutputStream fos = new FileOutputStream(target)) {
       while (--row > -1) {
         Vector v = (Vector) model.getDataVector().get(row);
         for (int i = 0; i < v.size(); i++) {
           if (v.get(i).toString().contains(",")) {
             v.set(i, ST.format("\"<%1>\"", v.get(i)));
           }
         }
         String line = ST.format("<%1:{ x |, <x>}>", v).substring(2);
         fos.write(line.getBytes(CHARSET));
         fos.write(Character.LINE_SEPARATOR);
       }
       written = true;
     }
     if (written) {
       LogEmitter.factory
           .get()
           .emit(
               this,
               Core.ALERT.INFO,
               ST.format("<%1> hosts written to <%2>", model.getRowCount(), target.getPath()));
     } else {
       LogEmitter.factory
           .get()
           .emit(this, Core.ALERT.DANGER, ST.format("Failed to export <%1>", target.getPath()));
     }
   } catch (FileNotFoundException ex) {
     Logger.getLogger(ConnectionDialog.class.getName()).log(Level.SEVERE, null, ex);
     LogEmitter.factory
         .get()
         .emit(this, Core.ALERT.DANGER, ST.format("Failed to export <%1>", target.getPath()));
   } catch (IOException ex) {
     Logger.getLogger(ConnectionDialog.class.getName()).log(Level.SEVERE, null, ex);
     LogEmitter.factory
         .get()
         .emit(this, Core.ALERT.DANGER, ST.format("Failed to export <%1>", target.getPath()));
   }
   toggle(true);
 }
Ejemplo n.º 7
0
  private void getNewCrs(int code) {
    if (code != -1) {
      //		Eliminar filas en cada nueva bsqueda
      int numRow = dtm.getRowCount();
      while (numRow != 0) {
        numRow = numRow - 1;
        dtm.removeRow(numRow);
      }
      String sentence =
          "SELECT usr_code, usr_wkt, usr_proj, usr_geog, usr_datum "
              + "FROM USR "
              + "WHERE usr_code = "
              + code;
      connect = new EpsgConnection();
      connect.setConnectionUsr();
      ResultSet result = Query.select(sentence, connect.getConnection());
      try {
        connect.shutdown();
      } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      Object[] data = new Object[4];
      try {
        while (result.next()) {
          data[0] = result.getString("usr_code");
          data[1] = result.getString("usr_wkt");
          String proj = result.getString("usr_proj");
          if (!proj.equals("")) {
            data[1] = proj;
            data[2] = PluginServices.getText(this, "si");
          } else {
            data[1] = result.getString("usr_geog");
            data[2] = PluginServices.getText(this, "no");
          }

          data[3] = result.getString("usr_datum");
          dtm.addRow(data);
        }
      } catch (SQLException e1) {
        e1.printStackTrace();
      }
      int numr = dtm.getRowCount();
      if (numr == 0) {
        searchButton();
      } else {
        this.getJTable().setRowSelectionInterval(0, 0);
      }
    }
  }
Ejemplo n.º 8
0
  public void initializeTable() {
    // Eliminar filas en cada nueva bsqueda
    int numRow = dtm.getRowCount();
    while (numRow != 0) {
      numRow = numRow - 1;
      dtm.removeRow(numRow);
    }

    String sentence =
        "SELECT usr_code, usr_wkt, usr_proj, usr_geog, usr_datum "
            + "FROM USR ORDER BY usr_code ASC";

    connect = new EpsgConnection();
    connect.setConnectionUsr();
    ResultSet result = Query.select(sentence, connect.getConnection());
    try {
      connect.shutdown();
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    Object[] data = new Object[4];
    try {
      while (result.next()) {
        data[0] = result.getString("usr_code");
        data[1] = result.getString("usr_wkt");
        String proj = result.getString("usr_proj");
        if (!proj.equals("")) {
          data[1] = proj;
          data[2] = PluginServices.getText(this, "si");
        } else {
          data[1] = result.getString("usr_geog");
          data[2] = PluginServices.getText(this, "no");
        }

        data[3] = result.getString("usr_datum");
        dtm.addRow(data);
      }
    } catch (SQLException e1) {
      e1.printStackTrace();
    }

    int numr = dtm.getRowCount();
    if (numr > 0) {
      this.getJTable().setRowSelectionInterval(0, 0);
      // getBtnEditar().setEnabled(true);
      // getBtnEliminar().setEnabled(true);
    }
  }
Ejemplo n.º 9
0
  /**
   * @param tableModel
   * @return
   */
  public org.jdesktop.swingx.tips.DefaultTip[] getTipsArray(
      javax.swing.table.DefaultTableModel tableModel) {

    org.jdesktop.swingx.tips.DefaultTip tips[] =
        new org.jdesktop.swingx.tips.DefaultTip[tableModel.getRowCount()];

    for (int i = 0; i < tableModel.getRowCount(); i++) {

      tips[i] =
          new org.jdesktop.swingx.tips.DefaultTip(
              tableModel.getValueAt(i, 0).toString(), tableModel.getValueAt(i, 1));
    }

    return tips;
  }
  public void saveUnit() {
    try {
      DefaultTableModel dtm = (DefaultTableModel) tblUnitList.getModel();
      unitLists.clear();
      unitNames.clear();

      if (dtm.getRowCount() == 0) {
        this.dispose();
        return;
      }
      for (int i = 0; i < dtm.getRowCount(); i++) {
        //                if (((Number) dtm.getValueAt(i, 4)).intValue() == 0 || (userTask ==
        // GlobalMode.RENEW)) {
        //                    RentalUnitBean rub = new RentalUnitBean();
        //                    rub.setRentalDetailID((int) dtm.getValueAt(i, 4));
        //                    UnitBean ub = new UnitBean();
        //                    ub.setUnitID((int) dtm.getValueAt(i, 2));
        //                    rub.setUnitBean(ub);
        //                    unitLists.add(rub);
        //                }
        if (((Number) dtm.getValueAt(i, 4)).intValue() == 0) {
          RentalUnitBean rub = new RentalUnitBean();
          rub.setRentalDetailID((int) dtm.getValueAt(i, 4));
          UnitBean ub = new UnitBean();
          ub.setUnitID((int) dtm.getValueAt(i, 2));
          rub.setUnitBean(ub);
          unitLists.add(rub);
        }
        floor = dtm.getValueAt(i, 3).toString();
        unitNames.add(dtm.getValueAt(i, 0).toString());
      }
      KeyValue kv = (KeyValue) cboBuilding.getSelectedItem();
      buildingID = (int) kv.getKey();
      buildingCode = kv.getRow().toString();

      bb.setBuildingID(buildingID);
      bb.setBuildingCode(buildingCode);
      bb.setBuildingName(cboBuilding.getSelectedItem().toString());
      bb.setContractDraft(kv.getOtherRow().toString());
      bb.setActualContract(kv.getOtherRow2().toString());

      RentalEntry re = (RentalEntry) this.getParent();
      re.setUnits(bb, unitNames, unitLists, floor, totalLeaseArea);
      this.dispose();
    } catch (Exception e) {
      Message.showError(e.getMessage());
    }
  }
Ejemplo n.º 11
0
 private void checkConstraints(DiscapacidadDetalle toAdd) throws MessageException {
   if (toAdd.getPeriodoYear() == null) {
     throw new MessageException("Número de carpeta no válida");
   }
   DefaultTableModel dtm = (DefaultTableModel) abmPanel.getjTable1().getModel();
   for (int row = 0; row < dtm.getRowCount(); row++) {
     DiscapacidadDetalle oldDiscapacidadDetalle = (DiscapacidadDetalle) dtm.getValueAt(row, 0);
     if (oldDiscapacidadDetalle.getTipoDocumento().equals(toAdd.getTipoDocumento())
         && Objects.equals(
             oldDiscapacidadDetalle.getSubTipoDocumento(), toAdd.getSubTipoDocumento())
         && Objects.equals(oldDiscapacidadDetalle.getDocumentoNumero(), toAdd.getDocumentoNumero())
         && Objects.equals(oldDiscapacidadDetalle.getPeriodoYear(), toAdd.getPeriodoYear())
         && Objects.equals(oldDiscapacidadDetalle.getNombre(), toAdd.getNombre())
         && Objects.equals(oldDiscapacidadDetalle.getApellido(), toAdd.getApellido())) {
       throw new MessageException(
           "Ya existe un detalle con los mismos datos:"
               + "\nTipo de Documento: "
               + toAdd.getTipoDocumento().getNombre()
               + "\nSub-Tipo de Documento: "
               + (toAdd.getSubTipoDocumento() == null
                   ? "<Sin Sub-Tipo>"
                   : toAdd.getSubTipoDocumento().getNombre())
               + "\nN° Documento: "
               + Objects.toString(toAdd.getDocumentoNumero(), "")
               + "\nPeriodo: "
               + Objects.toString(toAdd.getPeriodoYear(), "")
               + "\nNombre: "
               + (toAdd.getApellido() == null ? "" : toAdd.getApellido() + ", ")
               + (Objects.toString(toAdd.getNombre(), "")));
     }
   }
 }
 private void statusTabel(JTable tabela) {
   DefaultTableModel modelo = (DefaultTableModel) tabela.getModel();
   if (modelo.getRowCount() == 0) {
     modelo.addRow(new String[1]);
     tabela.setValueAt("Nenhuma Pendência", 0, 0);
   }
 }
  /**
   * Listens for a topic being removed from the space for either a MainMenuController or a
   * ChatroomController.
   */
  @Override
  public void notify(RemoteEvent remoteEvent) throws UnknownEventException, RemoteException {
    try {
      // Get the event that triggered the notification
      AvailabilityEvent availEvent = (AvailabilityEvent) remoteEvent;
      JMSTopicDeleted topicDeleted = (JMSTopicDeleted) availEvent.getEntry();

      if (isChatroomController) {
        // If the listener is for a ChatroomController, inform the given
        // chatroom that the chatroom's topic has been deleted
        chatroomController.handleTopicDeleted();
      } else {
        // If the listener is for a MainMenuController, remove the given
        // topic from the MainMenuController's topic list.
        DefaultTableModel topicTableModel = mainMenuController.getTopicTableModel();

        // Loop through all of the topics in the MainMenuController's
        // topic list and remove the one that was deleted
        for (int i = 0; i < topicTableModel.getRowCount(); i++) {
          UUID topicIdInTable = (UUID) topicTableModel.getValueAt(i, 3);
          JMSTopic topicRemoved = topicDeleted.getTopic();
          UUID topicDeletedId = topicRemoved.getId();

          if (topicIdInTable.equals(topicDeletedId)) {
            topicTableModel.removeRow(i);

            break;
          }
        }
      }
    } catch (Exception e) {
      System.err.println("Failed to remove topic from list or send notifications to users.");
      e.printStackTrace();
    }
  }
  @Override
  public DefaultTableModel removeRowsWithZero(DefaultTableModel org) {

    final DefaultTableModel copy = new DefaultTableModel();
    for (int column = 0; column < org.getColumnCount(); column++) {
      copy.addColumn(org.getColumnName(column));
    }

    for (int row = 0; row < org.getRowCount(); row++) {
      BigDecimal editableColumnValue = getNumericValueAt(org, row, getEditableColumnIdx());
      BigDecimal baseValue = getNumericValueAt(org, row, getEditableColumnIdx() - 1);

      if (editableColumnValue.doubleValue() > 0) {
        String tipo_fuente = (String) org.getValueAt(row, 1);
        if (tipo_fuente.equals("Punto rio") || tipo_fuente.equals("Manantial")) {
          if (baseValue.compareTo(editableColumnValue) >= 0) {
            Object rowData = org.getDataVector().get(row);
            copy.addRow((Vector) rowData);
          }
        } else {
          Object rowData = org.getDataVector().get(row);
          copy.addRow((Vector) rowData);
        }
      }
    }

    return copy;
  }
Ejemplo n.º 15
0
 private void updateTable(List list, final DefaultTableModel dftm) {
   int num = dftm.getRowCount();
   for (int i = 0; i < num; i++) dftm.removeRow(0);
   Iterator iterator = list.iterator();
   TbKhinfo khInfo;
   while (iterator.hasNext()) {
     List info = (List) iterator.next();
     Item item = new Item();
     item.setId((String) info.get(0));
     item.setName((String) info.get(1));
     khInfo = Dao.getKhInfo(item);
     Vector rowData = new Vector();
     rowData.add(khInfo.getId().trim());
     rowData.add(khInfo.getKhname().trim());
     rowData.add(khInfo.getAddress().trim());
     rowData.add(khInfo.getJian().trim());
     rowData.add(khInfo.getBianma().trim());
     rowData.add(khInfo.getTel().trim());
     rowData.add(khInfo.getFax().trim());
     rowData.add(khInfo.getLian().trim());
     rowData.add(khInfo.getLtel().trim());
     rowData.add(khInfo.getMail().trim());
     rowData.add(khInfo.getXinhang().trim());
     rowData.add(khInfo.getHao().trim());
     dftm.addRow(rowData);
   }
 }
Ejemplo n.º 16
0
 public void actionPerformed(ActionEvent e) {
   if (e.getActionCommand().equals("Add Column")) {
     PopMessage.popMsg("Invalid new column for this window");
     // defaultModel.addColumn("AddColumn");
   }
   if (e.getActionCommand().equals("Add Row")) defaultModel.addRow(new Vector());
   if (e.getActionCommand().equals("Remove Column")) {
     PopMessage.popMsg("Invalid new column for this window");
     //            int columncount = defaultModel.getColumnCount() - 1;
     //            if (columncount >= 0) {
     //                TableColumnModel columnModel = table.getColumnModel();
     //                TableColumn tableColumn = columnModel.getColumn(columncount);
     //                columnModel.removeColumn(tableColumn);
     //                defaultModel.setColumnCount(columncount);
     //            }
   }
   if (e.getActionCommand().equals("Remove Row")) {
     int rowcount = defaultModel.getRowCount() - 1;
     if (rowcount >= 0) {
       defaultModel.removeRow(rowcount);
       defaultModel.setRowCount(rowcount);
     }
   }
   table.revalidate();
 }
Ejemplo n.º 17
0
 public void displayQuizOptions() {
   // displays the the quizzes the pupil can do based on their skill level
   int quizNum = 0;
   int total = 0;
   String quizSkill = "";
   try {
     DatabaseConnect.init();
     Connection conn = DatabaseConnect.getConnection();
     Statement stmt = conn.createStatement();
     String query = "SELECT * FROM QUIZ where QUIZ_LEVEL ='" + skillLevel + "'";
     ResultSet result = stmt.executeQuery(query);
     DefaultTableModel model = (DefaultTableModel) tblQuiz.getModel();
     while (model.getRowCount() > 0) {
       model.removeRow(0);
     }
     if (result != null) {
       while (result.next()) {
         quizNum = result.getInt("QUIZ_NUMBER");
         total = result.getInt("TOTAL_POINTS");
         quizSkill = result.getString("QUIZ_LEVEL");
         int number = NumQuestions(quizNum);
         model.addRow(new Object[] {quizNum, quizSkill, total, number});
       }
     }
     stmt.close();
     conn.close();
     result.close();
   } // end try
   catch (Exception ex) {
     System.err.print("SQLException: ");
     System.err.println(ex.getMessage());
   }
 } // END method
Ejemplo n.º 18
0
  /** Method to update the friend's list. */
  public void updateFriends() {
    // Clear rows
    int count = friendListData.getRowCount();
    boolean online = false;

    for (int i = 0; i < count; i++) friendListData.removeRow(0);

    // Add rows
    for (Client c : Constants.getFriends()) {
      if (c.isOnline()) {
        switch (c.getStatus()) {
          case 0:
            if (!c.isPlayedSound()) {
              online = true;
              c.setPlayedSound(true);
            }
            friendListData.addRow(new Object[] {Constants.onlineIcon, c.getUsername()});
            break;
          case 1:
            friendListData.addRow(new Object[] {Constants.awayIcon, c.getUsername()});
            break;
          case 2:
            friendListData.addRow(new Object[] {Constants.dndIcon, c.getUsername()});
            break;
        }
      } else {
        friendListData.addRow(new Object[] {Constants.offlineIcon, c.getUsername()});
      }
    }

    repaint();

    if (Constants.isPlaySounds() && online) Constants.getAudioPlayer().play(AudioPlayer.ONLINE);
  }
 private void clearForm() {
   int tblsize = tblProduct_model.getRowCount();
   for (int i = 0; i < tblsize; i++) {
     tblProduct_model.removeRow(0);
   }
   option.setText("");
 }
  private void buscar() {
    CategoriaBL objCategoriaBL = new CategoriaBL();
    DefaultTableModel temp = (DefaultTableModel) this.tbCategoria.getModel();
    for (int i = temp.getRowCount() - 1; i >= 0; --i) {
      temp.removeRow(i);
    }
    String temp1 = "";
    for (int i = 0; i < this.txtNombre.getText().length(); ++i) {
      if (this.txtNombre.getText().charAt(i) != '\'') {
        temp1 += this.txtNombre.getText().charAt(i);
      }
    }
    String temp2 = "";
    for (int i = 0; i < this.txtDescripcion.getText().length(); ++i) {
      if (this.txtDescripcion.getText().charAt(i) != '\'') {
        temp2 += this.txtDescripcion.getText().charAt(i);
      }
    }
    ArrayList<CategoriaBE> alstResultado = objCategoriaBL.buscarCategoria(temp2, temp1);
    for (int i = 0; i < alstResultado.size(); ++i) {
      Object[] nuevo = {
        alstResultado.get(i).getIdCategoria(),
        alstResultado.get(i).getNombre(),
        alstResultado.get(i).getDescripcion()
      };
      temp.addRow(nuevo);
    }

    this.txtDescripcion.setText("");
    this.txtNombre.setText("");
  }
Ejemplo n.º 21
0
 private void btnEliminarTodoMouseClicked(
     java.awt.event.MouseEvent evt) { // GEN-FIRST:event_btnEliminarTodoMouseClicked
   DefaultTableModel modelo = (DefaultTableModel) tabla.getModel();
   for (int i = modelo.getRowCount() - 1; i >= 0; i--) {
     modelo.removeRow(i);
   }
 } // GEN-LAST:event_btnEliminarTodoMouseClicked
 private void pcodeKeyReleased(java.awt.event.KeyEvent evt) { // GEN-FIRST:event_pcodeKeyReleased
   // TODO add your handling code here:
   String code = pcode.getText();
   int tblsize = tblProduct_model.getRowCount();
   for (int i = 0; i < tblsize; i++) {
     tblProduct_model.removeRow(0);
   }
   pdesc.setText("");
   if (!code.trim().equals("")) {
     OptionGroup_Controller group = new OptionGroup_Controller();
     String groupName = group.seekGroup(code);
     if (groupName != null && !groupName.equals("")) {
       pdesc.setText(groupName);
       setDataToGrid(group.getOptionDetail(code));
     } else {
       pdesc.setText("**** GroupFile Error ****");
     }
   }
   if (evt.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER) {
     if (!pdesc.getText().equals("**** GroupFile Error ****")
         && !pdesc.getText().trim().equals("")) {
       option.requestFocus();
     }
   }
 } // GEN-LAST:event_pcodeKeyReleased
Ejemplo n.º 23
0
  public void loadTableData() {

    while (tableModel1.getRowCount() > 0) {
      tableModel1.removeRow(0);
    }

    vatList = dbValue.getVatDetail();
    yearList = dbValue.getFinancialYearDetail();
    /*
     * Collections.sort(yearList, new Comparator<FinancialYearModal>() {
     *
     * @Override public int compare(FinancialYearModal year1,
     * FinancialYearModal year2) {
     *
     * if(year1.getStartYear()==year2.getStartYear()) return 0; else return
     * year1.getStartYear()-year2.getStartYear();
     *
     * } });
     */
    for (int i = 0; i < vatList.size(); i++) {
      int startYear = 0, endYear = 0;
      vatModel = vatList.get(i);
      for (FinancialYearModal yearModel : yearList) {
        if (yearModel.getYearId() == vatModel.getYearId()) {
          startYear = yearModel.getStartYear();
          endYear = yearModel.getEndYear();
        }
      }
      tableModel1.addRow(new Object[] {i + 1, vatModel.getVatPercent(), startYear, endYear});
    }
  }
  private void WarehouseCBActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_WarehouseCBActionPerformed
    int warehouseindex =
        st.getWarehouseIndex(((String) WarehouseCB.getSelectedItem()).toLowerCase());

    QuantityLB.setText(
        "Total Quantity: "
            + st.getTotalQuantityByWarehouseAndCode(
                ((String) WarehouseCB.getSelectedItem()).toLowerCase(), item_code));

    ArrayList<String[]> quantity_expired_list =
        st.setQuantityExpiredDateTable(warehouseindex, itemindex);

    DefaultTableModel quantity_expired_model = (DefaultTableModel) QuantityTB.getModel();

    GuiHelper.ClearAllTable(QuantityTB);
    quantity_row_length = quantity_expired_list.size();
    for (int i = 0; i < quantity_row_length; i++) {
      if (i == quantity_expired_model.getRowCount()) {
        ((DefaultTableModel) quantity_expired_model)
            .addRow(
                new Object[] {
                  null, null, null, null, null, null, null, null, null, null, null, null, null,
                  null, null, null
                });
      }
      String[] single_list = (String[]) quantity_expired_list.get(i);
      quantity_expired_model.setValueAt(single_list[0], i, 0);
      quantity_expired_model.setValueAt(single_list[1], i, 1);
    }
  } // GEN-LAST:event_WarehouseCBActionPerformed
Ejemplo n.º 25
0
  private void importButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_importButtonActionPerformed
    // get selected items from list and try to start import ..
    List<VCard> selectedContacts = new ArrayList<VCard>();
    DefaultTableModel tableModel = (DefaultTableModel) importContactsTable.getModel();
    if (tableModel.getRowCount() == 0) {
      JOptionPane.showMessageDialog(
          this,
          bundle.getString("list.of.contacts.is.empty"),
          bundle.getString("error"),
          JOptionPane.ERROR_MESSAGE);
    } else {
      int[] sel = importContactsTable.getSelectedRows();
      for (int i = 0; i < sel.length; i++) {
        VCard v = (VCard) tableModel.getValueAt(sel[i], 0);
        selectedContacts.add(v);
      }

      if (selectedContacts.size() == 0) {
        JOptionPane.showMessageDialog(
            this,
            bundle.getString("no.contacts.selected"),
            bundle.getString("error"),
            JOptionPane.ERROR_MESSAGE);
      } else {
        // start import of selected contacts
        client.importContacts(
            selectedContacts.toArray(new VCard[selectedContacts.size()]), isVCFVerified);
        this.dispose();
      }
      for (VCard vc : selectedContacts) {
        System.out.println(vc.getStructuredName().getFamily());
      }
    }
  } // GEN-LAST:event_importButtonActionPerformed
Ejemplo n.º 26
0
 private void preencherTabela(Vector linhas) {
   DefaultTableModel modelo = (DefaultTableModel) this.tbCargos.getModel();
   int numLinhas = linhas.size();
   for (int i = 0; i < numLinhas; i++) {
     modelo.insertRow(modelo.getRowCount(), (Vector) linhas.get(i));
   }
 }
Ejemplo n.º 27
0
  private static void updateRegisteredKeypairsTable() {
    DefaultTableModel defaultTableModel = (DefaultTableModel) keypairsTable.getModel();
    while (defaultTableModel.getRowCount() != 0) {
      defaultTableModel.removeRow(0);
    }
    keypairs.clear();

    ArrayList<KeypairPOJO> registeredKeypairs = null;
    try {
      registeredKeypairs = KeypairDAO.getKeypairs();
    } catch (Exception e) {
      e.printStackTrace();
    }

    if (registeredKeypairs != null) {
      for (KeypairPOJO keypair : registeredKeypairs) {
        defaultTableModel.addRow(
            new String[] {
              keypair.getKeypairDescription(), keypair.getGenerationTimestampAsString()
            });
        keypairs.add(keypair);
      }
    }
    keypairsTable.setModel(defaultTableModel);
  }
  public void changeTaskData(TasksResponse tResponse) {

    DefaultTableModel dtm = (DefaultTableModel) tasksTable.getModel();

    if (dtm.getRowCount() > 1) {
      dtm.setRowCount(0);
    }

    if (tResponse != null) {
      for (Task t : tResponse.getList()) {
        Object o[] = {
          false,
          t.getId(),
          t.getName(),
          t.getDescription(),
          t.getAllowedApplications().toString(),
          t.getRestrictedApplications().toString(),
          t.getStartDateTime(),
          t.getEndDateTime(),
          t.getNotificationType().toString()
        };

        dtm.addRow(o);
      }
    }
  }
Ejemplo n.º 29
0
 public void moduleStateChanged() {
   if (myTable != null) {
     final DefaultTableModel tableModel = createModel();
     myTable.setModel(tableModel);
     myRemoveButton.setEnabled(tableModel.getRowCount() > 0);
   }
 }
  private void listaFacturasMouseClicked(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_listaFacturasMouseClicked
    try {

      if (rsVenta == null || listaFacturas.getSelectedIndex() == -1) {
        return;
      }

      rsVenta.absolute(listaFacturas.getSelectedIndex() + 1);

      lbNumeroVenta.setText(rsVenta.getString("id_venta"));
      lbNombre.setText(
          rsVenta.getString("nombre_cliente") + " " + rsVenta.getString("apellido_cliente"));
      lbCedulaRif.setText(rsVenta.getString("cedula_rif"));
      lbfecha.setText(rsVenta.getDate("fecha_venta").toString());
      lbDireccion.setText(rsVenta.getString("domicilio_cliente"));

      String sql =
          "SELECT venta.id_venta,  detalle_venta.cantidad,detalle_venta.importe, "
              + "producto.nombre_producto,producto.descripcion_producto,  producto.id_producto, producto.precio_producto "
              + "FROM public.venta "
              + "INNER JOIN public.detalle_venta ON venta.id_venta=detalle_venta.id_venta "
              + "INNER JOIN public.producto ON detalle_venta.id_producto=producto.id_producto "
              + "WHERE venta.id_venta ="
              + rsVenta.getInt("id_venta")
              + "ORDER BY id_venta ";

      Statement st =
          Conexion.getConnection()
              .createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
      ResultSet rs = st.executeQuery(sql);

      int cant = modeloTabla.getRowCount();
      for (int i = 0; i < cant; i++) {
        modeloTabla.removeRow(0);
      }

      float subTotal = 0f;

      while (rs.next()) {
        subTotal += rs.getFloat("precio_producto") * rs.getInt("cantidad");
        modeloTabla.addRow(
            new Object[] {
              rs.getInt("id_producto"),
              rs.getString("nombre_producto"),
              rs.getString("descripcion_producto"),
              rs.getInt("cantidad"),
              rs.getFloat("precio_producto"),
              subTotal
            });
      }

      tfSubTotal.setText(subTotal + "");
      tfIva.setText((subTotal * 0.12) + "");
      tfTotal.setText(rsVenta.getFloat("total_venta") + "");
    } catch (SQLException ex) {
      Logger.getLogger(cliente.class.getName()).log(Level.SEVERE, null, ex);
    }
  } // GEN-LAST:event_listaFacturasMouseClicked