* 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.Dimension;
import java.awt.Window; import java.awt.Window;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.net.URI; import java.net.URI;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@ -30,11 +31,6 @@ import javax.swing.SwingWorker;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; 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.miginfocom.swing.MigLayout;
import net.sourceforge.filebot.ResourceManager; import net.sourceforge.filebot.ResourceManager;
import net.sourceforge.filebot.Settings; import net.sourceforge.filebot.Settings;
@ -43,6 +39,10 @@ import net.sourceforge.filebot.web.SearchResult;
import net.sourceforge.tuned.ExceptionUtilities; import net.sourceforge.tuned.ExceptionUtilities;
import net.sourceforge.tuned.ListChangeSynchronizer; import net.sourceforge.tuned.ListChangeSynchronizer;
import net.sourceforge.tuned.ui.LabelProvider; 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 { public abstract class AbstractSearchPanel<S, E> extends JComponent {
@ -57,7 +57,7 @@ public abstract class AbstractSearchPanel<S, E> extends JComponent {
protected final EventList<String> searchHistory = createSearchHistory(); protected final EventList<String> searchHistory = createSearchHistory();
public AbstractSearchPanel() { public AbstractSearchPanel() {
historyPanel.setColumnHeader(2, "Duration"); historyPanel.setColumnHeader(2, "Duration");
@ -99,22 +99,22 @@ public abstract class AbstractSearchPanel<S, E> extends JComponent {
AutoCompleteSupport.install(searchTextField.getEditor(), searchHistory).setFilterMode(TextMatcherEditor.CONTAINS); AutoCompleteSupport.install(searchTextField.getEditor(), searchHistory).setFilterMode(TextMatcherEditor.CONTAINS);
installAction(this, KeyStroke.getKeyStroke("ENTER"), searchAction); installAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), searchAction);
} }
protected abstract S[] getSearchEngines(); protected abstract S[] getSearchEngines();
protected abstract LabelProvider<S> getSearchEngineLabelProvider(); protected abstract LabelProvider<S> getSearchEngineLabelProvider();
protected abstract Settings getSettings(); protected abstract Settings getSettings();
protected abstract RequestProcessor<?, E> createRequestProcessor(); protected abstract RequestProcessor<?, E> createRequestProcessor();
private void search(RequestProcessor<?, E> requestProcessor) { private void search(RequestProcessor<?, E> requestProcessor) {
FileBotTab<?> tab = requestProcessor.tab; FileBotTab<?> tab = requestProcessor.tab;
@ -130,7 +130,7 @@ public abstract class AbstractSearchPanel<S, E> extends JComponent {
new SearchTask(requestProcessor).execute(); new SearchTask(requestProcessor).execute();
} }
protected EventList<String> createSearchHistory() { protected EventList<String> createSearchHistory() {
// create in-memory history // create in-memory history
BasicEventList<String> history = new BasicEventList<String>(); BasicEventList<String> history = new BasicEventList<String>();
@ -148,9 +148,9 @@ public abstract class AbstractSearchPanel<S, E> extends JComponent {
return history; return history;
} }
private final AbstractAction searchAction = new AbstractAction("Find", ResourceManager.getIcon("action.find")) { private final AbstractAction searchAction = new AbstractAction("Find", ResourceManager.getIcon("action.find")) {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (e.getActionCommand() == null) { if (e.getActionCommand() == null) {
// command triggered by auto-completion // command triggered by auto-completion
@ -161,17 +161,17 @@ public abstract class AbstractSearchPanel<S, E> extends JComponent {
} }
}; };
private class SearchTask extends SwingWorker<Collection<? extends SearchResult>, Void> { private class SearchTask extends SwingWorker<Collection<? extends SearchResult>, Void> {
private final RequestProcessor<?, E> requestProcessor; private final RequestProcessor<?, E> requestProcessor;
public SearchTask(RequestProcessor<?, E> requestProcessor) { public SearchTask(RequestProcessor<?, E> requestProcessor) {
this.requestProcessor = requestProcessor; this.requestProcessor = requestProcessor;
} }
@Override @Override
protected Collection<? extends SearchResult> doInBackground() throws Exception { protected Collection<? extends SearchResult> doInBackground() throws Exception {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
@ -183,7 +183,7 @@ public abstract class AbstractSearchPanel<S, E> extends JComponent {
} }
} }
@Override @Override
public void done() { public void done() {
FileBotTab<?> tab = requestProcessor.tab; FileBotTab<?> tab = requestProcessor.tab;
@ -235,17 +235,17 @@ public abstract class AbstractSearchPanel<S, E> extends JComponent {
} }
} }
private class FetchTask extends SwingWorker<Collection<E>, Void> { private class FetchTask extends SwingWorker<Collection<E>, Void> {
private final RequestProcessor<?, E> requestProcessor; private final RequestProcessor<?, E> requestProcessor;
public FetchTask(RequestProcessor<?, E> requestProcessor) { public FetchTask(RequestProcessor<?, E> requestProcessor) {
this.requestProcessor = requestProcessor; this.requestProcessor = requestProcessor;
} }
@Override @Override
protected final Collection<E> doInBackground() throws Exception { protected final Collection<E> doInBackground() throws Exception {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
@ -257,7 +257,7 @@ public abstract class AbstractSearchPanel<S, E> extends JComponent {
} }
} }
@Override @Override
public void done() { public void done() {
FileBotTab<?> tab = requestProcessor.tab; FileBotTab<?> tab = requestProcessor.tab;
@ -291,24 +291,24 @@ public abstract class AbstractSearchPanel<S, E> extends JComponent {
} }
} }
protected static class Request { protected static class Request {
private final String searchText; private final String searchText;
public Request(String searchText) { public Request(String searchText) {
this.searchText = searchText; this.searchText = searchText;
} }
public String getSearchText() { public String getSearchText() {
return searchText; return searchText;
} }
} }
protected abstract static class RequestProcessor<R extends Request, E> { protected abstract static class RequestProcessor<R extends Request, E> {
protected final R request; protected final R request;
@ -319,45 +319,45 @@ public abstract class AbstractSearchPanel<S, E> extends JComponent {
private long duration = 0; private long duration = 0;
public RequestProcessor(R request, JComponent component) { public RequestProcessor(R request, JComponent component) {
this.request = request; this.request = request;
this.tab = new FileBotTab<JComponent>(component); this.tab = new FileBotTab<JComponent>(component);
} }
public abstract Collection<? extends SearchResult> search() throws Exception; public abstract Collection<? extends SearchResult> search() throws Exception;
public abstract Collection<E> fetch() throws Exception; public abstract Collection<E> fetch() throws Exception;
public abstract void process(Collection<E> elements); public abstract void process(Collection<E> elements);
public abstract URI getLink(); public abstract URI getLink();
public JComponent getComponent() { public JComponent getComponent() {
return tab.getComponent(); return tab.getComponent();
} }
public SearchResult getSearchResult() { public SearchResult getSearchResult() {
return searchResult; return searchResult;
} }
public void setSearchResult(SearchResult searchResult) { public void setSearchResult(SearchResult searchResult) {
this.searchResult = searchResult; this.searchResult = searchResult;
} }
public String getStatusMessage(Collection<E> result) { public String getStatusMessage(Collection<E> result) {
return String.format("%d elements found", result.size()); return String.format("%d elements found", result.size());
} }
public String getTitle() { public String getTitle() {
if (searchResult != null) if (searchResult != null)
return searchResult.getName(); return searchResult.getName();
@ -365,7 +365,7 @@ public abstract class AbstractSearchPanel<S, E> extends JComponent {
return request.getSearchText(); return request.getSearchText();
} }
public String getHistoryEntry() { public String getHistoryEntry() {
SeriesNameMatcher nameMatcher = new SeriesNameMatcher(); SeriesNameMatcher nameMatcher = new SeriesNameMatcher();
@ -374,12 +374,12 @@ public abstract class AbstractSearchPanel<S, E> extends JComponent {
return nameMatcher.matchByFirstCommonWordSequence(searchResult.getName(), request.getSearchText()); return nameMatcher.matchByFirstCommonWordSequence(searchResult.getName(), request.getSearchText());
} }
public Icon getIcon() { public Icon getIcon() {
return null; return null;
} }
protected SearchResult selectSearchResult(Collection<? extends SearchResult> searchResults, Window window) throws Exception { protected SearchResult selectSearchResult(Collection<? extends SearchResult> searchResults, Window window) throws Exception {
// multiple results have been found, user must select one // multiple results have been found, user must select one
SelectDialog<SearchResult> selectDialog = new SelectDialog<SearchResult>(window, searchResults); SelectDialog<SearchResult> selectDialog = new SelectDialog<SearchResult>(window, searchResults);
@ -391,14 +391,14 @@ public abstract class AbstractSearchPanel<S, E> extends JComponent {
return selectDialog.getSelectedValue(); return selectDialog.getSelectedValue();
} }
protected void configureSelectDialog(SelectDialog<SearchResult> selectDialog) { protected void configureSelectDialog(SelectDialog<SearchResult> selectDialog) {
selectDialog.setLocation(getOffsetLocation(selectDialog.getOwner())); selectDialog.setLocation(getOffsetLocation(selectDialog.getOwner()));
selectDialog.setIconImage(getImage(getIcon())); selectDialog.setIconImage(getImage(getIcon()));
selectDialog.setMinimumSize(new Dimension(250, 150)); selectDialog.setMinimumSize(new Dimension(250, 150));
} }
public long getDuration() { public long getDuration() {
return duration; return duration;
} }

View File

@ -4,6 +4,7 @@ package net.sourceforge.filebot.ui;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
import javax.swing.Action; import javax.swing.Action;
@ -48,48 +49,48 @@ public class FileBotList<E> extends JComponent {
// Shortcut DELETE, disabled by default // Shortcut DELETE, disabled by default
removeAction.setEnabled(false); removeAction.setEnabled(false);
TunedUtilities.installAction(this, KeyStroke.getKeyStroke("pressed DELETE"), removeAction); TunedUtilities.installAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), removeAction);
TunedUtilities.installAction(this, KeyStroke.getKeyStroke("pressed BACK_SPACE"), removeAction); TunedUtilities.installAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), removeAction);
} }
public EventList<E> getModel() { public EventList<E> getModel() {
return model; return model;
} }
public void setModel(EventList<E> model) { public void setModel(EventList<E> model) {
this.model = model; this.model = model;
list.setModel(new EventListModel<E>(model)); list.setModel(new EventListModel<E>(model));
} }
public JList getListComponent() { public JList getListComponent() {
return list; return list;
} }
public JScrollPane getListScrollPane() { public JScrollPane getListScrollPane() {
return listScrollPane; return listScrollPane;
} }
@Override @Override
public DefaultTransferHandler getTransferHandler() { public DefaultTransferHandler getTransferHandler() {
return (DefaultTransferHandler) list.getTransferHandler(); return (DefaultTransferHandler) list.getTransferHandler();
} }
public void setTransferablePolicy(TransferablePolicy transferablePolicy) { public void setTransferablePolicy(TransferablePolicy transferablePolicy) {
getTransferHandler().setTransferablePolicy(transferablePolicy); getTransferHandler().setTransferablePolicy(transferablePolicy);
} }
public TransferablePolicy getTransferablePolicy() { public TransferablePolicy getTransferablePolicy() {
return getTransferHandler().getTransferablePolicy(); return getTransferHandler().getTransferablePolicy();
} }
public void setExportHandler(TextFileExportHandler exportHandler) { public void setExportHandler(TextFileExportHandler exportHandler) {
getTransferHandler().setExportHandler(exportHandler); getTransferHandler().setExportHandler(exportHandler);
@ -97,17 +98,17 @@ public class FileBotList<E> extends JComponent {
list.setDragEnabled(exportHandler != null); list.setDragEnabled(exportHandler != null);
} }
public TextFileExportHandler getExportHandler() { public TextFileExportHandler getExportHandler() {
return (TextFileExportHandler) getTransferHandler().getExportHandler(); return (TextFileExportHandler) getTransferHandler().getExportHandler();
} }
public String getTitle() { public String getTitle() {
return (String) getClientProperty("title"); return (String) getClientProperty("title");
} }
public void setTitle(String title) { public void setTitle(String title) {
putClientProperty("title", title); putClientProperty("title", title);
@ -119,13 +120,14 @@ public class FileBotList<E> extends JComponent {
} }
} }
public Action getRemoveAction() { public Action getRemoveAction() {
return removeAction; return removeAction;
} }
private final AbstractAction removeAction = new AbstractAction("Remove") { private final AbstractAction removeAction = new AbstractAction("Remove") {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
int index = list.getSelectedIndex(); int index = list.getSelectedIndex();
Object values[] = list.getSelectedValues(); Object values[] = list.getSelectedValues();

View File

@ -8,6 +8,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.FocusEvent; import java.awt.event.FocusEvent;
import java.awt.event.FocusListener; import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -53,27 +54,28 @@ public class SelectButtonTextField<T> extends JComponent {
editor.setRenderer(new CompletionCellRenderer()); editor.setRenderer(new CompletionCellRenderer());
editor.setUI(new TextFieldComboBoxUI()); editor.setUI(new TextFieldComboBoxUI());
TunedUtilities.installAction(this, KeyStroke.getKeyStroke("ctrl UP"), new SpinClientAction(-1)); TunedUtilities.installAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.CTRL_MASK), new SpinClientAction(-1));
TunedUtilities.installAction(this, KeyStroke.getKeyStroke("ctrl DOWN"), new SpinClientAction(1)); TunedUtilities.installAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, KeyEvent.CTRL_MASK), new SpinClientAction(1));
} }
public String getText() { public String getText() {
return ((TextFieldComboBoxUI) editor.getUI()).getEditor().getText(); return ((TextFieldComboBoxUI) editor.getUI()).getEditor().getText();
} }
public JComboBox getEditor() { public JComboBox getEditor() {
return editor; return editor;
} }
public SelectButton<T> getSelectButton() { public SelectButton<T> getSelectButton() {
return selectButton; return selectButton;
} }
private final ActionListener textFieldFocusOnClick = new ActionListener() { private final ActionListener textFieldFocusOnClick = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
getEditor().requestFocus(); getEditor().requestFocus();
} }
@ -91,13 +93,14 @@ public class SelectButtonTextField<T> extends JComponent {
this.spin = spin; this.spin = spin;
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
selectButton.spinValue(spin); selectButton.spinValue(spin);
} }
} }
private class CompletionCellRenderer extends DefaultListCellRenderer { private class CompletionCellRenderer extends DefaultListCellRenderer {
@Override @Override
@ -128,7 +131,7 @@ public class SelectButtonTextField<T> extends JComponent {
} }
} }
private class TextFieldComboBoxUI extends BasicComboBoxUI { private class TextFieldComboBoxUI extends BasicComboBoxUI {
@Override @Override
@ -136,7 +139,7 @@ public class SelectButtonTextField<T> extends JComponent {
return new JButton(ResourceManager.getIcon("action.list")); return new JButton(ResourceManager.getIcon("action.list"));
} }
@Override @Override
public void configureArrowButton() { public void configureArrowButton() {
super.configureArrowButton(); super.configureArrowButton();
@ -145,7 +148,7 @@ public class SelectButtonTextField<T> extends JComponent {
arrowButton.setFocusable(false); arrowButton.setFocusable(false);
} }
@Override @Override
protected void configureEditor() { protected void configureEditor() {
JTextComponent editor = getEditor(); JTextComponent editor = getEditor();
@ -164,13 +167,13 @@ public class SelectButtonTextField<T> extends JComponent {
popup.getList().repaint(); popup.getList().repaint();
} }
@Override @Override
public void insertUpdate(DocumentEvent e) { public void insertUpdate(DocumentEvent e) {
popup.getList().repaint(); popup.getList().repaint();
} }
@Override @Override
public void removeUpdate(DocumentEvent e) { public void removeUpdate(DocumentEvent e) {
popup.getList().repaint(); popup.getList().repaint();
@ -179,12 +182,12 @@ public class SelectButtonTextField<T> extends JComponent {
}); });
} }
public JTextComponent getEditor() { public JTextComponent getEditor() {
return (JTextComponent) editor; return (JTextComponent) editor;
} }
@Override @Override
protected ComboPopup createPopup() { protected ComboPopup createPopup() {
return new BasicComboPopup(comboBox) { return new BasicComboPopup(comboBox) {
@ -194,7 +197,7 @@ public class SelectButtonTextField<T> extends JComponent {
super.show(invoker, x - selectButton.getWidth(), y); super.show(invoker, x - selectButton.getWidth(), y);
} }
@Override @Override
protected Rectangle computePopupBounds(int px, int py, int pw, int ph) { protected Rectangle computePopupBounds(int px, int py, int pw, int ph) {
Rectangle bounds = super.computePopupBounds(px, py, pw, ph); Rectangle bounds = super.computePopupBounds(px, py, pw, ph);
@ -205,7 +208,7 @@ public class SelectButtonTextField<T> extends JComponent {
}; };
} }
@Override @Override
protected FocusListener createFocusListener() { protected FocusListener createFocusListener() {
return new FocusHandler() { return new FocusHandler() {

View File

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

View File

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

View File

@ -9,6 +9,7 @@ import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable; import java.awt.datatransfer.Transferable;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.io.File; import java.io.File;
@ -81,8 +82,8 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
searchTextField.getSelectButton().addPropertyChangeListener(SelectButton.SELECTED_VALUE, selectButtonListener); searchTextField.getSelectButton().addPropertyChangeListener(SelectButton.SELECTED_VALUE, selectButtonListener);
TunedUtilities.installAction(this, KeyStroke.getKeyStroke("shift UP"), new SpinSeasonAction(1)); TunedUtilities.installAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.SHIFT_MASK), new SpinSeasonAction(1));
TunedUtilities.installAction(this, KeyStroke.getKeyStroke("shift DOWN"), 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)); return new EpisodeListRequestProcessor(new EpisodeListRequest(provider, text, season, order, language));
}; };
private final PropertyChangeListener selectButtonListener = new PropertyChangeListener() { private final PropertyChangeListener selectButtonListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
EpisodeListProvider provider = searchTextField.getSelectButton().getSelectedValue(); EpisodeListProvider provider = searchTextField.getSelectButton().getSelectedValue();
@ -139,6 +140,7 @@ public class EpisodeListPanel extends AbstractSearchPanel<EpisodeListProvider, E
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
seasonSpinnerModel.spin((Integer) getValue("spin")); 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.BorderLayout;
import java.awt.Font; import java.awt.Font;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -84,12 +85,13 @@ public class ListPanel extends JComponent {
list.add(buttonPanel, BorderLayout.SOUTH); 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") { private AbstractAction createAction = new AbstractAction("Create") {
@Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
// clear selection // clear selection

View File

@ -14,6 +14,7 @@ import java.awt.Desktop;
import java.awt.Font; import java.awt.Font;
import java.awt.Window; import java.awt.Window;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
@ -100,8 +101,7 @@ class FormatDialog extends JDialog {
public enum Mode { public enum Mode {
Episode, Episode, Movie;
Movie;
public Mode next() { public Mode next() {
if (ordinal() < values().length - 1) if (ordinal() < values().length - 1)
@ -200,7 +200,7 @@ class FormatDialog extends JDialog {
}); });
// install editor suggestions popup // 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 // episode mode by default
setMode(Mode.Episode); setMode(Mode.Episode);
@ -539,7 +539,6 @@ class FormatDialog extends JDialog {
dispose(); dispose();
} }
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

View File

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

View File

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

View File

@ -9,6 +9,7 @@ import static net.sourceforge.tuned.FileUtilities.*;
import static net.sourceforge.tuned.ui.TunedUtilities.*; import static net.sourceforge.tuned.ui.TunedUtilities.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
@ -38,6 +39,16 @@ import javax.swing.ListModel;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.border.LineBorder; 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.BasicEventList;
import ca.odell.glazedlists.EventList; import ca.odell.glazedlists.EventList;
import ca.odell.glazedlists.FilterList; 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.EventSelectionModel;
import ca.odell.glazedlists.swing.TextComponentMatcherEditor; 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 { class SubtitleDownloadComponent extends JComponent {
@ -73,7 +73,7 @@ class SubtitleDownloadComponent extends JComponent {
private JTextField filterEditor = new JTextField(); private JTextField filterEditor = new JTextField();
public SubtitleDownloadComponent() { public SubtitleDownloadComponent() {
final JList packageList = new JList(createPackageListModel()); final JList packageList = new JList(createPackageListModel());
packageList.setFixedCellHeight(32); packageList.setFixedCellHeight(32);
@ -96,7 +96,7 @@ class SubtitleDownloadComponent extends JComponent {
return file.getName(); return file.getName();
} }
@Override @Override
protected Icon convertValueToIcon(Object value) { protected Icon convertValueToIcon(Object value) {
if (SUBTITLE_FILES.accept(value.toString())) if (SUBTITLE_FILES.accept(value.toString()))
@ -133,7 +133,7 @@ class SubtitleDownloadComponent extends JComponent {
add(scrollPane, "newline, hmin max(80px, 30%)"); add(scrollPane, "newline, hmin max(80px, 30%)");
// install fetch action // 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 @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -142,7 +142,7 @@ class SubtitleDownloadComponent extends JComponent {
}); });
// install open action // 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 @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -151,7 +151,7 @@ class SubtitleDownloadComponent extends JComponent {
}); });
} }
protected ListModel createPackageListModel() { protected ListModel createPackageListModel() {
// allow filtering by language name and subtitle name // allow filtering by language name and subtitle name
MatcherEditor<SubtitlePackage> matcherEditor = new TextComponentMatcherEditor<SubtitlePackage>(filterEditor, new TextFilterator<SubtitlePackage>() { MatcherEditor<SubtitlePackage> matcherEditor = new TextComponentMatcherEditor<SubtitlePackage>(filterEditor, new TextFilterator<SubtitlePackage>() {
@ -176,7 +176,7 @@ class SubtitleDownloadComponent extends JComponent {
return new EventListModel<SubtitlePackage>(source); return new EventListModel<SubtitlePackage>(source);
} }
protected ListModel createFileListModel() { protected ListModel createFileListModel() {
// source list // source list
EventList<MemoryFile> source = getFileModel(); EventList<MemoryFile> source = getFileModel();
@ -194,7 +194,7 @@ class SubtitleDownloadComponent extends JComponent {
return new EventListModel<MemoryFile>(source); return new EventListModel<MemoryFile>(source);
} }
public void reset() { public void reset() {
// cancel and reset download workers // cancel and reset download workers
for (SubtitlePackage subtitle : packages) { for (SubtitlePackage subtitle : packages) {
@ -204,29 +204,29 @@ class SubtitleDownloadComponent extends JComponent {
files.clear(); files.clear();
} }
public EventList<SubtitlePackage> getPackageModel() { public EventList<SubtitlePackage> getPackageModel() {
return packages; return packages;
} }
public EventList<MemoryFile> getFileModel() { public EventList<MemoryFile> getFileModel() {
return files; return files;
} }
public void setLanguageVisible(boolean visible) { public void setLanguageVisible(boolean visible) {
renderer.getLanguageLabel().setVisible(visible); renderer.getLanguageLabel().setVisible(visible);
} }
private void fetch(Object[] selection) { private void fetch(Object[] selection) {
for (Object value : selection) { for (Object value : selection) {
fetch((SubtitlePackage) value); fetch((SubtitlePackage) value);
} }
} }
private void fetch(final SubtitlePackage subtitle) { private void fetch(final SubtitlePackage subtitle) {
if (subtitle.getDownload().isStarted()) { if (subtitle.getDownload().isStarted()) {
// download has been started already // download has been started already
@ -262,7 +262,7 @@ class SubtitleDownloadComponent extends JComponent {
subtitle.getDownload().start(); subtitle.getDownload().start();
} }
private void open(Object[] selection) { private void open(Object[] selection) {
try { try {
for (Object object : selection) { for (Object object : selection) {
@ -278,7 +278,7 @@ class SubtitleDownloadComponent extends JComponent {
} }
} }
private void open(MemoryFile file) throws IOException { private void open(MemoryFile file) throws IOException {
SubtitleViewer viewer = new SubtitleViewer(file.getName()); SubtitleViewer viewer = new SubtitleViewer(file.getName());
viewer.getTitleLabel().setText("Subtitle Viewer"); viewer.getTitleLabel().setText("Subtitle Viewer");
@ -288,7 +288,7 @@ class SubtitleDownloadComponent extends JComponent {
viewer.setVisible(true); viewer.setVisible(true);
} }
private void save(Object[] selection) { private void save(Object[] selection) {
try { try {
if (selection.length == 1) { if (selection.length == 1) {
@ -321,7 +321,7 @@ class SubtitleDownloadComponent extends JComponent {
} }
} }
private void export(Object[] selection) { private void export(Object[] selection) {
try { try {
if (selection.length == 1) { if (selection.length == 1) {
@ -365,7 +365,6 @@ class SubtitleDownloadComponent extends JComponent {
} }
} }
private final Action clearFilterAction = new AbstractAction(null, ResourceManager.getIcon("edit.clear")) { private final Action clearFilterAction = new AbstractAction(null, ResourceManager.getIcon("edit.clear")) {
@Override @Override
@ -386,19 +385,19 @@ class SubtitleDownloadComponent extends JComponent {
} }
} }
@Override @Override
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
maybeShowPopup(e); maybeShowPopup(e);
} }
@Override @Override
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
maybeShowPopup(e); maybeShowPopup(e);
} }
private void maybeShowPopup(MouseEvent e) { private void maybeShowPopup(MouseEvent e) {
if (e.isPopupTrigger()) { if (e.isPopupTrigger()) {
JList list = (JList) e.getSource(); JList list = (JList) e.getSource();
@ -431,7 +430,7 @@ class SubtitleDownloadComponent extends JComponent {
} }
} }
private boolean isPending(Object[] selection) { private boolean isPending(Object[] selection) {
for (Object value : selection) { for (Object value : selection) {
SubtitlePackage subtitle = (SubtitlePackage) value; SubtitlePackage subtitle = (SubtitlePackage) value;
@ -459,19 +458,19 @@ class SubtitleDownloadComponent extends JComponent {
} }
} }
@Override @Override
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
maybeShowPopup(e); maybeShowPopup(e);
} }
@Override @Override
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
maybeShowPopup(e); maybeShowPopup(e);
} }
private void maybeShowPopup(MouseEvent e) { private void maybeShowPopup(MouseEvent e) {
if (e.isPopupTrigger()) { if (e.isPopupTrigger()) {
JList list = (JList) e.getSource(); JList list = (JList) e.getSource();

View File

@ -66,7 +66,7 @@ public class SubtitleViewer extends JFrame {
private Color defaultFilterForeground = filterEditor.getForeground(); private Color defaultFilterForeground = filterEditor.getForeground();
private Color disabledFilterForeground = Color.lightGray; private Color disabledFilterForeground = Color.lightGray;
public SubtitleViewer(String title) { public SubtitleViewer(String title) {
super(title); super(title);
@ -102,7 +102,7 @@ public class SubtitleViewer extends JFrame {
pack(); pack();
} }
private JTable createTable(TableModel model) { private JTable createTable(TableModel model) {
final JTable table = new JTable(model); final JTable table = new JTable(model);
table.setBackground(Color.white); table.setBackground(Color.white);
@ -141,7 +141,7 @@ public class SubtitleViewer extends JFrame {
}); });
// focus around selected time stamp // 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 @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -168,7 +168,7 @@ public class SubtitleViewer extends JFrame {
return table; return table;
} }
private JTextField createFilterEditor() { private JTextField createFilterEditor() {
final JTextField editor = new JTextField() { final JTextField editor = new JTextField() {
@ -205,13 +205,13 @@ public class SubtitleViewer extends JFrame {
return editor; return editor;
} }
private RowFilter<?, ?> getTableFilter() { private RowFilter<?, ?> getTableFilter() {
TableRowSorter<?> sorter = (TableRowSorter<?>) subtitleTable.getRowSorter(); TableRowSorter<?> sorter = (TableRowSorter<?>) subtitleTable.getRowSorter();
return sorter.getRowFilter(); return sorter.getRowFilter();
} }
private void setTableFilter(String filter) { private void setTableFilter(String filter) {
// filter by words // filter by words
List<SubtitleFilter> filterList = new ArrayList<SubtitleFilter>(); List<SubtitleFilter> filterList = new ArrayList<SubtitleFilter>();
@ -230,22 +230,21 @@ public class SubtitleViewer extends JFrame {
filterEditor.setForeground(filterList.isEmpty() ? disabledFilterForeground : defaultFilterForeground); filterEditor.setForeground(filterList.isEmpty() ? disabledFilterForeground : defaultFilterForeground);
} }
public void setData(List<SubtitleElement> data) { public void setData(List<SubtitleElement> data) {
model.setData(data); model.setData(data);
} }
public JLabel getTitleLabel() { public JLabel getTitleLabel() {
return titleLabel; return titleLabel;
} }
public JLabel getInfoLabel() { public JLabel getInfoLabel() {
return infoLabel; return infoLabel;
} }
private final Action clearFilterAction = new AbstractAction(null, ResourceManager.getIcon("edit.clear")) { private final Action clearFilterAction = new AbstractAction(null, ResourceManager.getIcon("edit.clear")) {
@Override @Override
@ -254,17 +253,17 @@ public class SubtitleViewer extends JFrame {
} }
}; };
private static class SubtitleFilter extends RowFilter<Object, Integer> { private static class SubtitleFilter extends RowFilter<Object, Integer> {
private final Pattern filter; private final Pattern filter;
public SubtitleFilter(String filter) { public SubtitleFilter(String filter) {
this.filter = compile(quote(filter), CASE_INSENSITIVE | UNICODE_CASE | CANON_EQ); this.filter = compile(quote(filter), CASE_INSENSITIVE | UNICODE_CASE | CANON_EQ);
} }
@Override @Override
public boolean include(Entry<?, ? extends Integer> entry) { public boolean include(Entry<?, ? extends Integer> entry) {
SubtitleTableModel model = (SubtitleTableModel) entry.getModel(); SubtitleTableModel model = (SubtitleTableModel) entry.getModel();
@ -275,12 +274,12 @@ public class SubtitleViewer extends JFrame {
} }
private static class SubtitleTableModel extends AbstractTableModel { private static class SubtitleTableModel extends AbstractTableModel {
private List<SubtitleElement> data = emptyList(); private List<SubtitleElement> data = emptyList();
public void setData(List<SubtitleElement> data) { public void setData(List<SubtitleElement> data) {
this.data = new ArrayList<SubtitleElement>(data); this.data = new ArrayList<SubtitleElement>(data);
@ -288,12 +287,12 @@ public class SubtitleViewer extends JFrame {
fireTableDataChanged(); fireTableDataChanged();
} }
public SubtitleElement getRow(int row) { public SubtitleElement getRow(int row) {
return data.get(row); return data.get(row);
} }
@Override @Override
public String getColumnName(int column) { public String getColumnName(int column) {
switch (column) { switch (column) {
@ -310,19 +309,19 @@ public class SubtitleViewer extends JFrame {
} }
} }
@Override @Override
public int getColumnCount() { public int getColumnCount() {
return 4; return 4;
} }
@Override @Override
public int getRowCount() { public int getRowCount() {
return data.size(); return data.size();
} }
@Override @Override
public Class<?> getColumnClass(int column) { public Class<?> getColumnClass(int column) {
switch (column) { switch (column) {
@ -339,7 +338,7 @@ public class SubtitleViewer extends JFrame {
} }
} }
@Override @Override
public Object getValueAt(int row, int column) { public Object getValueAt(int row, int column) {
switch (column) { switch (column) {

View File

@ -16,6 +16,7 @@ import java.awt.Window;
import java.awt.dnd.DnDConstants; import java.awt.dnd.DnDConstants;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
@ -115,7 +116,7 @@ public final class TunedUtilities {
component.getDocument().addUndoableEditListener(undoSupport); component.getDocument().addUndoableEditListener(undoSupport);
// install undo action // 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 @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -125,7 +126,7 @@ public final class TunedUtilities {
}); });
// install redo action // 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 @Override
public void actionPerformed(ActionEvent e) { 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 * 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.
* of initiating a drag. This TableUI will give the JTable proper dnd behaviour.
*/ */
public static class DragDropRowTableUI extends BasicTableUI { public static class DragDropRowTableUI extends BasicTableUI {