private JPanel createDynamicCenterPanel(PrimitiveForm primitiveForm, DOTProperty property) {
    final JTable theTable = new JTable();
    PrimitiveFormPropertyPair pfpPair =
        new PrimitiveFormPropertyPair(primitiveForm.getName(), property);
    _dynamicTables.put(pfpPair, theTable);
    DOTPoint dotPoint = (DOTPoint) _dotDefinitionDialogFrame.getScratchDisplayObjectType();
    final DynamicDOTItemManager tableModel =
        (DynamicDOTItemManager) dotPoint.getTableModel(primitiveForm, property);
    theTable.setModel(tableModel);

    class NumberComparator implements Comparator<Number> {

      public int compare(Number o1, Number o2) {
        final double d1 = o1.doubleValue();
        final double d2 = o2.doubleValue();
        if (d1 < d2) {
          return -1;
        }
        if (d1 == d2) {
          return 0;
        }
        return 1;
      }
    }
    TableRowSorter<DynamicDOTItemManager> tableRowSorter =
        new TableRowSorter<DynamicDOTItemManager>();
    tableRowSorter.setModel(tableModel);
    tableRowSorter.setComparator(4, new NumberComparator());
    tableRowSorter.setComparator(5, new NumberComparator());
    theTable.setRowSorter(tableRowSorter);

    JButton newDOTItemButton = new JButton("Neue Zeile");
    newDOTItemButton.setEnabled(_dotDefinitionDialogFrame.isEditable());
    JButton deleteDOTItemButton = new JButton("Zeile löschen");
    deleteDOTItemButton.setEnabled(false);
    JButton showConflictsButton = new JButton("Zeige Konflikte");

    addButtonListeners(
        primitiveForm, property, newDOTItemButton, deleteDOTItemButton, showConflictsButton);
    addListSelectionListener(theTable, deleteDOTItemButton);

    JPanel dotButtonsPanel = new JPanel();
    dotButtonsPanel.setLayout(new SpringLayout());

    dotButtonsPanel.add(newDOTItemButton);
    dotButtonsPanel.add(deleteDOTItemButton);
    dotButtonsPanel.add(showConflictsButton);

    dotButtonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
    SpringUtilities.makeCompactGrid(dotButtonsPanel, 1, 5, 20);

    JPanel thePanel = new JPanel();
    thePanel.setLayout(new SpringLayout());
    thePanel.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.BLACK));
    thePanel.add(new JScrollPane(theTable));
    thePanel.add(dotButtonsPanel);
    SpringUtilities.makeCompactGrid(thePanel, 2, 20, 5);

    return thePanel;
  }
예제 #2
0
  @Override
  public void setModel(final TableModel model) {
    super.setModel(model);

    if (model instanceof SortableColumnModel) {
      final SortableColumnModel sortableModel = (SortableColumnModel) model;
      if (sortableModel.isSortable()) {
        final TableRowSorter<TableModel> rowSorter = createRowSorter(model);
        rowSorter.setSortsOnUpdates(isSortOnUpdates());
        setRowSorter(rowSorter);
        final RowSorter.SortKey sortKey = sortableModel.getDefaultSortKey();
        if (sortKey != null
            && sortKey.getColumn() >= 0
            && sortKey.getColumn() < model.getColumnCount()) {
          if (sortableModel.getColumnInfos()[sortKey.getColumn()].isSortable()) {
            rowSorter.setSortKeys(Arrays.asList(sortKey));
          }
        }
      } else {
        final RowSorter<? extends TableModel> rowSorter = getRowSorter();
        if (rowSorter instanceof DefaultColumnInfoBasedRowSorter) {
          setRowSorter(null);
        }
      }
    }
  }
  public void activarFiltrosTabla() {
    TableRowSorter<TableModel> modeloOrdenado;
    // model.setRowFilter(RowFilter.regexFilter("2", 1));
    modeloOrdenado = new TableRowSorter<TableModel>(model);
    tablaCapacitadores.setRowSorter(modeloOrdenado);

    if (filtroBuscarActivado) {
      String[] cadena = txtBuscar.getText().split(" ");
      List<RowFilter<Object, Object>> filters = new ArrayList<RowFilter<Object, Object>>();
      for (int i = 0; i < cadena.length; i++) {
        filters.add(RowFilter.regexFilter("(?i)" + cadena[i]));
      }
      if (rbFiltroActivos.isSelected()) {
        filters.add(RowFilter.regexFilter(gestor.nombreEstadoCapacitadorActivo(), 3));
      }
      RowFilter<Object, Object> cadenaFilter = RowFilter.andFilter(filters);
      modeloOrdenado.setRowFilter(cadenaFilter);

    } else {
      if (rbFiltroActivos.isSelected()) {
        modeloOrdenado.setRowFilter(
            RowFilter.regexFilter(gestor.nombreEstadoCapacitadorActivo(), 3));
      }
    }
  }
예제 #4
0
 public void filter() {
   String expr = filterField.getText().trim();
   if (expr.length() == 0) {
     expr = null;
   }
   try {
     final TableRowSorter<? extends TableModel> sorter =
         ((TableRowSorter<? extends TableModel>) shortcutTable.getRowSorter());
     if (expr == null) {
       sorter.setRowFilter(null);
     } else {
       expr = expr.replace("+", "\\+");
       // split search string on whitespace, do case-insensitive AND search
       ArrayList<RowFilter<Object, Object>> andFilters =
           new ArrayList<RowFilter<Object, Object>>();
       for (String word : expr.split("\\s+")) {
         andFilters.add(RowFilter.regexFilter("(?i)" + word));
       }
       sorter.setRowFilter(RowFilter.andFilter(andFilters));
     }
     model.fireTableDataChanged();
   } catch (PatternSyntaxException ex) {
   } catch (ClassCastException ex2) {
     /* eliminate warning */
   }
 }
예제 #5
0
 private void filterUsers(final String fragment) {
   table.clearSelection();
   userCertificatePanel.setUserCertificateModel(null);
   if (StringUtils.isEmpty(fragment)) {
     table.setRowSorter(defaultSorter);
     return;
   }
   RowFilter<UserCertificateTableModel, Object> containsFilter =
       new RowFilter<UserCertificateTableModel, Object>() {
         @Override
         public boolean include(
             Entry<? extends UserCertificateTableModel, ? extends Object> entry) {
           for (int i = entry.getValueCount() - 1; i >= 0; i--) {
             if (entry.getStringValue(i).toLowerCase().contains(fragment.toLowerCase())) {
               return true;
             }
           }
           return false;
         }
       };
   TableRowSorter<UserCertificateTableModel> sorter =
       new TableRowSorter<UserCertificateTableModel>(tableModel);
   sorter.setRowFilter(containsFilter);
   table.setRowSorter(sorter);
 }
예제 #6
0
  private void createUIComponents() {
    portFreightTableModel = new FreightTableModel(Game.getInstance().getFreightMarket());
    portFreightTable = new JTable(portFreightTableModel);
    TableRowSorter<FreightTableModel> portTableSorter =
        new TableRowSorter<FreightTableModel>(portFreightTableModel);
    portTableSorter.setRowFilter(new FreightTableModel.PortRowFilter(portProxy));
    portFreightTable.setRowSorter(portTableSorter);

    Company playerCompany = Game.getInstance().getPlayerCompany();
    List<ShipModel> shipsInPortList = playerCompany.findShipsInPort(portProxy);

    shipsInPortListBox = new JList(shipsInPortList.toArray());

    // TODO this is fugly-hacked at the moment.
    FreightTableModel shipFreightTableModel = null;

    if (shipsInPortList.size() > 0) {
      shipFreightTableModel = new FreightTableModel(shipsInPortList.get(0));
    } else {
      shipFreightTableModel = new FreightTableModel(null);
    }

    shipFreightTable = new JTable(shipFreightTableModel);
    TableRowSorter<FreightTableModel> shipTableSorter =
        new TableRowSorter<FreightTableModel>(shipFreightTableModel);
    shipFreightTable.setRowSorter(shipTableSorter);

    nameOfPort = new JLabel();
    nameOfPort.setText(portProxy.getName());
  }
예제 #7
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;
 }
예제 #8
0
 private void aplicaFiltro() {
   String textoFiltro = filtro.getText();
   if (textoFiltro.length() > 0) {
     sorter.setRowFilter(new BusquedaAutoRowFilter(textoFiltro));
   } else {
     sorter.setRowFilter(null);
   }
 }
 public void actionPerformed(ActionEvent arg0) {
   if (cmbEstablecimientos.getSelectedIndex() != 0) {
     trsfiltro.setRowFilter(
         RowFilter.regexFilter(cmbEstablecimientos.getSelectedItem() + "", 3));
   } else {
     trsfiltro.setRowFilter(RowFilter.regexFilter("", 2));
   }
 }
예제 #10
0
  @SuppressWarnings("unchecked")
  public JPanel view(String src_n, String dst_n) {
    List<JPanel> panels = new LinkedList<>();
    LinkedList<String> sorted = new LinkedList<>(data.keySet());
    sorted.sort(String::compareTo);
    for (String k : sorted) {
      Set<Pair<Object, Object>> xxx = data.get(k);
      List<Pair<Object, Object>> table = new LinkedList<>(xxx);

      Object[][] arr = new Object[table.size()][2];
      int i = 0;
      for (Pair<Object, Object> p : table) {
        arr[i][0] = p.first;
        arr[i][1] = p.second;
        i++;
      }
      @SuppressWarnings("serial")
      JTable t =
          new JTable(arr, new Object[] {src_n, dst_n}) {
            @Override
            public Dimension getPreferredScrollableViewportSize() {
              Dimension d = getPreferredSize();
              return new Dimension(d.width, d.height);
            }
          };
      // //t.setRowSelectionAllowed(false);
      // t.setColumnSelectionAllowed(false);
      // MouseListener[] listeners = t.getMouseListeners();
      // for (MouseListener l : listeners) {
      // t.removeMouseListener(l);
      // }
      TableRowSorter<?> sorter = new MyTableRowSorter(t.getModel());

      t.setRowSorter(sorter);
      sorter.allRowsChanged();
      sorter.toggleSortOrder(0);
      t.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
      JPanel p = new JPanel(new GridLayout(1, 1));
      p.add(new JScrollPane(t));
      p.setBorder(
          BorderFactory.createTitledBorder(
              BorderFactory.createEmptyBorder(2, 2, 2, 2), k + "  (" + xxx.size() + " rows)"));
      panels.add(p);
      //	p.setPreferredSize(new Dimension(60, 60));
    }

    /*int x = (int) Math.ceil(Math.sqrt(panels.size()));
    if (x == 0) {
    	return new JPanel();
    }
    JPanel panel = new JPanel(new GridLayout(x, x));
    for (JPanel p : panels) {
    	panel.add(p);
    }
    panel.setBorder(BorderFactory.createEtchedBorder()); */
    return FqlUtil.makeGrid(((List<JComponent>) ((Object) panels)));
  }
예제 #11
0
 private TableRowSorter<StockTableModel> createRowSorter(
     StockTableModel model, List<String> columns) {
   TableRowSorter<StockTableModel> rowSorter = new TableRowSorter<StockTableModel>(model);
   for (int i = 0; i < columns.size(); i++) {
     rowSorter.setComparator(i, DoubleAsStringComparator.instance);
   }
   rowSorter.toggleSortOrder(0);
   return rowSorter;
 }
예제 #12
0
 private void buscarJtblPagos() throws Exception {
   if (jtable.getModel().getRowCount() > 0) {
     String msg = jtfBuscar.getText();
     javax.swing.table.TableRowSorter modeloOrdenado =
         new javax.swing.table.TableRowSorter(jtable.getModel());
     modeloOrdenado.setRowFilter(javax.swing.RowFilter.regexFilter(msg));
     jtable.setRowSorter(modeloOrdenado);
   }
 }
예제 #13
0
  private JPanel createTablePanel(boolean away) {
    JPanel panel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    JLabel headerLabel = new JLabel();
    if (away) {
      headerLabel.setText(
          HOVerwaltung.instance().getLanguageString("ifa.statisticsTable.header.away"));
    } else {
      headerLabel.setText(
          HOVerwaltung.instance().getLanguageString("ifa.statisticsTable.header.home"));
    }
    Font boldFont = headerLabel.getFont().deriveFont(headerLabel.getFont().getStyle() ^ Font.BOLD);
    headerLabel.setFont(boldFont);
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.insets = new Insets(10, 10, 3, 10);
    panel.add(headerLabel, gbc);

    final IfaTableModel tblModel = new IfaTableModel();
    tblModel.setData(this.model, away);
    JTable table = new JTable(tblModel);
    IfaTableCellRenderer renderer = new IfaTableCellRenderer();
    table.getColumnModel().getColumn(0).setCellRenderer(renderer);
    table.getColumnModel().getColumn(1).setCellRenderer(renderer);
    table.getColumnModel().getColumn(2).setCellRenderer(renderer);
    table.getColumnModel().getColumn(3).setCellRenderer(renderer);
    table.getColumnModel().getColumn(4).setCellRenderer(renderer);
    table.getColumnModel().getColumn(5).setCellRenderer(renderer);
    table.getColumnModel().getColumn(6).setCellRenderer(renderer);

    TableRowSorter<TableModel> sorter = new SummaryTableSorter<TableModel>(table.getModel());
    table.setRowSorter(sorter);
    sorter.setComparator(
        0,
        new Comparator<Country>() {

          @Override
          public int compare(Country o1, Country o2) {
            return o1.getName().compareTo(o2.getName());
          }
        });
    List<SortKey> list = new ArrayList<SortKey>();
    list.add(new SortKey(5, SortOrder.DESCENDING));
    sorter.setSortKeys(list);

    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridy = 1;
    gbc.weightx = 1;
    gbc.weighty = 1;
    gbc.insets = new Insets(3, 10, 10, 10);
    panel.add(new JScrollPane(table), gbc);

    return panel;
  }
예제 #14
0
    public void setColumns(List<Column> columns) {
      model = new DataTableModel(columns);
      super.setModel(model);

      if (!isFooter) {
        sorter = new TableRowSorter<TableModel>(model);
        setRowSorter(sorter);
        List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>();
        sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
        sorter.setSortKeys(sortKeys);
        sorter.sort();
      }
    }
  public synchronized void setModel(StockTable model) {
    // we pass the model to the JTable
    this.table.setModel(model);
    // we set the first column to be larger (it contains the stock_name)
    TableColumn col = table.getColumnModel().getColumn(0);
    col.setPreferredWidth(250);

    // we add a sorter to the JTable (and we listen for sort changes, see below)
    TableRowSorter<StockTable> trs = new TableRowSorter<StockTable>(model);
    trs.addRowSorterListener(new SortListener());

    table.setRowSorter(trs);
  }
예제 #16
0
  public void repopulateTable() {
    populateTable();
    iProductsTable.scrollRowToVisible(0);
    TableRowSorter<DefaultTableModel> sorter =
        new TableRowSorter<>((DefaultTableModel) iProductsTable.getModel());
    iProductsTable.setRowSorter(sorter);
    List<RowSorter.SortKey> sortKeys = new ArrayList<>();

    int columnIndexToSort = 0;
    sortKeys.add(new RowSorter.SortKey(columnIndexToSort, SortOrder.ASCENDING));

    sorter.setSortKeys(sortKeys);
    sorter.sort();
  }
  /** Updates fields of the cardAnalyzeComponent. */
  public void updateAnalyzeComponent() {
    int totalCards = 0;
    double totalSumUAH = 0;

    int viewRows = sorter.getViewRowCount();
    List<DiscountCardJdo> selectedCards = new ArrayList<>();
    for (int i = 0; i < viewRows; i++) {
      int row = sorter.convertRowIndexToModel(i);
      selectedCards.add(tableModel.getDiscountCardByRowIndex(row));
    }
    for (DiscountCardJdo discountCardJdo : selectedCards) {
      ++totalCards;
      totalSumUAH += discountCardJdo.getSumTotalUAH();
    }
    cardAnalyzeComponent.updateFields(totalCards, totalSumUAH);
  }
예제 #18
0
  /**
   * @param sorter come from the same class of table
   * @param table need a array
   * @param stringFiltre1 filtre no1
   * @param idColFiltre1 col that apply the filtre no1
   * @param stringFiltre2 filtre no2
   * @param idColFiltre2 col that apply the filtre no2
   *     <p>This method handle the double filtrate of an array
   */
  public void doubleFilter(
      TableRowSorter<DefaultTableModel> sorter,
      JTable table,
      String stringFiltre1,
      int idColFiltre1,
      String stringFiltre2,
      int idColFiltre2) {

    RowFilter<DefaultTableModel, Object> rfType = null;
    RowFilter<DefaultTableModel, Object> rfStatus = null;

    System.out.println("double filtre, string 1 :" + stringFiltre1);
    System.out.println("double filtre, string 2 :" + stringFiltre2);

    if (stringFiltre1 == "Tout") {
      stringFiltre1 = "";
    }
    if (stringFiltre2 == "Tout") {
      stringFiltre2 = "";
    }
    rfType = RowFilter.regexFilter(stringFiltre1, idColFiltre1);
    rfStatus = RowFilter.regexFilter(stringFiltre2, idColFiltre2);

    ArrayList<RowFilter<DefaultTableModel, Object>> andFilters =
        new ArrayList<RowFilter<DefaultTableModel, Object>>();
    andFilters.add(rfType);
    andFilters.add(rfStatus);

    sorter.setRowFilter(RowFilter.andFilter(andFilters));

    nbRowsField.setText(table.getRowCount() + " trouvés");
    System.out.println(table.getRowCount());

    setAllAvgField(table, 1, 1, 3, 2);
  }
 // This method is used to filter table by column
 protected void update_filter() {
   txt_search_word.setText("");
   Object selected = cmb_search_catagory.getSelectedItem();
   TableRowSorter<?> sorter = (TableRowSorter<?>) tbl_service_details.getRowSorter();
   String text = "(?i)" + txt_search_text.getText();
   if ("Nothing".equals(selected)) {
     sorter.setRowFilter(null);
   } else {
     int col = -1;
     if ("Customer Name".equals(selected)) {
       col = 1;
     } else if ("Vehicle Number".equals(selected)) {
       col = 3;
     }
     sorter.setRowFilter(RowFilter.regexFilter(text, col));
   }
 }
예제 #20
0
    public Object getCellValue(int rowIndex, int columnIndex) {
      if (model == null) {
        throw new IllegalStateException("Model not set");
      }

      int modelIndex = sorter.convertRowIndexToModel(rowIndex);
      return model.getValueAt(modelIndex, columnIndex);
    }
예제 #21
0
 public void update() {
   if (model != null) {
     model.fireTableDataChanged();
     if (!isFooter) {
       resizeColumns();
       sorter.sort();
     }
   }
 }
예제 #22
0
  public static void cargarjugadorestorneo() {

    id_torneo = Principal.labelserialtorneo.getText();
    equipo = id_torneo + labelserial.getText();

    try {
      String[] titulos = {"N°", "Cedula", "Nombre", "Apellido"};
      String[] registro = new String[4];
      String sql =
          "Select hj.n_nomina ,j.cedula, j.nombre_j, j.apellido_j from jugador j, h_jugador hj where hj.cedula=j.cedula and hj.id_torneo='"
              + id_torneo
              + "' and hj.id_equipo='"
              + equipo
              + "' order by hj.n_nomina;";
      Conexion parametro = new Conexion();
      Class.forName(parametro.getDriver());
      Connection con =
          DriverManager.getConnection(
              parametro.getURL(), parametro.getUsuario(), parametro.getPass());
      modelo1 = new DefaultTableModel(null, titulos);
      Statement st =
          con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
      ResultSet rs = st.executeQuery(sql);
      while (rs.next()) {
        registro[0] = rs.getString("hj.n_nomina");
        registro[1] = rs.getString("j.cedula");
        registro[2] = rs.getString("j.nombre_j");
        registro[3] = rs.getString("j.apellido_j");
        modelo1.addRow(registro);
      }
      jugadorestorneo.setModel(modelo1);
      jugadorestorneo.getColumnModel().getColumn(0).setPreferredWidth(27);
      jugadorestorneo.getColumnModel().getColumn(1).setPreferredWidth(135);
      jugadorestorneo.getColumnModel().getColumn(2).setPreferredWidth(135);
      jugadorestorneo.getColumnModel().getColumn(3).setPreferredWidth(135);
      TableRowSorter modeloordenado = new TableRowSorter(modelo1);
      jugadorestorneo.setRowSorter(modeloordenado);
      modeloordenado.setRowFilter(RowFilter.regexFilter(filtro2.getText()));

    } catch (SQLException | ClassNotFoundException ex) {
      Logger.getLogger(jugadoresequipot.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
예제 #23
0
 public void clearReviewsActionPerformed(ActionEvent e) {
   int rowSorted = bookTable_.getSelectedRow();
   int row = sorter_.convertRowIndexToModel(rowSorted);
   if (row < 0) {
     System.err.println("No row selected...");
   } else {
     ATBookWrapper selectedBook = bookTableModel_.getBook(row);
     selectedBook.clearReviews();
   }
 }
예제 #24
0
  private void jBPesquisarActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jBPesquisarActionPerformed
    // TODO add your handling code here:

    String text = jTFPesquisar.getText();

    if (text.length() == 0) {
      sorter.setRowFilter(null);
    } else {
      try {
        sorter.setRowFilter(RowFilter.regexFilter(text));
      } catch (PatternSyntaxException pse) {
        JOptionPane.showMessageDialog(null, "Bad regex pattern");

      } catch (RuntimeException ex2) {
        JOptionPane.showMessageDialog(null, "Erro: " + ex2.getMessage());
      }
    }
  } // GEN-LAST:event_jBPesquisarActionPerformed
예제 #25
0
 protected void updatePersonnelTable() {
   personnelSorter.sort();
   if (!choiceNoSkill.equals(choiceSkill.getSelectedItem())) {
     int rows = personnelTable.getRowCount();
     matchedPersonnelLabel.setText(
         String.format(resourceMap.getString("eligible.format"), rows)); // $NON-NLS-1$
   } else {
     matchedPersonnelLabel.setText(""); // $NON-NLS-1$
   }
 }
예제 #26
0
 public void editKeywordsActionPerformed(ActionEvent e) {
   int rowSorted = bookTable_.getSelectedRow();
   int row = sorter_.convertRowIndexToModel(rowSorted);
   if (row < 0) {
     System.err.println("No row selected...");
   } else {
     ATBookWrapper selectedBook = bookTableModel_.getBook(row);
     keywordsPopup_.setBook(selectedBook);
     keywordsPopup_.popUp();
   }
 }
  @Test
  public void testFilteredTable() {
    JTable jTable = new JTable(10, 1);
    TableRowSorter rowSorter = new TableRowSorter(jTable.getModel());
    jTable.setRowSorter(rowSorter);
    RowFilter<TableModel, Integer> rowFilter =
        new RowFilter<TableModel, Integer>() {

          public boolean include(Entry<? extends TableModel, ? extends Integer> entry) {
            return entry.getIdentifier().intValue() % 2 == 0;
          }
        };

    rowSorter.setRowFilter(rowFilter);
    NextRowProvider nextRowProvider = NextRowProviderFactory.getNextFilteredTableRow(jTable);
    for (int i = 0; i < 5; i++) {
      int nextRow = nextRowProvider.getNextRow();
      assertEquals(i * 2, nextRow);
    }
    assertEquals(-1, nextRowProvider.getNextRow());
  }
예제 #28
0
  public void Pesquisar(String texto) {

    String textoInicialMaiuscula = "";

    if (texto != null && !texto.trim().equals("")) {
      textoInicialMaiuscula = texto.substring(0, 1).toUpperCase().concat(texto.substring(1));
    }

    if (textoInicialMaiuscula.length() == 0) {
      sorter.setRowFilter(null);
    } else {
      try {
        sorter.setRowFilter(RowFilter.regexFilter(textoInicialMaiuscula));
      } catch (PatternSyntaxException pse) {
        JOptionPane.showMessageDialog(null, "Bad regex pattern");

      } catch (RuntimeException ex2) {
        JOptionPane.showMessageDialog(null, "Erro: " + ex2.getMessage());
      }
    }

    tabela.grabFocus();
  }
예제 #29
0
  private void filterButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_filterButtonActionPerformed
    m = monthComboBox.getSelectedIndex();
    String yearString = yearField.getText();
    if (yearString.equals("")) {
      JOptionPane.showMessageDialog(null, "Введите год", "Ошибка", JOptionPane.ERROR_MESSAGE);
      return;
    }
    int year = Integer.valueOf(yearString);
    infoLabel.setText(
        "Отображаются записи за "
            + monthComboBox.getSelectedItem().toString()
            + " "
            + yearString
            + " года.");
    infoLabel.setVisible(true);
    Date beginDate = new Date();
    Date endDate = new Date();
    beginDate.setYear(year - 1900);
    beginDate.setMonth(m);
    beginDate.setDate(0);
    endDate.setYear(year - 1900);
    endDate.setMonth(m);
    endDate.setDate(SaldoCalculator.daysQuantity(m, year));

    List<RowFilter<Object, Object>> filters = new ArrayList<>(2);
    filters.add(RowFilter.dateFilter(ComparisonType.AFTER, beginDate));
    filters.add(RowFilter.dateFilter(ComparisonType.BEFORE, endDate));

    TableRowSorter moneySorter = new TableRowSorter(moneyTable.getModel());
    moneySorter.setRowFilter(RowFilter.andFilter(filters));
    moneyTable.setRowSorter(moneySorter);

    TableRowSorter productSorter = new TableRowSorter(productTable.getModel());
    productSorter.setRowFilter(RowFilter.andFilter(filters));
    productTable.setRowSorter(productSorter);
  } // GEN-LAST:event_filterButtonActionPerformed
예제 #30
-1
  private void jBPesquisarKeyTyped(
      java.awt.event.KeyEvent evt) { // GEN-FIRST:event_jBPesquisarKeyTyped

    if (evt.getKeyChar() == KeyEvent.VK_ENTER) {
      if (evt.getSource() == jBPesquisar) {

        String text = jTFPesquisar.getText();

        if (text.length() == 0) {
          sorter.setRowFilter(null);
        } else {
          try {
            sorter.setRowFilter(RowFilter.regexFilter(text));
            int total = calculaTotalPecas(text);
            jLabelTotalPecas.setText(String.valueOf(total));
          } catch (PatternSyntaxException pse) {
            JOptionPane.showMessageDialog(this, "Erro na pesquisa");
          } catch (RuntimeException ex2) {
            JOptionPane.showMessageDialog(null, "Erro: " + ex2.getMessage());
          }
        }
      }
    }
    tabela.grabFocus();
  } // GEN-LAST:event_jBPesquisarKeyTyped