提交 a9993d6f 编写于 作者: A asaha

8036983: JAB:Multiselection Ctrl+CursorUp/Down and ActivateDescenderPropertyChanged event

Reviewed-by: pchelko, alexsch
Contributed-by: vivi.an@oracle.com
上级 4fc36410
......@@ -6588,8 +6588,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
TableColumnModelListener, CellEditorListener, PropertyChangeListener,
AccessibleExtendedTable {
int lastSelectedRow;
int lastSelectedCol;
int previousFocusedRow;
int previousFocusedCol;
/**
* AccessibleJTable constructor
......@@ -6604,8 +6604,10 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
tcm.addColumnModelListener(this);
tcm.getSelectionModel().addListSelectionListener(this);
JTable.this.getModel().addTableModelListener(this);
lastSelectedRow = JTable.this.getSelectedRow();
lastSelectedCol = JTable.this.getSelectedColumn();
previousFocusedRow = JTable.this.getSelectionModel().
getLeadSelectionIndex();
previousFocusedCol = JTable.this.getColumnModel().
getSelectionModel().getLeadSelectionIndex();
}
// Listeners to track model, etc. changes to as to re-place the other
......@@ -6933,17 +6935,20 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
firePropertyChange(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY,
Boolean.valueOf(false), Boolean.valueOf(true));
int selectedRow = JTable.this.getSelectedRow();
int selectedCol = JTable.this.getSelectedColumn();
if (selectedRow != lastSelectedRow ||
selectedCol != lastSelectedCol) {
Accessible oldA = getAccessibleAt(lastSelectedRow,
lastSelectedCol);
Accessible newA = getAccessibleAt(selectedRow, selectedCol);
// Using lead selection index to cover both cases: node selected and node
// is focused but not selected (Ctrl+up/down)
int focusedRow = JTable.this.getSelectionModel().getLeadSelectionIndex();
int focusedCol = JTable.this.getColumnModel().getSelectionModel().
getLeadSelectionIndex();
if (focusedRow != previousFocusedRow ||
focusedCol != previousFocusedCol) {
Accessible oldA = getAccessibleAt(previousFocusedRow, previousFocusedCol);
Accessible newA = getAccessibleAt(focusedRow, focusedCol);
firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
oldA, newA);
lastSelectedRow = selectedRow;
lastSelectedCol = selectedCol;
previousFocusedRow = focusedRow;
previousFocusedCol = focusedCol;
}
}
......
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -1664,6 +1664,11 @@ public class JTree extends JComponent implements Scrollable, Accessible
leadPath = newPath;
firePropertyChange(LEAD_SELECTION_PATH_PROPERTY, oldValue, newPath);
if (accessibleContext != null){
((AccessibleJTree)accessibleContext).
fireActiveDescendantPropertyChange(oldValue, newPath);
}
}
/**
......@@ -4129,23 +4134,6 @@ public class JTree extends JComponent implements Scrollable, Accessible
*
*/
public void valueChanged(TreeSelectionEvent e) {
// Fixes 4546503 - JTree is sending incorrect active
// descendant events
TreePath oldLeadSelectionPath = e.getOldLeadSelectionPath();
leadSelectionPath = e.getNewLeadSelectionPath();
if (oldLeadSelectionPath != leadSelectionPath) {
// Set parent to null so AccessibleJTreeNode computes
// its parent.
Accessible oldLSA = leadSelectionAccessible;
leadSelectionAccessible = (leadSelectionPath != null)
? new AccessibleJTreeNode(JTree.this,
leadSelectionPath,
null) // parent
: null;
firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
oldLSA, leadSelectionAccessible);
}
firePropertyChange(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY,
Boolean.valueOf(false), Boolean.valueOf(true));
}
......@@ -4249,6 +4237,34 @@ public class JTree extends JComponent implements Scrollable, Accessible
}
}
/**
* Fire an active descendant property change notification.
* The active descendant is used for objects such as list,
* tree, and table, which may have transient children.
* It notifies screen readers the active child of the component
* has been changed so user can be notified from there.
*
* @param oldPath - lead path of previous active child
* @param newPath - lead path of current active child
*
*/
void fireActiveDescendantPropertyChange(TreePath oldPath, TreePath newPath){
if(oldPath != newPath){
Accessible oldLSA = (oldPath != null)
? new AccessibleJTreeNode(JTree.this,
oldPath,
null)
: null;
Accessible newLSA = (newPath != null)
? new AccessibleJTreeNode(JTree.this,
newPath,
null)
: null;
firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
oldLSA, newLSA);
}
}
private AccessibleContext getCurrentAccessibleContext() {
Component c = getCurrentComponent();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册