diff options
author | Andrew Su <[email protected]> | 2011-04-20 14:35:13 -0400 |
---|---|---|
committer | Andrew Su <[email protected]> | 2011-04-20 14:35:13 -0400 |
commit | cbfb2e88fcd89b117c7531970697bd037c1d5aa3 (patch) | |
tree | 67c1073c55de0db32c08cee068728a067dae7130 /netx/net/sourceforge | |
parent | 1520ee59a4f0d177424381cc724879fa91457bcd (diff) |
Allow delete only when plugin or javaws is not running
Diffstat (limited to 'netx/net/sourceforge')
-rw-r--r-- | netx/net/sourceforge/jnlp/controlpanel/CachePane.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/netx/net/sourceforge/jnlp/controlpanel/CachePane.java b/netx/net/sourceforge/jnlp/controlpanel/CachePane.java index 4c97897..950dc36 100644 --- a/netx/net/sourceforge/jnlp/controlpanel/CachePane.java +++ b/netx/net/sourceforge/jnlp/controlpanel/CachePane.java @@ -26,6 +26,10 @@ import java.awt.GridBagLayout; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.nio.channels.FileLock; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; @@ -125,8 +129,25 @@ public class CachePane extends JPanel { deleteButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { + FileLock fl = null; + File netxRunningFile = new File(config.getProperty(DeploymentConfiguration.KEY_USER_NETX_RUNNING_FILE)); + if (!netxRunningFile.exists()) { + try { + FileUtils.createParentDir(netxRunningFile); + FileUtils.createRestrictedFile(netxRunningFile, true); + } catch (IOException e1) { + e1.printStackTrace(); + } + } + + try { + fl = FileUtils.getFileLock(netxRunningFile.getPath(), false, false); + } catch (FileNotFoundException e1) { + } + int row = cacheTable.getSelectedRow(); try { + if (fl == null) return; if (row == -1 || row > cacheTable.getRowCount() - 1) return; int modelRow = cacheTable.convertRowIndexToModel(row); @@ -141,6 +162,15 @@ public class CachePane extends JPanel { } catch (Exception exception) { //ignore } + + if (fl != null) { + try { + fl.release(); + fl.channel().close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + } } }); buttons.add(deleteButton); |