* setup double-click actions for files (reveal in explorer) and movies (open tmdb/imdb page)

This commit is contained in:
Reinhard Pointner 2012-07-29 08:30:33 +00:00
parent 3ba2b40327
commit 859564bc15
3 changed files with 64 additions and 1 deletions

View File

@ -10,9 +10,13 @@ import static net.sourceforge.tuned.ui.LoadingOverlayPane.*;
import static net.sourceforge.tuned.ui.TunedUtilities.*; import static net.sourceforge.tuned.ui.TunedUtilities.*;
import java.awt.Component; import java.awt.Component;
import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.Insets; import java.awt.Insets;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.io.File; import java.io.File;
@ -22,6 +26,7 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
import javax.swing.Action; import javax.swing.Action;
@ -168,8 +173,54 @@ public class RenamePanel extends JComponent {
// open rename log button // open rename log button
filesList.getButtonPanel().add(createImageButton(openHistoryAction), "gap 0"); filesList.getButtonPanel().add(createImageButton(openHistoryAction), "gap 0");
setLayout(new MigLayout("fill, insets dialog, gapx 10px", "[fill][align center, pref!][fill]", "align 33%")); // reveal file location on double click
filesList.getListComponent().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent evt) {
if (evt.getClickCount() == 2) {
getWindow(evt.getSource()).setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
JList list = (JList) evt.getSource();
File item = (File) list.getSelectedValue();
Desktop.getDesktop().browse(item.getParentFile().toURI());
} catch (Exception e) {
Logger.getLogger(RenamePanel.class.getName()).log(Level.WARNING, e.getMessage());
} finally {
getWindow(evt.getSource()).setCursor(Cursor.getDefaultCursor());
}
}
}
});
// reveal file location on double click
namesList.getListComponent().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent evt) {
if (evt.getClickCount() == 2) {
try {
JList list = (JList) evt.getSource();
Object item = ((FormattedFuture) list.getSelectedValue()).getMatch().getValue();
if (item instanceof Movie) {
getWindow(evt.getSource()).setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
Movie m = (Movie) item;
if (m.getTmdbId() > 0) {
Desktop.getDesktop().browse(WebServices.TMDb.getMoviePageLink(m.getTmdbId()));
} else if (m.getImdbId() > 0) {
Desktop.getDesktop().browse(WebServices.IMDb.getMoviePageLink(m.getImdbId()));
}
}
} catch (Exception e) {
Logger.getLogger(RenamePanel.class.getName()).log(Level.WARNING, e.getMessage());
} finally {
getWindow(evt.getSource()).setCursor(Cursor.getDefaultCursor());
}
}
}
});
setLayout(new MigLayout("fill, insets dialog, gapx 10px", "[fill][align center, pref!][fill]", "align 33%"));
add(filesList, "grow, sizegroupx list"); add(filesList, "grow, sizegroupx list");
// make buttons larger // make buttons larger

View File

@ -11,6 +11,7 @@ import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.Reader; import java.io.Reader;
import java.net.URI;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@ -178,6 +179,11 @@ public class IMDbClient implements MovieIdentificationService {
} }
public URI getMoviePageLink(int imdbId) {
return URI.create(String.format("http://www.imdb.com/title/tt%07d/", imdbId));
}
@Override @Override
public Map<File, Movie> getMovieDescriptors(Collection<File> movieFiles, Locale locale) throws Exception { public Map<File, Movie> getMovieDescriptors(Collection<File> movieFiles, Locale locale) throws Exception {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();

View File

@ -10,6 +10,7 @@ import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
import java.net.URI;
import java.net.URL; import java.net.URL;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.charset.Charset; import java.nio.charset.Charset;
@ -97,6 +98,11 @@ public class TMDbClient implements MovieIdentificationService {
} }
public URI getMoviePageLink(int tmdbid) {
return URI.create("http://www.themoviedb.org/movie/" + tmdbid);
}
@Override @Override
public Movie getMovieDescriptor(int imdbid, Locale locale) throws IOException { public Movie getMovieDescriptor(int imdbid, Locale locale) throws IOException {
try { try {