private BarChart createBarChart() { CategoryAxis xAxis = new CategoryAxis(); xAxis.setCategories(FXCollections.<String>observableArrayList(tableModel.getColumnNames())); xAxis.setLabel("Year"); double tickUnit = tableModel.getTickUnit(); NumberAxis yAxis = new NumberAxis(); yAxis.setTickUnit(tickUnit); yAxis.setLabel("Units Sold"); final BarChart chart = new BarChart(xAxis, yAxis, tableModel.getBarChartData()); tableModel.addTableModelListener(new TableModelListener() { public void tableChanged(TableModelEvent e) { if (e.getType() == TableModelEvent.UPDATE) { final int row = e.getFirstRow(); final int column = e.getColumn(); final Object value = ((SampleTableModel) e.getSource()).getValueAt(row, column); Platform.runLater(new Runnable() { public void run() { XYChart.Series<String, Number> s = (XYChart.Series<String, Number>) chart.getData().get(row); BarChart.Data data = s.getData().get(column); data.setYValue(value); } }); } } }); return chart; }
/** Fires multiple table model events, setting the inMultiEvent flag * as appropriate. */ private void fireTableChange (TableModelEvent[] e) { //Event may be null for offscreen info, etc. if (e == null || e.length==0) { return; } TableModelListener[] listeners = getTableModelListeners(); inMultiEvent = e.length > 1; //System.err.println("fireTableChange("+Arrays.toString(e)+")"); try { for (int i=0; i < e.length; i++) { if (i == e.length-1) { inMultiEvent = false; } fireTableChange (e[i], listeners); } } finally { inMultiEvent = false; } }
@Override public void propertyChange(PropertyChangeEvent evt) { // Keep the row table in sync with the main table if ("rowHeight".equals(evt.getPropertyName())) { repaint(); } if ("model".equals(evt.getPropertyName())) { contentTable.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { revalidate(); } }); revalidate(); } }
private void setupTableModelListener() { //add listener which responds to tableChanged that is fired //by variationPerParameterTableModel.setValueAt(). this.variationPerParameterTableModel.addTableModelListener(new TableModelListener() { public void tableChanged(TableModelEvent e) { //update currentVariationFunctionContext. Variation variationFunction = variationPerParameterTableModel.getUncertaintiesObject() .getVariationFunction(variationPerParameterTableModel.getCurrentRow()); setCurrentVariationFunctionContext(new VariationFunctionContext(variationFunction)); //update panel. updateVariationPerParameterSidePanel(); //select row of currentVariationFunctionContext. int selectedRowIndex = variationPerParameterTableModel.getCurrentRow(); setSelectedRow(selectedRowIndex); } }); }
/** * Update the Correlation model Parameters Table. */ private void updateCorrelationModelParametersTable() { // Populate the correlation model parameters table. FunctionParameterTableModel parameterTableModel = new FunctionParameterTableModel(this.currentAutoCorrelationFunctionContext); this.parentController.getMainPanel().getAutoCorrelationParameterAndGraphPanel().getParametersTable() .setModel(parameterTableModel); //setup cell editor. TableColumn columnValue = parentController.getMainPanel().getAutoCorrelationParameterAndGraphPanel() .getParametersTable().getColumnModel().getColumn(FunctionParameterTableModel.COLUMN_VALUE); columnValue.setCellEditor(new TextCellEditor()); parameterTableModel.addTableModelListener(new TableModelListener() { public void tableChanged(TableModelEvent e) { updateCorrelationModelGraph(); } }); }
/** * Update the PDFDefinition Parameters Table. */ private void updatePDFDefinitionParametersTable() { // Populate the correlation model parameters table. FunctionParameterTableModel parameterTableModel; if (this.currentPdfContext != null && this.currentPdfContext.getPdfObject() != null) { parameterTableModel = new FunctionParameterTableModel(this.currentPdfContext); parentController.getMainPanel().getPdfParameterAndGraphPanel().getParametersTable() .setModel(parameterTableModel); //setup cell editor. TableColumn columnValue = parentController.getMainPanel().getPdfParameterAndGraphPanel() .getParametersTable().getColumnModel().getColumn(FunctionParameterTableModel.COLUMN_VALUE); columnValue.setCellEditor(new TextCellEditor()); parameterTableModel.addTableModelListener(new TableModelListener() { public void tableChanged(TableModelEvent e) { updatePDFDefinitionGraph(); } }); } }
private PropertiesTable getPropertiesPanel() { PropertiesTable result = this.propertiesPanel; if (result == null) { this.propertiesPanel = result = new PropertiesTable(GraphProperties.Key.class, true); result.setName("Properties"); result.setBackground(JAttr.EDITOR_BACKGROUND); result.setProperties(GraphInfo.getProperties(getGraph())); // add the listener after initialising the properties, to avoid needless refreshes result.getModel() .addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { if (GraphEditorTab.this.listenToPropertiesPanel) { changeProperties(GraphEditorTab.this.propertiesPanel.getProperties(), false); setDirty(false); } } }); this.listenToPropertiesPanel = true; } return result; }
/** * Delete a single column from the table model * * @param table target table * @param col target column * @deprecated */ static void deletecol(JTable table, int col) { DefaultTableModel tmodel = (DefaultTableModel) table.getModel(); DefaultTableModel tmodel1 = new DefaultTableModel(); TableModelListener[] listeners = tmodel.getTableModelListeners(); Vector<?> v = tmodel.getDataVector(); Vector<?> v1 = newvector(v, col); tmodel1.setDataVector(v1, getColumnIdentifiersremovecol(table, col)); table.setModel(tmodel1); for (TableModelListener l : listeners) { tmodel1.addTableModelListener(l); } }
public void test218096() { String[][] nodesDesc = new String[][]{ new String[]{"a", "b", "c"}, new String[]{"D", "E", "F"}, new String[]{"g", "h", "i"}}; Node rootNode = new TestNode(new StringListKeys(nodesDesc), "root"); OutlineViewComponent comp = new OutlineViewComponent(rootNode); Node[] rootChildNodes = rootNode.getChildren().getNodes(); assertEquals(3, rootChildNodes.length); Node[] firstNodeChildren = rootChildNodes[0].getChildren().getNodes(); assertEquals(3, firstNodeChildren.length); comp.view.expandNode(rootChildNodes[0]); assertEquals(6, comp.view.getOutline().getRowCount()); VisualizerNode dParentVisNode = (VisualizerNode) comp.view.getOutline() .getModel().getValueAt(4, 0); assertEquals("Dparent", dParentVisNode.getDisplayName()); TestNode.MarkedCookie mc = rootChildNodes[1].getLookup().lookup( TestNode.MarkedCookie.class); final AtomicBoolean notifiedAboutChange = new AtomicBoolean(false); comp.view.getOutline().getModel().addTableModelListener( new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { if (e.getFirstRow() <= 4 && e.getLastRow() >= 4) { notifiedAboutChange.set(true); } } }); mc.setMarked(true); assertTrue("Table model should be notified about name change", notifiedAboutChange.get()); }
/** * Creates new form RunNetworkVisual */ public RunPortBindingsVisual(DockerImageDetail info) { initComponents(); this.info = info; addExposedButton.setEnabled(info != null && !info.getExposedPorts().isEmpty()); portMappingTable.setModel(model); UiUtils.configureRowHeight(portMappingTable); TableColumn typeColumn = portMappingTable.getColumnModel().getColumn(0); JComboBox typeCombo = new JComboBox(ExposedPort.Type.values()); typeColumn.setCellEditor(new DefaultCellEditor(typeCombo)); typeColumn.setPreferredWidth(typeColumn.getPreferredWidth() / 2); TableColumn portColumn = portMappingTable.getColumnModel().getColumn(2); portColumn.setCellRenderer(new CellRenderer("<random>", false)); TableColumn addressColumn = portMappingTable.getColumnModel().getColumn(3); JComboBox addressCombo = new JComboBox(UiUtils.getAddresses(false, false).toArray()); addressCombo.setEditable(true); addressColumn.setCellEditor(new DefaultCellEditor(addressCombo)); addressColumn.setCellRenderer(new CellRenderer("<any>", false)); addressColumn.setPreferredWidth(addressColumn.getPreferredWidth() * 2); portMappingTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); model.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { changeSupport.fireChange(); } }); }
/** Fire a table change to the list of listeners supplied. The event should * already have its source set to be the OutlineModel we're proxying for. */ private void fireTableChange (TableModelEvent e, TableModelListener[] listeners) { //Event may be null for offscreen info, etc. if (e == null) { return; } assert (e.getSource() == getModel()); log ("fireTableChange", e); for (int i=0; i < listeners.length; i++) { listeners[i].tableChanged(e); } }
/** Fetch an array of the currently registered table model listeners */ private TableModelListener[] getTableModelListeners() { TableModelListener[] listeners; synchronized (this) { listeners = new TableModelListener[ tableListeners.size()]; listeners = tableListeners.toArray(listeners); } return listeners; }
private void fire (TableModelEvent e) { TableModelListener[] l; synchronized (this) { l = new TableModelListener[listeners.size()]; l = listeners.toArray (l); } for (int i=0; i < l.length; i++) { l[i].tableChanged(e); } }
protected TabTable( TabTableModel tableModel, int orientation ) { super( tableModel ); this.orientation = orientation; getModel().addTableModelListener( new TableModelListener() { @Override public void tableChanged( TableModelEvent e ) { if( e.getFirstRow() != TableModelEvent.HEADER_ROW ) adjustColumnWidths(); } }); configure(); }
private void separateStaticImportsCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_separateStaticImportsCheckBoxActionPerformed TableModel oldModel = importLayoutTable.getModel(); TableModel newModel = (DefaultTableModel)createTableModel(importGroupsOrder, preferences); importLayoutTable.setModel(newModel); setImportLayoutTableColumnsWidth(); for (TableModelListener l : ((DefaultTableModel)oldModel).getTableModelListeners()) { oldModel.removeTableModelListener(l); newModel.addTableModelListener(l); l.tableChanged(null); } }
/** * Creates a new {@link TablePanel} instance. * * @param model * @param useScrollPane * if set to <code>true</code>, will add a scrollpane around the GUI. * @param hideUnavailableContentAssist * if <code>true</code>, the content assist button will be hidden if no content * assist is available for the given field */ public TablePanel(final TablePanelModel model, boolean useScrollPane, boolean hideUnavailableContentAssist) { this.mapOfComponents = new HashMap<>(); this.useScrollPane = useScrollPane; this.hideUnavailableContentAssist = hideUnavailableContentAssist; this.listener = new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { // table structure changed, re-create it if (e.getFirstRow() == TableModelEvent.HEADER_ROW) { createGUI(); } else { updateComponent(e.getFirstRow(), e.getColumn()); } } }; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { initGUI(); setModel(model); } }); }
private void setupTableModelListener() { //add listener which responds to tableChanged that is fired //by correlationTableModel.setValueAt(). this.correlationTableModel.addTableModelListener(new TableModelListener() { public void tableChanged(TableModelEvent e) { //(re)select row after setValueAt was called. //select row of currentCorrelationContext. int selectedRowIndex = correlationTableModel.getCurrentRow(); setSelectedRow(selectedRowIndex); } }); }
@Override public void setValueAt(final Object aValue, final int rowIndex, final int columnIndex) { if (rowIndex < dynamicArray.size() && columnIndex < 2) { dynamicArray.get(rowIndex)[columnIndex] = aValue; } for (final TableModelListener l : getTableModelListeners()) { l.tableChanged(new TableModelEvent(this, rowIndex, rowIndex, columnIndex, TableModelEvent.UPDATE)); } }
@Override public void setValueAt(final Object aValue, final int rowIndex, final int columnIndex) { if (rowIndex < data.size() && columnIndex < columnSize) { data.get(rowIndex)[columnIndex] = aValue; } for (final TableModelListener l : this.getTableModelListeners()) { l.tableChanged(new TableModelEvent(this, rowIndex, rowIndex, columnIndex, TableModelEvent.UPDATE)); } }
/** Creates an instance of {@link TableModel}. */ private TableModel getTableModel() { if (this.tableModel == null) { this.tableModel = new TableModel(); this.tableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { setChanged(true); } }); } return this.tableModel; }
@Override protected JComponent getSwingComponent() { // Create columns names String columnNames[] = {"Column 1", "Column 2", "Column 3"}; // Create some data String dataValues[][] = { {"12", "234", "67"}, {"-123", "43", "853"}, {"93", "89.2", "109"}, {"279", "9033", "3092"}, {"12", "234", "67"}, {"-123", "43", "853"}, {"93", "89.2", "109"}, {"279", "9033", "3092"}, {"12", "234", "67"}, {"-123", "43", "853"}, {"93", "89.2", "109"}, {"279", "9033", "3092"}, {"12", "234", "67"}, {"-123", "43", "853"}, {"93", "89.2", "109"}, {"279", "9033", "3092"} }; // Create a new table instance JTable jt = new JTable(dataValues, columnNames); jt.getModel().addTableModelListener(new TableModelListener() { public void tableChanged(TableModelEvent e) { System.err.println("table changed"); } }); return jt; }
public void removeTableModelListener( TableModelListener tml ) { if (baseModel != null) return; baseModel.removeTableModelListener(tml); }
public TableModelListener[] getTableModelListeners() { if (baseModel == null) return new TableModelListener[0]; return baseModel.getTableModelListeners(); }
public void addTableModelListener(TableModelListener listener) { synchronized (listeners) { listeners.add(listener); } }
public void removeTableModelListener(TableModelListener listener) { synchronized (listeners) { listeners.remove(listener); } }
private void fireTableDataChanged(TableModelEvent event) { for (TableModelListener listener: listeners.toArray(new TableModelListener[0])) { listener.tableChanged(event); } }
@Override public void addTableModelListener(TableModelListener l) { }
@Override public void removeTableModelListener(TableModelListener l) { }
public void addTableModelListener(TableModelListener l) { }
public void removeTableModelListener(TableModelListener l) { }
@Override public final synchronized void addTableModelListener(TableModelListener l) { broadcaster.addTableModelListener (l); }
@Override public final synchronized void removeTableModelListener(TableModelListener l) { broadcaster.removeTableModelListener(l); }
@JsonIgnore @Override public void addTableModelListener(TableModelListener tl) { super.addTableModelListener(tl); }
/** Remove a table model listener. */ public synchronized void removeTableModelListener(TableModelListener l) { tableListeners.remove(l); }
@Override public synchronized void removeTableModelListener(TableModelListener l) { listeners.remove(l); }
@Override public void removeTableModelListener(TableModelListener l) { tableListeners.remove(l); }