mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 08:48:51 -05:00
* adjust default dialog sizes to make it work better on OSX
This commit is contained in:
parent
7756019568
commit
960b1bd9f8
@ -1,7 +1,5 @@
|
|||||||
|
|
||||||
package net.sourceforge.filebot.ui;
|
package net.sourceforge.filebot.ui;
|
||||||
|
|
||||||
|
|
||||||
import static java.awt.event.InputEvent.*;
|
import static java.awt.event.InputEvent.*;
|
||||||
import static java.awt.event.KeyEvent.*;
|
import static java.awt.event.KeyEvent.*;
|
||||||
import static javax.swing.KeyStroke.*;
|
import static javax.swing.KeyStroke.*;
|
||||||
@ -50,65 +48,63 @@ import net.sourceforge.tuned.ui.DefaultFancyListCellRenderer;
|
|||||||
import net.sourceforge.tuned.ui.ShadowBorder;
|
import net.sourceforge.tuned.ui.ShadowBorder;
|
||||||
import net.sourceforge.tuned.ui.TunedUtilities;
|
import net.sourceforge.tuned.ui.TunedUtilities;
|
||||||
|
|
||||||
|
|
||||||
public class MainFrame extends JFrame {
|
public class MainFrame extends JFrame {
|
||||||
|
|
||||||
private JList selectionList = new PanelSelectionList(createPanelBuilders());
|
private JList selectionList = new PanelSelectionList(createPanelBuilders());
|
||||||
|
|
||||||
private HeaderPanel headerPanel = new HeaderPanel();
|
private HeaderPanel headerPanel = new HeaderPanel();
|
||||||
|
|
||||||
private static final PreferencesEntry<String> persistentSelectedPanel = Settings.forPackage(MainFrame.class).entry("panel.selected").defaultValue("1");
|
private static final PreferencesEntry<String> persistentSelectedPanel = Settings.forPackage(MainFrame.class).entry("panel.selected").defaultValue("1");
|
||||||
|
|
||||||
|
|
||||||
public MainFrame() {
|
public MainFrame() {
|
||||||
super(Settings.getApplicationName());
|
super(Settings.getApplicationName());
|
||||||
|
|
||||||
// set taskbar / taskswitch icons
|
// set taskbar / taskswitch icons
|
||||||
List<Image> images = new ArrayList<Image>(3);
|
List<Image> images = new ArrayList<Image>(3);
|
||||||
for (String i : new String[] { "window.icon.large", "window.icon.medium", "window.icon.small" }) {
|
for (String i : new String[] { "window.icon.large", "window.icon.medium", "window.icon.small" }) {
|
||||||
images.add(ResourceManager.getImage(i));
|
images.add(ResourceManager.getImage(i));
|
||||||
}
|
}
|
||||||
setIconImages(images);
|
setIconImages(images);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// restore selected panel
|
// restore selected panel
|
||||||
selectionList.setSelectedIndex(Integer.parseInt(persistentSelectedPanel.getValue()));
|
selectionList.setSelectedIndex(Integer.parseInt(persistentSelectedPanel.getValue()));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
JScrollPane selectionListScrollPane = new JScrollPane(selectionList, VERTICAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_NEVER);
|
JScrollPane selectionListScrollPane = new JScrollPane(selectionList, VERTICAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
selectionListScrollPane.setBorder(new CompoundBorder(new ShadowBorder(), selectionListScrollPane.getBorder()));
|
selectionListScrollPane.setBorder(new CompoundBorder(new ShadowBorder(), selectionListScrollPane.getBorder()));
|
||||||
selectionListScrollPane.setOpaque(false);
|
selectionListScrollPane.setOpaque(false);
|
||||||
|
|
||||||
headerPanel.getTitleLabel().setBorder(new EmptyBorder(8, 90, 10, 0));
|
headerPanel.getTitleLabel().setBorder(new EmptyBorder(8, 90, 10, 0));
|
||||||
|
|
||||||
JComponent c = (JComponent) getContentPane();
|
JComponent c = (JComponent) getContentPane();
|
||||||
c.setLayout(new MigLayout("insets 0, fill, hidemode 3", "95px[fill]", "fill"));
|
c.setLayout(new MigLayout("insets 0, fill, hidemode 3", "95px[fill]", "fill"));
|
||||||
|
|
||||||
c.add(selectionListScrollPane, "pos 6px 10px n 100%-12px");
|
c.add(selectionListScrollPane, "pos 6px 10px n 100%-12px");
|
||||||
c.add(headerPanel, "growx, dock north");
|
c.add(headerPanel, "growx, dock north");
|
||||||
|
|
||||||
// show initial panel
|
// show initial panel
|
||||||
showPanel((PanelBuilder) selectionList.getSelectedValue());
|
showPanel((PanelBuilder) selectionList.getSelectedValue());
|
||||||
|
|
||||||
selectionList.addListSelectionListener(new ListSelectionListener() {
|
selectionList.addListSelectionListener(new ListSelectionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void valueChanged(ListSelectionEvent e) {
|
public void valueChanged(ListSelectionEvent e) {
|
||||||
showPanel((PanelBuilder) selectionList.getSelectedValue());
|
showPanel((PanelBuilder) selectionList.getSelectedValue());
|
||||||
|
|
||||||
if (!e.getValueIsAdjusting()) {
|
if (!e.getValueIsAdjusting()) {
|
||||||
persistentSelectedPanel.setValue(Integer.toString(selectionList.getSelectedIndex()));
|
persistentSelectedPanel.setValue(Integer.toString(selectionList.getSelectedIndex()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setSize(860, 630);
|
setSize(980, 630);
|
||||||
|
|
||||||
// KEYBOARD SHORTCUTS
|
// KEYBOARD SHORTCUTS
|
||||||
TunedUtilities.installAction(this.getRootPane(), getKeyStroke(VK_DELETE, CTRL_MASK | SHIFT_MASK), new AbstractAction("Clear Cache") {
|
TunedUtilities.installAction(this.getRootPane(), getKeyStroke(VK_DELETE, CTRL_MASK | SHIFT_MASK), new AbstractAction("Clear Cache") {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
CacheManager.getInstance().clearAll();
|
CacheManager.getInstance().clearAll();
|
||||||
@ -116,22 +112,20 @@ public class MainFrame extends JFrame {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static PanelBuilder[] createPanelBuilders() {
|
public static PanelBuilder[] createPanelBuilders() {
|
||||||
return new PanelBuilder[] { new ListPanelBuilder(), new RenamePanelBuilder(), new AnalyzePanelBuilder(), new EpisodeListPanelBuilder(), new SubtitlePanelBuilder(), new SfvPanelBuilder() };
|
return new PanelBuilder[] { new ListPanelBuilder(), new RenamePanelBuilder(), new AnalyzePanelBuilder(), new EpisodeListPanelBuilder(), new SubtitlePanelBuilder(), new SfvPanelBuilder() };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void showPanel(PanelBuilder selectedBuilder) {
|
protected void showPanel(PanelBuilder selectedBuilder) {
|
||||||
final JComponent contentPane = (JComponent) getContentPane();
|
final JComponent contentPane = (JComponent) getContentPane();
|
||||||
|
|
||||||
JComponent panel = null;
|
JComponent panel = null;
|
||||||
|
|
||||||
for (int i = 0; i < contentPane.getComponentCount(); i++) {
|
for (int i = 0; i < contentPane.getComponentCount(); i++) {
|
||||||
JComponent c = (JComponent) contentPane.getComponent(i);
|
JComponent c = (JComponent) contentPane.getComponent(i);
|
||||||
PanelBuilder builder = (PanelBuilder) c.getClientProperty("panelBuilder");
|
PanelBuilder builder = (PanelBuilder) c.getClientProperty("panelBuilder");
|
||||||
|
|
||||||
if (builder != null) {
|
if (builder != null) {
|
||||||
if (builder.equals(selectedBuilder)) {
|
if (builder.equals(selectedBuilder)) {
|
||||||
panel = c;
|
panel = c;
|
||||||
@ -140,15 +134,15 @@ public class MainFrame extends JFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (panel == null) {
|
if (panel == null) {
|
||||||
panel = selectedBuilder.create();
|
panel = selectedBuilder.create();
|
||||||
panel.setVisible(false); // invisible by default
|
panel.setVisible(false); // invisible by default
|
||||||
panel.putClientProperty("panelBuilder", selectedBuilder);
|
panel.putClientProperty("panelBuilder", selectedBuilder);
|
||||||
|
|
||||||
contentPane.add(panel);
|
contentPane.add(panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// make visible, ignore action is visible already
|
// make visible, ignore action is visible already
|
||||||
if (!panel.isVisible()) {
|
if (!panel.isVisible()) {
|
||||||
headerPanel.setTitle(selectedBuilder.getName());
|
headerPanel.setTitle(selectedBuilder.getName());
|
||||||
@ -156,33 +150,29 @@ public class MainFrame extends JFrame {
|
|||||||
Analytics.trackView(panel.getClass(), selectedBuilder.getName());
|
Analytics.trackView(panel.getClass(), selectedBuilder.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class PanelSelectionList extends JList {
|
private static class PanelSelectionList extends JList {
|
||||||
|
|
||||||
private static final int SELECTDELAY_ON_DRAG_OVER = 300;
|
private static final int SELECTDELAY_ON_DRAG_OVER = 300;
|
||||||
|
|
||||||
|
|
||||||
public PanelSelectionList(PanelBuilder[] builders) {
|
public PanelSelectionList(PanelBuilder[] builders) {
|
||||||
super(builders);
|
super(builders);
|
||||||
|
|
||||||
setCellRenderer(new PanelCellRenderer());
|
setCellRenderer(new PanelCellRenderer());
|
||||||
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
|
|
||||||
setBorder(new EmptyBorder(4, 5, 4, 5));
|
setBorder(new EmptyBorder(4, 5, 4, 5));
|
||||||
|
|
||||||
// initialize "drag over" panel selection
|
// initialize "drag over" panel selection
|
||||||
new DropTarget(this, new DragDropListener());
|
new DropTarget(this, new DragDropListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class DragDropListener extends DropTargetAdapter {
|
private class DragDropListener extends DropTargetAdapter {
|
||||||
|
|
||||||
private boolean selectEnabled = false;
|
private boolean selectEnabled = false;
|
||||||
|
|
||||||
private Timer dragEnterTimer;
|
private Timer dragEnterTimer;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dragOver(DropTargetDragEvent dtde) {
|
public void dragOver(DropTargetDragEvent dtde) {
|
||||||
if (selectEnabled) {
|
if (selectEnabled) {
|
||||||
@ -190,67 +180,62 @@ public class MainFrame extends JFrame {
|
|||||||
setSelectedIndex(index);
|
setSelectedIndex(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dragEnter(final DropTargetDragEvent dtde) {
|
public void dragEnter(final DropTargetDragEvent dtde) {
|
||||||
dragEnterTimer = TunedUtilities.invokeLater(SELECTDELAY_ON_DRAG_OVER, new Runnable() {
|
dragEnterTimer = TunedUtilities.invokeLater(SELECTDELAY_ON_DRAG_OVER, new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
selectEnabled = true;
|
selectEnabled = true;
|
||||||
|
|
||||||
// bring window to front when on dnd
|
// bring window to front when on dnd
|
||||||
SwingUtilities.getWindowAncestor(((DropTarget) dtde.getSource()).getComponent()).toFront();
|
SwingUtilities.getWindowAncestor(((DropTarget) dtde.getSource()).getComponent()).toFront();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dragExit(DropTargetEvent dte) {
|
public void dragExit(DropTargetEvent dte) {
|
||||||
selectEnabled = false;
|
selectEnabled = false;
|
||||||
|
|
||||||
if (dragEnterTimer != null) {
|
if (dragEnterTimer != null) {
|
||||||
dragEnterTimer.stop();
|
dragEnterTimer.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drop(DropTargetDropEvent dtde) {
|
public void drop(DropTargetDropEvent dtde) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class PanelCellRenderer extends DefaultFancyListCellRenderer {
|
private static class PanelCellRenderer extends DefaultFancyListCellRenderer {
|
||||||
|
|
||||||
public PanelCellRenderer() {
|
public PanelCellRenderer() {
|
||||||
super(10, 0, new Color(0x163264));
|
super(10, 0, new Color(0x163264));
|
||||||
|
|
||||||
// center labels in list
|
// center labels in list
|
||||||
setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
|
setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
|
||||||
|
|
||||||
setHighlightingEnabled(false);
|
setHighlightingEnabled(false);
|
||||||
|
|
||||||
setVerticalTextPosition(SwingConstants.BOTTOM);
|
setVerticalTextPosition(SwingConstants.BOTTOM);
|
||||||
setHorizontalTextPosition(SwingConstants.CENTER);
|
setHorizontalTextPosition(SwingConstants.CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configureListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
public void configureListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
super.configureListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
super.configureListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
|
||||||
PanelBuilder panel = (PanelBuilder) value;
|
PanelBuilder panel = (PanelBuilder) value;
|
||||||
setText(panel.getName());
|
setText(panel.getName());
|
||||||
setIcon(panel.getIcon());
|
setIcon(panel.getIcon());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ public class FormatDialog extends JDialog {
|
|||||||
|
|
||||||
// initialize window properties
|
// initialize window properties
|
||||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||||
setSize(610, 430);
|
setSize(620, 445);
|
||||||
|
|
||||||
// initialize data
|
// initialize data
|
||||||
setState(initMode, lockOnBinding != null ? lockOnBinding : restoreSample(initMode), lockOnBinding != null);
|
setState(initMode, lockOnBinding != null ? lockOnBinding : restoreSample(initMode), lockOnBinding != null);
|
||||||
|
Loading…
Reference in New Issue
Block a user