Although Massachusetts elected Edward W. Brooke , an African-American , attorney general in 1962 and senator in 1966 and 1972 , court-ordered desegregation in the 1970s opened an ugly chapter in Boston 's racial history .