javax.swing.table.AbstractTableModel Java Examples
The following examples show how to use
javax.swing.table.AbstractTableModel.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SchemaPanel.java From netbeans with Apache License 2.0 | 8 votes |
public void tableChanged(TableModelEvent e) { //System.out.println("TBALE changed"); //boolean prefixFlag = false; int row = e.getFirstRow(); int column = e.getColumn(); AbstractTableModel tblModel = (AbstractTableModel) e.getSource(); Object data = tblModel.getValueAt(row, column); if(column == SCHEMA_COL) { SchemaObject rowValue = (SchemaObject)data; if(rowValue.toString().equals(startString)) return; String genPrefix = (String) tblModel.getValueAt(row, PREFIX_COL); if (genPrefix == null || genPrefix.equals(" ") ) { String prefix = generateUniquePrefix(); tableModel.setValueAt(prefix, row, PREFIX_COL); } if(row == tableModel.getRowCount() - 1) { addRow(startString); } //if its the first row, then select it as primary if(row == 0) { // System.out.println("added first row"); tblModel.setValueAt(new Boolean(true), 0, 0); } } }
Example #2
Source File: ExcelResultSetConfiguration.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
/** * Creates an excel table model (either {@link ExcelSheetTableModel} or * {@link XlsxSheetTableModel}, depending on file). * * @param sheetSelection * the Sheet Selection method * @param readMode * the read mode for {@link XlsxSheetTableModel} creation. It defines whether only a * preview or the whole sheet content will be loaded * @param progressListener * the progress listener to report progress to * @return * @throws BiffException * @throws IOException * @throws InvalidFormatException */ public AbstractTableModel createExcelTableModel(ExcelSheetSelection sheetSelection, XlsxReadMode readMode, ProgressListener progressListener) throws BiffException, IOException, InvalidFormatException, OperatorException, ParseException { if (getFile().getAbsolutePath().toLowerCase(Locale.ENGLISH).endsWith(XLSX_FILE_ENDING)) { // excel 2007 file return new XlsxSheetTableModel(this, sheetSelection, readMode, getFile().getAbsolutePath(), progressListener); } else { // excel pre 2007 file progressListener.setCompleted(50); try { return new ExcelSheetTableModel(sheetSelection.selectSheetFrom(getOrCreateWorkbookJXL())); } catch (ExcelSheetSelection.SheetNotFoundException e) { throw new IOException(e); } } }
Example #3
Source File: DrawProbabilityPanel.java From MtgDesktopCompanion with GNU General Public License v3.0 | 6 votes |
private void initDeck() { model = new AbstractTableModel() { /** * */ private static final long serialVersionUID = 1L; @Override public String getColumnName(int t) { if (t == 0) return "Card"; else return "Turn " + t; } @Override public Object getValueAt(int r, int c) { if (c == 0) { return d.getUniqueCards().get(r); } else { return UITools.roundDouble(calc.getProbability(d,c - 1, d.getUniqueCards().get(r))); } } @Override public int getRowCount() { return d.getMain().keySet().size(); } @Override public int getColumnCount() { return maxTurn + 1; } }; table.setModel(model); model.fireTableDataChanged(); table.packAll(); }
Example #4
Source File: TaxonSetPanel.java From beast-mcmc with GNU Lesser General Public License v2.1 | 6 votes |
protected void initTaxonSetsTable(AbstractTableModel tableModel, final String[] columnToolTips) { taxonSetsTable = new JTable(tableModel) { //Implement table header tool tips. protected JTableHeader createDefaultTableHeader() { return new JTableHeader(columnModel) { public String getToolTipText(MouseEvent e) { Point p = e.getPoint(); int index = columnModel.getColumnIndexAtX(p.x); int realIndex = columnModel.getColumn(index).getModelIndex(); return columnToolTips[realIndex]; } }; } }; taxonSetsTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); taxonSetsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { taxonSetsTableSelectionChanged(); } }); taxonSetsTable.doLayout(); }
Example #5
Source File: QualifierView.java From ramus with GNU General Public License v3.0 | 6 votes |
@Override protected void createInnerComponent() { super.createInnerComponent(); ((AbstractTableModel) component.getTable().getModel()) .fireTableStructureChanged(); component.getTable().setLeafIcon( new ImageIcon(getClass().getResource( "/com/ramussoft/gui/table/qualifier.png"))); getComponent().getRowSet().addRowChildListener(new RowChildAdapter() { @Override public void added(Row parent, Row row, int index) { if (parent.getParent() == null) return; framework.propertyChanged( "CloseQualifier", StandardAttributesPlugin.getQualifierId(engine, parent.getElementId())); } }); }
Example #6
Source File: HerciLSTab.java From FoxTelem with GNU General Public License v3.0 | 5 votes |
protected void addTables(AbstractTableModel radTableModel, AbstractTableModel radPacketTableModel) { super.addTables(radTableModel, radPacketTableModel); TableColumn column = null; column = table.getColumnModel().getColumn(0); column.setPreferredWidth(45); column = table.getColumnModel().getColumn(1); column.setPreferredWidth(55); for (int i=0; i<58; i++) { column = table.getColumnModel().getColumn(i+2); column.setPreferredWidth(25); } column = packetTable.getColumnModel().getColumn(0); column.setPreferredWidth(45); column = packetTable.getColumnModel().getColumn(1); column.setPreferredWidth(55); column = packetTable.getColumnModel().getColumn(2); column.setPreferredWidth(80); column = packetTable.getColumnModel().getColumn(3); column.setPreferredWidth(70); column = packetTable.getColumnModel().getColumn(4); column.setPreferredWidth(600); //packetTable.getSelectionModel().addListSelectionListener(this); //table.getSelectionModel().addListSelectionListener(this); //packetTable.getRowSelectionAllowed(); }
Example #7
Source File: InspectionsConfigTreeTable.java From consulo with Apache License 2.0 | 5 votes |
public InspectionsConfigTreeTableModel(final InspectionsConfigTreeTableSettings settings, Disposable parentDisposable) { super(settings.getRoot()); mySettings = settings; myUpdateRunnable = new Runnable() { public void run() { settings.updateRightPanel(); ((AbstractTableModel)myTreeTable.getModel()).fireTableDataChanged(); } }; myUpdateAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD, parentDisposable); }
Example #8
Source File: FilterEditor.java From TrakEM2 with GNU General Public License v3.0 | 5 votes |
public TableAvailableFilters(final TableChosenFilters tcf) { setModel(new AbstractTableModel() { @Override public Object getValueAt(final int rowIndex, final int columnIndex) { return available[rowIndex].getSimpleName(); } @Override public int getRowCount() { return available.length; } @Override public int getColumnCount() { return 1; } @Override public String getColumnName(final int col) { return "Available Filters"; } }); addMouseListener(new MouseAdapter() { @Override public void mousePressed(final MouseEvent me) { if (2 == me.getClickCount()) { tcf.add(available[getSelectedRow()]); } } }); }
Example #9
Source File: InnerTablePanel.java From netbeans with Apache License 2.0 | 5 votes |
/** * Creates a new InnerTablePanel. * * @param model DefaultTableModel for included table */ public TablePanel(final AbstractTableModel model) { super(model); final JTable table = getTable(); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { int selectedRowCount = table.getSelectedRowCount(); removeButton.setEnabled(selectedRowCount > 0); editButton.setEnabled(selectedRowCount == 1); } }); }
Example #10
Source File: ThriftFacetConf.java From intellij-thrift with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(AnActionEvent e) { final Generator o = editItem(myType.create()); if (o == null) return; getData().add(o); int index = getData().size() - 1; ((AbstractTableModel)getTable().getModel()).fireTableRowsInserted(index, index); getTable().setRowSelectionInterval(index, index); }
Example #11
Source File: DefaultTasksPanel.java From opt4j with MIT License | 5 votes |
@Override public void startup() { this.setLayout(new BorderLayout()); AbstractTableModel model = getModel(); table = getTable(); table.setModel(model); table.getColumnModel().getColumn(0).setPreferredWidth(50); table.getColumnModel().getColumn(1).setPreferredWidth(500); scroll = new JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); this.add(scroll, BorderLayout.CENTER); }
Example #12
Source File: RTableTest.java From marathonv5 with Apache License 2.0 | 5 votes |
public void editCell() throws Throwable { final JTable table = (JTable) ComponentUtils.findComponent(JTable.class, frame); final LoggingRecorder lr = new LoggingRecorder(); siw(new Runnable() { @Override public void run() { table.addRowSelectionInterval(2, 2); table.addColumnSelectionInterval(2, 2); RTable rTable = new RTable(table, null, null, lr); rTable.focusGained(null); AbstractTableModel model = (AbstractTableModel) table.getModel(); model.setValueAt("Rowing", 2, 2); rTable.focusLost(null); } }); List<Call> calls = lr.getCalls(); Call call = calls.get(1); AssertJUnit.assertEquals("select", call.getFunction()); AssertJUnit.assertEquals("rows:[2],columns:[Sport]", call.getState()); call = calls.get(0); AssertJUnit.assertEquals("select", call.getFunction()); AssertJUnit.assertEquals("Rowing", call.getState()); AssertJUnit.assertEquals("{2, Sport}", call.getCellinfo()); }
Example #13
Source File: ETableTest.java From netbeans with Apache License 2.0 | 5 votes |
/** * Test that table can be sorted just after a column has been removed. See * bug 239045. */ public void testRemoveSortedColumn() { ETable t = new ETable(); final int[] size = new int[]{10, 4}; TableModel tm = new AbstractTableModel() { @Override public int getRowCount() { return size[0]; } @Override public int getColumnCount() { return size[1]; } @Override public Object getValueAt(int rowIndex, int columnIndex) { if (rowIndex < size[0] && columnIndex < size[1]) { return rowIndex; } else { throw new IndexOutOfBoundsException(); } } }; t.setModel(tm); ETableColumnModel etcm = (ETableColumnModel) t.getColumnModel(); ETableColumn etc = (ETableColumn) etcm.getColumn(3); etcm.toggleSortedColumn(etc, true); size[1] = 3; t.sortAndFilter(); }
Example #14
Source File: InnerTablePanel.java From netbeans with Apache License 2.0 | 5 votes |
/** * Creates a new InnerTablePanel. * * @param model DefaultTableModel for included table */ public TablePanel(final AbstractTableModel model) { super(model); final JTable table = getTable(); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { int selectedRowCount = table.getSelectedRowCount(); removeButton.setEnabled(selectedRowCount > 0); editButton.setEnabled(selectedRowCount == 1); } }); }
Example #15
Source File: DrawGridLinesTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void checkTableGridLines() { TableModel dataModel = new AbstractTableModel() { public int getColumnCount() { return 10; } public int getRowCount() { return 10; } public Object getValueAt(int row, int col) { return " "; } }; DefaultTableCellRenderer r = new DefaultTableCellRenderer(); r.setOpaque(true); r.setBackground(CELL_RENDERER_BACKGROUND_COLOR); JTable table = new JTable(dataModel); table.setSize(WIDTH, HEIGHT); table.setDefaultRenderer(Object.class, r); table.setGridColor(GRID_COLOR); table.setShowGrid(true); table.setShowHorizontalLines(true); table.setShowVerticalLines(true); table.setBackground(TABLE_BACKGROUND_COLOR); checkTableGridLines(table); }
Example #16
Source File: ColUndoableEdit.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 5 votes |
public ColUndoableEdit(AbstractTableModel model, UndoRedoProgress progress, String colName, int colIndex, Boolean added) { super(model, progress); this.colName = colName; this.colIndex = colIndex; this.added = added; this.values = new Object[model.getRowCount()]; loadValuesFromModel(); }
Example #17
Source File: ColUndoableEdit.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 5 votes |
public ColUndoableEdit(AbstractTableModel model, UndoRedoProgress progress, int colIndex, Boolean added) { super(model, progress); this.colName = getModel().getColumnName(colIndex); this.colIndex = colIndex; this.added = added; this.values = new Object[model.getRowCount()]; loadValuesFromModel(); }
Example #18
Source File: RowUndoableEdit.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 5 votes |
public RowUndoableEdit(AbstractTableModel model, UndoRedoProgress progress, int row, Boolean added) { super(model, progress); this.row = row; this.values = new Object[getModel().getColumnCount()]; for (int i = 0; i < values.length; i++) { values[i] = getModel().getValueAt(row, i); } this.added = added; }
Example #19
Source File: RowUndoableEdit.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 5 votes |
public RowUndoableEdit(AbstractTableModel model, UndoRedoProgress progress, int row, Object[] values, Boolean added) { super(model, progress); this.row = row; this.values = values; this.added = added; }
Example #20
Source File: CellUndoableEdit.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 5 votes |
public CellUndoableEdit(AbstractTableModel model, UndoRedoProgress progress, int row, int column, Object oldValue, Object newValue) { super(model, progress); this.row = row; this.column = column; this.oldValue = oldValue; this.newValue = newValue; }
Example #21
Source File: GanttProjectBase.java From ganttproject with GNU General Public License v3.0 | 5 votes |
@Override public void optionsChanged() { myTreeView.getTreeTable().setRowHeight(myChartModel.calculateRowHeight()); AbstractTableModel model = (AbstractTableModel) myTreeView.getTreeTable().getModel(); model.fireTableStructureChanged(); myTreeView.updateUI(); }
Example #22
Source File: AbstractTableModelAsAbstractColumnTableModelWrapper.java From zap-extensions with Apache License 2.0 | 5 votes |
public AbstractTableModelAsAbstractColumnTableModelWrapper( AbstractTableModel abstractTableModel, List<Column<T>> columns) { super(); this.abstractTableModel = abstractTableModel; this.columns = new ArrayList<>(columns); this.models = new ArrayList<>(); }
Example #23
Source File: DrawGridLInesTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static void checkTableGridLines() { TableModel dataModel = new AbstractTableModel() { public int getColumnCount() { return 10; } public int getRowCount() { return 10; } public Object getValueAt(int row, int col) { return " "; } }; DefaultTableCellRenderer r = new DefaultTableCellRenderer(); r.setOpaque(true); r.setBackground(CELL_RENDERER_BACKGROUND_COLOR); JTable table = new JTable(dataModel); table.setSize(WIDTH, HEIGHT); table.setDefaultRenderer(Object.class, r); table.setGridColor(GRID_COLOR); table.setShowGrid(true); table.setShowHorizontalLines(true); table.setShowVerticalLines(true); table.setBackground(TABLE_BACKGROUND_COLOR); checkTableGridLines(table); }
Example #24
Source File: ContinuousLoadPanel.java From openAGV with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private void locationsComboBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_locationsComboBoxItemStateChanged operationTypesComboBox.removeAllItems(); if (locationsComboBox.getSelectedItem() == null) { return; } TCSObjectReference<Location> loc = (TCSObjectReference<Location>) locationsComboBox.getSelectedItem(); Location location = objectService.fetchObject(Location.class, loc); TCSObjectReference<LocationType> locationRef = location.getType(); LocationType locationType = objectService.fetchObject(LocationType.class, locationRef); Set<String> operationTypes = new TreeSet<>(locationType.getAllowedOperations()); for (String j : operationTypes) { operationTypesComboBox.addItem(j); } // When selecting an item in the locationsComboBox we have // to update the vehicle operation in the DriveOrderTable manually, // otherwise the old value will persist and that could be a value // the new location doesn't support int selectedRow = doTable.getSelectedRow(); if (selectedRow >= 0) { DriveOrderTableModel model = (DriveOrderTableModel) doTable.getModel(); DriveOrderStructure dos = model.getDataAt(selectedRow); if (dos != null) { if (!operationTypes.isEmpty()) { dos.setDriveOrderVehicleOperation(operationTypes.iterator().next()); } else { dos.setDriveOrderVehicleOperation(null); } } ((AbstractTableModel) doTable.getModel()).fireTableDataChanged(); } }
Example #25
Source File: ExampleSourceConfigurationWizardDataTable.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
public void update() { ((AbstractTableModel) getModel()).fireTableStructureChanged(); TableColumnModel columnModel = getColumnModel(); for (int i = 0; i < columnModel.getColumnCount(); i++) { TableColumn tableColumn = columnModel.getColumn(i); tableColumn.setPreferredWidth(120); } }
Example #26
Source File: ExampleSourceConfigurationWizardAttributeTypeTable.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
public void update() { ((AbstractTableModel) getModel()).fireTableStructureChanged(); TableColumnModel columnModel = getColumnModel(); for (int i = 0; i < columnModel.getColumnCount(); i++) { TableColumn tableColumn = columnModel.getColumn(i); tableColumn.setPreferredWidth(120); } }
Example #27
Source File: ExampleSourceConfigurationWizardValueTypeTable.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
public void update() { ((AbstractTableModel) getModel()).fireTableStructureChanged(); TableColumnModel columnModel = getColumnModel(); for (int i = 0; i < columnModel.getColumnCount(); i++) { TableColumn tableColumn = columnModel.getColumn(i); tableColumn.setPreferredWidth(120); } }
Example #28
Source File: VulcanTab.java From FoxTelem with GNU General Public License v3.0 | 5 votes |
protected void addTables(AbstractTableModel radTableModel, AbstractTableModel radPacketTableModel) { super.addTables(radTableModel, radPacketTableModel); TableColumn column = null; column = table.getColumnModel().getColumn(0); column.setPreferredWidth(45); column = table.getColumnModel().getColumn(1); column.setPreferredWidth(55); for (int i=0; i<58; i++) { column = table.getColumnModel().getColumn(i+2); column.setPreferredWidth(25); } column = packetTable.getColumnModel().getColumn(0); column.setPreferredWidth(45); column = packetTable.getColumnModel().getColumn(1); column.setPreferredWidth(55); column = packetTable.getColumnModel().getColumn(2); column.setPreferredWidth(80); column = packetTable.getColumnModel().getColumn(3); column.setPreferredWidth(70); column = packetTable.getColumnModel().getColumn(4); column.setPreferredWidth(600); }
Example #29
Source File: ColUndoableEdit.java From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 | 5 votes |
public ColUndoableEdit(AbstractTableModel model, UndoRedoProgress progress, String colName, Boolean added) { super(model, progress); this.colName = colName; this.colIndex = getModel().findColumn(colName); this.added = added; this.values = new Object[model.getRowCount()]; loadValuesFromModel(); }
Example #30
Source File: EnumTableFormatAdaptor.java From jeveassets with GNU General Public License v2.0 | 4 votes |
public JMenu getMenu(final Program program, final AbstractTableModel tableModel, final JAutoColumnTable jTable, final String name, final boolean editable) { JMenu jMenu; JMenuItem jMenuItem; jMenu = new JMenu(GuiShared.get().tableSettings()); jMenu.setIcon(Images.TABLE_COLUMN_SHOW.getIcon()); if (editable) { if (editColumns == null) { //Create dialog (only once) editColumns = new EditColumnsDialog<T, Q>(program, this); } if (viewSave == null) { //Create dialog (only once) viewSave = new ViewSave(program); } if (viewManager == null) { //Create dialog (only once) viewManager = new ViewManager(program, this, tableModel, jTable); } jMenuItem = new JMenuItem(GuiShared.get().tableColumns(), Images.DIALOG_SETTINGS.getIcon()); jMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { editColumns.setVisible(true); tableModel.fireTableStructureChanged(); jTable.autoResizeColumns(); } }); jMenu.add(jMenuItem); jMenu.addSeparator(); jMenuItem = new JMenuItem(GuiShared.get().saveView(), Images.FILTER_SAVE.getIcon()); jMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { //Get views... Map<String, View> views = Settings.get().getTableViews(name); viewSave.updateData(new ArrayList<View>(views.values())); //Update views View view = viewSave.show(); if (view != null ) { //Validate view.setColumns(getColumns()); //Set data if (views.containsValue(view)) { //Ovwewrite? int value = JOptionPane.showConfirmDialog(program.getMainWindow().getFrame(), GuiShared.get().overwrite(), GuiShared.get().saveView(), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (value != JOptionPane.OK_OPTION) { return; } } Settings.lock("View (New)"); //Lock for View (New) views.remove(view.getName()); //Remove old views.put(view.getName(), view); //Add new Settings.unlock("View (New)"); //Unlock for View (New) program.saveSettings("View (New)"); //Save View (New) } } }); jMenu.add(jMenuItem); JMenu jLoad = new JMenu(GuiShared.get().loadView()); jLoad.setIcon(Images.FILTER_LOAD.getIcon()); jMenu.add(jLoad); JMenuItem jManage = new JMenuItem(GuiShared.get().editViews(), Images.DIALOG_SETTINGS.getIcon()); jManage.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { Map<String, View> views = Settings.get().getTableViews(name); viewManager.updateData(views); viewManager.setVisible(true); } }); if (!Settings.get().getTableViews(name).isEmpty()) { jLoad.setEnabled(true); jLoad.add(jManage); jLoad.addSeparator(); for (final View view : Settings.get().getTableViews(name).values()) { jMenuItem = new JMenuItem(view.getName(), Images.FILTER_LOAD.getIcon()); jMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { viewManager.loadView(view); } }); jLoad.add(jMenuItem); } } else { jLoad.setEnabled(false); } jMenu.addSeparator(); } jMenuItem = new JMenuItem(GuiShared.get().tableColumnsReset(), Images.TABLE_COLUMN_SHOW.getIcon()); jMenuItem.addActionListener(new ActionListener() {