* show recent formats via right-click as well as DOWN as a work-around for Mac
This commit is contained in:
parent
1372944851
commit
b6fd00cae6
|
@ -54,6 +54,8 @@ import javax.swing.KeyStroke;
|
||||||
import javax.swing.SwingWorker;
|
import javax.swing.SwingWorker;
|
||||||
import javax.swing.Timer;
|
import javax.swing.Timer;
|
||||||
import javax.swing.event.DocumentEvent;
|
import javax.swing.event.DocumentEvent;
|
||||||
|
import javax.swing.event.PopupMenuEvent;
|
||||||
|
import javax.swing.event.PopupMenuListener;
|
||||||
import javax.swing.text.JTextComponent;
|
import javax.swing.text.JTextComponent;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
@ -200,7 +202,15 @@ class FormatDialog extends JDialog {
|
||||||
});
|
});
|
||||||
|
|
||||||
// install editor suggestions popup
|
// install editor suggestions popup
|
||||||
TunedUtilities.installAction(editor, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), displayRecentFormatHistory);
|
editor.setComponentPopupMenu(createRecentFormatPopup());
|
||||||
|
TunedUtilities.installAction(editor, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), new AbstractAction("Recent") {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
// display popup below format editor
|
||||||
|
editor.getComponentPopupMenu().show(editor, 0, editor.getHeight() + 3);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// episode mode by default
|
// episode mode by default
|
||||||
setMode(Mode.Episode);
|
setMode(Mode.Episode);
|
||||||
|
@ -539,6 +549,43 @@ class FormatDialog extends JDialog {
|
||||||
dispose();
|
dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private JPopupMenu createRecentFormatPopup() {
|
||||||
|
JPopupMenu popup = new JPopupMenu();
|
||||||
|
popup.addPopupMenuListener(new PopupMenuListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void popupMenuWillBecomeVisible(PopupMenuEvent evt) {
|
||||||
|
JPopupMenu popup = (JPopupMenu) evt.getSource();
|
||||||
|
for (final String expression : mode.persistentFormatHistory()) {
|
||||||
|
JMenuItem item = popup.add(new AbstractAction(expression) {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
editor.setText(expression);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
item.setFont(new Font(MONOSPACED, PLAIN, 11));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void popupMenuWillBecomeInvisible(PopupMenuEvent evt) {
|
||||||
|
JPopupMenu popup = (JPopupMenu) evt.getSource();
|
||||||
|
popup.removeAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void popupMenuCanceled(PopupMenuEvent evt) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return popup;
|
||||||
|
}
|
||||||
|
|
||||||
protected final Action changeSampleAction = new AbstractAction("Change Sample", ResourceManager.getIcon("action.variable")) {
|
protected final Action changeSampleAction = new AbstractAction("Change Sample", ResourceManager.getIcon("action.variable")) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -569,29 +616,6 @@ class FormatDialog extends JDialog {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected final Action displayRecentFormatHistory = new AbstractAction("Recent") {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
JPopupMenu popup = new JPopupMenu();
|
|
||||||
|
|
||||||
for (final String expression : mode.persistentFormatHistory()) {
|
|
||||||
JMenuItem item = popup.add(new AbstractAction(expression) {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
editor.setText(expression);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
item.setFont(new Font(MONOSPACED, PLAIN, 11));
|
|
||||||
}
|
|
||||||
|
|
||||||
// display popup below format editor
|
|
||||||
popup.show(editor, 0, editor.getHeight() + 3);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
protected final Action cancelAction = new AbstractAction("Cancel", ResourceManager.getIcon("dialog.cancel")) {
|
protected final Action cancelAction = new AbstractAction("Cancel", ResourceManager.getIcon("dialog.cancel")) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue