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