Action getDocumentAction() {
final Document doc = getDocument();
if (doc != null) {
Action action = new ToggleAction(HideRegionsText, ShowRegionsText) {
protected void onActionPerformed(ActionEvent event) {
EditorMode mode = doc.getEditor().getMode();
if (mode != EditorMode.REGION) {
doc.getEditor().setMode(EditorMode.REGION);
}
else {
// We're out of phase with the ModeManager--
// toggle the mode anyway, but leave properties fixed.
doc.getEditor().setMode(EditorMode.ARROW);
EventQueue.invokeLater(
new Runnable() {
public void run() {
setState(false);
}
}
);
}
}
protected void offActionPerformed(ActionEvent event) {
EditorMode mode = doc.getEditor().getMode();
if (mode == EditorMode.REGION) {
doc.getEditor().setMode(EditorMode.ARROW);
}
else {
// We're out of phase with the ModeManager--