1 /*
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
6781 } else if (name.compareTo("tableCellEditor") == 0) {
6782
6783 if (oldValue != null && oldValue instanceof TableCellEditor) {
6784 ((TableCellEditor) oldValue).removeCellEditorListener(this);
6785 }
6786 if (newValue != null && newValue instanceof TableCellEditor) {
6787 ((TableCellEditor) newValue).addCellEditorListener(this);
6788 }
6789 }
6790 }
6791
6792
6793 // Listeners to echo changes to the AccessiblePropertyChange mechanism
6794
6795 /**
6796 * Describes a change in the accessible table model.
6797 */
6798 protected class AccessibleJTableModelChange
6799 implements AccessibleTableModelChange {
6800
6801 protected int type;
6802 protected int firstRow;
6803 protected int lastRow;
6804 protected int firstColumn;
6805 protected int lastColumn;
6806
6807 protected AccessibleJTableModelChange(int type, int firstRow,
6808 int lastRow, int firstColumn,
6809 int lastColumn) {
6810 this.type = type;
6811 this.firstRow = firstRow;
6812 this.lastRow = lastRow;
6813 this.firstColumn = firstColumn;
6814 this.lastColumn = lastColumn;
6815 }
6816
6817 public int getType() {
6818 return type;
6819 }
6820
6821 public int getFirstRow() {
6822 return firstRow;
6823 }
6824
6825 public int getLastRow() {
6826 return lastRow;
6827 }
6828
6829 public int getFirstColumn() {
6830 return firstColumn;
6831 }
6832
6833 public int getLastColumn() {
6834 return lastColumn;
6835 }
6836 }
6837
6838 /**
6839 * Track changes to the table contents
6840 *
6841 * @param e a {@code TableModelEvent} describing the event
6842 */
6843 public void tableChanged(TableModelEvent e) {
6844 firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
6845 null, null);
6846 if (e != null) {
6847 int firstColumn = e.getColumn();
6848 int lastColumn = e.getColumn();
6849 if (firstColumn == TableModelEvent.ALL_COLUMNS) {
6850 firstColumn = 0;
6851 lastColumn = getColumnCount() - 1;
6852 }
|
1 /*
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
6781 } else if (name.compareTo("tableCellEditor") == 0) {
6782
6783 if (oldValue != null && oldValue instanceof TableCellEditor) {
6784 ((TableCellEditor) oldValue).removeCellEditorListener(this);
6785 }
6786 if (newValue != null && newValue instanceof TableCellEditor) {
6787 ((TableCellEditor) newValue).addCellEditorListener(this);
6788 }
6789 }
6790 }
6791
6792
6793 // Listeners to echo changes to the AccessiblePropertyChange mechanism
6794
6795 /**
6796 * Describes a change in the accessible table model.
6797 */
6798 protected class AccessibleJTableModelChange
6799 implements AccessibleTableModelChange {
6800
6801 /** The type */
6802 protected int type;
6803 /** The first row */
6804 protected int firstRow;
6805 /** The last row */
6806 protected int lastRow;
6807 /** The first column */
6808 protected int firstColumn;
6809 /** The last column */
6810 protected int lastColumn;
6811
6812 /**
6813 * Constructs an {@code AccessibleJTableModelChange}.
6814 * @param type the type
6815 * @param firstRow the first row
6816 * @param lastRow the last row
6817 * @param firstColumn the first column
6818 * @param lastColumn the last column
6819 */
6820 protected AccessibleJTableModelChange(int type, int firstRow,
6821 int lastRow, int firstColumn,
6822 int lastColumn) {
6823 this.type = type;
6824 this.firstRow = firstRow;
6825 this.lastRow = lastRow;
6826 this.firstColumn = firstColumn;
6827 this.lastColumn = lastColumn;
6828 }
6829
6830 /**
6831 * Returns the type.
6832 * @return the type
6833 */
6834 public int getType() {
6835 return type;
6836 }
6837
6838 /**
6839 * Returns the first row.
6840 * @return the first row
6841 */
6842 public int getFirstRow() {
6843 return firstRow;
6844 }
6845
6846 /**
6847 * Returns the last row.
6848 * @return the last row
6849 */
6850 public int getLastRow() {
6851 return lastRow;
6852 }
6853
6854 /**
6855 * Returns the first column.
6856 * @return the first column
6857 */
6858 public int getFirstColumn() {
6859 return firstColumn;
6860 }
6861
6862 /**
6863 * Returns the last column.
6864 * @return the last column
6865 */
6866 public int getLastColumn() {
6867 return lastColumn;
6868 }
6869 }
6870
6871 /**
6872 * Track changes to the table contents
6873 *
6874 * @param e a {@code TableModelEvent} describing the event
6875 */
6876 public void tableChanged(TableModelEvent e) {
6877 firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
6878 null, null);
6879 if (e != null) {
6880 int firstColumn = e.getColumn();
6881 int lastColumn = e.getColumn();
6882 if (firstColumn == TableModelEvent.ALL_COLUMNS) {
6883 firstColumn = 0;
6884 lastColumn = getColumnCount() - 1;
6885 }
|