mirror of
https://github.com/mitb-archive/filebot
synced 2025-03-10 06:20:27 -04:00
Refactor
This commit is contained in:
parent
4aff8bb01e
commit
4d7a40b31b
@ -275,29 +275,24 @@ public class RenamePanel extends JComponent {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// reveal file location on double click
|
// reveal file location on double click
|
||||||
namesList.getListComponent().addMouseListener(new MouseAdapter() {
|
namesList.getListComponent().addMouseListener(mouseClicked(evt -> {
|
||||||
|
if (evt.getClickCount() == 2) {
|
||||||
@Override
|
JList list = (JList) evt.getSource();
|
||||||
public void mouseClicked(MouseEvent evt) {
|
if (list.getSelectedIndex() >= 0) {
|
||||||
if (evt.getClickCount() == 2) {
|
|
||||||
getWindow(evt.getSource()).setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
|
||||||
try {
|
try {
|
||||||
JList list = (JList) evt.getSource();
|
withWaitCursor(list, () -> {
|
||||||
if (list.getSelectedIndex() >= 0) {
|
|
||||||
Match<Object, File> match = renameModel.getMatch(list.getSelectedIndex());
|
Match<Object, File> match = renameModel.getMatch(list.getSelectedIndex());
|
||||||
Map<File, Object> context = renameModel.getMatchContext(match);
|
Map<File, Object> context = renameModel.getMatchContext(match);
|
||||||
|
|
||||||
MediaBindingBean sample = new MediaBindingBean(match.getValue(), match.getCandidate(), context);
|
MediaBindingBean sample = new MediaBindingBean(match.getValue(), match.getCandidate(), context);
|
||||||
showFormatEditor(sample);
|
showFormatEditor(sample);
|
||||||
}
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
debug.log(Level.WARNING, e.getMessage(), e);
|
debug.log(Level.WARNING, e.getMessage(), e);
|
||||||
} finally {
|
|
||||||
getWindow(evt.getSource()).setCursor(Cursor.getDefaultCursor());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
|
|
||||||
setLayout(new MigLayout("fill, insets dialog, gapx 10px", "[fill][align center, pref!][fill]", "align 33%"));
|
setLayout(new MigLayout("fill, insets dialog, gapx 10px", "[fill][align center, pref!][fill]", "align 33%"));
|
||||||
add(new LoadingOverlayPane(filesList, filesList, "37px", "30px"), "grow, sizegroupx list");
|
add(new LoadingOverlayPane(filesList, filesList, "37px", "30px"), "grow, sizegroupx list");
|
||||||
|
@ -14,7 +14,9 @@ import java.awt.Point;
|
|||||||
import java.awt.Window;
|
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.InputEvent;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
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;
|
||||||
@ -94,6 +96,10 @@ public final class SwingUI {
|
|||||||
return c == null ? "inherit" : String.format("#%02x%02x%02x", c.getRed(), c.getGreen(), c.getBlue());
|
return c == null ? "inherit" : String.format("#%02x%02x%02x", c.getRed(), c.getGreen(), c.getBlue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isShiftOrAltDown(InputEvent evt) {
|
||||||
|
return checkModifiers(evt.getModifiers(), ActionEvent.SHIFT_MASK) || checkModifiers(evt.getModifiers(), ActionEvent.ALT_MASK);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isShiftOrAltDown(ActionEvent evt) {
|
public static boolean isShiftOrAltDown(ActionEvent evt) {
|
||||||
return checkModifiers(evt.getModifiers(), ActionEvent.SHIFT_MASK) || checkModifiers(evt.getModifiers(), ActionEvent.ALT_MASK);
|
return checkModifiers(evt.getModifiers(), ActionEvent.SHIFT_MASK) || checkModifiers(evt.getModifiers(), ActionEvent.ALT_MASK);
|
||||||
}
|
}
|
||||||
@ -272,6 +278,16 @@ public final class SwingUI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MouseAdapter mouseClicked(Consumer<MouseEvent> handler) {
|
||||||
|
return new MouseAdapter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent evt) {
|
||||||
|
handler.accept(evt);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public static JButton newButton(String name, Icon icon, Consumer<ActionEvent> action) {
|
public static JButton newButton(String name, Icon icon, Consumer<ActionEvent> action) {
|
||||||
return new JButton(new LambdaAction(name, icon, action));
|
return new JButton(new LambdaAction(name, icon, action));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user