* remember window location/size
* remember last used load/save directory * disable ehcache update checker
This commit is contained in:
parent
6052f527c2
commit
33b439c620
|
@ -1,4 +1,4 @@
|
|||
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd">
|
||||
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="false">
|
||||
|
||||
<!--
|
||||
CacheManager Configuration
|
||||
|
|
|
@ -4,6 +4,9 @@ package net.sourceforge.filebot;
|
|||
|
||||
import static javax.swing.JFrame.*;
|
||||
|
||||
import java.awt.Window;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.security.CodeSource;
|
||||
import java.security.Permission;
|
||||
import java.security.PermissionCollection;
|
||||
|
@ -79,6 +82,13 @@ public class Main {
|
|||
frame.setLocationByPlatform(true);
|
||||
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
|
||||
try {
|
||||
// restore previous size and location
|
||||
restoreWindowBounds(frame, Settings.forPackage(MainFrame.class));
|
||||
} catch (Exception e) {
|
||||
// don't care, doesn't make a difference
|
||||
}
|
||||
|
||||
// start application
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
@ -86,6 +96,28 @@ public class Main {
|
|||
}
|
||||
|
||||
|
||||
private static void restoreWindowBounds(Window window, final Settings settings) {
|
||||
// store bounds on close
|
||||
window.addWindowListener(new WindowAdapter() {
|
||||
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
settings.put("window.x", String.valueOf(e.getWindow().getX()));
|
||||
settings.put("window.y", String.valueOf(e.getWindow().getY()));
|
||||
settings.put("window.width", String.valueOf(e.getWindow().getWidth()));
|
||||
settings.put("window.height", String.valueOf(e.getWindow().getHeight()));
|
||||
}
|
||||
});
|
||||
|
||||
// restore bounds
|
||||
int x = Integer.parseInt(settings.get("window.x"));
|
||||
int y = Integer.parseInt(settings.get("window.y"));
|
||||
int width = Integer.parseInt(settings.get("window.width"));
|
||||
int height = Integer.parseInt(settings.get("window.height"));
|
||||
window.setBounds(x, y, width, height);
|
||||
}
|
||||
|
||||
|
||||
private static void initializeLogging() {
|
||||
Logger uiLogger = Logger.getLogger("ui");
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.sourceforge.filebot.ui.transfer;
|
|||
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
@ -11,6 +12,7 @@ import javax.swing.Icon;
|
|||
import javax.swing.JFileChooser;
|
||||
|
||||
import net.sourceforge.filebot.ResourceManager;
|
||||
import net.sourceforge.filebot.Settings;
|
||||
import net.sourceforge.filebot.ui.transfer.TransferablePolicy.TransferAction;
|
||||
|
||||
|
||||
|
@ -18,7 +20,7 @@ public class LoadAction extends AbstractAction {
|
|||
|
||||
public static final String TRANSFERABLE_POLICY = "transferablePolicy";
|
||||
|
||||
|
||||
|
||||
public LoadAction(TransferablePolicy transferablePolicy) {
|
||||
this("Load", ResourceManager.getIcon("action.load"), transferablePolicy);
|
||||
}
|
||||
|
@ -37,6 +39,16 @@ public class LoadAction extends AbstractAction {
|
|||
}
|
||||
|
||||
|
||||
protected File getDefaultFolder() {
|
||||
String lastLocation = Settings.forPackage(LoadAction.class).get("load.location");
|
||||
|
||||
if (lastLocation == null || lastLocation.isEmpty())
|
||||
return null;
|
||||
|
||||
return new File(lastLocation);
|
||||
}
|
||||
|
||||
|
||||
public void actionPerformed(ActionEvent evt) {
|
||||
// get transferable policy from action properties
|
||||
TransferablePolicy transferablePolicy = (TransferablePolicy) getValue(TRANSFERABLE_POLICY);
|
||||
|
@ -44,7 +56,7 @@ public class LoadAction extends AbstractAction {
|
|||
if (transferablePolicy == null)
|
||||
return;
|
||||
|
||||
JFileChooser chooser = new JFileChooser();
|
||||
JFileChooser chooser = new JFileChooser(getDefaultFolder());
|
||||
|
||||
chooser.setFileFilter(new TransferablePolicyFileFilter(transferablePolicy));
|
||||
|
||||
|
@ -63,6 +75,9 @@ public class LoadAction extends AbstractAction {
|
|||
} catch (Exception e) {
|
||||
Logger.getLogger("ui").log(Level.WARNING, e.getMessage(), e);
|
||||
}
|
||||
|
||||
// remember last location
|
||||
Settings.forPackage(LoadAction.class).put("load.location", chooser.getCurrentDirectory().getPath());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import javax.swing.JComponent;
|
|||
import javax.swing.JFileChooser;
|
||||
|
||||
import net.sourceforge.filebot.ResourceManager;
|
||||
import net.sourceforge.filebot.Settings;
|
||||
|
||||
|
||||
public class SaveAction extends AbstractAction {
|
||||
|
@ -56,7 +57,12 @@ public class SaveAction extends AbstractAction {
|
|||
|
||||
|
||||
protected File getDefaultFolder() {
|
||||
return null;
|
||||
String lastLocation = Settings.forPackage(SaveAction.class).get("save.location");
|
||||
|
||||
if (lastLocation == null || lastLocation.isEmpty())
|
||||
return null;
|
||||
|
||||
return new File(lastLocation);
|
||||
}
|
||||
|
||||
|
||||
|
@ -78,5 +84,8 @@ public class SaveAction extends AbstractAction {
|
|||
} catch (IOException e) {
|
||||
Logger.getLogger(getClass().getName()).log(Level.SEVERE, e.toString(), e);
|
||||
}
|
||||
|
||||
// remember last location
|
||||
Settings.forPackage(SaveAction.class).put("save.location", chooser.getCurrentDirectory().getPath());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue