* try to fix Mac keyEvent issues

This commit is contained in:
Reinhard Pointner 2012-10-28 03:36:36 +00:00
parent c6433e5c81
commit 1372944851
13 changed files with 162 additions and 149 deletions

View File

@ -9,6 +9,7 @@ import static net.sourceforge.tuned.ui.TunedUtilities.*;
import java.awt.Dimension;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.net.URI;
import java.util.Arrays;
import java.util.Collection;
@ -30,11 +31,6 @@ import javax.swing.SwingWorker;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import ca.odell.glazedlists.BasicEventList;
import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.matchers.TextMatcherEditor;
import ca.odell.glazedlists.swing.AutoCompleteSupport;
import net.miginfocom.swing.MigLayout;
import net.sourceforge.filebot.ResourceManager;
import net.sourceforge.filebot.Settings;
@ -43,6 +39,10 @@ import net.sourceforge.filebot.web.SearchResult;
import net.sourceforge.tuned.ExceptionUtilities;
import net.sourceforge.tuned.ListChangeSynchronizer;
import net.sourceforge.tuned.ui.LabelProvider;
import ca.odell.glazedlists.BasicEventList;
import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.matchers.TextMatcherEditor;
import ca.odell.glazedlists.swing.AutoCompleteSupport;
public abstract class AbstractSearchPanel<S, E> extends JComponent {
@ -99,7 +99,7 @@ public abstract class AbstractSearchPanel<S, E> extends JComponent {
AutoCompleteSupport.install(searchTextField.getEditor(), searchHistory).setFilterMode(TextMatcherEditor.CONTAINS);
installAction(this, KeyStroke.getKeyStroke("ENTER"), searchAction);
installAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), searchAction);
}
@ -148,9 +148,9 @@ public abstract class AbstractSearchPanel<S, E> extends JComponent {
return history;
}
private final AbstractAction searchAction = new AbstractAction("Find", ResourceManager.getIcon("action.find")) {
@Override
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand() == null) {
// command triggered by auto-completion

View File

@ -4,6 +4,7 @@ package net.sourceforge.filebot.ui;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
@ -48,8 +49,8 @@ public class FileBotList<E> extends JComponent {
// Shortcut DELETE, disabled by default
removeAction.setEnabled(false);
TunedUtilities.installAction(this, KeyStroke.getKeyStroke("pressed DELETE"), removeAction);
TunedUtilities.installAction(this, KeyStroke.getKeyStroke("pressed BACK_SPACE"), removeAction);
TunedUtilities.installAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), removeAction);
TunedUtilities.installAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), removeAction);
}
@ -126,6 +127,7 @@ public class FileBotList<E> extends JComponent {
private final AbstractAction removeAction = new AbstractAction("Remove") {
@Override
public void actionPerformed(ActionEvent e) {
int index = list.getSelectedIndex();
Object values[] = list.getSelectedValues();

View File

@ -8,6 +8,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -53,8 +54,8 @@ public class SelectButtonTextField<T> extends JComponent {
editor.setRenderer(new CompletionCellRenderer());
editor.setUI(new TextFieldComboBoxUI());
TunedUtilities.installAction(this, KeyStroke.getKeyStroke("ctrl UP"), new SpinClientAction(-1));
TunedUtilities.installAction(this, KeyStroke.getKeyStroke("ctrl DOWN"), new SpinClientAction(1));
TunedUtilities.installAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.CTRL_MASK), new SpinClientAction(-1));
TunedUtilities.installAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.CTRL_MASK), new SpinClientAction(1));
}
@ -74,6 +75,7 @@ public class SelectButtonTextField<T> extends JComponent {
private final ActionListener textFieldFocusOnClick = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
getEditor().requestFocus();
}
@ -92,6 +94,7 @@ public class SelectButtonTextField<T> extends JComponent {
}
@Override
public void actionPerformed(ActionEvent e) {
selectButton.spinValue(spin);
}

View File

@ -7,6 +7,7 @@ import static net.sourceforge.tuned.ui.TunedUtilities.*;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Collection;
@ -77,7 +78,7 @@ public class SelectDialog<T> extends JDialog {
setSize(new Dimension(210, 210));
// Shortcut Enter
TunedUtilities.installAction(list, KeyStroke.getKeyStroke("ENTER"), selectAction);
TunedUtilities.installAction(list, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), selectAction);
}
@ -115,9 +116,9 @@ public class SelectDialog<T> extends JDialog {
return cancelAction;
}
private final Action selectAction = new AbstractAction("Select", ResourceManager.getIcon("dialog.continue")) {
@Override
public void actionPerformed(ActionEvent e) {
valueSelected = true;
close();
@ -126,6 +127,7 @@ public class SelectDialog<T> extends JDialog {
private final Action cancelAction = new AbstractAction("Cancel", ResourceManager.getIcon("dialog.cancel")) {
@Override
public void actionPerformed(ActionEvent e) {
valueSelected = false;
close();

View File

@ -5,6 +5,7 @@ package net.sourceforge.filebot.ui.analyze;
import static net.sourceforge.filebot.ui.transfer.BackgroundFileTransferablePolicy.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@ -54,6 +55,7 @@ class FileTreePanel extends JComponent {
// update tree when loading is finished
transferablePolicy.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (LOADING_PROPERTY.equals(evt.getPropertyName()) && !(Boolean) evt.getNewValue()) {
fireFileTreeChange();
@ -62,8 +64,8 @@ class FileTreePanel extends JComponent {
});
// Shortcut DELETE
TunedUtilities.installAction(fileTree, KeyStroke.getKeyStroke("DELETE"), removeAction);
TunedUtilities.installAction(fileTree, KeyStroke.getKeyStroke("BACK_SPACE"), removeAction);
TunedUtilities.installAction(fileTree, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), removeAction);
TunedUtilities.installAction(fileTree, KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), removeAction);
}
@ -76,11 +78,11 @@ class FileTreePanel extends JComponent {
return transferablePolicy;
}
private final LoadAction loadAction = new LoadAction(transferablePolicy);
private final AbstractAction clearAction = new AbstractAction("Clear", ResourceManager.getIcon("action.clear")) {
@Override
public void actionPerformed(ActionEvent e) {
transferablePolicy.reset();
fileTree.clear();
@ -90,6 +92,7 @@ class FileTreePanel extends JComponent {
private final AbstractAction removeAction = new AbstractAction("Remove") {
@Override
public void actionPerformed(ActionEvent e) {
if (fileTree.getSelectionCount() < 1)
return;

View File

@ -9,6 +9,7 @@ import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
@ -81,8 +82,8 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
searchTextField.getSelectButton().addPropertyChangeListener(SelectButton.SELECTED_VALUE, selectButtonListener);
TunedUtilities.installAction(this, KeyStroke.getKeyStroke("shift UP"), new SpinSeasonAction(1));
TunedUtilities.installAction(this, KeyStroke.getKeyStroke("shift DOWN"), new SpinSeasonAction(-1));
TunedUtilities.installAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.SHIFT_MASK), new SpinSeasonAction(1));
TunedUtilities.installAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.SHIFT_MASK), new SpinSeasonAction(-1));
}
@ -115,9 +116,9 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
return new EpisodeListRequestProcessor(new EpisodeListRequest(provider, text, season, order, language));
};
private final PropertyChangeListener selectButtonListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
EpisodeListProvider provider = searchTextField.getSelectButton().getSelectedValue();
@ -139,6 +140,7 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
}
@Override
public void actionPerformed(ActionEvent e) {
seasonSpinnerModel.spin((Integer) getValue("spin"));
}

View File

@ -9,6 +9,7 @@ import static net.sourceforge.filebot.ui.NotificationLogging.*;
import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Collection;
@ -84,12 +85,13 @@ public class ListPanel extends JComponent {
list.add(buttonPanel, BorderLayout.SOUTH);
TunedUtilities.installAction(this, KeyStroke.getKeyStroke("ENTER"), createAction);
TunedUtilities.installAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), createAction);
}
private AbstractAction createAction = new AbstractAction("Create") {
@Override
public void actionPerformed(ActionEvent evt) {
// clear selection

View File

@ -14,6 +14,7 @@ import java.awt.Desktop;
import java.awt.Font;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent;
@ -100,8 +101,7 @@ class FormatDialog extends JDialog {
public enum Mode {
Episode,
Movie;
Episode, Movie;
public Mode next() {
if (ordinal() < values().length - 1)
@ -200,7 +200,7 @@ class FormatDialog extends JDialog {
});
// install editor suggestions popup
TunedUtilities.installAction(editor, KeyStroke.getKeyStroke("pressed DOWN"), displayRecentFormatHistory);
TunedUtilities.installAction(editor, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), displayRecentFormatHistory);
// episode mode by default
setMode(Mode.Episode);
@ -539,7 +539,6 @@ class FormatDialog extends JDialog {
dispose();
}
protected final Action changeSampleAction = new AbstractAction("Change Sample", ResourceManager.getIcon("action.variable")) {
@Override

View File

@ -12,6 +12,7 @@ import java.awt.Component;
import java.awt.Dimension;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.io.File;
import java.util.AbstractList;
import java.util.ArrayList;
@ -93,7 +94,7 @@ class ValidateDialog extends JDialog {
content.add(new JButton(continueAction), "gap related");
content.add(new JButton(cancelAction), "gap 12mm");
installAction(content, KeyStroke.getKeyStroke("ESCAPE"), cancelAction);
installAction(content, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), cancelAction);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setMinimumSize(new Dimension(365, 280));
@ -118,7 +119,6 @@ class ValidateDialog extends JDialog {
dispose();
}
private final Action validateAction = new AbstractAction("Validate", ResourceManager.getIcon("dialog.continue")) {
@Override

View File

@ -7,6 +7,7 @@ import static net.sourceforge.filebot.ui.sfv.ChecksumTableModel.*;
import static net.sourceforge.filebot.ui.transfer.BackgroundFileTransferablePolicy.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
@ -90,8 +91,8 @@ public class SfvPanel extends JComponent {
putClientProperty("transferablePolicy", transferablePolicy);
// Shortcut DELETE
TunedUtilities.installAction(this, KeyStroke.getKeyStroke("DELETE"), removeAction);
TunedUtilities.installAction(this, KeyStroke.getKeyStroke("BACK_SPACE"), removeAction);
TunedUtilities.installAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), removeAction);
TunedUtilities.installAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), removeAction);
}
@ -128,13 +129,13 @@ public class SfvPanel extends JComponent {
}
}
private final SaveAction saveAction = new ChecksumTableSaveAction();
private final LoadAction loadAction = new LoadAction(transferablePolicy);
private final AbstractAction clearAction = new AbstractAction("Clear", ResourceManager.getIcon("action.clear")) {
@Override
public void actionPerformed(ActionEvent e) {
transferablePolicy.reset();
computationService.reset();
@ -145,6 +146,7 @@ public class SfvPanel extends JComponent {
private final AbstractAction removeAction = new AbstractAction("Remove") {
@Override
public void actionPerformed(ActionEvent e) {
if (table.getSelectedRowCount() < 1)
return;

View File

@ -9,6 +9,7 @@ import static net.sourceforge.tuned.FileUtilities.*;
import static net.sourceforge.tuned.ui.TunedUtilities.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
@ -38,6 +39,16 @@ import javax.swing.ListModel;
import javax.swing.SwingUtilities;
import javax.swing.border.LineBorder;
import net.miginfocom.swing.MigLayout;
import net.sourceforge.filebot.Analytics;
import net.sourceforge.filebot.ResourceManager;
import net.sourceforge.filebot.subtitle.SubtitleFormat;
import net.sourceforge.filebot.ui.subtitle.SubtitlePackage.Download.Phase;
import net.sourceforge.filebot.ui.transfer.DefaultTransferHandler;
import net.sourceforge.filebot.vfs.MemoryFile;
import net.sourceforge.tuned.ExceptionUtilities;
import net.sourceforge.tuned.ui.ListView;
import net.sourceforge.tuned.ui.TunedUtilities;
import ca.odell.glazedlists.BasicEventList;
import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.FilterList;
@ -51,17 +62,6 @@ import ca.odell.glazedlists.swing.EventListModel;
import ca.odell.glazedlists.swing.EventSelectionModel;
import ca.odell.glazedlists.swing.TextComponentMatcherEditor;
import net.miginfocom.swing.MigLayout;
import net.sourceforge.filebot.Analytics;
import net.sourceforge.filebot.ResourceManager;
import net.sourceforge.filebot.subtitle.SubtitleFormat;
import net.sourceforge.filebot.ui.subtitle.SubtitlePackage.Download.Phase;
import net.sourceforge.filebot.ui.transfer.DefaultTransferHandler;
import net.sourceforge.filebot.vfs.MemoryFile;
import net.sourceforge.tuned.ExceptionUtilities;
import net.sourceforge.tuned.ui.ListView;
import net.sourceforge.tuned.ui.TunedUtilities;
class SubtitleDownloadComponent extends JComponent {
@ -133,7 +133,7 @@ class SubtitleDownloadComponent extends JComponent {
add(scrollPane, "newline, hmin max(80px, 30%)");
// install fetch action
TunedUtilities.installAction(packageList, KeyStroke.getKeyStroke("ENTER"), new AbstractAction("Fetch") {
TunedUtilities.installAction(packageList, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), new AbstractAction("Fetch") {
@Override
public void actionPerformed(ActionEvent e) {
@ -142,7 +142,7 @@ class SubtitleDownloadComponent extends JComponent {
});
// install open action
TunedUtilities.installAction(fileList, KeyStroke.getKeyStroke("ENTER"), new AbstractAction("Open") {
TunedUtilities.installAction(fileList, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), new AbstractAction("Open") {
@Override
public void actionPerformed(ActionEvent e) {
@ -365,7 +365,6 @@ class SubtitleDownloadComponent extends JComponent {
}
}
private final Action clearFilterAction = new AbstractAction(null, ResourceManager.getIcon("edit.clear")) {
@Override

View File

@ -141,7 +141,7 @@ public class SubtitleViewer extends JFrame {
});
// focus around selected time stamp
installAction(table, KeyStroke.getKeyStroke("ENTER"), new AbstractAction("focus") {
installAction(table, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), new AbstractAction("focus") {
@Override
public void actionPerformed(ActionEvent e) {
@ -245,7 +245,6 @@ public class SubtitleViewer extends JFrame {
return infoLabel;
}
private final Action clearFilterAction = new AbstractAction(null, ResourceManager.getIcon("edit.clear")) {
@Override

View File

@ -16,6 +16,7 @@ import java.awt.Window;
import java.awt.dnd.DnDConstants;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.lang.reflect.InvocationTargetException;
@ -115,7 +116,7 @@ public final class TunedUtilities {
component.getDocument().addUndoableEditListener(undoSupport);
// install undo action
installAction(component, KeyStroke.getKeyStroke("control Z"), new AbstractAction("Undo") {
installAction(component, KeyStroke.getKeyStroke(KeyEvent.VK_Z, KeyEvent.CTRL_MASK), new AbstractAction("Undo") {
@Override
public void actionPerformed(ActionEvent e) {
@ -125,7 +126,7 @@ public final class TunedUtilities {
});
// install redo action
installAction(component, KeyStroke.getKeyStroke("control Y"), new AbstractAction("Redo") {
installAction(component, KeyStroke.getKeyStroke(KeyEvent.VK_Y, KeyEvent.CTRL_MASK), new AbstractAction("Redo") {
@Override
public void actionPerformed(ActionEvent e) {
@ -255,8 +256,7 @@ public final class TunedUtilities {
/**
* When trying to drag a row of a multi-select JTable, it will start selecting rows instead
* of initiating a drag. This TableUI will give the JTable proper dnd behaviour.
* When trying to drag a row of a multi-select JTable, it will start selecting rows instead of initiating a drag. This TableUI will give the JTable proper dnd behaviour.
*/
public static class DragDropRowTableUI extends BasicTableUI {