1303 } else {
1304 table.getSelectionModel().removeListSelectionListener(getHandler());
1305 timer = null;
1306 }
1307 } else if ("selectionModel" == changeName) {
1308 if (isFileList) {
1309 ListSelectionModel old = (ListSelectionModel)event.getOldValue();
1310 old.removeListSelectionListener(getHandler());
1311 table.getSelectionModel().addListSelectionListener(getHandler());
1312 }
1313 }
1314 }
1315
1316 private void repaintDropLocation(JTable.DropLocation loc) {
1317 if (loc == null) {
1318 return;
1319 }
1320
1321 if (!loc.isInsertRow() && !loc.isInsertColumn()) {
1322 Rectangle rect = table.getCellRect(loc.getRow(), loc.getColumn(), false);
1323 if (rect != null) {
1324 table.repaint(rect);
1325 }
1326 return;
1327 }
1328
1329 if (loc.isInsertRow()) {
1330 Rectangle rect = extendRect(getHDropLineRect(loc), true);
1331 if (rect != null) {
1332 table.repaint(rect);
1333 }
1334 }
1335
1336 if (loc.isInsertColumn()) {
1337 Rectangle rect = extendRect(getVDropLineRect(loc), false);
1338 if (rect != null) {
1339 table.repaint(rect);
1340 }
1341 }
1342 }
2035 for (int column = cMax; column >= cMin; column--) {
2036 int w = cm.getColumn(column).getWidth();
2037 x += w;
2038 g.drawLine(x - 1, 0, x - 1, tableHeight - 1);
2039 }
2040 }
2041 }
2042 }
2043
2044 private int viewIndexForColumn(TableColumn aColumn) {
2045 TableColumnModel cm = table.getColumnModel();
2046 for (int column = 0; column < cm.getColumnCount(); column++) {
2047 if (cm.getColumn(column) == aColumn) {
2048 return column;
2049 }
2050 }
2051 return -1;
2052 }
2053
2054 private void paintCells(Graphics g, int rMin, int rMax, int cMin, int cMax) {
2055 JTableHeader header = table.getTableHeader();
2056 TableColumn draggedColumn = (header == null) ? null : header.getDraggedColumn();
2057
2058 TableColumnModel cm = table.getColumnModel();
2059 int columnMargin = cm.getColumnMargin();
2060
2061 Rectangle cellRect;
2062 TableColumn aColumn;
2063 int columnWidth;
2064 if (table.getComponentOrientation().isLeftToRight()) {
2065 for(int row = rMin; row <= rMax; row++) {
2066 cellRect = table.getCellRect(row, cMin, false);
2067 for(int column = cMin; column <= cMax; column++) {
2068 aColumn = cm.getColumn(column);
2069 columnWidth = aColumn.getWidth();
2070 cellRect.width = columnWidth - columnMargin;
2071 if (aColumn != draggedColumn) {
2072 paintCell(g, cellRect, row, column);
2073 }
2074 cellRect.x += columnWidth;
2075 }
2076 }
2077 } else {
2078 for(int row = rMin; row <= rMax; row++) {
2079 cellRect = table.getCellRect(row, cMin, false);
2080 aColumn = cm.getColumn(cMin);
2081 if (aColumn != draggedColumn) {
2082 columnWidth = aColumn.getWidth();
2083 cellRect.width = columnWidth - columnMargin;
2084 paintCell(g, cellRect, row, cMin);
2085 }
2086 for(int column = cMin+1; column <= cMax; column++) {
2087 aColumn = cm.getColumn(column);
2088 columnWidth = aColumn.getWidth();
2089 cellRect.width = columnWidth - columnMargin;
2090 cellRect.x -= columnWidth;
|
1303 } else {
1304 table.getSelectionModel().removeListSelectionListener(getHandler());
1305 timer = null;
1306 }
1307 } else if ("selectionModel" == changeName) {
1308 if (isFileList) {
1309 ListSelectionModel old = (ListSelectionModel)event.getOldValue();
1310 old.removeListSelectionListener(getHandler());
1311 table.getSelectionModel().addListSelectionListener(getHandler());
1312 }
1313 }
1314 }
1315
1316 private void repaintDropLocation(JTable.DropLocation loc) {
1317 if (loc == null) {
1318 return;
1319 }
1320
1321 if (!loc.isInsertRow() && !loc.isInsertColumn()) {
1322 Rectangle rect = table.getCellRect(loc.getRow(), loc.getColumn(), false);
1323 if(table.getClientProperty("Table.showWholeRowAsDropTarget") == Boolean.TRUE) {
1324 // used by WindowsFileChooserUI in Details view
1325
1326 rect.x = 0;
1327 rect.width = table.getWidth();
1328 }
1329 if (rect != null) {
1330 table.repaint(rect);
1331 }
1332 return;
1333 }
1334
1335 if (loc.isInsertRow()) {
1336 Rectangle rect = extendRect(getHDropLineRect(loc), true);
1337 if (rect != null) {
1338 table.repaint(rect);
1339 }
1340 }
1341
1342 if (loc.isInsertColumn()) {
1343 Rectangle rect = extendRect(getVDropLineRect(loc), false);
1344 if (rect != null) {
1345 table.repaint(rect);
1346 }
1347 }
1348 }
2041 for (int column = cMax; column >= cMin; column--) {
2042 int w = cm.getColumn(column).getWidth();
2043 x += w;
2044 g.drawLine(x - 1, 0, x - 1, tableHeight - 1);
2045 }
2046 }
2047 }
2048 }
2049
2050 private int viewIndexForColumn(TableColumn aColumn) {
2051 TableColumnModel cm = table.getColumnModel();
2052 for (int column = 0; column < cm.getColumnCount(); column++) {
2053 if (cm.getColumn(column) == aColumn) {
2054 return column;
2055 }
2056 }
2057 return -1;
2058 }
2059
2060 private void paintCells(Graphics g, int rMin, int rMax, int cMin, int cMax) {
2061 boolean cellWidthHack = table.getClientProperty(
2062 "BasicTableUI.cellWidthHack") == Boolean.TRUE;
2063 // used by WindowsFileTableUI to remove borders between cells event when a row is selected
2064
2065 JTableHeader header = table.getTableHeader();
2066 TableColumn draggedColumn = (header == null) ? null : header.getDraggedColumn();
2067
2068 TableColumnModel cm = table.getColumnModel();
2069 int columnMargin = cm.getColumnMargin();
2070
2071 Rectangle cellRect;
2072 TableColumn aColumn;
2073 int columnWidth;
2074 if (table.getComponentOrientation().isLeftToRight()) {
2075 for(int row = rMin; row <= rMax; row++) {
2076 cellRect = table.getCellRect(row, cMin, false);
2077 for(int column = cMin; column <= cMax; column++) {
2078 aColumn = cm.getColumn(column);
2079 columnWidth = aColumn.getWidth();
2080 cellRect.width = columnWidth - columnMargin;
2081 if(cellWidthHack)
2082 cellRect.width += 1;
2083 if (aColumn != draggedColumn) {
2084 paintCell(g, cellRect, row, column);
2085 }
2086 cellRect.x += columnWidth;
2087 }
2088 }
2089 } else {
2090 for(int row = rMin; row <= rMax; row++) {
2091 cellRect = table.getCellRect(row, cMin, false);
2092 aColumn = cm.getColumn(cMin);
2093 if (aColumn != draggedColumn) {
2094 columnWidth = aColumn.getWidth();
2095 cellRect.width = columnWidth - columnMargin;
2096 paintCell(g, cellRect, row, cMin);
2097 }
2098 for(int column = cMin+1; column <= cMax; column++) {
2099 aColumn = cm.getColumn(column);
2100 columnWidth = aColumn.getWidth();
2101 cellRect.width = columnWidth - columnMargin;
2102 cellRect.x -= columnWidth;
|