From 6d9882321fc6e2bf6c8887c4b4ceaaad77f637f2 Mon Sep 17 00:00:00 2001 From: Andrew Su Date: Wed, 20 Apr 2011 16:58:29 -0400 Subject: Update recently_used when deleting cache entries with itw-settings --- netx/net/sourceforge/jnlp/controlpanel/CachePane.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'netx/net/sourceforge/jnlp/controlpanel') diff --git a/netx/net/sourceforge/jnlp/controlpanel/CachePane.java b/netx/net/sourceforge/jnlp/controlpanel/CachePane.java index 91849c4..e31b2bb 100644 --- a/netx/net/sourceforge/jnlp/controlpanel/CachePane.java +++ b/netx/net/sourceforge/jnlp/controlpanel/CachePane.java @@ -32,6 +32,7 @@ import java.io.IOException; import java.nio.channels.FileLock; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Enumeration; import java.util.List; import javax.swing.JButton; @@ -48,6 +49,7 @@ import net.sourceforge.jnlp.cache.DirectoryNode; import net.sourceforge.jnlp.config.DeploymentConfiguration; import net.sourceforge.jnlp.runtime.Translator; import net.sourceforge.jnlp.util.FileUtils; +import net.sourceforge.jnlp.util.PropertiesFile; public class CachePane extends JPanel { @@ -153,6 +155,7 @@ public class CachePane extends JPanel { int modelRow = cacheTable.convertRowIndexToModel(row); DirectoryNode fileNode = ((DirectoryNode) cacheTable.getModel().getValueAt(modelRow, 0)); if (fileNode.getFile().delete()) { + updateRecentlyUsed(fileNode.getFile()); fileNode.getParent().removeChild(fileNode); FileUtils.deleteWithErrMesg(fileNode.getInfoFile()); ((DefaultTableModel) cacheTable.getModel()).removeRow(modelRow); @@ -172,6 +175,20 @@ public class CachePane extends JPanel { } } } + + private void updateRecentlyUsed(File f) { + File recentlyUsedFile = new File(location + File.separator + "recently_used"); + PropertiesFile pf = new PropertiesFile(recentlyUsedFile); + pf.load(); + Enumeration en = pf.keys(); + while (en.hasMoreElements()) { + String key = (String) en.nextElement(); + if (pf.get(key).equals(f.getAbsolutePath())) { + pf.remove(key); + } + } + pf.store(); + } }); buttons.add(deleteButton); -- cgit v1.2.3