This commit is contained in:
Reinhard Pointner 2016-03-31 17:25:49 +00:00
parent 4aff8bb01e
commit 4d7a40b31b
2 changed files with 23 additions and 12 deletions

View File

@ -275,29 +275,24 @@ public class RenamePanel extends JComponent {
});
// reveal file location on double click
namesList.getListComponent().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent evt) {
if (evt.getClickCount() == 2) {
getWindow(evt.getSource()).setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
namesList.getListComponent().addMouseListener(mouseClicked(evt -> {
if (evt.getClickCount() == 2) {
JList list = (JList) evt.getSource();
if (list.getSelectedIndex() >= 0) {
try {
JList list = (JList) evt.getSource();
if (list.getSelectedIndex() >= 0) {
withWaitCursor(list, () -> {
Match<Object, File> match = renameModel.getMatch(list.getSelectedIndex());
Map<File, Object> context = renameModel.getMatchContext(match);
MediaBindingBean sample = new MediaBindingBean(match.getValue(), match.getCandidate(), context);
showFormatEditor(sample);
}
});
} catch (Exception 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%"));
add(new LoadingOverlayPane(filesList, filesList, "37px", "30px"), "grow, sizegroupx list");

View File

@ -14,7 +14,9 @@ import java.awt.Point;
import java.awt.Window;
import java.awt.dnd.DnDConstants;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
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());
}
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) {
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) {
return new JButton(new LambdaAction(name, icon, action));
}