@Override public int getModelRowCount() { return model.getRowCount(); }
public String[] getAxisLabels() { if (model.getRowCount() > 1) { int count = model.getRowCount() -1; String[] labels = new String[count]; for (int idx=0; idx < count; idx++) { labels[idx] = (String)model.getValueAt(idx,0); } return labels; } // API expects null, not empty array return null; }
/** * Enable or disable the delete button depending on whether or not there is * a row to be deleted. */ private void checkDeleteStatus() { // Disable DELETE if there are no rows in the table to delete. if (tableModel.getRowCount() == 0) { delete.setEnabled(false); } else { delete.setEnabled(true); } }
/** * Enable or disable the delete button depending on whether or not there is * a row to be deleted. */ private void checkDeleteAndBrowseStatus() { // Disable DELETE and BROWSE buttons if there are no rows in // the table to delete. if (tableModel.getRowCount() == 0) { browse.setEnabled(false); delete.setEnabled(false); } else { browse.setEnabled(true); delete.setEnabled(true); } }
public String[] getFiles() { String[] _files = new String[tableModel.getRowCount()]; for (int idx=0; idx < _files.length; idx++) { _files[idx] = (String)tableModel.getValueAt(idx,0); } return _files; }
protected void checkButtonsStatus() { if (!disableButtons) { // Disable DELETE if there are no rows in the table to delete. if (tableModel.getRowCount() == 0) { delete.setEnabled(false); showDetail.setEnabled(false); } else { delete.setEnabled(true); showDetail.setEnabled(true); } if(enableUpDown) { if(tableModel.getRowCount()>1) { up.setEnabled(true); down.setEnabled(true); } else { up.setEnabled(false); down.setEnabled(false); } } } }
@Override public void actionPerformed(ActionEvent e) { int[] rows = table.getSelectedRows(); for(int i=0; i<rows.length; i++){ model.removeRow(rows[i]-i); } if(model.getRowCount()>1) { upButton.setEnabled(true); downButton.setEnabled(true); } else { upButton.setEnabled(false); downButton.setEnabled(false); } } }
/** * We use this method to get the data, since we are using * ObjectTableModel, so the calling getDataVector doesn't * work as expected. * @param model {@link ObjectTableModel} * @param formats Array of {@link Format} array can contain null formatters in this case value is added as is * @return the data from the model */ public static List<List<Object>> getAllTableData(ObjectTableModel model, Format[] formats) { List<List<Object>> data = new ArrayList<>(); if (model.getRowCount() > 0) { for (int rw=0; rw < model.getRowCount(); rw++) { int cols = model.getColumnCount(); List<Object> column = new ArrayList<>(); data.add(column); for (int idx=0; idx < cols; idx++) { Object val = model.getValueAt(rw,idx); if(formats[idx] != null) { column.add(formats[idx].format(val)); } else { column.add(val); } } } } return data; }
private void actionMakeGraph() { if (model.getRowCount() > 1) { makeGraph(); tabbedGraph.setSelectedIndex(1); } else { JOptionPane.showMessageDialog(null, JMeterUtils .getResString("aggregate_graph_no_values_to_graph"), // $NON-NLS-1$ JMeterUtils.getResString("aggregate_graph_no_values_to_graph"), // $NON-NLS-1$ JOptionPane.WARNING_MESSAGE); } } @Override
public double[][] getData() { if (model.getRowCount() > 1) { int count = model.getRowCount() -1; int size = nbColToGraph; double[][] data = new double[size][count]; int s = 0; int cpt = 0; for (BarGraph bar : eltList) { if (bar.getChkBox().isSelected()) { int col = model.findColumn(columnsList.getItemAt(cpt)); for (int idx=0; idx < count; idx++) { data[s][idx] = ((Number)model.getValueAt(idx,col)).doubleValue(); } s++; } cpt++; } return data; } // API expects null, not empty array return null; }
/** * Do search * @param e {@link ActionEvent} */ @Override public void actionPerformed(ActionEvent e) { String action = e.getActionCommand(); if (action.equals(CLOSE)) { this.setVisible(false); } else if (action.equals(NEXT)) { selectedRow++; previousButton.setEnabled(true); nextButton.setEnabled(selectedRow < tableModel.getRowCount()-1); setValues(selectedRow); } else if (action.equals(PREVIOUS)) { selectedRow--; nextButton.setEnabled(true); previousButton.setEnabled(selectedRow > 0); setValues(selectedRow); } else if (action.equals(UPDATE)) { doUpdate(e); } }
/** * Remove the currently selected argument from the table. */ protected void deleteArgument() { GuiUtils.cancelEditing(table); int[] rowsSelected = table.getSelectedRows(); int anchorSelection = table.getSelectionModel().getAnchorSelectionIndex(); table.clearSelection(); if (rowsSelected.length > 0) { for (int i = rowsSelected.length - 1; i >= 0; i--) { tableModel.removeRow(rowsSelected[i]); } // Table still contains one or more rows, so highlight (select) // the appropriate one. if (tableModel.getRowCount() > 0) { if (anchorSelection >= tableModel.getRowCount()) { anchorSelection = tableModel.getRowCount() - 1; } table.setRowSelectionInterval(anchorSelection, anchorSelection); } checkButtonsStatus(); } }
/** * Sort table */ protected void sort() { if (comparator == null) { comparator = Stream.concat( Stream.concat( getPrimaryComparator() != null ? Stream.of(getPrimaryComparator()) : Stream.<Comparator<Row>>empty(), getSortKeys().stream().filter(sk -> sk != null && sk.getSortOrder() != SortOrder.UNSORTED).map(this::getComparatorFromSortKey) ), Stream.of(getFallbackComparator()) ).reduce(comparator, (result, current) -> result != null ? result.thenComparing(current) : current); } viewToModel.clear(); int rowCount = model.getRowCount(); viewToModel.ensureCapacity(rowCount); for (int i = 0; i < rowCount; i++) { viewToModel.add(new Row(i)); } Collections.sort(viewToModel, comparator); updateModelToView(); }
/** * Remove the currently selected argument from the table. */ private void deleteArgument() { // If a table cell is being edited, we must cancel the editing before // deleting the row GuiUtils.cancelEditing(table); int rowSelected = table.getSelectedRow(); if (rowSelected >= 0) { tableModel.removeRow(rowSelected); tableModel.fireTableDataChanged(); // Disable DELETE if there are no rows in the table to delete. if (tableModel.getRowCount() == 0) { delete.setEnabled(false); } // Table still contains one or more rows, so highlight (select) // the appropriate one. else { int rowToSelect = rowSelected; if (rowSelected >= tableModel.getRowCount()) { rowToSelect = rowSelected - 1; } table.setRowSelectionInterval(rowToSelect, rowToSelect); } } }
/** * Save the GUI data in the HTTPSamplerBase element. * * @param testElement {@link TestElement} to modify */ public void modifyTestElement(TestElement testElement) { GuiUtils.stopTableEditing(table); if (testElement instanceof HTTPSamplerBase) { HTTPSamplerBase base = (HTTPSamplerBase) testElement; int rows = tableModel.getRowCount(); @SuppressWarnings("unchecked") // we only put HTTPFileArgs in it Iterator<HTTPFileArg> modelData = (Iterator<HTTPFileArg>) tableModel.iterator(); HTTPFileArg[] files = new HTTPFileArg[rows]; int row = 0; while (modelData.hasNext()) { HTTPFileArg file = modelData.next(); files[row++] = file; } base.setHTTPFiles(files); } }
/** * Add a new argument row to the table. */ private void addArgument() { // If a table cell is being edited, we should accept the current value // and stop the editing before adding a new row. GuiUtils.stopTableEditing(table); tableModel.addRow(makeNewLDAPArgument()); // Enable DELETE (which may already be enabled, but it won't hurt) delete.setEnabled(true); // Highlight (select) the appropriate row. int rowToSelect = tableModel.getRowCount() - 1; table.setRowSelectionInterval(rowToSelect, rowToSelect); }
@Override public JComponent getPrintableComponent() { if (saveGraphToFile) { saveGraphToFile = false; // (re)draw the graph first to take settings into account (Bug 58329) if (model.getRowCount() > 1) { makeGraph(); } graphPanel.setBounds(graphPanel.getLocation().x,graphPanel.getLocation().y, graphPanel.width,graphPanel.height); return graphPanel; } return this; }
@Override public int compare(Row o1, Row o2) { int lastIndex = model.getRowCount() - 1; if (o1.getIndex() >= lastIndex || o2.getIndex() >= lastIndex) { return o1.getIndex() - o2.getIndex(); } return 0; } }
/** * Add a new file row to the table. */ private void addFile(String path) { // If a table cell is being edited, we should accept the current value // and stop the editing before adding a new row. GuiUtils.stopTableEditing(table); tableModel.addRow(new HTTPFileArg(path)); checkDeleteAndBrowseStatus(); // Highlight (select) the appropriate row. int rowToSelect = tableModel.getRowCount() - 1; table.setRowSelectionInterval(rowToSelect, rowToSelect); }
/** * Add a new argument row to the table. */ protected void addArgument() { // If a table cell is being edited, we should accept the current value // and stop the editing before adding a new row. GuiUtils.stopTableEditing(table); tableModel.addRow(makeNewArgument()); checkButtonsStatus(); // Highlight (select) and scroll to the appropriate row. int rowToSelect = tableModel.getRowCount() - 1; table.setRowSelectionInterval(rowToSelect, rowToSelect); table.scrollRectToVisible(table.getCellRect(rowToSelect, 0, true)); }